Skip to content

Commit e0bbb34

Browse files
committed
io-wq: cancel work if we fail getting a mm reference
If we require mm and user context, mark the request for cancellation if we fail to acquire the desired mm. Signed-off-by: Jens Axboe <[email protected]>
1 parent 74566df commit e0bbb34

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/io-wq.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,14 @@ static void io_worker_handle_work(struct io_worker *worker)
445445
task_unlock(current);
446446
}
447447
if ((work->flags & IO_WQ_WORK_NEEDS_USER) && !worker->mm &&
448-
wq->mm && mmget_not_zero(wq->mm)) {
449-
use_mm(wq->mm);
450-
set_fs(USER_DS);
451-
worker->mm = wq->mm;
448+
wq->mm) {
449+
if (mmget_not_zero(wq->mm)) {
450+
use_mm(wq->mm);
451+
set_fs(USER_DS);
452+
worker->mm = wq->mm;
453+
} else {
454+
work->flags |= IO_WQ_WORK_CANCEL;
455+
}
452456
}
453457
if (!worker->creds)
454458
worker->creds = override_creds(wq->creds);

0 commit comments

Comments
 (0)