]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
virtio-blk: Don't use MAX_DISCARD_SEGMENTS if max_discard_seg is zero
authorXie Yongji <xieyongji@bytedance.com>
Fri, 4 Mar 2022 10:00:57 +0000 (18:00 +0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Wed, 23 Mar 2022 10:49:00 +0000 (11:49 +0100)
commite2d98cceeabd2625dc18cc228b3f810ecf53e443
treeea754e214b0847838b56486554abde129e7b2c50
parent0c7ca06a64520da867cbaf46933ca5e7a3058a3f
virtio-blk: Don't use MAX_DISCARD_SEGMENTS if max_discard_seg is zero

BugLink: https://bugs.launchpad.net/bugs/1966056
[ Upstream commit dacc73ed0b88f1a787ec20385f42ca9dd9eddcd0 ]

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: 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support")
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Link: https://lore.kernel.org/r/20220304100058.116-1-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/block/virtio_blk.c