[virtio-dev] [PATCH] virtio-blk: add DISCARD support to virtio-blk driver

Paolo Bonzini
Mon, 27 Mar 2017 11:34:17 -0000

On 28/03/2017 10:39, Changpeng Liu wrote:
> +	if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) {
> +		q->limits.discard_zeroes_data = 0;

Maybe you could use another feature bit to populate discard_zeroes_data.

Paolo

> +		q->limits.discard_alignment = blk_size;
> +		q->limits.discard_granularity = blk_size;
> +		blk_queue_max_discard_sectors(q, UINT_MAX);
> +		blk_queue_max_discard_segments(q, 1);
> +		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
> +	}
> +