From: Jens Axboe <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
Jens Axboe <[email protected]>
Subject: [PATCH 4/6] fs: move filp_close() outside of __close_fd_get_file()
Date: Tue, 7 Jan 2020 10:00:32 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Just one caller of this, and just use filp_close() there manually.
This is important to allow async close/removal of the fd.
Signed-off-by: Jens Axboe <[email protected]>
---
drivers/android/binder.c | 6 ++++--
fs/file.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index b2dad43dbf82..cf72ca250a08 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2249,10 +2249,12 @@ static void binder_deferred_fd_close(int fd)
return;
init_task_work(&twcb->twork, binder_do_fd_close);
__close_fd_get_file(fd, &twcb->file);
- if (twcb->file)
+ if (twcb->file) {
+ filp_close(twcb->file, current->files);
task_work_add(current, &twcb->twork, true);
- else
+ } else {
kfree(twcb);
+ }
}
static void binder_transaction_buffer_release(struct binder_proc *proc,
diff --git a/fs/file.c b/fs/file.c
index 3da91a112bab..fb7081bfac2b 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -642,7 +642,9 @@ int __close_fd(struct files_struct *files, unsigned fd)
EXPORT_SYMBOL(__close_fd); /* for ksys_close() */
/*
- * variant of __close_fd that gets a ref on the file for later fput
+ * 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, and then
+ * an fput().
*/
int __close_fd_get_file(unsigned int fd, struct file **res)
{
@@ -662,7 +664,7 @@ int __close_fd_get_file(unsigned int fd, struct file **res)
spin_unlock(&files->file_lock);
get_file(file);
*res = file;
- return filp_close(file, files);
+ return 0;
out_unlock:
spin_unlock(&files->file_lock);
--
2.24.1
next prev parent reply other threads:[~2020-01-07 17:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-07 17:00 [PATCHSET v2 0/6] io_uring: add support for open/close Jens Axboe
2020-01-07 17:00 ` [PATCH 1/6] fs: add namei support for doing a non-blocking path lookup Jens Axboe
2020-01-25 13:15 ` Jeff Layton
2020-01-07 17:00 ` [PATCH 2/6] fs: make build_open_flags() available internally Jens Axboe
2020-01-07 17:00 ` [PATCH 3/6] io_uring: add support for IORING_OP_OPENAT Jens Axboe
2020-01-08 13:05 ` Stefan Metzmacher
2020-01-08 16:20 ` Jens Axboe
2020-01-08 16:32 ` Stefan Metzmacher
2020-01-08 16:40 ` Jens Axboe
2020-01-08 17:04 ` Stefan Metzmacher
2020-01-08 22:53 ` Jens Axboe
2020-01-08 23:03 ` Stefan Metzmacher
2020-01-08 23:05 ` Jens Axboe
2020-01-08 23:11 ` Stefan Metzmacher
2020-01-08 23:22 ` Jens Axboe
2020-01-09 10:40 ` Stefan Metzmacher
2020-01-09 21:31 ` Jens Axboe
2020-01-16 22:42 ` Stefan Metzmacher
2020-01-17 0:16 ` Jens Axboe
2020-01-07 17:00 ` Jens Axboe [this message]
2020-01-07 17:00 ` [PATCH 5/6] io-wq: add support for uncancellable work Jens Axboe
2020-01-07 17:00 ` [PATCH 6/6] io_uring: add support for IORING_OP_CLOSE Jens Axboe
2020-01-08 21:17 ` [PATCHSET v2 0/6] io_uring: add support for open/close Stefan Metzmacher
2020-01-08 22:57 ` Jens Axboe
2020-01-08 23:05 ` Stefan Metzmacher
2020-01-09 1:02 ` Jens Axboe
2020-01-09 2:03 ` Jens Axboe
2020-01-16 22:50 ` Stefan Metzmacher
2020-01-17 0:18 ` Jens Axboe
2020-01-20 12:15 ` Stefan Metzmacher
2020-01-20 13:04 ` Pavel Begunkov
2020-01-17 0:44 ` Colin Walters
2020-01-17 0:51 ` Jens Axboe
2020-01-17 9:32 ` Pavel Begunkov
2020-01-17 15:21 ` Jens Axboe
2020-01-17 22:27 ` Pavel Begunkov
2020-01-17 22:36 ` Jens Axboe
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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