locks: consolidate "nolease" routines
authorJeff Layton <jlayton@primarydata.com>
Wed, 27 Aug 2014 10:49:41 +0000 (06:49 -0400)
committerJeff Layton <jlayton@primarydata.com>
Tue, 9 Sep 2014 20:01:36 +0000 (16:01 -0400)
GFS2 and NFS have setlease routines that always just return -EINVAL.
Turn that into a generic routine that can live in fs/libfs.c.

Cc: <linux-nfs@vger.kernel.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: <cluster-devel@redhat.com>
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Acked-by: Trond Myklebust <trond.myklebust@primarydata.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/gfs2/file.c
fs/libfs.c
fs/nfs/file.c
fs/nfs/internal.h
fs/nfs/nfs4file.c
include/linux/fs.h

index 26b3f952e6b19cccd2e0333f45498c5531a99c62..2c02478a86b0b48d087d05aee4148eb8ccb06db3 100644 (file)
@@ -912,26 +912,6 @@ out_uninit:
 
 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
 
-/**
- * gfs2_setlease - acquire/release a file lease
- * @file: the file pointer
- * @arg: lease type
- * @fl: file lock
- *
- * We don't currently have a way to enforce a lease across the whole
- * cluster; until we do, disable leases (by just returning -EINVAL),
- * unless the administrator has requested purely local locking.
- *
- * Locking: called under i_lock
- *
- * Returns: errno
- */
-
-static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
-{
-       return -EINVAL;
-}
-
 /**
  * gfs2_lock - acquire/release a posix lock on a file
  * @file: the file pointer
@@ -1069,7 +1049,7 @@ const struct file_operations gfs2_file_fops = {
        .flock          = gfs2_flock,
        .splice_read    = generic_file_splice_read,
        .splice_write   = iter_file_splice_write,
-       .setlease       = gfs2_setlease,
+       .setlease       = simple_nosetlease,
        .fallocate      = gfs2_fallocate,
 };
 
index 88e3e00e2eca0d72aa2bc2af350682d26ca7c7ca..29012a303ef83b1e55e9aaa54bfc315cfc3c35bc 100644 (file)
@@ -1075,3 +1075,19 @@ struct inode *alloc_anon_inode(struct super_block *s)
        return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
+
+/**
+ * simple_nosetlease - generic helper for prohibiting leases
+ * @filp: file pointer
+ * @arg: type of lease to obtain
+ * @flp: new lease supplied for insertion
+ *
+ * Generic helper for filesystems that do not wish to allow leases to be set.
+ * All arguments are ignored and it just returns -EINVAL.
+ */
+int
+simple_nosetlease(struct file *filp, long arg, struct file_lock **flp)
+{
+       return -EINVAL;
+}
+EXPORT_SYMBOL(simple_nosetlease);
index 524dd80d189862db5a76a7bb9e8a263ce857ffeb..8c4048ecdad1836cfbe291203f12be29624145b8 100644 (file)
@@ -891,17 +891,6 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
 }
 EXPORT_SYMBOL_GPL(nfs_flock);
 
-/*
- * There is no protocol support for leases, so we have no way to implement
- * them correctly in the face of opens by other clients.
- */
-int nfs_setlease(struct file *file, long arg, struct file_lock **fl)
-{
-       dprintk("NFS: setlease(%pD2, arg=%ld)\n", file, arg);
-       return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(nfs_setlease);
-
 const struct file_operations nfs_file_operations = {
        .llseek         = nfs_file_llseek,
        .read           = new_sync_read,
@@ -918,6 +907,6 @@ const struct file_operations nfs_file_operations = {
        .splice_read    = nfs_file_splice_read,
        .splice_write   = iter_file_splice_write,
        .check_flags    = nfs_check_flags,
-       .setlease       = nfs_setlease,
+       .setlease       = simple_nosetlease,
 };
 EXPORT_SYMBOL_GPL(nfs_file_operations);
index 9056622d223005c087caac590ed8139743665277..94d922ebb5acdc0a381b9b7cfff9ecc534e53cfb 100644 (file)
@@ -346,7 +346,6 @@ int nfs_file_release(struct inode *, struct file *);
 int nfs_lock(struct file *, int, struct file_lock *);
 int nfs_flock(struct file *, int, struct file_lock *);
 int nfs_check_flags(int);
-int nfs_setlease(struct file *, long, struct file_lock **);
 
 /* inode.c */
 extern struct workqueue_struct *nfsiod_workqueue;
index a816f0627a6ce03cda2502c42c780c5ab6a2742c..3e987ad9ae2547488f6a24d9ac0a411c122028ac 100644 (file)
@@ -131,5 +131,5 @@ const struct file_operations nfs4_file_operations = {
        .splice_read    = nfs_file_splice_read,
        .splice_write   = iter_file_splice_write,
        .check_flags    = nfs_check_flags,
-       .setlease       = nfs_setlease,
+       .setlease       = simple_nosetlease,
 };
index 458f733c96bd314840cf2d1f9cd00558ca226772..435e3d9ec5cf18fe12504291c48307e1ef8c44ef 100644 (file)
@@ -2599,6 +2599,7 @@ extern int simple_write_end(struct file *file, struct address_space *mapping,
                        struct page *page, void *fsdata);
 extern int always_delete_dentry(const struct dentry *);
 extern struct inode *alloc_anon_inode(struct super_block *);
+extern int simple_nosetlease(struct file *, long, struct file_lock **);
 extern const struct dentry_operations simple_dentry_operations;
 
 extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);