From: Christian Brauner <brauner@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>, Anuj Gupta <anuj20.g@samsung.com>,
Kanchan Joshi <joshi.k@samsung.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
io-uring@vger.kernel.org
Subject: Re: [PATCH 1/2] fs: add a FMODE_ flag to indicate IOCB_HAS_METADATA availability
Date: Tue, 19 Aug 2025 11:14:41 +0200 [thread overview]
Message-ID: <20250819-erwirbt-freischaffend-e3d3c1e8967a@brauner> (raw)
In-Reply-To: <20250819082517.2038819-2-hch@lst.de>
On Tue, Aug 19, 2025 at 10:25:00AM +0200, Christoph Hellwig wrote:
> Currently the kernel will happily route io_uring requests with metadata
> to file operations that don't support it. Add a FMODE_ flag to guard
> that.
>
> Fixes: 4de2ce04c862 ("fs: introduce IOCB_HAS_METADATA for metadata")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
It kind of feels like that f_iocb_flags should be changed so that
subsystems like block can just raise some internal flags directly
instead of grabbing a f_mode flag everytime they need to make some
IOCB_* flag conditional on the file. That would mean changing the
unconditional assigment to file->f_iocb_flags to a |= to not mask flags
raised by the kernel itself.
Then you can just push the burden of stuff like IOCB_HAS_* vs
IOCB_SUPPORTS/CAN_* to f_iocb_flags instead of the FMODE_* space.
> block/fops.c | 3 +++
> include/linux/fs.h | 3 ++-
> io_uring/rw.c | 3 +++
> 3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/block/fops.c b/block/fops.c
> index 82451ac8ff25..08e7c21bd9f1 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -7,6 +7,7 @@
> #include <linux/init.h>
> #include <linux/mm.h>
> #include <linux/blkdev.h>
> +#include <linux/blk-integrity.h>
> #include <linux/buffer_head.h>
> #include <linux/mpage.h>
> #include <linux/uio.h>
> @@ -687,6 +688,8 @@ static int blkdev_open(struct inode *inode, struct file *filp)
>
> if (bdev_can_atomic_write(bdev))
> filp->f_mode |= FMODE_CAN_ATOMIC_WRITE;
> + if (blk_get_integrity(bdev->bd_disk))
> + filp->f_mode |= FMODE_HAS_METADATA;
>
> ret = bdev_open(bdev, mode, filp->private_data, NULL, filp);
> if (ret)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index d7ab4f96d705..601d036a6c78 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -149,7 +149,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
> /* Expect random access pattern */
> #define FMODE_RANDOM ((__force fmode_t)(1 << 12))
>
> -/* FMODE_* bit 13 */
> +/* Supports IOCB_HAS_METADATA */
> +#define FMODE_HAS_METADATA ((__force fmode_t)(1 << 13))
>
> /* File is opened with O_PATH; almost nothing can be done with it */
> #define FMODE_PATH ((__force fmode_t)(1 << 14))
> diff --git a/io_uring/rw.c b/io_uring/rw.c
> index 52a5b950b2e5..af5a54b5db12 100644
> --- a/io_uring/rw.c
> +++ b/io_uring/rw.c
> @@ -886,6 +886,9 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type)
> if (req->flags & REQ_F_HAS_METADATA) {
> struct io_async_rw *io = req->async_data;
>
> + if (!(file->f_mode & FMODE_HAS_METADATA))
> + return -EINVAL;
> +
> /*
> * We have a union of meta fields with wpq used for buffered-io
> * in io_async_rw, so fail it here.
> --
> 2.47.2
>
next prev parent reply other threads:[~2025-08-19 9:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 8:24 io_uring / dio metadata fixes Christoph Hellwig
2025-08-19 8:25 ` [PATCH 1/2] fs: add a FMODE_ flag to indicate IOCB_HAS_METADATA availability Christoph Hellwig
2025-08-19 9:14 ` Christian Brauner [this message]
2025-08-19 9:22 ` Christoph Hellwig
2025-08-19 10:14 ` Christian Brauner
2025-08-19 13:34 ` Christoph Hellwig
2025-08-20 9:40 ` Christian Brauner
2025-08-21 8:42 ` Christoph Hellwig
2025-08-25 12:01 ` Christian Brauner
2025-08-25 13:35 ` Christoph Hellwig
2025-08-19 8:25 ` [PATCH 2/2] block: don't silently ignore metadata for sync read/write Christoph Hellwig
2025-08-20 3:23 ` Martin K. Petersen
2025-08-20 9:13 ` io_uring / dio metadata fixes Christian Brauner
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=20250819-erwirbt-freischaffend-e3d3c1e8967a@brauner \
--to=brauner@kernel.org \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=io-uring@vger.kernel.org \
--cc=jack@suse.cz \
--cc=joshi.k@samsung.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.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).