2020-09-25 19:04:20

by Chuck Lever III

[permalink] [raw]
Subject: [PATCH] nfsd: rq_lease_breaker cleanup

From: J. Bruce Fields <[email protected]>

Since only the v4 code cares about it, maybe it's better to leave
rq_lease_breaker out of the common dispatch code?

Signed-off-by: J. Bruce Fields <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
---
fs/nfsd/nfs4state.c | 3 +++
fs/nfsd/nfs4xdr.c | 1 +
fs/nfsd/nfssvc.c | 2 --
3 files changed, 4 insertions(+), 2 deletions(-)

Hey Bruce-

This seems to work a little better than the patch you sent me
this morning.

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 8b08a1ea58fe..8899342f2eb7 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4637,6 +4637,9 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
if (!i_am_nfsd())
return NULL;
rqst = kthread_data(current);
+ /* Note rq_prog == NFS_ACL_PROGRAM is also possible: */
+ if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
+ return NULL;
if (!rqst->rq_lease_breaker)
return NULL;
clp = *(rqst->rq_lease_breaker);
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 758d8154a5b3..2a374231bd1c 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -5173,6 +5173,7 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p)
__func__, svc_addr(rqstp), be32_to_cpu(rqstp->rq_xid));
return 0;
}
+ rqstp->rq_lease_breaker = NULL;
args->p = p;
args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len;
args->pagelist = rqstp->rq_arg.pages;
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index eb07bbd565d7..2117cc70b493 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -1022,8 +1022,6 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
if (nfs_request_too_big(rqstp, proc))
goto out_too_large;

- rqstp->rq_lease_breaker = NULL;
-
/*
* Give the xdr decoder a chance to change this if it wants
* (necessary in the NFSv4.0 compound case)



2020-09-25 20:48:47

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH] nfsd: rq_lease_breaker cleanup

On Fri, Sep 25, 2020 at 03:03:42PM -0400, Chuck Lever wrote:
> From: J. Bruce Fields <[email protected]>
>
> Since only the v4 code cares about it, maybe it's better to leave
> rq_lease_breaker out of the common dispatch code?
>
> Signed-off-by: J. Bruce Fields <[email protected]>
> Signed-off-by: Chuck Lever <[email protected]>
> ---
> fs/nfsd/nfs4state.c | 3 +++
> fs/nfsd/nfs4xdr.c | 1 +
> fs/nfsd/nfssvc.c | 2 --
> 3 files changed, 4 insertions(+), 2 deletions(-)
>
> Hey Bruce-
>
> This seems to work a little better than the patch you sent me
> this morning.

Oops, right, I should have warned that was untested! I don't know how
it got past me that I was trying to read rqst before it was set....

The other two lines aren't needed, though.

(The only place we read rq_lease_breaker is in nfsd_breaker_owns_lease(),
and only after we've checked that we're running as an nfsd thread
processing an NFSv4 rpc.

Such a thread shouldn't touch the filesystem and trigger this callback
until it's in nfsd4_proc_compound. Which sets rq_lease_breaker at the
start.)

--b.

commit 4abef2c530f7
Author: J. Bruce Fields <[email protected]>
Date: Fri Sep 25 10:12:39 2020 -0400

nfsd: rq_lease_breaker cleanup

Since only the v4 code cares about it, maybe it's better to leave
rq_lease_breaker out of the common dispatch code?

Signed-off-by: J. Bruce Fields <[email protected]>

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 62afcae18e17..c13b04718a3f 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4598,6 +4598,9 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
if (!i_am_nfsd())
return NULL;
rqst = kthread_data(current);
+ /* Note rq_prog == NFS_ACL_PROGRAM is also possible: */
+ if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
+ return NULL;
clp = *(rqst->rq_lease_breaker);
return dl->dl_stid.sc_client == clp;
}
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index b603dfcdd361..8d6f6f4c8b28 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -1016,7 +1016,6 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
*statp = rpc_garbage_args;
return 1;
}
- rqstp->rq_lease_breaker = NULL;
/*
* Give the xdr decoder a chance to change this if it wants
* (necessary in the NFSv4.0 compound case)

2020-09-25 20:50:26

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH] nfsd: rq_lease_breaker cleanup



> On Sep 25, 2020, at 4:48 PM, J. Bruce Fields <[email protected]> wrote:
>
> On Fri, Sep 25, 2020 at 03:03:42PM -0400, Chuck Lever wrote:
>> From: J. Bruce Fields <[email protected]>
>>
>> Since only the v4 code cares about it, maybe it's better to leave
>> rq_lease_breaker out of the common dispatch code?
>>
>> Signed-off-by: J. Bruce Fields <[email protected]>
>> Signed-off-by: Chuck Lever <[email protected]>
>> ---
>> fs/nfsd/nfs4state.c | 3 +++
>> fs/nfsd/nfs4xdr.c | 1 +
>> fs/nfsd/nfssvc.c | 2 --
>> 3 files changed, 4 insertions(+), 2 deletions(-)
>>
>> Hey Bruce-
>>
>> This seems to work a little better than the patch you sent me
>> this morning.
>
> Oops, right, I should have warned that was untested! I don't know how
> it got past me that I was trying to read rqst before it was set....
>
> The other two lines aren't needed, though.
>
> (The only place we read rq_lease_breaker is in nfsd_breaker_owns_lease(),
> and only after we've checked that we're running as an nfsd thread
> processing an NFSv4 rpc.
>
> Such a thread shouldn't touch the filesystem and trigger this callback
> until it's in nfsd4_proc_compound. Which sets rq_lease_breaker at the
> start.)
>
> --b.
>
> commit 4abef2c530f7
> Author: J. Bruce Fields <[email protected]>
> Date: Fri Sep 25 10:12:39 2020 -0400
>
> nfsd: rq_lease_breaker cleanup
>
> Since only the v4 code cares about it, maybe it's better to leave
> rq_lease_breaker out of the common dispatch code?
>
> Signed-off-by: J. Bruce Fields <[email protected]>
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 62afcae18e17..c13b04718a3f 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4598,6 +4598,9 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
> if (!i_am_nfsd())
> return NULL;
> rqst = kthread_data(current);
> + /* Note rq_prog == NFS_ACL_PROGRAM is also possible: */
> + if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
> + return NULL;

Am I missing a patch that removes

if (!rqst->rq_lease_breaker)
return NULL;

> clp = *(rqst->rq_lease_breaker);
> return dl->dl_stid.sc_client == clp;
> }
> diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
> index b603dfcdd361..8d6f6f4c8b28 100644
> --- a/fs/nfsd/nfssvc.c
> +++ b/fs/nfsd/nfssvc.c
> @@ -1016,7 +1016,6 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
> *statp = rpc_garbage_args;
> return 1;
> }
> - rqstp->rq_lease_breaker = NULL;
> /*
> * Give the xdr decoder a chance to change this if it wants
> * (necessary in the NFSv4.0 compound case)

--
Chuck Lever



2020-09-25 21:03:59

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH] nfsd: rq_lease_breaker cleanup

On Fri, Sep 25, 2020 at 04:49:57PM -0400, Chuck Lever wrote:
> Am I missing a patch that removes
>
> if (!rqst->rq_lease_breaker)
> return NULL;

I've been working off 5.9-rc1, which doesn't have it, sorry about that.

--b.

commit 58b869423e3d
Author: J. Bruce Fields <[email protected]>
Date: Fri Sep 25 10:12:39 2020 -0400

nfsd: rq_lease_breaker cleanup

Since only the v4 code cares about it, maybe it's better to leave
rq_lease_breaker out of the common dispatch code?

Signed-off-by: J. Bruce Fields <[email protected]>

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index a59551efd263..4f3964582b68 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4598,7 +4598,8 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
if (!i_am_nfsd())
return NULL;
rqst = kthread_data(current);
- if (!rqst->rq_lease_breaker)
+ /* Note rq_prog == NFS_ACL_PROGRAM is also possible: */
+ if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4)
return NULL;
clp = *(rqst->rq_lease_breaker);
return dl->dl_stid.sc_client == clp;
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index f7f6473578af..f6bc94cab9da 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -1016,7 +1016,6 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
*statp = rpc_garbage_args;
return 1;
}
- rqstp->rq_lease_breaker = NULL;
/*
* Give the xdr decoder a chance to change this if it wants
* (necessary in the NFSv4.0 compound case)