From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>, stable@vger.kernel.org
Subject: [PATCH 1/3] io-wq: add support for inheriting ->fs
Date: Sun, 9 Feb 2020 10:11:11 -0700 [thread overview]
Message-ID: <20200209171113.14270-2-axboe@kernel.dk> (raw)
In-Reply-To: <20200209171113.14270-1-axboe@kernel.dk>
Some work items need this for relative path lookup, make it available
like the other inherited credentials/mm/etc.
Cc: stable@vger.kernel.org # 5.3+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
fs/io-wq.c | 19 +++++++++++++++----
fs/io-wq.h | 4 +++-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index cb60a42b9fdf..58b1891bcfe5 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/kthread.h>
#include <linux/rculist_nulls.h>
+#include <linux/fs_struct.h>
#include "io-wq.h"
@@ -59,6 +60,7 @@ struct io_worker {
const struct cred *cur_creds;
const struct cred *saved_creds;
struct files_struct *restore_files;
+ struct fs_struct *restore_fs;
};
#if BITS_PER_LONG == 64
@@ -141,13 +143,17 @@ static bool __io_worker_unuse(struct io_wqe *wqe, struct io_worker *worker)
worker->cur_creds = worker->saved_creds = NULL;
}
- if (current->files != worker->restore_files) {
+ if ((current->files != worker->restore_files) ||
+ (current->fs != worker->restore_fs)) {
__acquire(&wqe->lock);
spin_unlock_irq(&wqe->lock);
dropped_lock = true;
task_lock(current);
- current->files = worker->restore_files;
+ if (current->files != worker->restore_files)
+ current->files = worker->restore_files;
+ if (current->fs != worker->restore_fs)
+ current->fs = worker->restore_fs;
task_unlock(current);
}
@@ -311,6 +317,7 @@ static void io_worker_start(struct io_wqe *wqe, struct io_worker *worker)
worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
worker->restore_files = current->files;
+ worker->restore_fs = current->fs;
io_wqe_inc_running(wqe, worker);
}
@@ -476,9 +483,13 @@ static void io_worker_handle_work(struct io_worker *worker)
if (work->flags & IO_WQ_WORK_CB)
work->func(&work);
- if (work->files && current->files != work->files) {
+ if ((work->files && current->files != work->files) ||
+ (work->fs && current->fs != work->fs)) {
task_lock(current);
- current->files = work->files;
+ if (work->files && current->files != work->files)
+ current->files = work->files;
+ if (work->fs && current->fs != work->fs)
+ current->fs = work->fs;
task_unlock(current);
}
if (work->mm != worker->mm)
diff --git a/fs/io-wq.h b/fs/io-wq.h
index 50b3378febf2..f152ba677d8f 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -74,6 +74,7 @@ struct io_wq_work {
struct files_struct *files;
struct mm_struct *mm;
const struct cred *creds;
+ struct fs_struct *fs;
unsigned flags;
};
@@ -81,10 +82,11 @@ struct io_wq_work {
do { \
(work)->list.next = NULL; \
(work)->func = _func; \
- (work)->flags = 0; \
(work)->files = NULL; \
(work)->mm = NULL; \
(work)->creds = NULL; \
+ (work)->fs = NULL; \
+ (work)->flags = 0; \
} while (0) \
typedef void (get_work_fn)(struct io_wq_work *);
--
2.25.0
next prev parent reply other threads:[~2020-02-09 17:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-09 17:11 [PATCHSET v2] io_uring: Allow relative lookups Jens Axboe
2020-02-09 17:11 ` Jens Axboe [this message]
2020-02-11 3:31 ` [PATCH 1/3] io-wq: add support for inheriting ->fs Sasha Levin
2020-02-09 17:11 ` [PATCH 2/3] io_uring: grab ->fs as part of async preparation Jens Axboe
2020-02-11 3:31 ` Sasha Levin
2020-02-09 17:11 ` [PATCH 3/3] io_uring: allow AT_FDCWD for non-file openat/openat2/statx 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 \
--in-reply-to=20200209171113.14270-2-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.