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 *);
Hi,
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: 5.3+
The bot has tested the following trees: v5.5.2, v5.4.18.
v5.5.2: Failed to apply! Possible dependencies: 05f3fb3c5397 ("io_uring: avoid ring quiesce for fixed file set unregister and update") 15b71abe7b52 ("io_uring: add support for IORING_OP_OPENAT") 66f4af93da57 ("io_uring: add support for probing opcodes") b5dba59e0cf7 ("io_uring: add support for IORING_OP_CLOSE") d3656344fea0 ("io_uring: add lookup table for various opcode needs") d63d1b5edb7b ("io_uring: add support for fallocate()") eddc7ef52a6b ("io_uring: add support for IORING_OP_STATX") f86cd20c9454 ("io_uring: fix linked command file table usage")
v5.4.18: Failed to apply! Possible dependencies: 561fb04a6a22 ("io_uring: replace workqueue usage with io-wq") 771b53d033e8 ("io-wq: small threadpool implementation for io_uring") ba5290ccb6b5 ("io_uring: replace s->needs_lock with s->in_async") ba816ad61fdf ("io_uring: run dependent links inline if possible") c5def4ab8494 ("io-wq: add support for bounded vs unbunded work") c826bd7a743f ("io_uring: add set of tracing events") fcb323cc53e2 ("io_uring: io_uring: add support for async work inheriting files")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
linux-stable-mirror@lists.linaro.org