diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-10-02 16:47:14 -0700 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-10-02 16:47:14 -0700 |
commit | 5a65503f3dbdb4aa1cd6cb58c479c015d093292b (patch) | |
tree | 86b6b53646ac748c6ef75c5f22b3c2ed55312a88 /fs/nfs | |
parent | 038d6493763d900797dfeb555502d3b0d8103fba (diff) | |
download | linux-5a65503f3dbdb4aa1cd6cb58c479c015d093292b.tar.gz linux-5a65503f3dbdb4aa1cd6cb58c479c015d093292b.tar.bz2 linux-5a65503f3dbdb4aa1cd6cb58c479c015d093292b.zip |
NFSv4.1: Deal with wraparound issues when updating the layout stateid
...and add a helper function.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-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) } } +/* + * Compare 2 layout stateid sequence ids, to see which is newer, + * taking into account wraparound issues. + */ +static bool pnfs_seqid_is_newer(u32 s1, u32 s2) +{ + return (s32)s1 - (s32)s2 > 0; +} + /* update lo->plh_stateid with new if is more recent */ void 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, oldseq = be32_to_cpu(lo->plh_stateid.seqid); newseq = be32_to_cpu(new->seqid); - if (list_empty(&lo->plh_segs) || (int)(newseq - oldseq) > 0) { + if (list_empty(&lo->plh_segs) || pnfs_seqid_is_newer(newseq, oldseq)) { nfs4_stateid_copy(&lo->plh_stateid, new); if (update_barrier) { u32 new_barrier = be32_to_cpu(new->seqid); |