]> www.infradead.org Git - users/hch/xfs.git/commitdiff
io_uring: enable per-io hinting capability
authorKanchan Joshi <joshi.k@samsung.com>
Tue, 29 Oct 2024 15:19:19 +0000 (08:19 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 5 Nov 2024 15:35:38 +0000 (16:35 +0100)
With F_SET_RW_HINT fcntl, user can set a hint on the file inode, and
all the subsequent writes on the file pass that hint value down. This
can be limiting for block device as all the writes will be tagged with
only one lifetime hint value. Concurrent writes (with different hint
values) are hard to manage. Per-IO hinting solves that problem.

Allow userspace to pass additional metadata in the SQE.

__u16 write_hint;

If the hint is provided, filesystems may optionally use it. A filesytem
may ignore this field if it does not support per-io hints, or if the
value is invalid for its backing storage. Just like the inode hints,
requesting values that are not supported by the hardware are not an
error.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
include/uapi/linux/io_uring.h
io_uring/io_uring.c
io_uring/rw.c

index 1fe79e750470bf7f84eb0413fc1abc49c6167bae..de0bdd08e175dfa91a37ddce28dd22581c7bc40d 100644 (file)
@@ -92,6 +92,10 @@ struct io_uring_sqe {
                        __u16   addr_len;
                        __u16   __pad3[1];
                };
+               struct {
+                       __u16   write_hint;
+                       __u16   __pad4[1];
+               };
        };
        union {
                struct {
index b2736e3491b86222fb78012866e40bab0a2b05bc..eb01d27bdf21dbf12178aeed76af92723a557e55 100644 (file)
@@ -3826,7 +3826,9 @@ static int __init io_uring_init(void)
        BUILD_BUG_SQE_ELEM(44, __s32,  splice_fd_in);
        BUILD_BUG_SQE_ELEM(44, __u32,  file_index);
        BUILD_BUG_SQE_ELEM(44, __u16,  addr_len);
+       BUILD_BUG_SQE_ELEM(44, __u16,  write_hint);
        BUILD_BUG_SQE_ELEM(46, __u16,  __pad3[0]);
+       BUILD_BUG_SQE_ELEM(46, __u16,  __pad4[0]);
        BUILD_BUG_SQE_ELEM(48, __u64,  addr3);
        BUILD_BUG_SQE_ELEM_SIZE(48, 0, cmd);
        BUILD_BUG_SQE_ELEM(56, __u64,  __pad2);
index 354c4e175654cf74d4e61933f5fd2bd4efd8efc8..8d442e62be68afabaa41892b38382d040cc6d297 100644 (file)
@@ -279,7 +279,8 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
                rw->kiocb.ki_ioprio = get_current_ioprio();
        }
        rw->kiocb.dio_complete = NULL;
-
+       if (ddir == ITER_SOURCE)
+               rw->kiocb.ki_write_hint = READ_ONCE(sqe->write_hint);
        rw->addr = READ_ONCE(sqe->addr);
        rw->len = READ_ONCE(sqe->len);
        rw->flags = READ_ONCE(sqe->rw_flags);