Skip to content

Commit a88c955

Browse files
committed
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>
1 parent 253ca86 commit a88c955

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

drivers/android/binder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ static void binder_deferred_fd_close(int fd)
19211921
if (!twcb)
19221922
return;
19231923
init_task_work(&twcb->twork, binder_do_fd_close);
1924-
twcb->file = close_fd_get_file(fd);
1924+
twcb->file = file_close_fd(fd);
19251925
if (twcb->file) {
19261926
// pin it until binder_do_fd_close(); see comments there
19271927
get_file(twcb->file);

fs/file.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -796,19 +796,23 @@ int __close_range(unsigned fd, unsigned max_fd, unsigned int flags)
796796
}
797797

798798
/*
799-
* See close_fd_get_file() below, this variant assumes current->files->file_lock
799+
* See file_close_fd() below, this variant assumes current->files->file_lock
800800
* is held.
801801
*/
802802
struct file *__close_fd_get_file(unsigned int fd)
803803
{
804804
return pick_file(current->files, fd);
805805
}
806806

807-
/*
808-
* variant of close_fd that gets a ref on the file for later fput.
809-
* The caller must ensure that filp_close() called on the file.
807+
/**
808+
* file_close_fd - return file associated with fd
809+
* @fd: file descriptor to retrieve file for
810+
*
811+
* Doesn't take a separate reference count.
812+
*
813+
* Returns: The file associated with @fd (NULL if @fd is not open)
810814
*/
811-
struct file *close_fd_get_file(unsigned int fd)
815+
struct file *file_close_fd(unsigned int fd)
812816
{
813817
struct files_struct *files = current->files;
814818
struct file *file;

fs/open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ SYSCALL_DEFINE1(close, unsigned int, fd)
15771577
int retval;
15781578
struct file *file;
15791579

1580-
file = close_fd_get_file(fd);
1580+
file = file_close_fd(fd);
15811581
if (!file)
15821582
return -EBADF;
15831583

include/linux/fdtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int iterate_fd(struct files_struct *, unsigned,
119119

120120
extern int close_fd(unsigned int fd);
121121
extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags);
122-
extern struct file *close_fd_get_file(unsigned int fd);
122+
extern struct file *file_close_fd(unsigned int fd);
123123
extern int unshare_fd(unsigned long unshare_flags, unsigned int max_fds,
124124
struct files_struct **new_fdp);
125125

0 commit comments

Comments
 (0)