提交 a1cb1836 编写于 作者: J Jens Axboe 提交者: Cheng Jian

io-wq: add support for inheriting ->fs

mainline inclusion
from mainline-5.6-rc2
commit 9392a27d
category: feature
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27
CVE: NA
---------------------------

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: NJens Axboe <axboe@kernel.dk>
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 30547401
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/rculist_nulls.h> #include <linux/rculist_nulls.h>
#include <linux/fs_struct.h>
#include "io-wq.h" #include "io-wq.h"
...@@ -60,6 +61,7 @@ struct io_worker { ...@@ -60,6 +61,7 @@ struct io_worker {
const struct cred *cur_creds; const struct cred *cur_creds;
const struct cred *saved_creds; const struct cred *saved_creds;
struct files_struct *restore_files; struct files_struct *restore_files;
struct fs_struct *restore_fs;
}; };
#if BITS_PER_LONG == 64 #if BITS_PER_LONG == 64
...@@ -152,6 +154,9 @@ static bool __io_worker_unuse(struct io_wqe *wqe, struct io_worker *worker) ...@@ -152,6 +154,9 @@ static bool __io_worker_unuse(struct io_wqe *wqe, struct io_worker *worker)
task_unlock(current); task_unlock(current);
} }
if (current->fs != worker->restore_fs)
current->fs = worker->restore_fs;
/* /*
* If we have an active mm, we need to drop the wq lock before unusing * If we have an active mm, we need to drop the wq lock before unusing
* it. If we do, return true and let the caller retry the idle loop. * it. If we do, return true and let the caller retry the idle loop.
...@@ -312,6 +317,7 @@ static void io_worker_start(struct io_wqe *wqe, struct io_worker *worker) ...@@ -312,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->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING);
worker->restore_files = current->files; worker->restore_files = current->files;
worker->restore_fs = current->fs;
io_wqe_inc_running(wqe, worker); io_wqe_inc_running(wqe, worker);
} }
...@@ -482,6 +488,8 @@ static void io_worker_handle_work(struct io_worker *worker) ...@@ -482,6 +488,8 @@ static void io_worker_handle_work(struct io_worker *worker)
current->files = work->files; current->files = work->files;
task_unlock(current); task_unlock(current);
} }
if (work->fs && current->fs != work->fs)
current->fs = work->fs;
if (work->mm != worker->mm) if (work->mm != worker->mm)
io_wq_switch_mm(worker, work); io_wq_switch_mm(worker, work);
if (worker->cur_creds != work->creds) if (worker->cur_creds != work->creds)
......
...@@ -74,6 +74,7 @@ struct io_wq_work { ...@@ -74,6 +74,7 @@ struct io_wq_work {
struct files_struct *files; struct files_struct *files;
struct mm_struct *mm; struct mm_struct *mm;
const struct cred *creds; const struct cred *creds;
struct fs_struct *fs;
unsigned flags; unsigned flags;
}; };
...@@ -81,10 +82,11 @@ struct io_wq_work { ...@@ -81,10 +82,11 @@ struct io_wq_work {
do { \ do { \
(work)->list.next = NULL; \ (work)->list.next = NULL; \
(work)->func = _func; \ (work)->func = _func; \
(work)->flags = 0; \
(work)->files = NULL; \ (work)->files = NULL; \
(work)->mm = NULL; \ (work)->mm = NULL; \
(work)->creds = NULL; \ (work)->creds = NULL; \
(work)->fs = NULL; \
(work)->flags = 0; \
} while (0) \ } while (0) \
typedef void (get_work_fn)(struct io_wq_work *); typedef void (get_work_fn)(struct io_wq_work *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册