nfsd: use nfsd_v4client() in nfsd_breaker_owns_lease()
nfsd_breaker_owns_lease() currently open-codes the same test that nfsd_v4client() performs. With this patch we use nfsd_v4client() instead. Also as i_am_nfsd() is only used in combination with kthread_data(), replace it with nfsd_current_rqst() which combines the two and returns a valid svc_rqst, or NULL. The test for NULL is moved into nfsd_v4client() for code clarity. Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
9fd45c16f3
commit
4f67d24f72
3 changed files with 8 additions and 9 deletions
|
@ -5277,11 +5277,8 @@ static bool nfsd_breaker_owns_lease(struct file_lease *fl)
|
||||||
struct svc_rqst *rqst;
|
struct svc_rqst *rqst;
|
||||||
struct nfs4_client *clp;
|
struct nfs4_client *clp;
|
||||||
|
|
||||||
if (!i_am_nfsd())
|
rqst = nfsd_current_rqst();
|
||||||
return false;
|
if (!nfsd_v4client(rqst))
|
||||||
rqst = kthread_data(current);
|
|
||||||
/* Note rq_prog == NFS_ACL_PROGRAM is also possible: */
|
|
||||||
if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
|
|
||||||
return false;
|
return false;
|
||||||
clp = *(rqst->rq_lease_breaker);
|
clp = *(rqst->rq_lease_breaker);
|
||||||
return dl->dl_stid.sc_client == clp;
|
return dl->dl_stid.sc_client == clp;
|
||||||
|
|
|
@ -118,7 +118,7 @@ int nfsd_get_nrthreads(int n, int *, struct net *);
|
||||||
int nfsd_set_nrthreads(int n, int *, struct net *);
|
int nfsd_set_nrthreads(int n, int *, struct net *);
|
||||||
void nfsd_shutdown_threads(struct net *net);
|
void nfsd_shutdown_threads(struct net *net);
|
||||||
|
|
||||||
bool i_am_nfsd(void);
|
struct svc_rqst *nfsd_current_rqst(void);
|
||||||
|
|
||||||
struct nfsdfs_client {
|
struct nfsdfs_client {
|
||||||
struct kref cl_ref;
|
struct kref cl_ref;
|
||||||
|
@ -159,7 +159,7 @@ extern int nfsd_max_blksize;
|
||||||
|
|
||||||
static inline int nfsd_v4client(struct svc_rqst *rq)
|
static inline int nfsd_v4client(struct svc_rqst *rq)
|
||||||
{
|
{
|
||||||
return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
|
return rq && rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
|
||||||
}
|
}
|
||||||
static inline struct user_namespace *
|
static inline struct user_namespace *
|
||||||
nfsd_user_namespace(const struct svc_rqst *rqstp)
|
nfsd_user_namespace(const struct svc_rqst *rqstp)
|
||||||
|
|
|
@ -578,9 +578,11 @@ void nfsd_shutdown_threads(struct net *net)
|
||||||
mutex_unlock(&nfsd_mutex);
|
mutex_unlock(&nfsd_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool i_am_nfsd(void)
|
struct svc_rqst *nfsd_current_rqst(void)
|
||||||
{
|
{
|
||||||
return kthread_func(current) == nfsd;
|
if (kthread_func(current) == nfsd)
|
||||||
|
return kthread_data(current);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nfsd_create_serv(struct net *net)
|
int nfsd_create_serv(struct net *net)
|
||||||
|
|
Loading…
Reference in a new issue