diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2008-07-25 04:48:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:48 -0400 |
commit | 764c76b371722e0cba5c24d91225f0f954b69d44 (patch) | |
tree | 3f9bd533878f502b1235194b50a101a84a7c68be /fs/locks.c | |
parent | b648a6de00770cc325c22f43bdd4e935f6a2ee55 (diff) |
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>
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/fs/locks.c b/fs/locks.c index 6222e4b580e2..01490300f7cb 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1747,21 +1747,16 @@ static int do_lock_file_wait(struct file *filp, unsigned int cmd, | |||
1747 | if (error) | 1747 | if (error) |
1748 | return error; | 1748 | return error; |
1749 | 1749 | ||
1750 | if (filp->f_op && filp->f_op->lock != NULL) | 1750 | for (;;) { |
1751 | error = filp->f_op->lock(filp, cmd, fl); | 1751 | error = vfs_lock_file(filp, cmd, fl, NULL); |
1752 | else { | 1752 | if (error != FILE_LOCK_DEFERRED) |
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); | ||
1763 | break; | 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 | return error; | 1762 | return error; |