Commit 14b7f4a1 authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

nfsd: handle seqid wraparound in nfsd4_preprocess_layout_stateid

Move the existing static function to an inline helper, and call it.
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJeff Layton <jeff.layton@primarydata.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 64c59a37
...@@ -289,7 +289,7 @@ nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp, ...@@ -289,7 +289,7 @@ nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp,
status = nfserr_bad_stateid; status = nfserr_bad_stateid;
mutex_lock(&ls->ls_mutex); mutex_lock(&ls->ls_mutex);
if (stateid->si_generation > stid->sc_stateid.si_generation) if (nfsd4_stateid_generation_after(stateid, &stid->sc_stateid))
goto out_unlock_stid; goto out_unlock_stid;
if (layout_type != ls->ls_layout_type) if (layout_type != ls->ls_layout_type)
goto out_unlock_stid; goto out_unlock_stid;
......
...@@ -4651,12 +4651,6 @@ grace_disallows_io(struct net *net, struct inode *inode) ...@@ -4651,12 +4651,6 @@ grace_disallows_io(struct net *net, struct inode *inode)
return opens_in_grace(net) && mandatory_lock(inode); return opens_in_grace(net) && mandatory_lock(inode);
} }
/* Returns true iff a is later than b: */
static bool stateid_generation_after(stateid_t *a, stateid_t *b)
{
return (s32)(a->si_generation - b->si_generation) > 0;
}
static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session) static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session)
{ {
/* /*
...@@ -4670,7 +4664,7 @@ static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_s ...@@ -4670,7 +4664,7 @@ static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_s
return nfs_ok; return nfs_ok;
/* If the client sends us a stateid from the future, it's buggy: */ /* If the client sends us a stateid from the future, it's buggy: */
if (stateid_generation_after(in, ref)) if (nfsd4_stateid_generation_after(in, ref))
return nfserr_bad_stateid; return nfserr_bad_stateid;
/* /*
* However, we could see a stateid from the past, even from a * However, we could see a stateid from the past, even from a
......
...@@ -573,6 +573,11 @@ enum nfsd4_cb_op { ...@@ -573,6 +573,11 @@ enum nfsd4_cb_op {
NFSPROC4_CLNT_CB_SEQUENCE, NFSPROC4_CLNT_CB_SEQUENCE,
}; };
/* Returns true iff a is later than b: */
static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b)
{
return (s32)(a->si_generation - b->si_generation) > 0;
}
struct nfsd4_compound_state; struct nfsd4_compound_state;
struct nfsd_net; struct nfsd_net;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment