Skip to content

Commit 42c304c

Browse files
author
Trond Myklebust
committed
NFS: nfs_inode_find_state_and_recover() fix stateid matching
In nfs_inode_find_state_and_recover() we want to mark for recovery only those stateids that match or are older than the supplied stateid parameter. Signed-off-by: Trond Myklebust <[email protected]>
1 parent 3887ce1 commit 42c304c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

fs/nfs/delegation.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,8 @@ void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
12071207
rcu_read_lock();
12081208
delegation = rcu_dereference(NFS_I(inode)->delegation);
12091209
if (delegation &&
1210-
nfs4_stateid_match_other(&delegation->stateid, stateid)) {
1210+
nfs4_stateid_match_or_older(&delegation->stateid, stateid) &&
1211+
!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) {
12111212
nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation);
12121213
found = true;
12131214
}

fs/nfs/nfs4_fs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stat
572572
return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
573573
}
574574

575+
static inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src)
576+
{
577+
return nfs4_stateid_match_other(dst, src) &&
578+
!(src->seqid && nfs4_stateid_is_newer(dst, src));
579+
}
580+
575581
static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1)
576582
{
577583
u32 seqid = be32_to_cpu(s1->seqid);

fs/nfs/nfs4state.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ nfs_state_find_lock_state_by_stateid(struct nfs4_state *state,
14071407
list_for_each_entry(pos, &state->lock_states, ls_locks) {
14081408
if (!test_bit(NFS_LOCK_INITIALIZED, &pos->ls_flags))
14091409
continue;
1410-
if (nfs4_stateid_match_other(&pos->ls_stateid, stateid))
1410+
if (nfs4_stateid_match_or_older(&pos->ls_stateid, stateid))
14111411
return pos;
14121412
}
14131413
return NULL;
@@ -1441,12 +1441,13 @@ void nfs_inode_find_state_and_recover(struct inode *inode,
14411441
state = ctx->state;
14421442
if (state == NULL)
14431443
continue;
1444-
if (nfs4_stateid_match_other(&state->stateid, stateid) &&
1444+
if (nfs4_stateid_match_or_older(&state->stateid, stateid) &&
14451445
nfs4_state_mark_reclaim_nograce(clp, state)) {
14461446
found = true;
14471447
continue;
14481448
}
1449-
if (nfs4_stateid_match_other(&state->open_stateid, stateid) &&
1449+
if (test_bit(NFS_OPEN_STATE, &state->flags) &&
1450+
nfs4_stateid_match_or_older(&state->open_stateid, stateid) &&
14501451
nfs4_state_mark_reclaim_nograce(clp, state)) {
14511452
found = true;
14521453
continue;

0 commit comments

Comments
 (0)