locks: allow ->lock() to return FILE_LOCK_DEFERRED

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, July 25, 2008 - 12:11 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=764c76...
Commit:     764c76b371722e0cba5c24d91225f0f954b69d44
Parent:     b648a6de00770cc325c22f43bdd4e935f6a2ee55
Author:     Miklos Szeredi <mszeredi@suse.cz>
AuthorDate: Fri Jul 25 01:48:58 2008 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Fri Jul 25 10:53:48 2008 -0700

    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>
---
 fs/locks.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 6222e4b..0149030 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,
 	if (error)
 		return error;
 
-	if (filp->f_op && filp->f_op->lock != NULL)
-		error = filp->f_op->lock(filp, cmd, fl);
-	else {
-		for (;;) {
-			error = posix_lock_file(filp, fl, NULL);
-			if (error != FILE_LOCK_DEFERRED)
-				break;
-			error = wait_event_interruptible(fl->fl_wait,
-							 !fl->fl_next);
-			if (!error)
-				continue;
-
-			locks_delete_block(fl);
+	for (;;) {
+		error = vfs_lock_file(filp, cmd, fl, NULL);
+		if (error != FILE_LOCK_DEFERRED)
 			break;
-		}
+		error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
+		if (!error)
+			continue;
+
+		locks_delete_block(fl);
+		break;
 	}
 
 	return error;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
locks: allow ->lock() to return FILE_LOCK_DEFERRED, Linux Kernel Mailing ..., (Fri Jul 25, 12:11 pm)