diff options
-rw-r--r-- | fs/nfs/pnfs.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index c8c1d0cc197a..f1387e87513f 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -549,6 +549,15 @@ pnfs_destroy_all_layouts(struct nfs_client *clp) | |||
549 | } | 549 | } |
550 | } | 550 | } |
551 | 551 | ||
552 | /* | ||
553 | * Compare 2 layout stateid sequence ids, to see which is newer, | ||
554 | * taking into account wraparound issues. | ||
555 | */ | ||
556 | static bool pnfs_seqid_is_newer(u32 s1, u32 s2) | ||
557 | { | ||
558 | return (s32)s1 - (s32)s2 > 0; | ||
559 | } | ||
560 | |||
552 | /* update lo->plh_stateid with new if is more recent */ | 561 | /* update lo->plh_stateid with new if is more recent */ |
553 | void | 562 | void |
554 | 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, |
@@ -558,7 +567,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | |||
558 | 567 | ||
559 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); | 568 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); |
560 | newseq = be32_to_cpu(new->seqid); | 569 | newseq = be32_to_cpu(new->seqid); |
561 | if (list_empty(&lo->plh_segs) || (int)(newseq - oldseq) > 0) { | 570 | if (list_empty(&lo->plh_segs) || pnfs_seqid_is_newer(newseq, oldseq)) { |
562 | nfs4_stateid_copy(&lo->plh_stateid, new); | 571 | nfs4_stateid_copy(&lo->plh_stateid, new); |
563 | if (update_barrier) { | 572 | if (update_barrier) { |
564 | u32 new_barrier = be32_to_cpu(new->seqid); | 573 | u32 new_barrier = be32_to_cpu(new->seqid); |