Commit 764c76b371722e0cba5c24d91225f0f954b69d44
Committed by
Linus Torvalds
1 parent
b648a6de00
Exists in
master
and in
7 other branches
locks: allow ->lock() to return FILE_LOCK_DEFERRED
Allow filesystem's ->lock() method to call posix_lock_file() instead of posix_lock_file_wait(), and return FILE_LOCK_DEFERRED. This makes it possible to implement a such a ->lock() function, that works with the lock manager, which needs the call to be asynchronous. Now the vfs_lock_file() helper can be used, so this is a cleanup as well. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: Matthew Wilcox <matthew@wil.cx> Cc: David Teigland <teigland@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 9 additions and 14 deletions Side-by-side Diff
fs/locks.c
... | ... | @@ -1747,21 +1747,16 @@ |
1747 | 1747 | if (error) |
1748 | 1748 | return error; |
1749 | 1749 | |
1750 | - if (filp->f_op && filp->f_op->lock != NULL) | |
1751 | - error = filp->f_op->lock(filp, cmd, fl); | |
1752 | - else { | |
1753 | - for (;;) { | |
1754 | - error = posix_lock_file(filp, fl, NULL); | |
1755 | - if (error != FILE_LOCK_DEFERRED) | |
1756 | - break; | |
1757 | - error = wait_event_interruptible(fl->fl_wait, | |
1758 | - !fl->fl_next); | |
1759 | - if (!error) | |
1760 | - continue; | |
1761 | - | |
1762 | - locks_delete_block(fl); | |
1750 | + for (;;) { | |
1751 | + error = vfs_lock_file(filp, cmd, fl, NULL); | |
1752 | + if (error != FILE_LOCK_DEFERRED) | |
1763 | 1753 | break; |
1764 | - } | |
1754 | + error = wait_event_interruptible(fl->fl_wait, !fl->fl_next); | |
1755 | + if (!error) | |
1756 | + continue; | |
1757 | + | |
1758 | + locks_delete_block(fl); | |
1759 | + break; | |
1765 | 1760 | } |
1766 | 1761 | |
1767 | 1762 | return error; |