[PATCH 058/437] fs: add IOCB_VECTORED flags

From: Jens Axboe
Date: Thu Apr 11 2024 - 12:13:53 EST


This allows a user of ->read_iter() or ->write_iter() to tell if this
request originally came as a readv/writev, or if it was a normal
read/write operation.

Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
---
fs/read_write.c | 1 +
include/linux/fs.h | 2 ++
2 files changed, 3 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 1d035293607b..efddd395d436 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -733,6 +733,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
ret = kiocb_set_rw_flags(&kiocb, flags);
if (ret)
return ret;
+ kiocb.ki_flags |= IOCB_VECTORED;
kiocb.ki_pos = (ppos ? *ppos : 0);

if (type == READ)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 483c70d3941e..69e4dfac2853 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -346,6 +346,8 @@ struct readahead_control;
#define IOCB_DIO_CALLER_COMP (1 << 22)
/* kiocb is a read or write operation submitted by fs/aio.c. */
#define IOCB_AIO_RW (1 << 23)
+/* came from readv/writev */
+#define IOCB_VECTORED (1 << 24)

/* for use in trace events */
#define TRACE_IOCB_STRINGS \
--
2.43.0