All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/core: Use fdget() and fdput()
@ 2023-05-05  3:33 ye.xingchen
  2023-05-05 11:56 ` Jason Gunthorpe
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ye.xingchen @ 2023-05-05  3:33 UTC (permalink / raw)
  To: jgg; +Cc: leon, jiangjian, linux-rdma, linux-kernel

From: Ye Xingchen <ye.xingchen@zte.com.cn>

convert the fget()/fput() uses to fdget()/fdput().

Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
---
 drivers/infiniband/core/rdma_core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
index 29b1ab1d5f93..c35df0b27e86 100644
--- a/drivers/infiniband/core/rdma_core.c
+++ b/drivers/infiniband/core/rdma_core.c
@@ -335,7 +335,7 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
 		      enum rdma_lookup_mode mode)
 {
 	const struct uverbs_obj_fd_type *fd_type;
-	struct file *f;
+	struct fd f = fdget(fdno);
 	struct ib_uobject *uobject;
 	int fdno = id;

@@ -350,18 +350,17 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
 	fd_type =
 		container_of(obj->type_attrs, struct uverbs_obj_fd_type, type);

-	f = fget(fdno);
-	if (!f)
+	if (!f.file)
 		return ERR_PTR(-EBADF);

-	uobject = f->private_data;
+	uobject = f.file->private_data;
 	/*
 	 * fget(id) ensures we are not currently running
 	 * uverbs_uobject_fd_release(), and the caller is expected to ensure
 	 * that release is never done while a call to lookup is possible.
 	 */
-	if (f->f_op != fd_type->fops || uobject->ufile != ufile) {
-		fput(f);
+	if (f.file->f_op != fd_type->fops || uobject->ufile != ufile) {
+		fdput(f);
 		return ERR_PTR(-EBADF);
 	}

-- 
2.25.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMA/core: Use fdget() and fdput()
  2023-05-05  3:33 [PATCH] RDMA/core: Use fdget() and fdput() ye.xingchen
@ 2023-05-05 11:56 ` Jason Gunthorpe
  2023-05-05 16:32 ` Leon Romanovsky
  2023-05-11  5:42 ` Al Viro
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2023-05-05 11:56 UTC (permalink / raw)
  To: ye.xingchen; +Cc: leon, jiangjian, linux-rdma, linux-kernel

On Fri, May 05, 2023 at 11:33:57AM +0800, ye.xingchen@zte.com.cn wrote:
> From: Ye Xingchen <ye.xingchen@zte.com.cn>
> 
> convert the fget()/fput() uses to fdget()/fdput().
> 
> Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/infiniband/core/rdma_core.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
> index 29b1ab1d5f93..c35df0b27e86 100644
> --- a/drivers/infiniband/core/rdma_core.c
> +++ b/drivers/infiniband/core/rdma_core.c
> @@ -335,7 +335,7 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
>  		      enum rdma_lookup_mode mode)
>  {
>  	const struct uverbs_obj_fd_type *fd_type;
> -	struct file *f;
> +	struct fd f = fdget(fdno);
>  	struct ib_uobject *uobject;
>  	int fdno = id;
> 
> @@ -350,18 +350,17 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
>  	fd_type =
>  		container_of(obj->type_attrs, struct uverbs_obj_fd_type, type);
> 
> -	f = fget(fdno);
> -	if (!f)
> +	if (!f.file)
>  		return ERR_PTR(-EBADF);

This also has incorrect pairing with fdput

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMA/core: Use fdget() and fdput()
  2023-05-05  3:33 [PATCH] RDMA/core: Use fdget() and fdput() ye.xingchen
  2023-05-05 11:56 ` Jason Gunthorpe
@ 2023-05-05 16:32 ` Leon Romanovsky
  2023-05-11  5:42 ` Al Viro
  2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2023-05-05 16:32 UTC (permalink / raw)
  To: ye.xingchen; +Cc: jgg, jiangjian, linux-rdma, linux-kernel

On Fri, May 05, 2023 at 11:33:57AM +0800, ye.xingchen@zte.com.cn wrote:
> From: Ye Xingchen <ye.xingchen@zte.com.cn>
> 
> convert the fget()/fput() uses to fdget()/fdput().

Why? What is wrong with current implementation?

Thanks

> 
> Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/infiniband/core/rdma_core.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
> index 29b1ab1d5f93..c35df0b27e86 100644
> --- a/drivers/infiniband/core/rdma_core.c
> +++ b/drivers/infiniband/core/rdma_core.c
> @@ -335,7 +335,7 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
>  		      enum rdma_lookup_mode mode)
>  {
>  	const struct uverbs_obj_fd_type *fd_type;
> -	struct file *f;
> +	struct fd f = fdget(fdno);
>  	struct ib_uobject *uobject;
>  	int fdno = id;
> 
> @@ -350,18 +350,17 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
>  	fd_type =
>  		container_of(obj->type_attrs, struct uverbs_obj_fd_type, type);
> 
> -	f = fget(fdno);
> -	if (!f)
> +	if (!f.file)
>  		return ERR_PTR(-EBADF);
> 
> -	uobject = f->private_data;
> +	uobject = f.file->private_data;
>  	/*
>  	 * fget(id) ensures we are not currently running
>  	 * uverbs_uobject_fd_release(), and the caller is expected to ensure
>  	 * that release is never done while a call to lookup is possible.
>  	 */
> -	if (f->f_op != fd_type->fops || uobject->ufile != ufile) {
> -		fput(f);
> +	if (f.file->f_op != fd_type->fops || uobject->ufile != ufile) {
> +		fdput(f);
>  		return ERR_PTR(-EBADF);
>  	}
> 
> -- 
> 2.25.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMA/core: Use fdget() and fdput()
  2023-05-05  3:33 [PATCH] RDMA/core: Use fdget() and fdput() ye.xingchen
  2023-05-05 11:56 ` Jason Gunthorpe
  2023-05-05 16:32 ` Leon Romanovsky
@ 2023-05-11  5:42 ` Al Viro
  2 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2023-05-11  5:42 UTC (permalink / raw)
  To: ye.xingchen; +Cc: jgg, leon, jiangjian, linux-rdma, linux-kernel

On Fri, May 05, 2023 at 11:33:57AM +0800, ye.xingchen@zte.com.cn wrote:
> From: Ye Xingchen <ye.xingchen@zte.com.cn>
> 
> convert the fget()/fput() uses to fdget()/fdput().

NAK on the entire series.  *IF* you do that kind of replacements,
you need to understand what you are doing; it's not "fdget() is
like fget(), only better; using it will improve things".

	If that comes from seeing my patch series doing fget() to
fdget() conversions, you might consider the possibility that
I *do* know how to use grep.  And that there might be some
objective difference between the instances that had been changed
and the one that had been left alone.  You could try to figure it
out.  Or look through the list archives.  Or ask...

	Al, more than slightly offended by the implications ;-/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-11  5:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05  3:33 [PATCH] RDMA/core: Use fdget() and fdput() ye.xingchen
2023-05-05 11:56 ` Jason Gunthorpe
2023-05-05 16:32 ` Leon Romanovsky
2023-05-11  5:42 ` Al Viro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.