On Thu, Mar 26, 2026, at 6:47 PM, NeilBrown wrote:
> From: NeilBrown <[email protected]>
>
> The F_GETLK fcntl can work with either read access or write access or
> both. It can query F_RDLCK and F_WRLCK locks in either case.
> diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
> index 4b6f18d97734..75e020a8bfd0 100644
> --- a/fs/lockd/svc4proc.c
> +++ b/fs/lockd/svc4proc.c
> @@ -26,6 +26,8 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct
> nlm_args *argp,
> struct nlm_host *host = NULL;
> struct nlm_file *file = NULL;
> struct nlm_lock *lock = &argp->lock;
> + bool is_test = (rqstp->rq_proc == NLMPROC_TEST ||
> + rqstp->rq_proc == NLMPROC_TEST_MSG);
> __be32 error = 0;
>
> /* nfsd callbacks must have been installed for this procedure */
> @@ -46,15 +48,20 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp,
> struct nlm_args *argp,
> if (filp != NULL) {
> int mode = lock_to_openmode(&lock->fl);
>
> + if (is_test)
> + mode = O_RDWR;
> +
> lock->fl.c.flc_flags = FL_POSIX;
>
> - error = nlm_lookup_file(rqstp, &file, lock);
> + error = nlm_lookup_file(rqstp, &file, lock, mode);
> if (error)
> goto no_locks;
> *filp = file;
> -
> /* Set up the missing parts of the file_lock structure */
> - lock->fl.c.flc_file = file->f_file[mode];
> + if (is_test)
> + lock->fl.c.flc_file = nlmsvc_file_file(file);
> + else
> + 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 ?
We have a new problem now (or maybe just I do).
I think the stable folks will insist on this fix going into
upstream first. However, this version of the fix does not
apply to nfsd-testing because that branch has the NLMv4
xdrgen rewrite.
That rewrite is not likely to be backported to LTS. So this
version will have to be directed to stable once upstream has
been fixed. We cannot rely on automation to get upstream's
version of the fix backported to v6.19 and earlier.
--
Chuck Lever