locks: remove i_have_this_lease check from __break_lease
authorJeff Layton <jlayton@primarydata.com>
Mon, 1 Sep 2014 18:27:43 +0000 (14:27 -0400)
committerJeff Layton <jlayton@primarydata.com>
Tue, 7 Oct 2014 18:06:13 +0000 (14:06 -0400)
I think that the intent of this code was to ensure that a process won't
deadlock if it has one fd open with a lease on it and then breaks that
lease by opening another fd. In that case it'll treat the __break_lease
call as if it were non-blocking.

This seems wrong -- the process could (for instance) be multithreaded
and managing different fds via different threads. I also don't see any
mention of this limitation in the (somewhat sketchy) documentation.

Remove the check and the non-blocking behavior when i_have_this_lease
is true.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
fs/locks.c

index c0f789d..4e8cf5d 100644 (file)
@@ -1370,7 +1370,6 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
        struct file_lock *new_fl, *flock;
        struct file_lock *fl;
        unsigned long break_time;
-       int i_have_this_lease = 0;
        bool lease_conflict = false;
        int want_write = (mode & O_ACCMODE) != O_RDONLY;
        LIST_HEAD(dispose);
@@ -1391,8 +1390,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
        for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
                if (leases_conflict(fl, new_fl)) {
                        lease_conflict = true;
-                       if (fl->fl_owner == current->files)
-                               i_have_this_lease = 1;
+                       break;
                }
        }
        if (!lease_conflict)
@@ -1422,7 +1420,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
                fl->fl_lmops->lm_break(fl);
        }
 
-       if (i_have_this_lease || (mode & O_NONBLOCK)) {
+       if (mode & O_NONBLOCK) {
                trace_break_lease_noblock(inode, new_fl);
                error = -EWOULDBLOCK;
                goto out;