Commit 2ab99ee1 authored by Christoph Hellwig's avatar Christoph Hellwig

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: default avatarChristoph Hellwig <hch@lst.de>
parent 6cae0a46
...@@ -1661,7 +1661,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr ...@@ -1661,7 +1661,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
*/ */
error = -EAGAIN; error = -EAGAIN;
list_for_each_entry(fl, &ctx->flc_lease, fl_list) { 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; my_fl = fl;
continue; continue;
} }
...@@ -1721,7 +1722,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr ...@@ -1721,7 +1722,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
return error; return error;
} }
static int generic_delete_lease(struct file *filp) static int generic_delete_lease(struct file *filp, void *owner)
{ {
int error = -EAGAIN; int error = -EAGAIN;
struct file_lock *fl, *victim = NULL; struct file_lock *fl, *victim = NULL;
...@@ -1737,7 +1738,8 @@ static int generic_delete_lease(struct file *filp) ...@@ -1737,7 +1738,8 @@ static int generic_delete_lease(struct file *filp)
spin_lock(&ctx->flc_lock); spin_lock(&ctx->flc_lock);
list_for_each_entry(fl, &ctx->flc_lease, fl_list) { 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; victim = fl;
break; break;
} }
...@@ -1778,7 +1780,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp, ...@@ -1778,7 +1780,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
switch (arg) { switch (arg) {
case F_UNLCK: case F_UNLCK:
return generic_delete_lease(filp); return generic_delete_lease(filp, *priv);
case F_RDLCK: case F_RDLCK:
case F_WRLCK: case F_WRLCK:
if (!(*flp)->fl_lmops->lm_break) { if (!(*flp)->fl_lmops->lm_break) {
...@@ -1857,7 +1859,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg) ...@@ -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) int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
{ {
if (arg == F_UNLCK) 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); return do_fcntl_add_lease(fd, filp, arg);
} }
......
...@@ -683,7 +683,7 @@ static void nfs4_put_deleg_lease(struct nfs4_file *fp) ...@@ -683,7 +683,7 @@ static void nfs4_put_deleg_lease(struct nfs4_file *fp)
spin_unlock(&fp->fi_lock); spin_unlock(&fp->fi_lock);
if (filp) { if (filp) {
vfs_setlease(filp, F_UNLCK, NULL, NULL); vfs_setlease(filp, F_UNLCK, NULL, (void **)&fp);
fput(filp); fput(filp);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment