]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
locks: fix setlease methods to free passed-in lock
authorJ. Bruce Fields <bfields@redhat.com>
Sat, 30 Oct 2010 21:31:15 +0000 (17:31 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 31 Oct 2010 01:08:15 +0000 (18:08 -0700)
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>
fs/cifs/cifsfs.c
fs/gfs2/file.c
fs/locks.c
fs/nfs/file.c
include/linux/fs.h

index 75c4eaa7958821483c6829658ab6469a8ad8c152..54745b6c3db9c50af75b393c8b80d96460439c80 100644 (file)
@@ -625,8 +625,11 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
                   knows that the file won't be changed on the server
                   by anyone else */
                return generic_setlease(file, arg, lease);
-       else
+       else {
+               if (arg != F_UNLCK)
+                       locks_free_lock(*lease);
                return -EAGAIN;
+       }
 }
 
 struct file_system_type cifs_fs_type = {
index aa996471ec5c961d7d94c62c10a20d29ac8e1bbb..ac943c1307b5e33272f2d91d07f95c6a332f3e7a 100644 (file)
@@ -629,6 +629,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 
 static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
 {
+       if (arg != F_UNLCK)
+               locks_free_lock(*fl);
        return -EINVAL;
 }
 
index 63fbc41cc573c0161c19ed83a1f16819acd0f7fd..5b526a9778828977871d01e610fdfd797da0527a 100644 (file)
@@ -186,7 +186,7 @@ void locks_release_private(struct file_lock *fl)
 EXPORT_SYMBOL_GPL(locks_release_private);
 
 /* Free a lock which is not in use. */
-static void locks_free_lock(struct file_lock *fl)
+void locks_free_lock(struct file_lock *fl)
 {
        BUG_ON(waitqueue_active(&fl->fl_wait));
        BUG_ON(!list_empty(&fl->fl_block));
@@ -195,6 +195,7 @@ static void locks_free_lock(struct file_lock *fl)
        locks_release_private(fl);
        kmem_cache_free(filelock_cache, fl);
 }
+EXPORT_SYMBOL(locks_free_lock);
 
 void locks_init_lock(struct file_lock *fl)
 {
index e756075637b005ba1937b275c2d77ed3ff8ad676..1e524fb73ba56200be86a3675181c78d7bd02fde 100644 (file)
@@ -884,6 +884,7 @@ static int nfs_setlease(struct file *file, long arg, struct file_lock **fl)
        dprintk("NFS: setlease(%s/%s, arg=%ld)\n",
                        file->f_path.dentry->d_parent->d_name.name,
                        file->f_path.dentry->d_name.name, arg);
-
+       if (arg != F_UNLCK)
+               locks_free_lock(*fl);
        return -EINVAL;
 }
index 7b7b507ffa1cb269266e74044e8e57ec8e0b5d7b..1eb29399a4ff4b82f00257e3c03090015c00060a 100644 (file)
@@ -1129,6 +1129,7 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
 extern int fcntl_getlease(struct file *filp);
 
 /* fs/locks.c */
+void locks_free_lock(struct file_lock *fl);
 extern void locks_init_lock(struct file_lock *);
 extern struct file_lock * locks_alloc_lock(void);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);