Skip to content

Commit df56ddd

Browse files
author
Trond Myklebust
committed
NFSv4.x: Directory delegations don't require any state recovery
The state recovery code in nfs_end_delegation_return() is intended to allow regular files to recover cached open and lock state. It has no function for directory delegations, and may cause corruption. Fixes: 156b094 ("NFS: Request a directory delegation on ACCESS, CREATE, and UNLINK") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 3f77eda commit df56ddd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

fs/nfs/delegation.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation
581581
if (delegation == NULL)
582582
return 0;
583583

584+
/* Directory delegations don't require any state recovery */
585+
if (!S_ISREG(inode->i_mode))
586+
goto out_return;
587+
584588
if (!issync)
585589
mode |= O_NONBLOCK;
586590
/* Recall of any remaining application leases */
@@ -604,6 +608,7 @@ static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation
604608
goto out;
605609
}
606610

611+
out_return:
607612
err = nfs_do_return_delegation(inode, delegation, issync);
608613
out:
609614
/* Refcount matched in nfs_start_delegation_return_locked() */

fs/nfs/nfs4state.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,8 @@ void nfs_inode_find_state_and_recover(struct inode *inode,
14451445
struct nfs4_state *state;
14461446
bool found = false;
14471447

1448+
if (!S_ISREG(inode->i_mode))
1449+
goto out;
14481450
rcu_read_lock();
14491451
list_for_each_entry_rcu(ctx, &nfsi->open_files, list) {
14501452
state = ctx->state;
@@ -1466,7 +1468,7 @@ void nfs_inode_find_state_and_recover(struct inode *inode,
14661468
found = true;
14671469
}
14681470
rcu_read_unlock();
1469-
1471+
out:
14701472
nfs_inode_find_delegation_state_and_recover(inode, stateid);
14711473
if (found)
14721474
nfs4_schedule_state_manager(clp);
@@ -1478,6 +1480,8 @@ static void nfs4_state_mark_open_context_bad(struct nfs4_state *state, int err)
14781480
struct nfs_inode *nfsi = NFS_I(inode);
14791481
struct nfs_open_context *ctx;
14801482

1483+
if (!S_ISREG(inode->i_mode))
1484+
return;
14811485
rcu_read_lock();
14821486
list_for_each_entry_rcu(ctx, &nfsi->open_files, list) {
14831487
if (ctx->state != state)

0 commit comments

Comments
 (0)