From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bvanassche@acm.org>,
Dave Chinner <dchinner@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Benjamin LaHaise <bcrl@kvack.org>,
David Howells <dhowells@redhat.com>,
Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: [PATCH 03/13] fs: Restore kiocb.ki_hint
Date: Wed, 20 Sep 2023 12:14:28 -0700 [thread overview]
Message-ID: <20230920191442.3701673-4-bvanassche@acm.org> (raw)
In-Reply-To: <20230920191442.3701673-1-bvanassche@acm.org>
Restore support for passing write hint information from a filesystem to the
block layer. Write hint information can be set via fcntl(fd, F_SET_RW_HINT,
&hint). This patch reverts commit 41d36a9f3e53 ("fs: remove kiocb.ki_hint").
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
fs/aio.c | 1 +
fs/cachefiles/io.c | 2 ++
fs/f2fs/file.c | 6 ++++++
include/linux/fs.h | 12 ++++++++++++
include/trace/events/f2fs.h | 5 ++++-
io_uring/rw.c | 1 +
6 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/fs/aio.c b/fs/aio.c
index a4c2a6bac72c..a09743049738 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 = ki_hint_validate(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/cachefiles/io.c b/fs/cachefiles/io.c
index 009d23cd435b..ad2870748c15 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -138,6 +138,7 @@ static int cachefiles_read(struct netfs_cache_resources *cres,
ki->iocb.ki_filp = file;
ki->iocb.ki_pos = start_pos + skipped;
ki->iocb.ki_flags = IOCB_DIRECT;
+ ki->iocb.ki_hint = ki_hint_validate(file_write_hint(file));
ki->iocb.ki_ioprio = get_current_ioprio();
ki->skipped = skipped;
ki->object = object;
@@ -306,6 +307,7 @@ int __cachefiles_write(struct cachefiles_object *object,
ki->iocb.ki_filp = file;
ki->iocb.ki_pos = start_pos;
ki->iocb.ki_flags = IOCB_DIRECT | IOCB_WRITE;
+ ki->iocb.ki_hint = ki_hint_validate(file_write_hint(file));
ki->iocb.ki_ioprio = get_current_ioprio();
ki->object = object;
ki->start = start_pos;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ca5904129b16..9dc0e06c38ba 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4634,8 +4634,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;
@@ -4668,6 +4670,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
@@ -4690,6 +4694,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 ba2c5c90af6d..8ebed22dfc88 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -374,6 +374,7 @@ struct kiocb {
void (*ki_complete)(struct kiocb *iocb, long ret);
void *private;
int ki_flags;
+ u16 ki_hint;
u16 ki_ioprio; /* See linux/ioprio.h */
union {
/*
@@ -2143,11 +2144,21 @@ static inline enum rw_hint file_write_hint(struct file *file)
return file_inode(file)->i_write_hint;
}
+static inline u16 ki_hint_validate(enum rw_hint hint)
+{
+ typeof(((struct kiocb *)0)->ki_hint) max_hint = -1;
+
+ if (hint <= max_hint)
+ return hint;
+ return 0;
+}
+
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 = ki_hint_validate(file_write_hint(filp)),
.ki_ioprio = get_current_ioprio(),
};
}
@@ -2158,6 +2169,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..9247ad58034e 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 c8c822fa7980..c41ae6654116 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -677,6 +677,7 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
req->flags |= io_file_get_flags(file);
kiocb->ki_flags = file->f_iocb_flags;
+ kiocb->ki_hint = file_inode(file)->i_write_hint;
ret = kiocb_set_rw_flags(kiocb, rw->flags);
if (unlikely(ret))
return ret;
next prev parent reply other threads:[~2023-09-20 19:15 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 19:14 [PATCH 00/13] Pass data temperature information to zoned UFS devices Bart Van Assche
2023-09-20 19:14 ` [PATCH 01/13] fs/f2fs: Restore the whint_mode mount option Bart Van Assche
2023-10-02 10:32 ` Avri Altman
2023-10-03 19:33 ` Bean Huo
2023-09-20 19:14 ` [PATCH 02/13] fs: Restore support for F_GET_FILE_RW_HINT and F_SET_FILE_RW_HINT Bart Van Assche
2023-10-02 10:35 ` Avri Altman
2023-10-03 19:42 ` Bean Huo
2023-09-20 19:14 ` Bart Van Assche [this message]
2023-10-02 10:45 ` [PATCH 03/13] fs: Restore kiocb.ki_hint Avri Altman
2023-10-02 16:39 ` Bart Van Assche
2023-09-20 19:14 ` [PATCH 04/13] block: Restore write hint support Bart Van Assche
2023-10-02 11:23 ` Avri Altman
2023-10-02 17:02 ` Bart Van Assche
2023-10-02 18:08 ` Avri Altman
2023-10-03 19:52 ` Bean Huo
2023-09-20 19:14 ` [PATCH 05/13] scsi: core: Query the Block Limits Extension VPD page Bart Van Assche
2023-10-02 11:29 ` Avri Altman
2023-09-20 19:14 ` [PATCH 06/13] scsi_proto: Add struct io_group_descriptor Bart Van Assche
2023-10-02 11:41 ` Avri Altman
2023-10-02 17:16 ` Bart Van Assche
2023-10-02 18:16 ` Avri Altman
2023-09-20 19:14 ` [PATCH 07/13] sd: Translate data lifetime information Bart Van Assche
2023-10-02 13:11 ` Avri Altman
2023-10-02 17:42 ` Bart Van Assche
2023-10-03 5:48 ` Avri Altman
2023-10-03 16:58 ` Bart Van Assche
2023-10-03 16:59 ` Bart Van Assche
2023-09-20 19:14 ` [PATCH 08/13] scsi_debug: Reduce code duplication Bart Van Assche
2023-10-03 6:49 ` Avri Altman
2023-09-20 19:14 ` [PATCH 09/13] scsi_debug: Support the block limits extension VPD page Bart Van Assche
2023-09-20 19:14 ` [PATCH 10/13] scsi_debug: Rework page code error handling Bart Van Assche
2023-09-20 19:14 ` [PATCH 11/13] scsi_debug: Rework subpage " Bart Van Assche
2023-09-20 19:14 ` [PATCH 12/13] scsi_debug: Implement the IO Advice Hints Grouping mode page Bart Van Assche
2023-09-20 19:14 ` [PATCH 13/13] scsi_debug: Maintain write statistics per group number Bart Van Assche
2023-09-20 19:28 ` [PATCH 00/13] Pass data temperature information to zoned UFS devices Matthew Wilcox
2023-09-20 20:46 ` Bart Van Assche
2023-09-21 7:46 ` Niklas Cassel
2023-09-21 14:27 ` Bart Van Assche
2023-09-21 15:34 ` Niklas Cassel
2023-09-21 17:00 ` Bart Van Assche
2023-09-21 19:27 ` Matthew Wilcox
2023-09-21 19:39 ` Bart Van Assche
2023-09-21 19:46 ` Matthew Wilcox
2023-09-21 20:11 ` Bart Van Assche
2023-09-21 20:47 ` Jaegeuk Kim
2023-09-27 19:14 ` Martin K. Petersen
2023-09-27 20:49 ` Bart Van Assche
2023-10-02 11:38 ` Niklas Cassel
2023-10-02 11:53 ` Niklas Cassel
2023-10-02 16:33 ` Bart Van Assche
2023-10-02 19:19 ` Niklas Cassel
2023-10-02 17:20 ` Bart Van Assche
2023-10-03 1:40 ` Martin K. Petersen
2023-10-03 17:26 ` Bart Van Assche
2023-10-03 18:45 ` Niklas Cassel
2023-10-04 3:17 ` Martin K. Petersen
[not found] ` <CGME20230920191557epcas2p34a114957acf221c0d8f60acbb3107c77@epcms2p6>
2023-10-05 11:41 ` [PATCH 01/13] fs/f2fs: Restore the whint_mode mount option Daejun Park
[not found] ` <CGME20230920191549epcas2p35174687f1bebe87c42a658fa6aa57bff@epcms2p7>
2023-10-05 11:43 ` [PATCH 02/13] fs: Restore support for F_GET_FILE_RW_HINT and F_SET_FILE_RW_HINT Daejun Park
[not found] ` <CGME20230920191556epcas2p39b150e6715248b625588a50b333e82e2@epcms2p1>
2023-10-05 11:46 ` [PATCH 04/13] block: Restore write hint support Daejun Park
[not found] ` <CGME20230920191816epcas2p1b30d19aa41e51ffaf7c95f9100ee6311@epcms2p3>
2023-10-05 11:58 ` [PATCH 05/13] scsi: core: Query the Block Limits Extension VPD page Daejun Park
[not found] ` <CGME20230920191554epcas2p2280a25d6b2a7fa81563bd6cf1e75549d@epcms2p8>
2023-10-05 11:59 ` [PATCH 06/13] scsi_proto: Add struct io_group_descriptor Daejun Park
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=20230920191442.3701673-4-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=bcrl@kvack.org \
--cc=brauner@kernel.org \
--cc=chao@kernel.org \
--cc=dchinner@redhat.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--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).