mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 05:12:49 +00:00
file: s/close_fd_get_file()/file_close_fd()/g
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. Link: https://lore.kernel.org/r/20231130-vfs-files-fixes-v1-1-e73ca6f4ea83@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
253ca8678d
commit
a88c955fcf
4 changed files with 12 additions and 8 deletions
|
@ -1921,7 +1921,7 @@ static void binder_deferred_fd_close(int fd)
|
||||||
if (!twcb)
|
if (!twcb)
|
||||||
return;
|
return;
|
||||||
init_task_work(&twcb->twork, binder_do_fd_close);
|
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) {
|
if (twcb->file) {
|
||||||
// pin it until binder_do_fd_close(); see comments there
|
// pin it until binder_do_fd_close(); see comments there
|
||||||
get_file(twcb->file);
|
get_file(twcb->file);
|
||||||
|
|
14
fs/file.c
14
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.
|
* is held.
|
||||||
*/
|
*/
|
||||||
struct file *__close_fd_get_file(unsigned int fd)
|
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);
|
return pick_file(current->files, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* variant of close_fd that gets a ref on the file for later fput.
|
* file_close_fd - return file associated with fd
|
||||||
* The caller must ensure that filp_close() called on the file.
|
* @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 files_struct *files = current->files;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
|
|
@ -1577,7 +1577,7 @@ SYSCALL_DEFINE1(close, unsigned int, fd)
|
||||||
int retval;
|
int retval;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
|
||||||
file = close_fd_get_file(fd);
|
file = file_close_fd(fd);
|
||||||
if (!file)
|
if (!file)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ int iterate_fd(struct files_struct *, unsigned,
|
||||||
|
|
||||||
extern int close_fd(unsigned int fd);
|
extern int close_fd(unsigned int fd);
|
||||||
extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags);
|
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,
|
extern int unshare_fd(unsigned long unshare_flags, unsigned int max_fds,
|
||||||
struct files_struct **new_fdp);
|
struct files_struct **new_fdp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue