@@ -1268,12 +1268,10 @@ static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl)
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_blocker);
- if (!error)
- continue;
-
- locks_delete_block(fl);
- break;
+ if (error)
+ break;
}
+ locks_delete_block(fl);
return error;
}
@@ -1962,12 +1960,10 @@ static int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl)
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_blocker);
- if (!error)
- continue;
-
- locks_delete_block(fl);
- break;
+ if (error)
+ break;
}
+ locks_delete_block(fl);
return error;
}
@@ -2241,12 +2237,10 @@ static int do_lock_file_wait(struct file *filp, unsigned int cmd,
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_blocker);
- if (!error)
- continue;
-
- locks_delete_block(fl);
- break;
+ if (error)
+ break;
}
+ locks_delete_block(fl);
return error;
}
Now that requests can block other requests, we need to be careful to always clean up those blocked requests. Any time that we wait for a request, we might have other requests attached, and when we stop waiting, we must clean them up. If the lock was granted, the requests might have been moved to the new lock, though when merged with a pre-exiting lock, this might not happen. In all cases we don't want blocked locks to remain attached, so we remove them to be safe. Signed-off-by: NeilBrown <neilb@suse.com> --- fs/locks.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)