From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.com>,
Jens Axboe <axboe@kernel.dk>, Carlos Llamas <cmllamas@google.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH RFC 1/5] file: s/close_fd_get_file()/file_close_fd()/g
Date: Thu, 30 Nov 2023 17:39:29 +0100 [thread overview]
Message-ID: <20231130163929.dacbkntq7ij7ipws@quack3> (raw)
In-Reply-To: <20231130-vfs-files-fixes-v1-1-e73ca6f4ea83@kernel.org>
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@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
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@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-11-30 16:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 12:49 [PATCH RFC 0/5] file: minor fixes Christian Brauner
2023-11-30 12:49 ` [PATCH RFC 1/5] file: s/close_fd_get_file()/file_close_fd()/g Christian Brauner
2023-11-30 16:39 ` Jan Kara [this message]
2023-11-30 12:49 ` [PATCH RFC 2/5] file: remove pointless wrapper Christian Brauner
2023-11-30 14:22 ` Jens Axboe
2023-11-30 16:40 ` Jan Kara
2023-11-30 12:49 ` [PATCH RFC 3/5] fs: replace f_rcuhead with f_tw Christian Brauner
2023-11-30 16:42 ` Jan Kara
2023-11-30 23:37 ` Linus Torvalds
2023-12-01 13:19 ` Christian Brauner
2023-11-30 12:49 ` [PATCH RFC 4/5] file: stop exposing receive_fd_user() Christian Brauner
2023-11-30 14:23 ` Jens Axboe
2023-11-30 16:43 ` Jan Kara
2023-11-30 12:49 ` [PATCH RFC 5/5] file: remove __receive_fd() Christian Brauner
2023-11-30 13:20 ` Matthew Wilcox
2023-12-01 13:12 ` Christian Brauner
2023-11-30 16:44 ` Jan Kara
2023-11-30 14:23 ` [PATCH RFC 0/5] file: minor fixes Jens Axboe
2023-12-01 13:23 ` Christian Brauner
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=20231130163929.dacbkntq7ij7ipws@quack3 \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=jack@suse.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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