aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/pnfs.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 42613bd19f8e..861dd97b569e 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -563,28 +563,23 @@ void
563pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, 563pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new,
564 bool update_barrier) 564 bool update_barrier)
565{ 565{
566 u32 oldseq, newseq; 566 u32 oldseq, newseq, new_barrier;
567 int empty = list_empty(&lo->plh_segs);
567 568
568 oldseq = be32_to_cpu(lo->plh_stateid.seqid); 569 oldseq = be32_to_cpu(lo->plh_stateid.seqid);
569 newseq = be32_to_cpu(new->seqid); 570 newseq = be32_to_cpu(new->seqid);
570 if (list_empty(&lo->plh_segs) || pnfs_seqid_is_newer(newseq, oldseq)) { 571 if (empty || pnfs_seqid_is_newer(newseq, oldseq)) {
571 nfs4_stateid_copy(&lo->plh_stateid, new); 572 nfs4_stateid_copy(&lo->plh_stateid, new);
572 if (update_barrier) { 573 if (update_barrier) {
573 u32 new_barrier = be32_to_cpu(new->seqid); 574 new_barrier = be32_to_cpu(new->seqid);
574
575 if (pnfs_seqid_is_newer(new_barrier, lo->plh_barrier))
576 lo->plh_barrier = new_barrier;
577 } else { 575 } else {
578 /* Because of wraparound, we want to keep the barrier 576 /* Because of wraparound, we want to keep the barrier
579 * "close" to the current seqids. It needs to be 577 * "close" to the current seqids.
580 * within 2**31 to count as "behind", so if it
581 * gets too near that limit, give us a litle leeway
582 * and bring it to within 2**30.
583 * NOTE - and yes, this is all unsigned arithmetic.
584 */ 578 */
585 if (unlikely((newseq - lo->plh_barrier) > (3 << 29))) 579 new_barrier = newseq - atomic_read(&lo->plh_outstanding);
586 lo->plh_barrier = newseq - (1 << 30);
587 } 580 }
581 if (empty || pnfs_seqid_is_newer(new_barrier, lo->plh_barrier))
582 lo->plh_barrier = new_barrier;
588 } 583 }
589} 584}
590 585