Skip to content

Commit 6bdc784

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA: report virtio-block write zeroes configuration to user space
This commits reports write zeroes configuration of virtio-block devices to user space, includes: 1)maximum write zeroes sectors size 2)maximum write zeroes segment number Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Message-Id: <20240218185606.13509-9-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 65848f4 commit 6bdc784

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/vdpa/vdpa.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,26 @@ static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,
10641064
return 0;
10651065
}
10661066

1067+
static int
1068+
vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,
1069+
const struct virtio_blk_config *config)
1070+
{
1071+
u32 val_u32;
1072+
1073+
if ((features & BIT_ULL(VIRTIO_BLK_F_WRITE_ZEROES)) == 0)
1074+
return 0;
1075+
1076+
val_u32 = __virtio32_to_cpu(true, config->max_write_zeroes_sectors);
1077+
if (nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC, val_u32))
1078+
return -EMSGSIZE;
1079+
1080+
val_u32 = __virtio32_to_cpu(true, config->max_write_zeroes_seg);
1081+
if (nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG, val_u32))
1082+
return -EMSGSIZE;
1083+
1084+
return 0;
1085+
}
1086+
10671087
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10681088
struct sk_buff *msg)
10691089
{
@@ -1099,6 +1119,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10991119
if (vdpa_dev_blk_discard_config_fill(msg, features_device, &config))
11001120
return -EMSGSIZE;
11011121

1122+
if (vdpa_dev_blk_write_zeroes_config_fill(msg, features_device, &config))
1123+
return -EMSGSIZE;
1124+
11021125
return 0;
11031126
}
11041127

include/uapi/linux/vdpa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ enum vdpa_attr {
6868
VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC, /* u32 */
6969
VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG, /* u32 */
7070
VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN,/* u32 */
71+
VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC, /* u32 */
72+
VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG, /* u32 */
7173

7274
/* new attributes must be added above here */
7375
VDPA_ATTR_MAX,

0 commit comments

Comments
 (0)