Skip to content

Commit bf0291d

Browse files
committed
pNFS: Ensure LAYOUTGET and LAYOUTRETURN are properly serialised
According to RFC5661, the client is responsible for serialising LAYOUTGET and LAYOUTRETURN to avoid ambiguity. Consider the case where we send both in parallel. Client Server ====== ====== LAYOUTGET(seqid=X) LAYOUTRETURN(seqid=X) LAYOUTGET return seqid=X+1 LAYOUTRETURN return seqid=X+2 Process LAYOUTRETURN Forget layout stateid Process LAYOUTGET Set seqid=X+1 The client processes the layoutget/layoutreturn in the wrong order, and since the result of the layoutreturn was to clear the only existing layout segment, the client forgets the layout stateid. When the LAYOUTGET comes in, it is treated as having a completely new stateid, and so the client sets the wrong sequence id... Fix is to check if there are outstanding LAYOUTGET requests before we send the LAYOUTRETURN (note that LAYOUGET will already wait if it sees an outstanding LAYOUTRETURN). Signed-off-by: Trond Myklebust <[email protected]> Cc: [email protected] # v4.5+ Signed-off-by: Trond Myklebust <[email protected]>
1 parent c49edec commit bf0291d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/nfs/pnfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,9 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo,
899899
nfs4_stateid *stateid,
900900
enum pnfs_iomode *iomode)
901901
{
902+
/* Serialise LAYOUTGET/LAYOUTRETURN */
903+
if (atomic_read(&lo->plh_outstanding) != 0)
904+
return false;
902905
if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
903906
return false;
904907
pnfs_get_layout_hdr(lo);

0 commit comments

Comments
 (0)