file locks: Use wait_event_interruptible_timeout()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Monday, February 4, 2008 - 1:00 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4321e0...
Commit:     4321e01e7dce8042758349ffa2929c723b0d4107
Parent:     b533184fc353d4a2d07929b4ac424a6f1bf5a3b9
Author:     Matthew Wilcox <matthew@wil.cx>
AuthorDate: Mon Jan 14 21:28:30 2008 -0700
Committer:  J. Bruce Fields <bfields@citi.umich.edu>
CommitDate: Sun Feb 3 17:51:36 2008 -0500

    file locks: Use wait_event_interruptible_timeout()
    
    interruptible_sleep_on_locked() is just an open-coded
    wait_event_interruptible_timeout(), with the one difference that
    interruptible_sleep_on_locked() doesn't bother to check the condition on
    which it is waiting, depending instead on the BKL to avoid the case
    where it blocks after the wakeup has already been called.
    
    locks_block_on_timeout() is only used in one place, so it's actually
    simpler to inline it into its caller.
    
    Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
    Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
 fs/locks.c |   32 ++++----------------------------
 1 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index c3eecb8..faddccb 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -634,33 +634,6 @@ static int flock_locks_conflict(struct file_lock *caller_fl, struct file_lock *s
 	return (locks_conflict(caller_fl, sys_fl));
 }
 
-static int interruptible_sleep_on_locked(wait_queue_head_t *fl_wait, int timeout)
-{
-	int result = 0;
-	DECLARE_WAITQUEUE(wait, current);
-
-	__set_current_state(TASK_INTERRUPTIBLE);
-	add_wait_queue(fl_wait, &wait);
-	if (timeout == 0)
-		schedule();
-	else
-		result = schedule_timeout(timeout);
-	if (signal_pending(current))
-		result = -ERESTARTSYS;
-	remove_wait_queue(fl_wait, &wait);
-	__set_current_state(TASK_RUNNING);
-	return result;
-}
-
-static int locks_block_on_timeout(struct file_lock *blocker, struct file_lock *waiter, int time)
-{
-	int result;
-	locks_insert_block(blocker, waiter);
-	result = interruptible_sleep_on_locked(&waiter->fl_wait, time);
-	__locks_delete_block(waiter);
-	return result;
-}
-
 void
 posix_test_lock(struct file *filp, struct file_lock *fl)
 {
@@ -1266,7 +1239,10 @@ restart:
 		if (break_time == 0)
 			break_time++;
 	}
-	error = locks_block_on_timeout(flock, new_fl, break_time);
+	locks_insert_block(flock, new_fl);
+	error = wait_event_interruptible_timeout(new_fl->fl_wait,
+						!new_fl->fl_next, break_time);
+	__locks_delete_block(new_fl);
 	if (error >= 0) {
 		if (error == 0)
 			time_out_leases(inode);
-
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:
file locks: Use wait_event_interruptible_timeout(), Linux Kernel Mailing ..., (Mon Feb 4, 1:00 pm)