diff options
author | Christoph Hellwig <hch@lst.de> | 2015-01-21 21:14:02 +0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2015-02-02 20:09:38 +0300 |
commit | 2ab99ee12440e66ec1efd2a98599010471de785e (patch) | |
tree | e9d8946babd68a56c0c35bdf77d852ee74e346dc /fs/locks.c | |
parent | 6cae0a4648c0db2a74efb816cd2ce84390c90480 (diff) | |
download | linux-2ab99ee12440e66ec1efd2a98599010471de785e.tar.xz |
fs: track fl_owner for leases
Just like for other lock types we should allow different owners to have
a read lease on a file. Currently this can't happen, but with the addition
of pNFS layout leases we'll need this feature.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/locks.c b/fs/locks.c index 4d0d41163a50..22ac7694cc84 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1661,7 +1661,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr */ error = -EAGAIN; list_for_each_entry(fl, &ctx->flc_lease, fl_list) { - if (fl->fl_file == filp) { + if (fl->fl_file == filp && + fl->fl_owner == lease->fl_owner) { my_fl = fl; continue; } @@ -1721,7 +1722,7 @@ out: return error; } -static int generic_delete_lease(struct file *filp) +static int generic_delete_lease(struct file *filp, void *owner) { int error = -EAGAIN; struct file_lock *fl, *victim = NULL; @@ -1737,7 +1738,8 @@ static int generic_delete_lease(struct file *filp) spin_lock(&ctx->flc_lock); list_for_each_entry(fl, &ctx->flc_lease, fl_list) { - if (fl->fl_file == filp) { + if (fl->fl_file == filp && + fl->fl_owner == owner) { victim = fl; break; } @@ -1778,7 +1780,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp, switch (arg) { case F_UNLCK: - return generic_delete_lease(filp); + return generic_delete_lease(filp, *priv); case F_RDLCK: case F_WRLCK: if (!(*flp)->fl_lmops->lm_break) { @@ -1857,7 +1859,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) int fcntl_setlease(unsigned int fd, struct file *filp, long arg) { if (arg == F_UNLCK) - return vfs_setlease(filp, F_UNLCK, NULL, NULL); + return vfs_setlease(filp, F_UNLCK, NULL, (void **)&filp); return do_fcntl_add_lease(fd, filp, arg); } |