Skip to content

Commit 4f67d24

Browse files
neilbrownchucklever
authored andcommitted
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 <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 9fd45c1 commit 4f67d24

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

fs/nfsd/nfs4state.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,11 +5277,8 @@ static bool nfsd_breaker_owns_lease(struct file_lease *fl)
52775277
struct svc_rqst *rqst;
52785278
struct nfs4_client *clp;
52795279

5280-
if (!i_am_nfsd())
5281-
return false;
5282-
rqst = kthread_data(current);
5283-
/* Note rq_prog == NFS_ACL_PROGRAM is also possible: */
5284-
if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
5280+
rqst = nfsd_current_rqst();
5281+
if (!nfsd_v4client(rqst))
52855282
return false;
52865283
clp = *(rqst->rq_lease_breaker);
52875284
return dl->dl_stid.sc_client == clp;

fs/nfsd/nfsd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int nfsd_get_nrthreads(int n, int *, struct net *);
118118
int nfsd_set_nrthreads(int n, int *, struct net *);
119119
void nfsd_shutdown_threads(struct net *net);
120120

121-
bool i_am_nfsd(void);
121+
struct svc_rqst *nfsd_current_rqst(void);
122122

123123
struct nfsdfs_client {
124124
struct kref cl_ref;
@@ -159,7 +159,7 @@ extern int nfsd_max_blksize;
159159

160160
static inline int nfsd_v4client(struct svc_rqst *rq)
161161
{
162-
return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
162+
return rq && rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
163163
}
164164
static inline struct user_namespace *
165165
nfsd_user_namespace(const struct svc_rqst *rqstp)

fs/nfsd/nfssvc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,11 @@ void nfsd_shutdown_threads(struct net *net)
578578
mutex_unlock(&nfsd_mutex);
579579
}
580580

581-
bool i_am_nfsd(void)
581+
struct svc_rqst *nfsd_current_rqst(void)
582582
{
583-
return kthread_func(current) == nfsd;
583+
if (kthread_func(current) == nfsd)
584+
return kthread_data(current);
585+
return NULL;
584586
}
585587

586588
int nfsd_create_serv(struct net *net)

0 commit comments

Comments
 (0)