Re: [PATCH RFC 1/5] file: s/close_fd_get_file()/file_close_fd()/g

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 30-11-23 13:49:07, Christian Brauner wrote:
> That really shouldn't have "get" in there as that implies we're bumping
> the reference count which we don't do at all. We used to but not anmore.
> Now we're just closing the fd and pick that file from the fdtable
> without bumping the reference count. Update the wrong documentation
> while at it.
> 
> Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  drivers/android/binder.c |  2 +-
>  fs/file.c                | 14 +++++++++-----
>  fs/open.c                |  2 +-
>  include/linux/fdtable.h  |  2 +-
>  4 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 92128aae2d06..7658103ba760 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -1921,7 +1921,7 @@ static void binder_deferred_fd_close(int fd)
>  	if (!twcb)
>  		return;
>  	init_task_work(&twcb->twork, binder_do_fd_close);
> -	twcb->file = close_fd_get_file(fd);
> +	twcb->file = file_close_fd(fd);
>  	if (twcb->file) {
>  		// pin it until binder_do_fd_close(); see comments there
>  		get_file(twcb->file);
> diff --git a/fs/file.c b/fs/file.c
> index 50df31e104a5..66f04442a384 100644
> --- a/fs/file.c
> +++ b/fs/file.c
> @@ -796,7 +796,7 @@ int __close_range(unsigned fd, unsigned max_fd, unsigned int flags)
>  }
>  
>  /*
> - * See close_fd_get_file() below, this variant assumes current->files->file_lock
> + * See file_close_fd() below, this variant assumes current->files->file_lock
>   * is held.
>   */
>  struct file *__close_fd_get_file(unsigned int fd)
> @@ -804,11 +804,15 @@ struct file *__close_fd_get_file(unsigned int fd)
>  	return pick_file(current->files, fd);
>  }
>  
> -/*
> - * variant of close_fd that gets a ref on the file for later fput.
> - * The caller must ensure that filp_close() called on the file.
> +/**
> + * file_close_fd - return file associated with fd
> + * @fd: file descriptor to retrieve file for
> + *
> + * Doesn't take a separate reference count.
> + *
> + * Returns: The file associated with @fd (NULL if @fd is not open)
>   */
> -struct file *close_fd_get_file(unsigned int fd)
> +struct file *file_close_fd(unsigned int fd)
>  {
>  	struct files_struct *files = current->files;
>  	struct file *file;
> diff --git a/fs/open.c b/fs/open.c
> index 0bd7fce21cbf..328dc6ef1883 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -1578,7 +1578,7 @@ SYSCALL_DEFINE1(close, unsigned int, fd)
>  	int retval;
>  	struct file *file;
>  
> -	file = close_fd_get_file(fd);
> +	file = file_close_fd(fd);
>  	if (!file)
>  		return -EBADF;
>  
> diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
> index 80bd7789bab1..78c8326d74ae 100644
> --- a/include/linux/fdtable.h
> +++ b/include/linux/fdtable.h
> @@ -119,7 +119,7 @@ int iterate_fd(struct files_struct *, unsigned,
>  
>  extern int close_fd(unsigned int fd);
>  extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags);
> -extern struct file *close_fd_get_file(unsigned int fd);
> +extern struct file *file_close_fd(unsigned int fd);
>  extern int unshare_fd(unsigned long unshare_flags, unsigned int max_fds,
>  		      struct files_struct **new_fdp);
>  
> 
> -- 
> 2.42.0
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux