aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-08-27 06:49:41 -0400
committerJeff Layton <jlayton@primarydata.com>2014-09-09 16:01:36 -0400
commit1c994a0909a556508c2cc26ab5d9e13c5ce33aa0 (patch)
tree6bb67db15f5e74c07c793ce3e27165c542f14c95
parent699688a416524c3cea9eafaca69fc6c06c13c02e (diff)
locks: consolidate "nolease" routines
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>
-rw-r--r--fs/gfs2/file.c22
-rw-r--r--fs/libfs.c16
-rw-r--r--fs/nfs/file.c13
-rw-r--r--fs/nfs/internal.h1
-rw-r--r--fs/nfs/nfs4file.c2
-rw-r--r--include/linux/fs.h1
6 files changed, 20 insertions, 35 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 26b3f952e6b1..2c02478a86b0 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -913,26 +913,6 @@ out_uninit:
913#ifdef CONFIG_GFS2_FS_LOCKING_DLM 913#ifdef CONFIG_GFS2_FS_LOCKING_DLM
914 914
915/** 915/**
916 * gfs2_setlease - acquire/release a file lease
917 * @file: the file pointer
918 * @arg: lease type
919 * @fl: file lock
920 *
921 * We don't currently have a way to enforce a lease across the whole
922 * cluster; until we do, disable leases (by just returning -EINVAL),
923 * unless the administrator has requested purely local locking.
924 *
925 * Locking: called under i_lock
926 *
927 * Returns: errno
928 */
929
930static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
931{
932 return -EINVAL;
933}
934
935/**
936 * gfs2_lock - acquire/release a posix lock on a file 916 * gfs2_lock - acquire/release a posix lock on a file
937 * @file: the file pointer 917 * @file: the file pointer
938 * @cmd: either modify or retrieve lock state, possibly wait 918 * @cmd: either modify or retrieve lock state, possibly wait
@@ -1069,7 +1049,7 @@ const struct file_operations gfs2_file_fops = {
1069 .flock = gfs2_flock, 1049 .flock = gfs2_flock,
1070 .splice_read = generic_file_splice_read, 1050 .splice_read = generic_file_splice_read,
1071 .splice_write = iter_file_splice_write, 1051 .splice_write = iter_file_splice_write,
1072 .setlease = gfs2_setlease, 1052 .setlease = simple_nosetlease,
1073 .fallocate = gfs2_fallocate, 1053 .fallocate = gfs2_fallocate,
1074}; 1054};
1075 1055
diff --git a/fs/libfs.c b/fs/libfs.c
index 88e3e00e2eca..29012a303ef8 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1075,3 +1075,19 @@ struct inode *alloc_anon_inode(struct super_block *s)
1075 return inode; 1075 return inode;
1076} 1076}
1077EXPORT_SYMBOL(alloc_anon_inode); 1077EXPORT_SYMBOL(alloc_anon_inode);
1078
1079/**
1080 * simple_nosetlease - generic helper for prohibiting leases
1081 * @filp: file pointer
1082 * @arg: type of lease to obtain
1083 * @flp: new lease supplied for insertion
1084 *
1085 * Generic helper for filesystems that do not wish to allow leases to be set.
1086 * All arguments are ignored and it just returns -EINVAL.
1087 */
1088int
1089simple_nosetlease(struct file *filp, long arg, struct file_lock **flp)
1090{
1091 return -EINVAL;
1092}
1093EXPORT_SYMBOL(simple_nosetlease);
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 524dd80d1898..8c4048ecdad1 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -891,17 +891,6 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
891} 891}
892EXPORT_SYMBOL_GPL(nfs_flock); 892EXPORT_SYMBOL_GPL(nfs_flock);
893 893
894/*
895 * There is no protocol support for leases, so we have no way to implement
896 * them correctly in the face of opens by other clients.
897 */
898int nfs_setlease(struct file *file, long arg, struct file_lock **fl)
899{
900 dprintk("NFS: setlease(%pD2, arg=%ld)\n", file, arg);
901 return -EINVAL;
902}
903EXPORT_SYMBOL_GPL(nfs_setlease);
904
905const struct file_operations nfs_file_operations = { 894const struct file_operations nfs_file_operations = {
906 .llseek = nfs_file_llseek, 895 .llseek = nfs_file_llseek,
907 .read = new_sync_read, 896 .read = new_sync_read,
@@ -918,6 +907,6 @@ const struct file_operations nfs_file_operations = {
918 .splice_read = nfs_file_splice_read, 907 .splice_read = nfs_file_splice_read,
919 .splice_write = iter_file_splice_write, 908 .splice_write = iter_file_splice_write,
920 .check_flags = nfs_check_flags, 909 .check_flags = nfs_check_flags,
921 .setlease = nfs_setlease, 910 .setlease = simple_nosetlease,
922}; 911};
923EXPORT_SYMBOL_GPL(nfs_file_operations); 912EXPORT_SYMBOL_GPL(nfs_file_operations);
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 9056622d2230..94d922ebb5ac 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -346,7 +346,6 @@ int nfs_file_release(struct inode *, struct file *);
346int nfs_lock(struct file *, int, struct file_lock *); 346int nfs_lock(struct file *, int, struct file_lock *);
347int nfs_flock(struct file *, int, struct file_lock *); 347int nfs_flock(struct file *, int, struct file_lock *);
348int nfs_check_flags(int); 348int nfs_check_flags(int);
349int nfs_setlease(struct file *, long, struct file_lock **);
350 349
351/* inode.c */ 350/* inode.c */
352extern struct workqueue_struct *nfsiod_workqueue; 351extern struct workqueue_struct *nfsiod_workqueue;
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index a816f0627a6c..3e987ad9ae25 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -131,5 +131,5 @@ const struct file_operations nfs4_file_operations = {
131 .splice_read = nfs_file_splice_read, 131 .splice_read = nfs_file_splice_read,
132 .splice_write = iter_file_splice_write, 132 .splice_write = iter_file_splice_write,
133 .check_flags = nfs_check_flags, 133 .check_flags = nfs_check_flags,
134 .setlease = nfs_setlease, 134 .setlease = simple_nosetlease,
135}; 135};
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 458f733c96bd..435e3d9ec5cf 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2599,6 +2599,7 @@ extern int simple_write_end(struct file *file, struct address_space *mapping,
2599 struct page *page, void *fsdata); 2599 struct page *page, void *fsdata);
2600extern int always_delete_dentry(const struct dentry *); 2600extern int always_delete_dentry(const struct dentry *);
2601extern struct inode *alloc_anon_inode(struct super_block *); 2601extern struct inode *alloc_anon_inode(struct super_block *);
2602extern int simple_nosetlease(struct file *, long, struct file_lock **);
2602extern const struct dentry_operations simple_dentry_operations; 2603extern const struct dentry_operations simple_dentry_operations;
2603 2604
2604extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); 2605extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);