Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] virtio_blk: missing VIRTIO_BLK_F_REQ_FLAGS check in
  virtblk_setup_cmd()
--

commit f7bfe54853bedaa1afa630f98325bb99ee3bb7cb
Author: Alberto Faria <[email protected]>

virtio_blk: add fua write support

This commit adds UAPI definitions for virtio-blk request flags and
VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA, and teaches virtio_blk to advertise and
handle REQ_FUA writes.

> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 2b462005cdb68..b91d7dbd25cfd 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,10 @@ 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_OUT_FUA))
> +                     vbr->out_hdr.flags |= cpu_to_virtio32(vdev,
> +                             BIT(VIRTIO_BLK_REQ_FLAG_OUT_FUA));
>               break;

[Severity: Medium]
Should REQ_OP_WRITE also check VIRTIO_BLK_F_REQ_FLAGS before touching
vbr->out_hdr.flags, or should virtio_blk clear
VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA in a .validate callback when
VIRTIO_BLK_F_REQ_FLAGS is not offered?

Unlike virtblk_probe() and cache_type_store(), which check both features,
virtblk_setup_cmd() only checks VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA here.  If
VIRTIO_BLK_F_REQ_FLAGS is not negotiated (for example, when filtered out
via debugfs_filter_features), virtio_blk accepts
VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA without its prerequisite feature and can
fail feature negotiation with spec-compliant devices, or overwrite
vbr->out_hdr.ioprio in the union if a REQ_FUA write reaches the queue.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to