Skip to contentSkip to conversation

io-wq: cancel work if we fail getting a mm reference

PATCH New Jens Axboe 1 participant 1 message Jan 15, 2020

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 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.

---
 fs/io-wq.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
fs/io-wq.c +8 -4
index 541c8a3e0bbb..5147d2213b01 100644
@@ -445,10 +445,14 @@ static void io_worker_handle_work(struct io_worker *worker)
 			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);
Signature · 4 lines
2.25.0

-- 
Jens Axboe