Patch "io_uring: io_kiocb_update_pos() should not touch file for non -1 offset" has been added to the 5.10-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: io_kiocb_update_pos() should not touch file for non -1 offset

to the 5.10-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-io_kiocb_update_pos-should-not-touch-file-for-non-1-offset.patch
and it can be found in the queue-5.10 subdirectory.

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


>From 6f83ab22adcb77a5824d2c274dace0d99e21319f Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@xxxxxxxxx>
Date: Mon, 11 Apr 2022 09:48:30 -0600
Subject: io_uring: io_kiocb_update_pos() should not touch file for non -1 offset

From: Jens Axboe <axboe@xxxxxxxxx>

commit 6f83ab22adcb77a5824d2c274dace0d99e21319f upstream.

-1 tells use to use the current position, but we check if the file is
a stream regardless of that. Fix up io_kiocb_update_pos() to only
dip into file if we need to. This is both more efficient and also drops
12 bytes of text on aarch64 and 64 bytes on x86-64.

Fixes: b4aec4001595 ("io_uring: do not recalculate ppos unnecessarily")
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 io_uring/io_uring.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3011,19 +3011,18 @@ static inline void io_rw_done(struct kio
 static inline loff_t *io_kiocb_update_pos(struct io_kiocb *req)
 {
 	struct kiocb *kiocb = &req->rw.kiocb;
-	bool is_stream = req->file->f_mode & FMODE_STREAM;
 
-	if (kiocb->ki_pos == -1) {
-		if (!is_stream) {
-			req->flags |= REQ_F_CUR_POS;
-			kiocb->ki_pos = req->file->f_pos;
-			return &kiocb->ki_pos;
-		} else {
-			kiocb->ki_pos = 0;
-			return NULL;
-		}
+	if (kiocb->ki_pos != -1)
+		return &kiocb->ki_pos;
+
+	if (!(req->file->f_mode & FMODE_STREAM)) {
+		req->flags |= REQ_F_CUR_POS;
+		kiocb->ki_pos = req->file->f_pos;
+		return &kiocb->ki_pos;
 	}
-	return is_stream ? NULL : &kiocb->ki_pos;
+
+	kiocb->ki_pos = 0;
+	return NULL;
 }
 
 static void kiocb_done(struct kiocb *kiocb, ssize_t ret,


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

queue-5.10/io_uring-improve-send-recv-error-handling.patch
queue-5.10/io_uring-remove-duplicated-calls-to-io_kiocb_ppos.patch
queue-5.10/io_uring-add-flag-for-disabling-provided-buffer-recy.patch
queue-5.10/io_uring-fix-async-accept-on-o_nonblock-sockets.patch
queue-5.10/io_uring-ensure-recv-and-recvmsg-handle-msg_waitall-.patch
queue-5.10/io_uring-don-t-gate-task_work-run-on-tif_notify_sign.patch
queue-5.10/io_uring-update-kiocb-ki_pos-at-execution-time.patch
queue-5.10/io_uring-do-not-recalculate-ppos-unnecessarily.patch
queue-5.10/io_uring-support-msg_waitall-for-ioring_op_send-msg.patch
queue-5.10/io_uring-check-for-valid-register-opcode-earlier.patch
queue-5.10/io_uring-allow-re-poll-if-we-made-progress.patch
queue-5.10/io_uring-net-fix-fast_iov-assignment-in-io_setup_async_msg.patch
queue-5.10/io_uring-fix-cq-waiting-timeout-handling.patch
queue-5.10/io_uring-ensure-that-cached-task-references-are-alwa.patch
queue-5.10/io_uring-lock-overflowing-for-iopoll.patch
queue-5.10/io_uring-rw-defer-fsnotify-calls-to-task-context.patch
queue-5.10/io_uring-io_kiocb_update_pos-should-not-touch-file-for-non-1-offset.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