Skip to content

Commit

Permalink
locks: move locks_free_lock calls in do_fcntl_add_lease outside spinlock
Browse files Browse the repository at this point in the history
There's no need to call locks_free_lock here while still holding the
i_lock. Defer that until the lock has been dropped.

Acked-by: J. Bruce Fields <bfields@fieldses.org>
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
  • Loading branch information
Jeff Layton committed Aug 14, 2014
1 parent ed9814d commit 2dfb928
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1761,13 +1761,10 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
ret = fl;
spin_lock(&inode->i_lock);
error = __vfs_setlease(filp, arg, &ret);
if (error) {
spin_unlock(&inode->i_lock);
locks_free_lock(fl);
goto out_free_fasync;
}
if (ret != fl)
locks_free_lock(fl);
if (error)
goto out_unlock;
if (ret == fl)
fl = NULL;

/*
* fasync_insert_entry() returns the old entry if any.
Expand All @@ -1779,9 +1776,10 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
new = NULL;

error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
out_unlock:
spin_unlock(&inode->i_lock);

out_free_fasync:
if (fl)
locks_free_lock(fl);
if (new)
fasync_free(new);
return error;
Expand Down

0 comments on commit 2dfb928

Please sign in to comment.