]> git.baikalelectronics.ru Git - kernel.git/commitdiff
io-wq: cancel work if we fail getting a mm reference
authorJens Axboe <axboe@kernel.dk>
Wed, 15 Jan 2020 05:06:11 +0000 (22:06 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Jan 2020 05:06:11 +0000 (22:06 -0700)
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 <axboe@kernel.dk>
fs/io-wq.c

index 541c8a3e0bbb5154468dd84164fbb0319d8e8b91..5147d2213b019f9b80841a0e14a1709ba719bf69 100644 (file)
@@ -445,10 +445,14 @@ next:
                        task_unlock(current);
                }
                if ((work->flags & IO_WQ_WORK_NEEDS_USER) && !worker->mm &&
-                   wq->mm && mmget_not_zero(wq->mm)) {
-                       use_mm(wq->mm);
-                       set_fs(USER_DS);
-                       worker->mm = wq->mm;
+                   wq->mm) {
+                       if (mmget_not_zero(wq->mm)) {
+                               use_mm(wq->mm);
+                               set_fs(USER_DS);
+                               worker->mm = wq->mm;
+                       } else {
+                               work->flags |= IO_WQ_WORK_CANCEL;
+                       }
                }
                if (!worker->creds)
                        worker->creds = override_creds(wq->creds);