aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2008-01-14 23:28:30 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-02-03 17:51:36 -0500
commit4321e01e7dce8042758349ffa2929c723b0d4107 (patch)
tree32b7b1a4af4b28c3ce1fc013bc7a2da4f2e21fde
parentb533184fc353d4a2d07929b4ac424a6f1bf5a3b9 (diff)
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>
-rw-r--r--fs/locks.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/fs/locks.c b/fs/locks.c
index c3eecb895acf..faddccb6336a 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
634 return (locks_conflict(caller_fl, sys_fl)); 634 return (locks_conflict(caller_fl, sys_fl));
635} 635}
636 636
637static int interruptible_sleep_on_locked(wait_queue_head_t *fl_wait, int timeout)
638{
639 int result = 0;
640 DECLARE_WAITQUEUE(wait, current);
641
642 __set_current_state(TASK_INTERRUPTIBLE);
643 add_wait_queue(fl_wait, &wait);
644 if (timeout == 0)
645 schedule();
646 else
647 result = schedule_timeout(timeout);
648 if (signal_pending(current))
649 result = -ERESTARTSYS;
650 remove_wait_queue(fl_wait, &wait);
651 __set_current_state(TASK_RUNNING);
652 return result;
653}
654
655static int locks_block_on_timeout(struct file_lock *blocker, struct file_lock *waiter, int time)
656{
657 int result;
658 locks_insert_block(blocker, waiter);
659 result = interruptible_sleep_on_locked(&waiter->fl_wait, time);
660 __locks_delete_block(waiter);
661 return result;
662}
663
664void 637void
665posix_test_lock(struct file *filp, struct file_lock *fl) 638posix_test_lock(struct file *filp, struct file_lock *fl)
666{ 639{
@@ -1266,7 +1239,10 @@ restart:
1266 if (break_time == 0) 1239 if (break_time == 0)
1267 break_time++; 1240 break_time++;
1268 } 1241 }
1269 error = locks_block_on_timeout(flock, new_fl, break_time); 1242 locks_insert_block(flock, new_fl);
1243 error = wait_event_interruptible_timeout(new_fl->fl_wait,
1244 !new_fl->fl_next, break_time);
1245 __locks_delete_block(new_fl);
1270 if (error >= 0) { 1246 if (error >= 0) {
1271 if (error == 0) 1247 if (error == 0)
1272 time_out_leases(inode); 1248 time_out_leases(inode);