From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever III <chuck.lever@oracle.com>
Cc: Chuck Lever <cel@kernel.org>, Neil Brown <neilb@suse.de>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags
Date: Thu, 17 Oct 2024 15:30:08 -0400 [thread overview]
Message-ID: <03d89ad174357456abf2053e22bfd61ce59b5658.camel@kernel.org> (raw)
In-Reply-To: <396ABDBD-E05E-44F7-8297-CE421EB44319@oracle.com>
On Thu, 2024-10-17 at 19:16 +0000, Chuck Lever III wrote:
>
> > On Oct 17, 2024, at 3:13 PM, Jeff Layton <jlayton@kernel.org> wrote:
> >
> > On Thu, 2024-10-17 at 09:36 -0400, cel@kernel.org wrote:
> > > From: Chuck Lever <chuck.lever@oracle.com>
> > >
> > > 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.
> > >
> > > Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> > > ---
> > > fs/lockd/svc4proc.c | 5 +++--
> > > fs/lockd/xdr4.c | 1 -
> > > 2 files changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
> > > index 2cb603013111..109e5caae8c7 100644
> > > --- a/fs/lockd/svc4proc.c
> > > +++ b/fs/lockd/svc4proc.c
> > > @@ -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 ?
> > > diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c
> > > index 60466b8bac58..e343c820301f 100644
> > > --- a/fs/lockd/xdr4.c
> > > +++ b/fs/lockd/xdr4.c
> > > @@ -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.
>
> Thanks!
>
>
> > 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?
>
> 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.
>
> > Also, I think the same duplication is in nlmsvc_retrieve_args and the
> > nlmv3 version of svcxdr_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 <jlayton@kernel.org>
next prev parent reply other threads:[~2024-10-17 19:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 13:36 [PATCH 0/5] Simple lockd clean-ups cel
2024-10-17 13:36 ` [PATCH 1/5] lockd: Remove unused typedef cel
2024-10-17 13:36 ` [PATCH 2/5] lockd: Remove unnecessary memset() cel
2024-10-17 13:36 ` [PATCH 3/5] lockd: Remove some snippets of unfinished code cel
2024-10-17 13:36 ` [PATCH 4/5] lockd: Remove unused parameter to nlmsvc_testlock() cel
2024-10-17 21:06 ` NeilBrown
2024-10-17 13:36 ` [PATCH 5/5] lockd: Remove unneeded initialization of file_lock::c.flc_flags cel
2024-10-17 19:13 ` Jeff Layton
2024-10-17 19:16 ` Chuck Lever III
2024-10-17 19:30 ` Jeff Layton [this message]
2024-10-17 21:22 ` NeilBrown
2024-10-17 21:34 ` Chuck Lever
2024-10-17 20:56 ` NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=03d89ad174357456abf2053e22bfd61ce59b5658.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=dai.ngo@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox