aboutsummaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-08-19 10:59:49 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-08-19 13:25:35 -0400
commitc1f24ef4ed46f58ea5e524a2364c93b6847fb164 (patch)
tree863e467d36dc13d5012076d9fd31e2ffc86ee0d8 /fs/locks.c
parent778fc546f749c588aa2f6cd50215d2715c374252 (diff)
locks: setlease cleanup
There's an incorrect comment here. Also clean up the logic: the "rdlease" and "wrlease" locals are confusingly named, and don't really add anything since we can make a decision as soon as we hit one of these cases. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/fs/locks.c b/fs/locks.c
index c525aa4de234..9b8408eb6946 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1368,7 +1368,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1368 struct file_lock *fl, **before, **my_before = NULL, *lease; 1368 struct file_lock *fl, **before, **my_before = NULL, *lease;
1369 struct dentry *dentry = filp->f_path.dentry; 1369 struct dentry *dentry = filp->f_path.dentry;
1370 struct inode *inode = dentry->d_inode; 1370 struct inode *inode = dentry->d_inode;
1371 int error, rdlease_count = 0, wrlease_count = 0; 1371 int error;
1372 1372
1373 lease = *flp; 1373 lease = *flp;
1374 1374
@@ -1404,27 +1404,28 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1404 * then the file is not open by anyone (including us) 1404 * then the file is not open by anyone (including us)
1405 * except for this filp. 1405 * except for this filp.
1406 */ 1406 */
1407 error = -EAGAIN;
1407 for (before = &inode->i_flock; 1408 for (before = &inode->i_flock;
1408 ((fl = *before) != NULL) && IS_LEASE(fl); 1409 ((fl = *before) != NULL) && IS_LEASE(fl);
1409 before = &fl->fl_next) { 1410 before = &fl->fl_next) {
1410 if (fl->fl_file == filp) 1411 if (fl->fl_file == filp) {
1411 my_before = before; 1412 my_before = before;
1412 else if (fl->fl_flags & FL_UNLOCK_PENDING) 1413 continue;
1413 /* 1414 }
1414 * Someone is in the process of opening this 1415 /*
1415 * file for writing so we may not take an 1416 * No exclusive leases if someone else has a lease on
1416 * exclusive lease on it. 1417 * this file:
1417 */ 1418 */
1418 wrlease_count++; 1419 if (arg == F_WRLCK)
1419 else 1420 goto out;
1420 rdlease_count++; 1421 /*
1422 * Modifying our existing lease is OK, but no getting a
1423 * new lease if someone else is opening for write:
1424 */
1425 if (fl->fl_flags & FL_UNLOCK_PENDING)
1426 goto out;
1421 } 1427 }
1422 1428
1423 error = -EAGAIN;
1424 if ((arg == F_RDLCK && (wrlease_count > 0)) ||
1425 (arg == F_WRLCK && ((rdlease_count + wrlease_count) > 0)))
1426 goto out;
1427
1428 if (my_before != NULL) { 1429 if (my_before != NULL) {
1429 error = lease->fl_lmops->lm_change(my_before, arg); 1430 error = lease->fl_lmops->lm_change(my_before, arg);
1430 if (!error) 1431 if (!error)