All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Alberto Faria <afaria@redhat.com>
Cc: linux-block@vger.kernel.org
Subject: Re: [RFC 1/2] virtio_blk: add fua write support
Date: Thu, 8 May 2025 16:33:13 -0400	[thread overview]
Message-ID: <20250508203313.GA63568@fedora> (raw)
In-Reply-To: <20250508001951.421467-2-afaria@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]

On Thu, May 08, 2025 at 01:19:50AM +0100, Alberto Faria wrote:
> Add the proposed VIRTIO_BLK_{F,T}_OUT_FUA uapi definitions and
> corresponding virtio-blk support.
> 
> Signed-off-by: Alberto Faria <afaria@redhat.com>
> ---
>  drivers/block/virtio_blk.c      | 10 +++++++---
>  include/uapi/linux/virtio_blk.h |  4 ++++
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 7cffea01d868c..021f05c469c50 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -256,7 +256,8 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
>  		sector = blk_rq_pos(req);
>  		break;
>  	case REQ_OP_WRITE:
> -		type = VIRTIO_BLK_T_OUT;
> +		type = req->cmd_flags & REQ_FUA ?
> +			VIRTIO_BLK_T_OUT_FUA : VIRTIO_BLK_T_OUT;
>  		sector = blk_rq_pos(req);
>  		break;
>  	case REQ_OP_FLUSH:
> @@ -1500,6 +1501,9 @@ static int virtblk_probe(struct virtio_device *vdev)
>  	if (virtblk_get_cache_mode(vdev))
>  		lim.features |= BLK_FEAT_WRITE_CACHE;
>  
> +	if (virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_OUT_FUA))
> +		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);
> @@ -1650,7 +1654,7 @@ static unsigned int features_legacy[] = {
>  	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_SECURE_ERASE, VIRTIO_BLK_F_OUT_FUA,

This is a new feature. Legacy VIRTIO devices don't support it.
VIRTIO_BLK_F_ZONED was not added to features_legacy[] when it was
introduced either.

>  }
>  ;
>  static unsigned int features[] = {
> @@ -1658,7 +1662,7 @@ 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_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..52be7943f6b8d 100644
> --- a/include/uapi/linux/virtio_blk.h
> +++ b/include/uapi/linux/virtio_blk.h
> @@ -42,6 +42,7 @@
>  #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_OUT_FUA		18	/* FUA write is supported */
>  
>  /* Legacy feature bits */
>  #ifndef VIRTIO_BLK_NO_LEGACY
> @@ -206,6 +207,9 @@ struct virtio_blk_config {
>  /* Reset All zones command */
>  #define VIRTIO_BLK_T_ZONE_RESET_ALL 26
>  
> +/* FUA write command */
> +#define VIRTIO_BLK_T_OUT_FUA        27
> +
>  #ifndef VIRTIO_BLK_NO_LEGACY
>  /* Barrier before this op. */
>  #define VIRTIO_BLK_T_BARRIER	0x80000000
> -- 
> 2.49.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2025-05-08 20:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08  0:19 [RFC 0/2] virtio_blk: add fua write support Alberto Faria
2025-05-08  0:19 ` [RFC 1/2] " Alberto Faria
2025-05-08 20:33   ` Stefan Hajnoczi [this message]
2026-05-12 19:18     ` [RFC PATCH v2] " Sana Sharma
2026-05-14 18:22       ` Stefan Hajnoczi
2025-05-08  0:19 ` [RFC 2/2] vdpa_sim_blk: add support for fua write commands Alberto Faria
2025-05-08 20:34   ` Stefan Hajnoczi

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=20250508203313.GA63568@fedora \
    --to=stefanha@redhat.com \
    --cc=afaria@redhat.com \
    --cc=linux-block@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.