Skip to content

Commit fbf4bcc

Browse files
author
Trond Myklebust
committed
NFS: Fix an ABBA spinlock issue in pnfs_update_layout()
We need to drop the inode spinlock while calling nfs4_select_rw_stateid(), since nfs4_copy_delegation_stateid() could take the delegation lock. Note that it is safe to do this, since all other calls to pnfs_update_layout() for that inode will find themselves blocked by the lock we hold on NFS_LAYOUT_FIRST_LAYOUTGET. Fixes: fc51b1c ("NFS: Beware when dereferencing the delegation cred") Signed-off-by: Trond Myklebust <[email protected]>
1 parent 8f3d9f3 commit fbf4bcc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/nfs/pnfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,7 @@ pnfs_update_layout(struct inode *ino,
20232023
goto lookup_again;
20242024
}
20252025

2026+
spin_unlock(&ino->i_lock);
20262027
first = true;
20272028
status = nfs4_select_rw_stateid(ctx->state,
20282029
iomode == IOMODE_RW ? FMODE_WRITE : FMODE_READ,
@@ -2032,12 +2033,12 @@ pnfs_update_layout(struct inode *ino,
20322033
trace_pnfs_update_layout(ino, pos, count,
20332034
iomode, lo, lseg,
20342035
PNFS_UPDATE_LAYOUT_INVALID_OPEN);
2035-
spin_unlock(&ino->i_lock);
20362036
nfs4_schedule_stateid_recovery(server, ctx->state);
20372037
pnfs_clear_first_layoutget(lo);
20382038
pnfs_put_layout_hdr(lo);
20392039
goto lookup_again;
20402040
}
2041+
spin_lock(&ino->i_lock);
20412042
} else {
20422043
nfs4_stateid_copy(&stateid, &lo->plh_stateid);
20432044
}

0 commit comments

Comments
 (0)