From: Damien Le Moal <dlemoal@kernel.org>
To: Alberto Faria <afaria@redhat.com>, linux-block@vger.kernel.org
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jens Axboe" <axboe@kernel.dk>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Jason Wang" <jasowangio@gmail.com>
Subject: Re: [PATCH v3 1/2] virtio_blk: add fua write support
Date: Wed, 25 Nov 2026 18:09:13 +0900 [thread overview]
Message-ID: <b274eaac-4bf3-4d6e-8451-461c02c1fad7@kernel.org> (raw)
In-Reply-To: <20261125083947.263216-2-afaria@redhat.com>
On 2026/11/25 17:39, Alberto Faria wrote:
> Add the new virtio-blk request FUA flag uapi definitions and
> corresponding virtio-blk support.
>
> Signed-off-by: Alberto Faria <afaria@redhat.com>
> ---
> drivers/block/virtio_blk.c | 29 +++++++++++++++++++++++++++--
> include/uapi/linux/virtio_blk.h | 13 +++++++++++--
> 2 files changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 2b462005cdb68..7ee2e6a6a591b 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -248,7 +248,10 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
> return BLK_STS_NOTSUPP;
>
> /* Set fields for all request types */
> - vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
> + if (virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS))
> + vbr->out_hdr.flags = 0;
> + else
> + vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
>
> switch (req_op(req)) {
> case REQ_OP_READ:
> @@ -258,6 +261,11 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
> case REQ_OP_WRITE:
> type = VIRTIO_BLK_T_OUT;
> sector = blk_rq_pos(req);
> + if ((req->cmd_flags & REQ_FUA) &&
> + virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS) &&
> + virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA))
> + vbr->out_hdr.flags |= cpu_to_virtio32(vdev,
> + BIT(VIRTIO_BLK_REQ_FLAG_OUT_FUA));
> break;
> case REQ_OP_FLUSH:
> type = VIRTIO_BLK_T_FLUSH;
> @@ -1151,10 +1159,17 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
> virtio_cwrite8(vdev, offsetof(struct virtio_blk_config, wce), i);
>
> lim = queue_limits_start_update(disk->queue);
> +
White line change.
> if (virtblk_get_cache_mode(vdev))
> lim.features |= BLK_FEAT_WRITE_CACHE;
> else
> lim.features &= ~BLK_FEAT_WRITE_CACHE;
> +
> + if (virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS) &&
> + virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA) &&
> + !(lim.features & BLK_FEAT_ZONED))
> + lim.features |= BLK_FEAT_FUA;
> +
> i = queue_limits_commit_update_frozen(disk->queue, &lim);
> if (i)
> return i;
> @@ -1575,6 +1590,15 @@ static int virtblk_probe(struct virtio_device *vdev)
> if (virtblk_get_cache_mode(vdev))
> lim.features |= BLK_FEAT_WRITE_CACHE;
>
> + /*
> + * Do not advertise FUA when the device is zoned, since we
> + * would not be able to handle it on REQ_OP_ZONE_APPEND.
> + */
Why is that? I do not see any reason for this.
> + if (virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS) &&
> + virtio_has_feature(vdev, VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA) &&
> + !(lim.features & BLK_FEAT_ZONED))
> + lim.features |= BLK_FEAT_FUA;
> +
> vblk->disk = blk_mq_alloc_disk(&vblk->tag_set, &lim, vblk);
> if (IS_ERR(vblk->disk)) {
> err = PTR_ERR(vblk->disk);
> @@ -1740,7 +1764,8 @@ static unsigned int features[] = {
> VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
> VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE,
> VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_WRITE_ZEROES,
> - VIRTIO_BLK_F_SECURE_ERASE, VIRTIO_BLK_F_ZONED,
> + VIRTIO_BLK_F_SECURE_ERASE, VIRTIO_BLK_F_ZONED, VIRTIO_BLK_F_REQ_FLAGS,
> + VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA,
> };
>
> static struct virtio_driver virtio_blk = {
> diff --git a/include/uapi/linux/virtio_blk.h b/include/uapi/linux/virtio_blk.h
> index 3744e4da1b2a7..c5047e6a9a9bc 100644
> --- a/include/uapi/linux/virtio_blk.h
> +++ b/include/uapi/linux/virtio_blk.h
> @@ -42,6 +42,8 @@
> #define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */
> #define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */
> #define VIRTIO_BLK_F_ZONED 17 /* Zoned block device */
> +#define VIRTIO_BLK_F_REQ_FLAGS 18 /* Request flags supported */
> +#define VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA 19 /* FUA flag supported */
>
> /* Legacy feature bits */
> #ifndef VIRTIO_BLK_NO_LEGACY
> @@ -211,6 +213,9 @@ struct virtio_blk_config {
> #define VIRTIO_BLK_T_BARRIER 0x80000000
> #endif /* !VIRTIO_BLK_NO_LEGACY */
>
> +/* Request flag bits */
> +#define VIRTIO_BLK_REQ_FLAG_OUT_FUA 0
> +
> /*
> * This comes first in the read scatter-gather list.
> * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated,
> @@ -219,8 +224,12 @@ struct virtio_blk_config {
> struct virtio_blk_outhdr {
> /* VIRTIO_BLK_T* */
> __virtio32 type;
> - /* io priority. */
> - __virtio32 ioprio;
> + union {
> + /* io priority. */
> + __virtio32 ioprio;
> + /* Request flags. */
> + __virtio32 flags;
> + };
> /* Sector (ie. 512 byte offset) */
> __virtio64 sector;
> };
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-11-25 9:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 8:39 [PATCH v3 0/2] virtio_blk: add FUA write support Alberto Faria
2026-11-25 8:39 ` [PATCH v3 1/2] virtio_blk: add fua " Alberto Faria
2026-11-25 9:07 ` Johannes Thumshirn
2026-11-25 9:16 ` Alberto Faria
2026-11-25 9:09 ` Damien Le Moal [this message]
2026-11-25 8:39 ` [PATCH v3 2/2] vdpa_sim_blk: add support for FUA writes Alberto Faria
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=b274eaac-4bf3-4d6e-8451-461c02c1fad7@kernel.org \
--to=dlemoal@kernel.org \
--cc=afaria@redhat.com \
--cc=axboe@kernel.dk \
--cc=eperezma@redhat.com \
--cc=jasowangio@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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