Patch "io_uring/rw: ensure kiocb_end_write() is always called" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    io_uring/rw: ensure kiocb_end_write() is always called

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-rw-ensure-kiocb_end_write-is-always-called.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 2ec33a6c3cca9fe2465e82050c81f5ffdc508b36 Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@xxxxxxxxx>
Date: Tue, 11 Oct 2022 09:06:23 -0600
Subject: io_uring/rw: ensure kiocb_end_write() is always called

From: Jens Axboe <axboe@xxxxxxxxx>

commit 2ec33a6c3cca9fe2465e82050c81f5ffdc508b36 upstream.

A previous commit moved the notifications and end-write handling, but
it is now missing a few spots where we also want to call both of those.
Without that, we can potentially be missing file notifications, and
more importantly, have an imbalance in the super_block writers sem
accounting.

Fixes: b000145e9907 ("io_uring/rw: defer fsnotify calls to task context")
Reported-by: Dave Chinner <david@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/20221010050319.GC2703033@xxxxxxxxxxxxxxxxxxx/
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 io_uring/rw.c |   38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -184,11 +184,34 @@ static void kiocb_end_write(struct io_ki
 	}
 }
 
+/*
+ * Trigger the notifications after having done some IO, and finish the write
+ * accounting, if any.
+ */
+static void io_req_io_end(struct io_kiocb *req)
+{
+	struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
+
+	WARN_ON(!in_task());
+
+	if (rw->kiocb.ki_flags & IOCB_WRITE) {
+		kiocb_end_write(req);
+		fsnotify_modify(req->file);
+	} else {
+		fsnotify_access(req->file);
+	}
+}
+
 static bool __io_complete_rw_common(struct io_kiocb *req, long res)
 {
 	if (unlikely(res != req->cqe.res)) {
 		if ((res == -EAGAIN || res == -EOPNOTSUPP) &&
 		    io_rw_should_reissue(req)) {
+			/*
+			 * Reissue will start accounting again, finish the
+			 * current cycle.
+			 */
+			io_req_io_end(req);
 			req->flags |= REQ_F_REISSUE | REQ_F_PARTIAL_IO;
 			return true;
 		}
@@ -214,15 +237,7 @@ static inline int io_fixup_rw_res(struct
 
 static void io_req_rw_complete(struct io_kiocb *req, bool *locked)
 {
-	struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
-
-	if (rw->kiocb.ki_flags & IOCB_WRITE) {
-		kiocb_end_write(req);
-		fsnotify_modify(req->file);
-	} else {
-		fsnotify_access(req->file);
-	}
-
+	io_req_io_end(req);
 	io_req_task_complete(req, locked);
 }
 
@@ -267,6 +282,11 @@ static int kiocb_done(struct io_kiocb *r
 		req->file->f_pos = rw->kiocb.ki_pos;
 	if (ret >= 0 && (rw->kiocb.ki_complete == io_complete_rw)) {
 		if (!__io_complete_rw_common(req, ret)) {
+			/*
+			 * Safe to call io_end from here as we're inline
+			 * from the submission path.
+			 */
+			io_req_io_end(req);
 			io_req_set_res(req, final_ret,
 				       io_put_kbuf(req, issue_flags));
 			return IOU_OK;


Patches currently in stable-queue which might be from axboe@xxxxxxxxx are

queue-6.0/io_uring-net-don-t-update-msg_name-if-not-provided.patch
queue-6.0/block-replace-blk_queue_nowait-with-bdev_nowait.patch
queue-6.0/io_uring-net-handle-einprogress-correct-for-ioring_op_connect.patch
queue-6.0/io_uring-rw-fix-unexpected-link-breakage.patch
queue-6.0/block-sed-opal-add-ioctl-to-return-device-status.patch
queue-6.0/io_uring-rw-don-t-lose-short-results-on-io_setup_async_rw.patch
queue-6.0/io_uring-rw-ensure-kiocb_end_write-is-always-called.patch
queue-6.0/io_uring-add-custom-opcode-hooks-on-fail.patch
queue-6.0/io_uring-net-fix-notif-cqe-reordering.patch
queue-6.0/io_uring-correct-pinned_vm-accounting.patch
queue-6.0/io_uring-net-rename-io_sendzc.patch
queue-6.0/sbitmap-avoid-leaving-waitqueue-in-invalid-state-in-.patch
queue-6.0/blk-wbt-fix-that-rwb-wc-is-always-set-to-1-in-wbt_init.patch
queue-6.0/blk-throttle-prevent-overflow-while-calculating-wait.patch
queue-6.0/blk-mq-use-quiesced-elevator-switch-when-reinitializ.patch
queue-6.0/io_uring-af_unix-defer-registered-files-gc-to-io_uring-release.patch
queue-6.0/io_uring-net-refactor-io_sr_msg-types.patch
queue-6.0/sbitmap-fix-possible-io-hung-due-to-lost-wakeup.patch
queue-6.0/io_uring-net-don-t-lose-partial-send-recv-on-fail.patch
queue-6.0/io_uring-net-don-t-lose-partial-send_zc-on-fail.patch
queue-6.0/eventfd-guard-wake_up-in-eventfd-fs-calls-as-well.patch
queue-6.0/io_uring-net-don-t-skip-notifs-for-failed-requests.patch
queue-6.0/blk-throttle-fix-that-io-throttle-can-only-work-for-single-bio.patch
queue-6.0/io_uring-fix-fdinfo-sqe-offsets-calculation.patch
queue-6.0/io_uring-rw-don-t-lose-partial-io-result-on-fail.patch
queue-6.0/io_uring-limit-registration-w-single_issuer.patch
queue-6.0/block-fix-the-enum-blk_eh_timer_return-documentation.patch
queue-6.0/io_uring-fix-cqe-reordering.patch
queue-6.0/blk-wbt-call-rq_qos_add-after-wb_normal-is-initialized.patch
queue-6.0/io_uring-net-fix-fast_iov-assignment-in-io_setup_async_msg.patch
queue-6.0/io_uring-fdinfo-fix-sqe-dumping-for-ioring_setup_sqe.patch
queue-6.0/bcache-fix-set_at_max_writeback_rate-for-multiple-at.patch
queue-6.0/io_uring-net-use-io_sr_msg-for-sendzc.patch
queue-6.0/io_uring-rw-defer-fsnotify-calls-to-task-context.patch
queue-6.0/nbd-fix-hung-when-signal-interrupts-nbd_start_device.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux