linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>,
	Daejun Park <daejun7.park@samsung.com>,
	Kanchan Joshi <joshi.k@samsung.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Subject: [PATCH v5 05/17] fs: Restore kiocb.ki_hint
Date: Wed, 29 Nov 2023 17:33:10 -0800	[thread overview]
Message-ID: <20231130013322.175290-6-bvanassche@acm.org> (raw)
In-Reply-To: <20231130013322.175290-1-bvanassche@acm.org>

Restore support for passing file and/or inode write hints to the code
that processes struct kiocb. This patch reverts commit 41d36a9f3e53
("fs: remove kiocb.ki_hint").

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fs/aio.c                    | 1 +
 fs/f2fs/file.c              | 6 ++++++
 include/linux/fs.h          | 3 +++
 include/trace/events/f2fs.h | 5 ++++-
 io_uring/rw.c               | 1 +
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/aio.c b/fs/aio.c
index f8589caef9c1..a9dc84a984db 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1466,6 +1466,7 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb)
 	req->ki_flags = req->ki_filp->f_iocb_flags;
 	if (iocb->aio_flags & IOCB_FLAG_RESFD)
 		req->ki_flags |= IOCB_EVENTFD;
+	req->ki_hint = file_write_hint(req->ki_filp);
 	if (iocb->aio_flags & IOCB_FLAG_IOPRIO) {
 		/*
 		 * If the IOCB_FLAG_IOPRIO flag of aio_flags is set, then
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index e50363583f01..6ffafa29f1a2 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4644,8 +4644,10 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from,
 	struct f2fs_inode_info *fi = F2FS_I(inode);
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	const bool do_opu = f2fs_lfs_mode(sbi);
+	const int whint_mode = F2FS_OPTION(sbi).whint_mode;
 	const loff_t pos = iocb->ki_pos;
 	const ssize_t count = iov_iter_count(from);
+	const enum rw_hint hint = iocb->ki_hint;
 	unsigned int dio_flags;
 	struct iomap_dio *dio;
 	ssize_t ret;
@@ -4678,6 +4680,8 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from,
 		if (do_opu)
 			f2fs_down_read(&fi->i_gc_rwsem[READ]);
 	}
+	if (whint_mode == WHINT_MODE_OFF)
+		iocb->ki_hint = WRITE_LIFE_NOT_SET;
 
 	/*
 	 * We have to use __iomap_dio_rw() and iomap_dio_complete() instead of
@@ -4700,6 +4704,8 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from,
 		ret = iomap_dio_complete(dio);
 	}
 
+	if (whint_mode == WHINT_MODE_OFF)
+		iocb->ki_hint = hint;
 	if (do_opu)
 		f2fs_up_read(&fi->i_gc_rwsem[READ]);
 	f2fs_up_read(&fi->i_gc_rwsem[WRITE]);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a6e0c4b5a72b..acc0cbab93dd 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -362,6 +362,7 @@ struct kiocb {
 	void (*ki_complete)(struct kiocb *iocb, long ret);
 	void			*private;
 	int			ki_flags;
+	u8			ki_hint;
 	u16			ki_ioprio; /* See linux/ioprio.h */
 	union {
 		/*
@@ -2176,6 +2177,7 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
 	*kiocb = (struct kiocb) {
 		.ki_filp = filp,
 		.ki_flags = filp->f_iocb_flags,
+		.ki_hint = file_write_hint(filp),
 		.ki_ioprio = get_current_ioprio(),
 	};
 }
@@ -2186,6 +2188,7 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
 	*kiocb = (struct kiocb) {
 		.ki_filp = filp,
 		.ki_flags = kiocb_src->ki_flags,
+		.ki_hint = kiocb_src->ki_hint,
 		.ki_ioprio = kiocb_src->ki_ioprio,
 		.ki_pos = kiocb_src->ki_pos,
 	};
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 793f82cc1515..eb9ba109949e 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -946,6 +946,7 @@ TRACE_EVENT(f2fs_direct_IO_enter,
 		__field(ino_t,	ino)
 		__field(loff_t,	ki_pos)
 		__field(int,	ki_flags)
+		__field(u16,	ki_hint)
 		__field(u16,	ki_ioprio)
 		__field(unsigned long,	len)
 		__field(int,	rw)
@@ -956,16 +957,18 @@ TRACE_EVENT(f2fs_direct_IO_enter,
 		__entry->ino		= inode->i_ino;
 		__entry->ki_pos		= iocb->ki_pos;
 		__entry->ki_flags	= iocb->ki_flags;
+		__entry->ki_hint	= iocb->ki_hint;
 		__entry->ki_ioprio	= iocb->ki_ioprio;
 		__entry->len		= len;
 		__entry->rw		= rw;
 	),
 
-	TP_printk("dev = (%d,%d), ino = %lu pos = %lld len = %lu ki_flags = %x ki_ioprio = %x rw = %d",
+	TP_printk("dev = (%d,%d), ino = %lu pos = %lld len = %lu ki_flags = %x ki_hint = %x ki_ioprio = %x rw = %d",
 		show_dev_ino(__entry),
 		__entry->ki_pos,
 		__entry->len,
 		__entry->ki_flags,
+		__entry->ki_hint,
 		__entry->ki_ioprio,
 		__entry->rw)
 );
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 64390d4e20c1..24a6122c837b 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -994,6 +994,7 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
 		kfree(iovec);
 		return ret;
 	}
+	kiocb->ki_hint = file_write_hint(req->file);
 	req->cqe.res = iov_iter_count(&s->iter);
 
 	if (force_nonblock) {

  parent reply	other threads:[~2023-11-30  1:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30  1:33 [PATCH v5 00/17] Pass data lifetime information to SCSI disk devices Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 01/17] fs: Fix rw_hint validation Bart Van Assche
2023-12-07 17:42   ` Christoph Hellwig
2023-11-30  1:33 ` [PATCH v5 02/17] fs: Move enum rw_hint into a new header file Bart Van Assche
2023-12-07 17:44   ` Christoph Hellwig
2023-11-30  1:33 ` [PATCH v5 03/17] fs/f2fs: Restore the whint_mode mount option Bart Van Assche
2023-12-07 17:45   ` Christoph Hellwig
2023-12-07 19:39     ` Bart Van Assche
2023-12-11 16:44       ` Christoph Hellwig
2023-11-30  1:33 ` [PATCH v5 04/17] fs: Restore F_[GS]ET_FILE_RW_HINT support Bart Van Assche
2023-12-07 17:46   ` Christoph Hellwig
2023-12-07 19:37     ` Bart Van Assche
2023-12-11 16:45       ` Christoph Hellwig
2023-11-30  1:33 ` Bart Van Assche [this message]
2023-12-07 17:46   ` [PATCH v5 05/17] fs: Restore kiocb.ki_hint Christoph Hellwig
2023-12-07 23:40     ` Bart Van Assche
2023-12-11 16:46       ` Christoph Hellwig
2023-11-30  1:33 ` [PATCH v5 06/17] block: Restore the per-bio/request data lifetime fields Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 07/17] block: Propagate write hints to the block device inode Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 08/17] scsi: core: Query the Block Limits Extension VPD page Bart Van Assche
2023-11-30 12:21   ` Johannes Thumshirn
2023-11-30  1:33 ` [PATCH v5 09/17] scsi_proto: Add structures and constants related to I/O groups and streams Bart Van Assche
2023-11-30 13:19   ` Johannes Thumshirn
2023-12-01  1:46     ` Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 10/17] sd: Translate data lifetime information Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 11/17] scsi_debug: Reduce code duplication Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 12/17] scsi_debug: Support the block limits extension VPD page Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 13/17] scsi_debug: Rework page code error handling Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 14/17] scsi_debug: Rework subpage " Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 15/17] scsi_debug: Implement the IO Advice Hints Grouping mode page Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 16/17] scsi_debug: Implement GET STREAM STATUS Bart Van Assche
2023-11-30  1:33 ` [PATCH v5 17/17] scsi_debug: Maintain write statistics per group number Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231130013322.175290-6-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=daejun7.park@samsung.com \
    --cc=hch@lst.de \
    --cc=joshi.k@samsung.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).