Simple lockd clean-ups
Subsystems (2)
[email protected]
maintainercover Simple lockd clean-ups
From: Chuck Lever <[email protected]>
Clean up a few nits I noticed while working on converting lockd to use xdrgen-generated XDR functions.
Chuck Lever (5):
lockd: Remove unused typedef
lockd: Remove unnecessary memset()
lockd: Remove some snippets of unfinished code
lockd: Remove unused parameter to nlmsvc_testlock()
lockd: Remove unneeded initialization of file_lock::c.flc_flags
fs/lockd/svc4proc.c | 20 +++++--------------- fs/lockd/svclock.c | 2 +- fs/lockd/svcproc.c | 15 ++------------- fs/lockd/xdr4.c | 2 -- include/linux/lockd/lockd.h | 6 +++--- include/linux/lockd/xdr.h | 2 -- 6 files changed, 11 insertions(+), 36 deletions(-)
Signature · 1 line
2.46.2
[email protected]
maintainerPATCH 1/5 lockd: Remove unused typedef
From: Chuck Lever <[email protected]>
Clean up: Looks like the last usage of this typedef was removed by commit 026fec7e7c47 ("sunrpc: properly type pc_decode callbacks") in 2017.
--- include/linux/lockd/xdr.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/lockd/xdr.h +0 -2
@@ -73,8 +73,6 @@ struct nlm_args {u32 fsm_mode; }; -typedef struct nlm_args nlm_args ; -/* * Generic lockd result */
Signature · 1 line
2.46.2
[email protected]
maintainerPATCH 2/5 lockd: Remove unnecessary memset()
In reply to [email protected]From: Chuck Lever <[email protected]>
Since commit 103cc1fafee4 ("SUNRPC: Parametrize how much of argsize should be zeroed") (and possibly long before that, even) all of the memory underlying rqstp->rq_argp is zeroed already. There's no need for the memset() in nlm4svc_decode_shareargs().
--- fs/lockd/xdr4.c | 1 - 1 file changed, 1 deletion(-)
fs/lockd/xdr4.c +0 -1
@@ -268,7 +268,6 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)struct nlm_args *argp = rqstp->rq_argp;struct nlm_lock *lock = &argp->lock; -memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ;
Signature · 1 line
2.46.2
[email protected]
maintainerPATCH 3/5 lockd: Remove some snippets of unfinished code
In reply to [email protected]From: Chuck Lever <[email protected]>
Clean up.
--- fs/lockd/svc4proc.c | 12 ------------ fs/lockd/svcproc.c | 12 ------------ 2 files changed, 24 deletions(-)
fs/lockd/svc4proc.c +0 -12
@@ -142,18 +142,6 @@ __nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)if ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file)))return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; -#if 0 -/* If supplied state doesn't match current state, we assume it's -* an old request that time-warped somehow. Any error return would -* do in this case because it's irrelevant anyway. -* -* NB: We don't retrieve the remote host's state yet. -*/ -if (host->h_nsmstate && host->h_nsmstate != argp->state) { - resp->status = nlm_lck_denied_nolocks; - } else -#endif -/* Now try to lock the file */ resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock, argp->block, &argp->cookie,
fs/lockd/svcproc.c +0 -12
@@ -165,18 +165,6 @@ __nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)if ((resp->status =nlmsvc_retrieve_args (rqstp, argp, &host, &file)))return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; -#if 0 -/* If supplied state doesn't match current state, we assume it's -* an old request that time-warped somehow. Any error return would -* do in this case because it's irrelevant anyway. -* -* NB: We don't retrieve the remote host's state yet. -*/ -if (host->h_nsmstate && host->h_nsmstate != argp->state) { - resp->status = nlm_lck_denied_nolocks; - } else -#endif -/* Now try to lock the file */ resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock, argp->block, &argp->cookie,
Signature · 1 line
2.46.2
[email protected]
maintainerPATCH 4/5 lockd: Remove unused parameter to nlmsvc_testlock()
In reply to [email protected]From: Chuck Lever <[email protected]>
This parameter has been unused since commit 09802fd2a8ca ("lockd:
rip out deferred lock handling from testlock codepath").
--- fs/lockd/svc4proc.c | 3 ++- fs/lockd/svclock.c | 2 +- fs/lockd/svcproc.c | 3 ++- include/linux/lockd/lockd.h | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-)
fs/lockd/svc4proc.c +2 -1
@@ -108,7 +108,8 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) test_owner = argp->lock.fl.c.flc_owner;/* Now check for conflicting locks */ - resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie); + resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, + &resp->lock);if (resp->status == nlm_drop_reply) rc = rpc_drop_reply;else
fs/lockd/svclock.c +1 -1
@@ -609,7 +609,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,__be32 nlmsvc_testlock (struct svc_rqst *rqstp,struct nlm_file *file,struct nlm_host *host,struct nlm_lock *lock, -struct nlm_lock *conflock,struct nlm_cookie *cookie) +struct nlm_lock *conflock) {int error;int mode;
fs/lockd/svcproc.c +2 -1
@@ -130,7 +130,8 @@ __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) test_owner = argp->lock.fl.c.flc_owner;/* Now check for conflicting locks */ - resp->status =cast_status (nlmsvc_testlock (rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie)); + resp->status =cast_status (nlmsvc_testlock (rqstp, file, host, + &argp->lock, &resp->lock));if (resp->status == nlm_drop_reply) rc = rpc_drop_reply;else
include/linux/lockd/lockd.h +3 -3
@@ -278,9 +278,9 @@ __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, struct nlm_host *, struct nlm_lock *, int, struct nlm_cookie *, int);__be32 nlmsvc_unlock (struct net *net,struct nlm_file *,struct nlm_lock *); -__be32 nlmsvc_testlock (struct svc_rqst *,struct nlm_file *, -struct nlm_host *,struct nlm_lock *, -struct nlm_lock *,struct nlm_cookie *); +__be32 nlmsvc_testlock (struct svc_rqst *rqstp,struct nlm_file *file, +struct nlm_host *host,struct nlm_lock *lock, +struct nlm_lock *conflock);__be32 nlmsvc_cancel_blocked (struct net *net,struct nlm_file *,struct nlm_lock *);void nlmsvc_retry_blocked (struct svc_rqst *rqstp); void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
Signature · 1 line
2.46.2
[email protected]
maintainerPATCH 5/5 lockd: Remove unneeded initialization of file_lock::c.flc_flags
In reply to [email protected]From: Chuck Lever <[email protected]>
Since commit 75c7940d2a86 ("lockd: set missing fl_flags field when retrieving args"), nlmsvc_retrieve_args() initializes the flc_flags field. svcxdr_decode_lock() no longer needs to do this.
This clean up removes one dependency on the nlm_lock:fl field. No behavior change is expected.
Analysis:
svcxdr_decode_lock() is called by:
nlm4svc_decode_testargs()nlm4svc_decode_lockargs()nlm4svc_decode_cancargs()nlm4svc_decode_unlockargs()
nlm4svc_decode_testargs() is used by:
- NLMPROC4_TEST and NLMPROC4_TEST_MSG, which call nlmsvc_retrieve_args()
- NLMPROC4_GRANTED and NLMPROC4_GRANTED_MSG, which don't pass the lock's file_lock to the generic lock API
nlm4svc_decode_lockargs() is used by:
- NLMPROC4_LOCK and NLM4PROC4_LOCK_MSG, which call nlmsvc_retrieve_args()
- NLMPROC4_UNLOCK and NLM4PROC4_UNLOCK_MSG, which call nlmsvc_retrieve_args()
- NLMPROC4_NM_LOCK, which calls nlmsvc_retrieve_args()
nlm4svc_decode_cancargs() is used by:
- NLMPROC4_CANCEL and NLMPROC4_CANCEL_MSG, which call nlmsvc_retrieve_args()
nlm4svc_decode_unlockargs() is used by:
- NLMPROC4_UNLOCK and NLMPROC4_UNLOCK_MSG, which call nlmsvc_retrieve_args()
All callers except GRANTED/GRANTED_MSG eventually call nlmsvc_retrieve_args() before using nlm_lock::fl.c.flc_flags. Thus this change is safe.
--- fs/lockd/svc4proc.c | 5 +++-- fs/lockd/xdr4.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-)
fs/lockd/svc4proc.c +3 -2
@@ -46,14 +46,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,if (filp !=NULL ) {int mode =lock_to_openmode (&lock->fl); + lock->fl.c.flc_flags =FL_POSIX ; + error =nlm_lookup_file (rqstp, &file, lock);if (error) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_flags =FL_POSIX ; - lock->fl.c.flc_file = file->f_file[mode]; + lock->fl.c.flc_file = file->f_file[mode]; lock->fl.c.flc_pid = current->tgid; lock->fl.fl_start = (loff_t )lock->lock_start; lock->fl.fl_end = lock->lock_len ?
fs/lockd/xdr4.c +0 -1
@@ -89,7 +89,6 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)return false;locks_init_lock (fl); - fl->c.flc_flags =FL_POSIX ; fl->c.flc_type =F_RDLCK ;nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len);return true;
Signature · 1 line
2.46.2
Jeff Layton
maintainerRe: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
Quoted 71 lines · On Thu, 2024-10-17 at 09:36 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Since commit
75c7940d2a86("lockd: set missingfl_flagsfield when retrieving args"),nlmsvc_retrieve_args()initializes theflc_flagsfield.svcxdr_decode_lock()no longer needs to do this.This clean up removes one dependency on the nlm_lock:fl field. No behavior change is expected.
Analysis:
svcxdr_decode_lock()is called by:
nlm4svc_decode_testargs()nlm4svc_decode_lockargs()nlm4svc_decode_cancargs()nlm4svc_decode_unlockargs()
nlm4svc_decode_testargs()is used by:
-NLMPROC4_TESTandNLMPROC4_TEST_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_GRANTEDandNLMPROC4_GRANTED_MSG, which don't pass the lock'sfile_lockto the generic lock API
nlm4svc_decode_lockargs()is used by:
-NLMPROC4_LOCKandNLM4PROC4_LOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_UNLOCKandNLM4PROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_NM_LOCK, which callsnlmsvc_retrieve_args()
nlm4svc_decode_cancargs()is used by:
-NLMPROC4_CANCELandNLMPROC4_CANCEL_MSG, which callnlmsvc_retrieve_args()
nlm4svc_decode_unlockargs()is used by:
-NLMPROC4_UNLOCKandNLMPROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()All callers except GRANTED/GRANTED_MSG eventually call
nlmsvc_retrieve_args()before usingnlm_lock::fl.c.flc_flags. Thus this change is safe.Signed-off-by Chuck Lever <[email protected]>--- fs/lockd/svc4proc.c | 5 +++-- fs/lockd/xdr4.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-)fs/lockd/svc4proc.c +3
-2@@ -46,14 +46,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,if (filp !=NULL ) {int mode =lock_to_openmode (&lock->fl); + lock->fl.c.flc_flags =FL_POSIX ; + error =nlm_lookup_file (rqstp, &file, lock);if (error) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_flags =FL_POSIX ; - lock->fl.c.flc_file = file->f_file[mode]; + lock->fl.c.flc_file = file->f_file[mode]; lock->fl.c.flc_pid = current->tgid; lock->fl.fl_start = (loff_t )lock->lock_start; lock->fl.fl_end = lock->lock_len ?fs/lockd/xdr4.c +0
-0
fs/lockd/xdr4.c svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) · line 94
Quoted 7 lines
fs/lockd/xdr4.c +0
-1@@ -89,7 +89,6 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)return false;locks_init_lock (fl); - fl->c.flc_flags =FL_POSIX ; fl->c.flc_type =F_RDLCK ;nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len);return true;
1-4 look fine. You can add my R-b to those.
For this one, I think I'd rather see this go the other way, and just eliminate the setting of flc_flags in nlm4svc_retrieve_args. We only deal with FL_POSIX locks in svc lockd, and that does it right after locks_init_lock, so I think that means it'll be done earlier, no?
Also, I think the same duplication is in nlmsvc_retrieve_args and the nlmv3 version of svcxdr_decode_lock.
--
Jeff Layton <[email protected]>
Re: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
Quoted 78 lines · Jeff Layton
Quoted 73 lines · On Thu, 2024-10-17 at 09:36 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Since commit
75c7940d2a86("lockd: set missingfl_flagsfield when retrieving args"),nlmsvc_retrieve_args()initializes theflc_flagsfield.svcxdr_decode_lock()no longer needs to do this.This clean up removes one dependency on the nlm_lock:fl field. No behavior change is expected.
Analysis:
svcxdr_decode_lock()is called by:
nlm4svc_decode_testargs()nlm4svc_decode_lockargs()nlm4svc_decode_cancargs()nlm4svc_decode_unlockargs()
nlm4svc_decode_testargs()is used by:
-NLMPROC4_TESTandNLMPROC4_TEST_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_GRANTEDandNLMPROC4_GRANTED_MSG, which don't pass the lock'sfile_lockto the generic lock API
nlm4svc_decode_lockargs()is used by:
-NLMPROC4_LOCKandNLM4PROC4_LOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_UNLOCKandNLM4PROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_NM_LOCK, which callsnlmsvc_retrieve_args()
nlm4svc_decode_cancargs()is used by:
-NLMPROC4_CANCELandNLMPROC4_CANCEL_MSG, which callnlmsvc_retrieve_args()
nlm4svc_decode_unlockargs()is used by:
-NLMPROC4_UNLOCKandNLMPROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()All callers except GRANTED/GRANTED_MSG eventually call
nlmsvc_retrieve_args()before usingnlm_lock::fl.c.flc_flags. Thus this change is safe.Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c| 5 +++--fs/lockd/xdr4.c| 1 -2 files changed, 3 insertions(+), 3 deletions(-)fs/lockd/svc4proc.c +3
-2@@ -46,14 +46,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,if (filp !=NULL ) {int mode =lock_to_openmode (&lock->fl); + lock->fl.c.flc_flags =FL_POSIX ; + error =nlm_lookup_file (rqstp, &file, lock);if (error) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_flags =FL_POSIX ; - lock->fl.c.flc_file = file->f_file[mode]; + lock->fl.c.flc_file = file->f_file[mode]; lock->fl.c.flc_pid = current->tgid; lock->fl.fl_start = (loff_t )lock->lock_start;
lock->fl.fl_end=lock->lock_len?fs/lockd/xdr4.c +0
-0@@ -89,7 +89,6 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)return false;
Quoted 7 lines
fs/lockd/xdr4.c svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) · line 94
Quoted 5 lines
fs/lockd/xdr4.c +0
-1locks_init_lock (fl); - fl->c.flc_flags =FL_POSIX ; fl->c.flc_type =F_RDLCK ;nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len);return true;1-4 look fine. You can add my R-b to those.
Thanks!
Quoted 4 lines
For this one, I think I'd rather see this go the other way, and just eliminate the setting of
flc_flagsinnlm4svc_retrieve_args. We only deal withFL_POSIXlocks in svc lockd, and that does it right afterlocks_init_lock, so I think that means it'll be done earlier, no?
Have a look at the nlm4 branch in my kernel.org <http://kernel.org/> repo to see where this is headed.
Quoted 2 lines
Also, I think the same duplication is in
nlmsvc_retrieve_argsand the nlmv3 version ofsvcxdr_decode_lock.
Which is going away when NFSv2 is removed. I'm not too concerned about that duplication.
--
Chuck Lever
Re: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
Quoted 88 lines · Chuck Lever III
Quoted 77 lines · Jeff Layton
Quoted 73 lines · On Thu, 2024-10-17 at 09:36 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Since commit
75c7940d2a86("lockd: set missingfl_flagsfield when retrieving args"),nlmsvc_retrieve_args()initializes theflc_flagsfield.svcxdr_decode_lock()no longer needs to do this.This clean up removes one dependency on the nlm_lock:fl field. No behavior change is expected.
Analysis:
svcxdr_decode_lock()is called by:
nlm4svc_decode_testargs()nlm4svc_decode_lockargs()nlm4svc_decode_cancargs()nlm4svc_decode_unlockargs()
nlm4svc_decode_testargs()is used by:
-NLMPROC4_TESTandNLMPROC4_TEST_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_GRANTEDandNLMPROC4_GRANTED_MSG, which don't pass the lock'sfile_lockto the generic lock API
nlm4svc_decode_lockargs()is used by:
-NLMPROC4_LOCKandNLM4PROC4_LOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_UNLOCKandNLM4PROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_NM_LOCK, which callsnlmsvc_retrieve_args()
nlm4svc_decode_cancargs()is used by:
-NLMPROC4_CANCELandNLMPROC4_CANCEL_MSG, which callnlmsvc_retrieve_args()
nlm4svc_decode_unlockargs()is used by:
-NLMPROC4_UNLOCKandNLMPROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()All callers except GRANTED/GRANTED_MSG eventually call
nlmsvc_retrieve_args()before usingnlm_lock::fl.c.flc_flags. Thus this change is safe.Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c| 5 +++--fs/lockd/xdr4.c| 1 -2 files changed, 3 insertions(+), 3 deletions(-)fs/lockd/svc4proc.c +3
-2@@ -46,14 +46,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,if (filp !=NULL ) {int mode =lock_to_openmode (&lock->fl); + lock->fl.c.flc_flags =FL_POSIX ; + error =nlm_lookup_file (rqstp, &file, lock);if (error) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_flags =FL_POSIX ; - lock->fl.c.flc_file = file->f_file[mode]; + lock->fl.c.flc_file = file->f_file[mode]; lock->fl.c.flc_pid = current->tgid; lock->fl.fl_start = (loff_t )lock->lock_start;
lock->fl.fl_end=lock->lock_len?fs/lockd/xdr4.c +0
-0@@ -89,7 +89,6 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)return false;Quoted 7 lines
fs/lockd/xdr4.c svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) · line 94
Quoted 5 lines
fs/lockd/xdr4.c +0
-1locks_init_lock (fl); - fl->c.flc_flags =FL_POSIX ; fl->c.flc_type =F_RDLCK ;nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len);return true;1-4 look fine. You can add my R-b to those.
Thanks!
Quoted 8 lines
Quoted 4 lines
For this one, I think I'd rather see this go the other way, and just eliminate the setting of
flc_flagsinnlm4svc_retrieve_args. We only deal withFL_POSIXlocks in svc lockd, and that does it right afterlocks_init_lock, so I think that means it'll be done earlier, no?Have a look at the nlm4 branch in my kernel.org <http://kernel.org/> repo to see where this is headed.
(For everyone following along: It's actually in Chuck's xdrgen branch)
Oh ok, I see. This is an interim step toward moving all of the lock initialization into nlm4svc_retrieve_args(). That probably is better. I withdraw my objection.
Quoted 7 lines
Quoted 3 lines
Also, I think the same duplication is in
nlmsvc_retrieve_argsand the nlmv3 version ofsvcxdr_decode_lock.Which is going away when NFSv2 is removed. I'm not too concerned about that duplication.
Fair enough. I'm fine with leaving that to wither for now:
Re: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
In reply to Chuck Lever IIIQuoted 4 lines · Chuck Lever III
Which is going away when NFSv2 is removed. I'm not too concerned about that duplication.
We have a customer with industrial hardware which stores data (logs?) via NFSv2. So we might need to continue to support v2 indefinitely.
Possibly we could use a user-space-nfsd solution if/when v2 service is removed from the kernel, but I would rather not.
Reverting the nfs-utils patches which remove v2 support is fairly easy. Reverting kernel patches that remove v2 support wouldn't be so easy in the long term.
So I'd vote for not removing NFSv2 from the server.
Thanks,
NeilBrown
Re: [PATCH 4/5] lockd: Remove unused parameter to nlmsvc_testlock()
In reply to [email protected]Quoted 4 lines · On Fri, 18 Oct 2024, [email protected] wrote:
From: Chuck Lever <[email protected]>
This parameter has been unused since commit
09802fd2a8ca("lockd:
rip out deferred lock handling from testlock codepath").
It's a minor point, but the parameter is described as "unused" and "this" but never as "cookie" or "nlm_cookie". So I enter the code section of the patch not being entirely sure what is being removed.
NeilBrown
Quoted 71 lines
Signed-off-by Chuck Lever <[email protected]>--- fs/lockd/svc4proc.c | 3 ++- fs/lockd/svclock.c | 2 +- fs/lockd/svcproc.c | 3 ++- include/linux/lockd/lockd.h | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-)fs/lockd/svc4proc.c +2
-1@@ -108,7 +108,8 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) test_owner = argp->lock.fl.c.flc_owner;/* Now check for conflicting locks */ - resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie); + resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, + &resp->lock);if (resp->status == nlm_drop_reply) rc = rpc_drop_reply;else fs/lockd/svclock.c +1
-1@@ -609,7 +609,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,__be32 nlmsvc_testlock (struct svc_rqst *rqstp,struct nlm_file *file,struct nlm_host *host,struct nlm_lock *lock, -struct nlm_lock *conflock,struct nlm_cookie *cookie) +struct nlm_lock *conflock) {int error;int mode;fs/lockd/svcproc.c +2
-1@@ -130,7 +130,8 @@ __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) test_owner = argp->lock.fl.c.flc_owner;/* Now check for conflicting locks */ - resp->status =cast_status (nlmsvc_testlock (rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie)); + resp->status =cast_status (nlmsvc_testlock (rqstp, file, host, + &argp->lock, &resp->lock));if (resp->status == nlm_drop_reply) rc = rpc_drop_reply;else include/linux/lockd/lockd.h +3
-3@@ -278,9 +278,9 @@ __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, struct nlm_host *, struct nlm_lock *, int, struct nlm_cookie *, int);__be32 nlmsvc_unlock (struct net *net,struct nlm_file *,struct nlm_lock *); -__be32 nlmsvc_testlock (struct svc_rqst *,struct nlm_file *, -struct nlm_host *,struct nlm_lock *, -struct nlm_lock *,struct nlm_cookie *); +__be32 nlmsvc_testlock (struct svc_rqst *rqstp,struct nlm_file *file, +struct nlm_host *host,struct nlm_lock *lock, +struct nlm_lock *conflock);__be32 nlmsvc_cancel_blocked (struct net *net,struct nlm_file *,struct nlm_lock *);void nlmsvc_retry_blocked (struct svc_rqst *rqstp); void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,Signature · 1 line
2.46.2
NeilBrown
Reviewed-byRe: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
In reply to Jeff LaytonQuoted 98 lines · Jeff Layton
Quoted 88 lines · Chuck Lever III
Quoted 77 lines · Jeff Layton
Quoted 73 lines · On Thu, 2024-10-17 at 09:36 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Since commit
75c7940d2a86("lockd: set missingfl_flagsfield when retrieving args"),nlmsvc_retrieve_args()initializes theflc_flagsfield.svcxdr_decode_lock()no longer needs to do this.This clean up removes one dependency on the nlm_lock:fl field. No behavior change is expected.
Analysis:
svcxdr_decode_lock()is called by:
nlm4svc_decode_testargs()nlm4svc_decode_lockargs()nlm4svc_decode_cancargs()nlm4svc_decode_unlockargs()
nlm4svc_decode_testargs()is used by:
-NLMPROC4_TESTandNLMPROC4_TEST_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_GRANTEDandNLMPROC4_GRANTED_MSG, which don't pass the lock'sfile_lockto the generic lock API
nlm4svc_decode_lockargs()is used by:
-NLMPROC4_LOCKandNLM4PROC4_LOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_UNLOCKandNLM4PROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_NM_LOCK, which callsnlmsvc_retrieve_args()
nlm4svc_decode_cancargs()is used by:
-NLMPROC4_CANCELandNLMPROC4_CANCEL_MSG, which callnlmsvc_retrieve_args()
nlm4svc_decode_unlockargs()is used by:
-NLMPROC4_UNLOCKandNLMPROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()All callers except GRANTED/GRANTED_MSG eventually call
nlmsvc_retrieve_args()before usingnlm_lock::fl.c.flc_flags. Thus this change is safe.Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c| 5 +++--fs/lockd/xdr4.c| 1 -2 files changed, 3 insertions(+), 3 deletions(-)fs/lockd/svc4proc.c +3
-2@@ -46,14 +46,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,if (filp !=NULL ) {int mode =lock_to_openmode (&lock->fl); + lock->fl.c.flc_flags =FL_POSIX ; + error =nlm_lookup_file (rqstp, &file, lock);if (error) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_flags =FL_POSIX ; - lock->fl.c.flc_file = file->f_file[mode]; + lock->fl.c.flc_file = file->f_file[mode]; lock->fl.c.flc_pid = current->tgid; lock->fl.fl_start = (loff_t )lock->lock_start;
lock->fl.fl_end=lock->lock_len?fs/lockd/xdr4.c +0
-0@@ -89,7 +89,6 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)return false;Quoted 7 lines
fs/lockd/xdr4.c svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) · line 94
Quoted 5 lines
fs/lockd/xdr4.c +0
-1locks_init_lock (fl); - fl->c.flc_flags =FL_POSIX ; fl->c.flc_type =F_RDLCK ;nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len);return true;1-4 look fine. You can add my R-b to those.
Thanks!
Quoted 8 lines
Quoted 4 lines
For this one, I think I'd rather see this go the other way, and just eliminate the setting of
flc_flagsinnlm4svc_retrieve_args. We only deal withFL_POSIXlocks in svc lockd, and that does it right afterlocks_init_lock, so I think that means it'll be done earlier, no?Have a look at the nlm4 branch in my kernel.org <http://kernel.org/> repo to see where this is headed.
Quoted 5 lines
(For everyone following along: It's actually in Chuck's xdrgen branch)
Oh ok, I see. This is an interim step toward moving all of the lock initialization into
nlm4svc_retrieve_args(). That probably is better. I withdraw my objection.
Adding that observation to the commit message would help with review. I agree that moving the initialisation to nlm4svc_retrieve_args() seems sensible. The half-way version in this patch looks really odd without that explanation.
But the whole series
Thanks,
NeilBrown
Quoted 13 lines
Quoted 8 lines
Quoted 4 lines
Also, I think the same duplication is in
nlmsvc_retrieve_argsand the nlmv3 version ofsvcxdr_decode_lock.Which is going away when NFSv2 is removed. I'm not too concerned about that duplication.
Fair enough. I'm fine with leaving that to wither for now:
Reviewed-by Jeff Layton <[email protected]>
Re: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
Quoted 99 lines · NeilBrown
Quoted 98 lines · Jeff Layton
Quoted 96 lines · Chuck Lever III
Quoted 77 lines · Jeff Layton
Quoted 73 lines · On Thu, 2024-10-17 at 09:36 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Since commit
75c7940d2a86("lockd: set missingfl_flagsfield when retrieving args"),nlmsvc_retrieve_args()initializes theflc_flagsfield.svcxdr_decode_lock()no longer needs to do this.This clean up removes one dependency on the nlm_lock:fl field. No behavior change is expected.
Analysis:
svcxdr_decode_lock()is called by:
nlm4svc_decode_testargs()nlm4svc_decode_lockargs()nlm4svc_decode_cancargs()nlm4svc_decode_unlockargs()
nlm4svc_decode_testargs()is used by:
-NLMPROC4_TESTandNLMPROC4_TEST_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_GRANTEDandNLMPROC4_GRANTED_MSG, which don't pass the lock'sfile_lockto the generic lock API
nlm4svc_decode_lockargs()is used by:
-NLMPROC4_LOCKandNLM4PROC4_LOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_UNLOCKandNLM4PROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()
-NLMPROC4_NM_LOCK, which callsnlmsvc_retrieve_args()
nlm4svc_decode_cancargs()is used by:
-NLMPROC4_CANCELandNLMPROC4_CANCEL_MSG, which callnlmsvc_retrieve_args()
nlm4svc_decode_unlockargs()is used by:
-NLMPROC4_UNLOCKandNLMPROC4_UNLOCK_MSG, which callnlmsvc_retrieve_args()All callers except GRANTED/GRANTED_MSG eventually call
nlmsvc_retrieve_args()before usingnlm_lock::fl.c.flc_flags. Thus this change is safe.Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c| 5 +++--fs/lockd/xdr4.c| 1 -2 files changed, 3 insertions(+), 3 deletions(-)fs/lockd/svc4proc.c +3
-2@@ -46,14 +46,15 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,if (filp !=NULL ) {int mode =lock_to_openmode (&lock->fl); + lock->fl.c.flc_flags =FL_POSIX ; + error =nlm_lookup_file (rqstp, &file, lock);if (error) goto no_locks; *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.c.flc_flags =FL_POSIX ; - lock->fl.c.flc_file = file->f_file[mode]; + lock->fl.c.flc_file = file->f_file[mode]; lock->fl.c.flc_pid = current->tgid; lock->fl.fl_start = (loff_t )lock->lock_start;
lock->fl.fl_end=lock->lock_len?fs/lockd/xdr4.c +0
-0@@ -89,7 +89,6 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)return false;Quoted 7 lines
fs/lockd/xdr4.c svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) · line 94
Quoted 5 lines
fs/lockd/xdr4.c +0
-1locks_init_lock (fl); - fl->c.flc_flags =FL_POSIX ; fl->c.flc_type =F_RDLCK ;nlm4svc_set_file_lock_range (fl, lock->lock_start, lock->lock_len);return true;1-4 look fine. You can add my R-b to those.
Thanks!
Quoted 4 lines
For this one, I think I'd rather see this go the other way, and just eliminate the setting of
flc_flagsinnlm4svc_retrieve_args. We only deal withFL_POSIXlocks in svc lockd, and that does it right afterlocks_init_lock, so I think that means it'll be done earlier, no?Have a look at the nlm4 branch in my kernel.org <http://kernel.org/> repo to see where this is headed.
Quoted 7 lines
Quoted 5 lines
(For everyone following along: It's actually in Chuck's xdrgen branch)
Oh ok, I see. This is an interim step toward moving all of the lock initialization into
nlm4svc_retrieve_args(). That probably is better. I withdraw my objection.Adding that observation to the commit message would help with review.
I was hoping to break these up to make them easier to review, but for 5/5 I guess it didn't help.
I can send more of these clean-up/refactors along for v6.13. But I'm not sure the actual conversion later in the xdrgen branch is ready for prime time.
Quoted 26 lines
I agree that moving the initialisation to
nlm4svc_retrieve_args()seems sensible. The half-way version in this patch looks really odd without that explanation.But the whole series
Reviewed-by NeilBrown <[email protected]>Thanks,
NeilBrownQuoted 13 lines
Quoted 8 lines
Quoted 4 lines
Also, I think the same duplication is in
nlmsvc_retrieve_argsand the nlmv3 version ofsvcxdr_decode_lock.Which is going away when NFSv2 is removed. I'm not too concerned about that duplication.
Fair enough. I'm fine with leaving that to wither for now:
Reviewed-by Jeff Layton <[email protected]>
Signature · 1 line
Chuck Lever