Skip to content

Commit a668a77

Browse files
Trond Myklebustgregkh
authored andcommitted
NFSv4/pnfs: Fix the layout barrier update
[ Upstream commit aa95edf ] If we have multiple outstanding layoutget requests, the current code to update the layout barrier assumes that the outstanding layout stateids are updated in order. That's not necessarily the case. Instead of using the value of lo->plh_outstanding as a guesstimate for the window of values we need to accept, just wait to update the window until we're processing the last one. The intention here is just to ensure that we don't process 2^31 seqid updates without also updating the barrier. Fixes: 1bcf34f ("pNFS/NFSv4: Update the layout barrier when we schedule a layoutreturn") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6ccccc0 commit a668a77

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

‎fs/nfs/pnfs.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -966,10 +966,8 @@ void
966966
pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new,
967967
const struct cred *cred, bool update_barrier)
968968
{
969-
u32 oldseq, newseq, new_barrier = 0;
970-
971-
oldseq = be32_to_cpu(lo->plh_stateid.seqid);
972-
newseq = be32_to_cpu(new->seqid);
969+
u32 oldseq = be32_to_cpu(lo->plh_stateid.seqid);
970+
u32 newseq = be32_to_cpu(new->seqid);
973971

974972
if (!pnfs_layout_is_valid(lo)) {
975973
pnfs_set_layout_cred(lo, cred);
@@ -979,19 +977,21 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new,
979977
clear_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
980978
return;
981979
}
982-
if (pnfs_seqid_is_newer(newseq, oldseq)) {
980+
981+
if (pnfs_seqid_is_newer(newseq, oldseq))
983982
nfs4_stateid_copy(&lo->plh_stateid, new);
984-
/*
985-
* Because of wraparound, we want to keep the barrier
986-
* "close" to the current seqids.
987-
*/
988-
new_barrier = newseq - atomic_read(&lo->plh_outstanding);
989-
}
990-
if (update_barrier)
991-
new_barrier = be32_to_cpu(new->seqid);
992-
else if (new_barrier == 0)
983+
984+
if (update_barrier) {
985+
pnfs_barrier_update(lo, newseq);
993986
return;
994-
pnfs_barrier_update(lo, new_barrier);
987+
}
988+
/*
989+
* Because of wraparound, we want to keep the barrier
990+
* "close" to the current seqids. We really only want to
991+
* get here from a layoutget call.
992+
*/
993+
if (atomic_read(&lo->plh_outstanding) == 1)
994+
pnfs_barrier_update(lo, be32_to_cpu(lo->plh_stateid.seqid));
995995
}
996996

997997
static bool

0 commit comments

Comments
 (0)