Skip to content

Commit 2ab99ee

Browse files
author
Christoph Hellwig
committed
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>
1 parent 6cae0a4 commit 2ab99ee

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

fs/locks.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
16611661
*/
16621662
error = -EAGAIN;
16631663
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
1664-
if (fl->fl_file == filp) {
1664+
if (fl->fl_file == filp &&
1665+
fl->fl_owner == lease->fl_owner) {
16651666
my_fl = fl;
16661667
continue;
16671668
}
@@ -1721,7 +1722,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
17211722
return error;
17221723
}
17231724

1724-
static int generic_delete_lease(struct file *filp)
1725+
static int generic_delete_lease(struct file *filp, void *owner)
17251726
{
17261727
int error = -EAGAIN;
17271728
struct file_lock *fl, *victim = NULL;
@@ -1737,7 +1738,8 @@ static int generic_delete_lease(struct file *filp)
17371738

17381739
spin_lock(&ctx->flc_lock);
17391740
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
1740-
if (fl->fl_file == filp) {
1741+
if (fl->fl_file == filp &&
1742+
fl->fl_owner == owner) {
17411743
victim = fl;
17421744
break;
17431745
}
@@ -1778,7 +1780,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
17781780

17791781
switch (arg) {
17801782
case F_UNLCK:
1781-
return generic_delete_lease(filp);
1783+
return generic_delete_lease(filp, *priv);
17821784
case F_RDLCK:
17831785
case F_WRLCK:
17841786
if (!(*flp)->fl_lmops->lm_break) {
@@ -1857,7 +1859,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
18571859
int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
18581860
{
18591861
if (arg == F_UNLCK)
1860-
return vfs_setlease(filp, F_UNLCK, NULL, NULL);
1862+
return vfs_setlease(filp, F_UNLCK, NULL, (void **)&filp);
18611863
return do_fcntl_add_lease(fd, filp, arg);
18621864
}
18631865

fs/nfsd/nfs4state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static void nfs4_put_deleg_lease(struct nfs4_file *fp)
683683
spin_unlock(&fp->fi_lock);
684684

685685
if (filp) {
686-
vfs_setlease(filp, F_UNLCK, NULL, NULL);
686+
vfs_setlease(filp, F_UNLCK, NULL, (void **)&fp);
687687
fput(filp);
688688
}
689689
}

0 commit comments

Comments
 (0)