diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-04-11 01:46:28 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-11 19:30:41 -0600 |
commit | a1fde923e3065a89abccfeef95096c933f6a954c (patch) | |
tree | 55f0b87ccd7b45a00254af3cf74889514359abe6 /fs/io_uring.c | |
parent | 3f48cf18f886c97a7e775af10696bfed9ddcff31 (diff) | |
download | lwn-a1fde923e3065a89abccfeef95096c933f6a954c.tar.gz lwn-a1fde923e3065a89abccfeef95096c933f6a954c.zip |
io_uring: refactor io_close
A small refactoring shrinking it and making easier to read.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/19b24eed7cd491a0243b50366dd2a23b558e2665.1618101759.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 8e2a0f9acba8..f886a5b2ea57 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4181,11 +4181,9 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) struct files_struct *files = current->files; struct io_close *close = &req->close; struct fdtable *fdt; - struct file *file; - int ret; + struct file *file = NULL; + int ret = -EBADF; - file = NULL; - ret = -EBADF; spin_lock(&files->file_lock); fdt = files_fdtable(files); if (close->fd >= fdt->max_fds) { @@ -4193,12 +4191,7 @@ static int io_close(struct io_kiocb *req, unsigned int issue_flags) goto err; } file = fdt->fd[close->fd]; - if (!file) { - spin_unlock(&files->file_lock); - goto err; - } - - if (file->f_op == &io_uring_fops) { + if (!file || file->f_op == &io_uring_fops) { spin_unlock(&files->file_lock); file = NULL; goto err; |