diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-10-04 19:32:22 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-10-04 19:57:48 -0400 |
commit | 22aaf71495570b31350c37fd0aa736551bbaa3c9 (patch) | |
tree | 513b8cb36005322aa2c418e3e0519aefe597cda5 /fs/nfs/pnfs.c | |
parent | 0f35ad6f688e9b7bcaa918a42130695822906f11 (diff) |
NFSv4.1: Ensure that the layout sequence id stays 'close' to the current
Clamp the layout barrier sequence id to the current sequence id
minus the maximum number of outstanding layoutget requests.
Also ensure that we correctly initialise lo->plh_barrier if there are
no layout segments associated to this layout header.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r-- | fs/nfs/pnfs.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 42613bd19f8..861dd97b569 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -563,28 +563,23 @@ void | |||
563 | pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | 563 | pnfs_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 | ||