Skip to content
Commit dacc73ed authored by Xie Yongji's avatar Xie Yongji Committed by Michael S. Tsirkin
Browse files

virtio-blk: Don't use MAX_DISCARD_SEGMENTS if max_discard_seg is zero

Currently the value of max_discard_segment will be set to
MAX_DISCARD_SEGMENTS (256) with no basis in hardware if device
set 0 to max_discard_seg in configuration space. It's incorrect
since the device might not be able to handle such large descriptors.
To fix it, let's follow max_segments restrictions in this case.

Fixes: 1f23816b

 ("virtio_blk: add discard and write zeroes support")
Signed-off-by: default avatarXie Yongji <xieyongji@bytedance.com>
Link: https://lore.kernel.org/r/20220304100058.116-1-xieyongji@bytedance.com
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent e2ae38cf
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment