From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: add ioctl to get IO priority hint
Date: Thu, 6 Feb 2025 18:32:34 +0000 [thread overview]
Message-ID: <Z6UAQjJixONcx0bu@google.com> (raw)
In-Reply-To: <7d99f84f-5f99-4434-a3ef-5054caee22ef@kernel.org>
On 02/06, Chao Yu wrote:
> On 2/6/25 05:40, Jaegeuk Kim via Linux-f2fs-devel wrote:
> > This patch adds an ioctl to give a per-file priority hint to attach
> > REQ_PRIO.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/data.c | 6 ++++++
> > fs/f2fs/f2fs.h | 7 +++++++
> > fs/f2fs/file.c | 20 ++++++++++++++++++++
> > include/uapi/linux/f2fs.h | 1 +
> > 4 files changed, 34 insertions(+)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 07b46b444d31..24c5cb1f5ada 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -413,6 +413,7 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
> > static blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio)
> > {
> > unsigned int temp_mask = GENMASK(NR_TEMP_TYPE - 1, 0);
> > + struct folio *fio_folio = page_folio(fio->page);
> > unsigned int fua_flag, meta_flag, io_flag;
> > blk_opf_t op_flags = 0;
> >
> > @@ -438,6 +439,11 @@ static blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio)
> > op_flags |= REQ_META;
> > if (BIT(fio->temp) & fua_flag)
> > op_flags |= REQ_FUA;
> > +
> > + if (fio->type == DATA &&
> > + F2FS_I(fio_folio->mapping->host)->ioprio_hint == F2FS_IOPRIO_WRITE)
> > + op_flags |= REQ_PRIO;
> > +
> > return op_flags;
> > }
> >
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index bd0d8138b71d..c0a5f0df8781 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -816,6 +816,12 @@ enum {
> > FI_MAX, /* max flag, never be used */
> > };
> >
> > +/* used for f2fs_inode_info->ioprio_hint. */
> > +enum {
> > + F2FS_IOPRIO_WRITE = 1, /* high write priority */
> > + F2FS_IOPRIO_MAX,
> > +};
>
> This needs to be exported to user via include/uapi/linux/f2fs.h
>
> > +
> > struct f2fs_inode_info {
> > struct inode vfs_inode; /* serve a vfs inode */
> > unsigned long i_flags; /* keep an inode flags for ioctl */
> > @@ -830,6 +836,7 @@ struct f2fs_inode_info {
> >
> > /* Use below internally in f2fs*/
> > unsigned long flags[BITS_TO_LONGS(FI_MAX)]; /* use to pass per-file flags */
> > + unsigned int ioprio_hint; /* hint for IO priority */
>
> Seems one bit in f2fs_inode_info->flags is enough to store write priority?
I wanted to isolate this from general flags and open for more in future.
>
> > struct f2fs_rwsem i_sem; /* protect fi info */
> > atomic_t dirty_pages; /* # of dirty pages */
> > f2fs_hash_t chash; /* hash value of given file name */
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 642b8d85a035..2f93a27d2f45 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -3503,6 +3503,23 @@ static int f2fs_ioc_get_dev_alias_file(struct file *filp, unsigned long arg)
> > (u32 __user *)arg);
> > }
> >
> > +static int f2fs_ioc_io_prio(struct file *filp, unsigned long arg)
> > +{
> > + struct inode *inode = file_inode(filp);
> > + __u32 level;
> > +
> > + if (get_user(level, (__u32 __user *)arg))
> > + return -EFAULT;
> > +
> > + if (!S_ISREG(inode->i_mode) || level >= F2FS_IOPRIO_MAX)
> > + return -EINVAL;
> > +
> > + inode_lock(inode);
> > + F2FS_I(inode)->ioprio_hint = level;
> > + inode_unlock(inode);
> > + return 0;
> > +}
> > +
> > int f2fs_precache_extents(struct inode *inode)
> > {
> > struct f2fs_inode_info *fi = F2FS_I(inode);
> > @@ -4606,6 +4623,8 @@ static long __f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> > return f2fs_ioc_compress_file(filp);
> > case F2FS_IOC_GET_DEV_ALIAS_FILE:
> > return f2fs_ioc_get_dev_alias_file(filp, arg);
> > + case F2FS_IOC_IO_PRIO:
> > + return f2fs_ioc_io_prio(filp, arg);
> > default:
> > return -ENOTTY;
> > }
> > @@ -5321,6 +5340,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> > case F2FS_IOC_DECOMPRESS_FILE:
> > case F2FS_IOC_COMPRESS_FILE:
> > case F2FS_IOC_GET_DEV_ALIAS_FILE:
> > + case F2FS_IOC_IO_PRIO:
> > break;
> > default:
> > return -ENOIOCTLCMD;
> > diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h
> > index cd38a7c166e6..fb2f85b3c540 100644
> > --- a/include/uapi/linux/f2fs.h
> > +++ b/include/uapi/linux/f2fs.h
> > @@ -46,6 +46,7 @@
> > #define F2FS_IOC_GET_DEV_ALIAS_FILE _IOR(F2FS_IOCTL_MAGIC, 26, __u32)
> > #define F2FS_IOC_DONATE_RANGE _IOW(F2FS_IOCTL_MAGIC, 27, \
> > struct f2fs_donate_range)
> > +#define F2FS_IOC_IO_PRIO _IOW(F2FS_IOCTL_MAGIC, 28, __u32)
> >
> > /*
> > * should be same as XFS_IOC_GOINGDOWN.
next prev parent reply other threads:[~2025-02-06 18:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 21:40 [PATCH] f2fs: add ioctl to get IO priority hint Jaegeuk Kim
2025-02-06 2:33 ` [f2fs-dev] " Chao Yu
2025-02-06 18:32 ` Jaegeuk Kim [this message]
2025-02-11 21:01 ` [PATCH v2] " Jaegeuk Kim
2025-02-12 2:19 ` [f2fs-dev] " Chao Yu
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=Z6UAQjJixONcx0bu@google.com \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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).