diff mbox series

[2/8] nlm: minor nlm_lookup_file argument change

Message ID 1629493326-28336-3-git-send-email-bfields@redhat.com (mailing list archive)
State New, archived
Headers show
Series reexport lock fixes v3 | expand

Commit Message

Bruce Fields Aug. 20, 2021, 9:02 p.m. UTC
From: "J. Bruce Fields" <bfields@redhat.com>

It'll come in handy to get the whole nlm_lock.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/lockd/svc4proc.c         |  2 +-
 fs/lockd/svcproc.c          |  2 +-
 fs/lockd/svcsubs.c          | 14 +++++++-------
 include/linux/lockd/lockd.h |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

Comments

Chuck Lever Aug. 21, 2021, 4:30 p.m. UTC | #1
> On Aug 20, 2021, at 5:02 PM, J. Bruce Fields <bfields@redhat.com> wrote:
> 
> From: "J. Bruce Fields" <bfields@redhat.com>
> 
> It'll come in handy to get the whole nlm_lock.
> 
> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> ---
> fs/lockd/svc4proc.c         |  2 +-
> fs/lockd/svcproc.c          |  2 +-
> fs/lockd/svcsubs.c          | 14 +++++++-------
> include/linux/lockd/lockd.h |  2 +-
> 4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
> index 4c10fb5138f1..aa8eca7c38a1 100644
> --- a/fs/lockd/svc4proc.c
> +++ b/fs/lockd/svc4proc.c
> @@ -40,7 +40,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
> 
> 	/* Obtain file pointer. Not used by FREE_ALL call. */
> 	if (filp != NULL) {
> -		if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0)
> +		if ((error = nlm_lookup_file(rqstp, &file, lock)) != 0)

Style: Replace the "assignment in if statement" in these spots,
bitte?

Since we're dealing with a __be32 result, a direct comparison
with "0" is misleading. It might be better documentation to
go with:

    error = nlm_lookup_file(rqstp, &file, lock);
    if (error)


> 			goto no_locks;
> 		*filp = file;
> 
> diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
> index 4ae4b63b5392..f4e5e0eb30fd 100644
> --- a/fs/lockd/svcproc.c
> +++ b/fs/lockd/svcproc.c
> @@ -69,7 +69,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
> 
> 	/* Obtain file pointer. Not used by FREE_ALL call. */
> 	if (filp != NULL) {
> -		error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh));
> +		error = cast_status(nlm_lookup_file(rqstp, &file, lock));
> 		if (error != 0)
> 			goto no_locks;
> 		*filp = file;
> diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
> index 028fc152da22..bbd2bdde4bea 100644
> --- a/fs/lockd/svcsubs.c
> +++ b/fs/lockd/svcsubs.c
> @@ -82,31 +82,31 @@ static inline unsigned int file_hash(struct nfs_fh *f)
>  */
> __be32
> nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
> -					struct nfs_fh *f)
> +					struct nlm_lock *lock)
> {
> 	struct nlm_file	*file;
> 	unsigned int	hash;
> 	__be32		nfserr;
> 
> -	nlm_debug_print_fh("nlm_lookup_file", f);
> +	nlm_debug_print_fh("nlm_lookup_file", &lock->fh);
> 
> -	hash = file_hash(f);
> +	hash = file_hash(&lock->fh);
> 
> 	/* Lock file table */
> 	mutex_lock(&nlm_file_mutex);
> 
> 	hlist_for_each_entry(file, &nlm_files[hash], f_list)
> -		if (!nfs_compare_fh(&file->f_handle, f))
> +		if (!nfs_compare_fh(&file->f_handle, &lock->fh))
> 			goto found;
> 
> -	nlm_debug_print_fh("creating file for", f);
> +	nlm_debug_print_fh("creating file for", &lock->fh);
> 
> 	nfserr = nlm_lck_denied_nolocks;
> 	file = kzalloc(sizeof(*file), GFP_KERNEL);
> 	if (!file)
> 		goto out_unlock;
> 
> -	memcpy(&file->f_handle, f, sizeof(struct nfs_fh));
> +	memcpy(&file->f_handle, &lock->fh, sizeof(struct nfs_fh));
> 	mutex_init(&file->f_mutex);
> 	INIT_HLIST_NODE(&file->f_list);
> 	INIT_LIST_HEAD(&file->f_blocks);
> @@ -117,7 +117,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
> 	 * We have to make sure we have the right credential to open
> 	 * the file.
> 	 */
> -	if ((nfserr = nlmsvc_ops->fopen(rqstp, f, &file->f_file)) != 0) {
> +	if ((nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file)) != 0) {

Ditto.


> 		dprintk("lockd: open failed (error %d)\n", nfserr);
> 		goto out_free;
> 	}
> diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
> index 666f5f310a04..81b71ad2040a 100644
> --- a/include/linux/lockd/lockd.h
> +++ b/include/linux/lockd/lockd.h
> @@ -286,7 +286,7 @@ void		  nlmsvc_locks_init_private(struct file_lock *, struct nlm_host *, pid_t);
>  * File handling for the server personality
>  */
> __be32		  nlm_lookup_file(struct svc_rqst *, struct nlm_file **,
> -					struct nfs_fh *);
> +					struct nlm_lock *);
> void		  nlm_release_file(struct nlm_file *);
> void		  nlmsvc_release_lockowner(struct nlm_lock *);
> void		  nlmsvc_mark_resources(struct net *);
> -- 
> 2.31.1
> 

--
Chuck Lever
J. Bruce Fields Aug. 23, 2021, 4:01 p.m. UTC | #2
From: "J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH] nlm: minor style issue

Make the assignment separate.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/lockd/svc4proc.c | 3 ++-
 fs/lockd/svcsubs.c  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

> Style: Replace the "assignment in if statement" in these spots,
> bitte?

Feel free to fold this in if you'd prefer.--b.

diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index aa8eca7c38a1..bc496bbd696b 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -40,7 +40,8 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
 
 	/* Obtain file pointer. Not used by FREE_ALL call. */
 	if (filp != NULL) {
-		if ((error = nlm_lookup_file(rqstp, &file, lock)) != 0)
+		error = nlm_lookup_file(rqstp, &file, lock);
+		if (error)
 			goto no_locks;
 		*filp = file;
 
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index bbd2bdde4bea..2d62633b39e5 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -117,7 +117,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
 	 * We have to make sure we have the right credential to open
 	 * the file.
 	 */
-	if ((nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file)) != 0) {
+	nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file);
+	if (nfserr) {
 		dprintk("lockd: open failed (error %d)\n", nfserr);
 		goto out_free;
 	}
Chuck Lever Aug. 23, 2021, 5:02 p.m. UTC | #3
> On Aug 23, 2021, at 12:01 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
> 
> From: "J. Bruce Fields" <bfields@redhat.com>
> Subject: [PATCH] nlm: minor style issue
> 
> Make the assignment separate.
> 
> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> ---
> fs/lockd/svc4proc.c | 3 ++-
> fs/lockd/svcsubs.c  | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
> 
>> Style: Replace the "assignment in if statement" in these spots,
>> bitte?
> 
> Feel free to fold this in if you'd prefer.--b.

Squashed. However, this change conflicts with 5/8. I've fixed
that up in my tree.

There are still several outstanding inline comments for 5/8,
in case you missed those.


> diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
> index aa8eca7c38a1..bc496bbd696b 100644
> --- a/fs/lockd/svc4proc.c
> +++ b/fs/lockd/svc4proc.c
> @@ -40,7 +40,8 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
> 
> 	/* Obtain file pointer. Not used by FREE_ALL call. */
> 	if (filp != NULL) {
> -		if ((error = nlm_lookup_file(rqstp, &file, lock)) != 0)
> +		error = nlm_lookup_file(rqstp, &file, lock);
> +		if (error)
> 			goto no_locks;
> 		*filp = file;
> 
> diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
> index bbd2bdde4bea..2d62633b39e5 100644
> --- a/fs/lockd/svcsubs.c
> +++ b/fs/lockd/svcsubs.c
> @@ -117,7 +117,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
> 	 * We have to make sure we have the right credential to open
> 	 * the file.
> 	 */
> -	if ((nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file)) != 0) {
> +	nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file);
> +	if (nfserr) {
> 		dprintk("lockd: open failed (error %d)\n", nfserr);
> 		goto out_free;
> 	}
> -- 
> 2.31.1
> 

--
Chuck Lever
J. Bruce Fields Aug. 23, 2021, 5:21 p.m. UTC | #4
On Mon, Aug 23, 2021 at 05:02:19PM +0000, Chuck Lever III wrote:
> 
> 
> > On Aug 23, 2021, at 12:01 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
> > 
> > From: "J. Bruce Fields" <bfields@redhat.com>
> > Subject: [PATCH] nlm: minor style issue
> > 
> > Make the assignment separate.
> > 
> > Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> > ---
> > fs/lockd/svc4proc.c | 3 ++-
> > fs/lockd/svcsubs.c  | 3 ++-
> > 2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> >> Style: Replace the "assignment in if statement" in these spots,
> >> bitte?
> > 
> > Feel free to fold this in if you'd prefer.--b.
> 
> Squashed. However, this change conflicts with 5/8. I've fixed
> that up in my tree.

Thanks.

> There are still several outstanding inline comments for 5/8,
> in case you missed those.

Whoops, I did.  Looking....--b.

> 
> 
> > diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
> > index aa8eca7c38a1..bc496bbd696b 100644
> > --- a/fs/lockd/svc4proc.c
> > +++ b/fs/lockd/svc4proc.c
> > @@ -40,7 +40,8 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
> > 
> > 	/* Obtain file pointer. Not used by FREE_ALL call. */
> > 	if (filp != NULL) {
> > -		if ((error = nlm_lookup_file(rqstp, &file, lock)) != 0)
> > +		error = nlm_lookup_file(rqstp, &file, lock);
> > +		if (error)
> > 			goto no_locks;
> > 		*filp = file;
> > 
> > diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
> > index bbd2bdde4bea..2d62633b39e5 100644
> > --- a/fs/lockd/svcsubs.c
> > +++ b/fs/lockd/svcsubs.c
> > @@ -117,7 +117,8 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
> > 	 * We have to make sure we have the right credential to open
> > 	 * the file.
> > 	 */
> > -	if ((nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file)) != 0) {
> > +	nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file);
> > +	if (nfserr) {
> > 		dprintk("lockd: open failed (error %d)\n", nfserr);
> > 		goto out_free;
> > 	}
> > -- 
> > 2.31.1
> > 
> 
> --
> Chuck Lever
> 
>
diff mbox series

Patch

diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 4c10fb5138f1..aa8eca7c38a1 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -40,7 +40,7 @@  nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
 
 	/* Obtain file pointer. Not used by FREE_ALL call. */
 	if (filp != NULL) {
-		if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0)
+		if ((error = nlm_lookup_file(rqstp, &file, lock)) != 0)
 			goto no_locks;
 		*filp = file;
 
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 4ae4b63b5392..f4e5e0eb30fd 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -69,7 +69,7 @@  nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
 
 	/* Obtain file pointer. Not used by FREE_ALL call. */
 	if (filp != NULL) {
-		error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh));
+		error = cast_status(nlm_lookup_file(rqstp, &file, lock));
 		if (error != 0)
 			goto no_locks;
 		*filp = file;
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 028fc152da22..bbd2bdde4bea 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -82,31 +82,31 @@  static inline unsigned int file_hash(struct nfs_fh *f)
  */
 __be32
 nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
-					struct nfs_fh *f)
+					struct nlm_lock *lock)
 {
 	struct nlm_file	*file;
 	unsigned int	hash;
 	__be32		nfserr;
 
-	nlm_debug_print_fh("nlm_lookup_file", f);
+	nlm_debug_print_fh("nlm_lookup_file", &lock->fh);
 
-	hash = file_hash(f);
+	hash = file_hash(&lock->fh);
 
 	/* Lock file table */
 	mutex_lock(&nlm_file_mutex);
 
 	hlist_for_each_entry(file, &nlm_files[hash], f_list)
-		if (!nfs_compare_fh(&file->f_handle, f))
+		if (!nfs_compare_fh(&file->f_handle, &lock->fh))
 			goto found;
 
-	nlm_debug_print_fh("creating file for", f);
+	nlm_debug_print_fh("creating file for", &lock->fh);
 
 	nfserr = nlm_lck_denied_nolocks;
 	file = kzalloc(sizeof(*file), GFP_KERNEL);
 	if (!file)
 		goto out_unlock;
 
-	memcpy(&file->f_handle, f, sizeof(struct nfs_fh));
+	memcpy(&file->f_handle, &lock->fh, sizeof(struct nfs_fh));
 	mutex_init(&file->f_mutex);
 	INIT_HLIST_NODE(&file->f_list);
 	INIT_LIST_HEAD(&file->f_blocks);
@@ -117,7 +117,7 @@  nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
 	 * We have to make sure we have the right credential to open
 	 * the file.
 	 */
-	if ((nfserr = nlmsvc_ops->fopen(rqstp, f, &file->f_file)) != 0) {
+	if ((nfserr = nlmsvc_ops->fopen(rqstp, &lock->fh, &file->f_file)) != 0) {
 		dprintk("lockd: open failed (error %d)\n", nfserr);
 		goto out_free;
 	}
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 666f5f310a04..81b71ad2040a 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -286,7 +286,7 @@  void		  nlmsvc_locks_init_private(struct file_lock *, struct nlm_host *, pid_t);
  * File handling for the server personality
  */
 __be32		  nlm_lookup_file(struct svc_rqst *, struct nlm_file **,
-					struct nfs_fh *);
+					struct nlm_lock *);
 void		  nlm_release_file(struct nlm_file *);
 void		  nlmsvc_release_lockowner(struct nlm_lock *);
 void		  nlmsvc_mark_resources(struct net *);