Skip to content

Commit 1ac61dd

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA: report virtio-blk flush info to user space
This commit reports whether a virtio-blk device support cache flush command to user space Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Message-Id: <20240218185606.13509-11-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent ae1374b commit 1ac61dd

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/vdpa/vdpa.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,17 @@ static int vdpa_dev_blk_ro_config_fill(struct sk_buff *msg, u64 features)
10951095
return 0;
10961096
}
10971097

1098+
static int vdpa_dev_blk_flush_config_fill(struct sk_buff *msg, u64 features)
1099+
{
1100+
u8 flush;
1101+
1102+
flush = ((features & BIT_ULL(VIRTIO_BLK_F_FLUSH)) == 0) ? 0 : 1;
1103+
if (nla_put_u8(msg, VDPA_ATTR_DEV_BLK_CFG_FLUSH, flush))
1104+
return -EMSGSIZE;
1105+
1106+
return 0;
1107+
}
1108+
10981109
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10991110
struct sk_buff *msg)
11001111
{
@@ -1136,6 +1147,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
11361147
if (vdpa_dev_blk_ro_config_fill(msg, features_device))
11371148
return -EMSGSIZE;
11381149

1150+
if (vdpa_dev_blk_flush_config_fill(msg, features_device))
1151+
return -EMSGSIZE;
1152+
11391153
return 0;
11401154
}
11411155

include/uapi/linux/vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ enum vdpa_attr {
7171
VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC, /* u32 */
7272
VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG, /* u32 */
7373
VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, /* u8 */
74+
VDPA_ATTR_DEV_BLK_CFG_FLUSH, /* u8 */
7475

7576
/* new attributes must be added above here */
7677
VDPA_ATTR_MAX,

0 commit comments

Comments
 (0)