locks: fix setlease methods to free passed-in lock

We modified setlease to require the caller to allocate the new lease in
the case of creating a new lease, but forgot to fix up the filesystem
methods.

Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Steve French <sfrench@samba.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by J. Bruce Fields and committed by Linus Torvalds 05fa3135 096657b6

+11 -3
+4 -1
fs/cifs/cifsfs.c
··· 625 knows that the file won't be changed on the server 626 by anyone else */ 627 return generic_setlease(file, arg, lease); 628 - else 629 return -EAGAIN; 630 } 631 632 struct file_system_type cifs_fs_type = {
··· 625 knows that the file won't be changed on the server 626 by anyone else */ 627 return generic_setlease(file, arg, lease); 628 + else { 629 + if (arg != F_UNLCK) 630 + locks_free_lock(*lease); 631 return -EAGAIN; 632 + } 633 } 634 635 struct file_system_type cifs_fs_type = {
+2
fs/gfs2/file.c
··· 629 630 static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) 631 { 632 return -EINVAL; 633 } 634
··· 629 630 static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) 631 { 632 + if (arg != F_UNLCK) 633 + locks_free_lock(*fl); 634 return -EINVAL; 635 } 636
+2 -1
fs/locks.c
··· 186 EXPORT_SYMBOL_GPL(locks_release_private); 187 188 /* Free a lock which is not in use. */ 189 - static void locks_free_lock(struct file_lock *fl) 190 { 191 BUG_ON(waitqueue_active(&fl->fl_wait)); 192 BUG_ON(!list_empty(&fl->fl_block)); ··· 195 locks_release_private(fl); 196 kmem_cache_free(filelock_cache, fl); 197 } 198 199 void locks_init_lock(struct file_lock *fl) 200 {
··· 186 EXPORT_SYMBOL_GPL(locks_release_private); 187 188 /* Free a lock which is not in use. */ 189 + void locks_free_lock(struct file_lock *fl) 190 { 191 BUG_ON(waitqueue_active(&fl->fl_wait)); 192 BUG_ON(!list_empty(&fl->fl_block)); ··· 195 locks_release_private(fl); 196 kmem_cache_free(filelock_cache, fl); 197 } 198 + EXPORT_SYMBOL(locks_free_lock); 199 200 void locks_init_lock(struct file_lock *fl) 201 {
+2 -1
fs/nfs/file.c
··· 884 dprintk("NFS: setlease(%s/%s, arg=%ld)\n", 885 file->f_path.dentry->d_parent->d_name.name, 886 file->f_path.dentry->d_name.name, arg); 887 - 888 return -EINVAL; 889 }
··· 884 dprintk("NFS: setlease(%s/%s, arg=%ld)\n", 885 file->f_path.dentry->d_parent->d_name.name, 886 file->f_path.dentry->d_name.name, arg); 887 + if (arg != F_UNLCK) 888 + locks_free_lock(*fl); 889 return -EINVAL; 890 }
+1
include/linux/fs.h
··· 1129 extern int fcntl_getlease(struct file *filp); 1130 1131 /* fs/locks.c */ 1132 extern void locks_init_lock(struct file_lock *); 1133 extern struct file_lock * locks_alloc_lock(void); 1134 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
··· 1129 extern int fcntl_getlease(struct file *filp); 1130 1131 /* fs/locks.c */ 1132 + void locks_free_lock(struct file_lock *fl); 1133 extern void locks_init_lock(struct file_lock *); 1134 extern struct file_lock * locks_alloc_lock(void); 1135 extern void locks_copy_lock(struct file_lock *, struct file_lock *);