Commit c6ff732f authored by Xie Yongji's avatar Xie Yongji Committed by Zheng Zengkai
Browse files

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

stable inclusion
from stable-v5.10.106
commit cca9d5035bd055a8824ae9e8e1e144eb22ae4b0b
bugzilla: https://gitee.com/openeuler/kernel/issues/I573US

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=cca9d5035bd055a8824ae9e8e1e144eb22ae4b0b



--------------------------------

[ Upstream commit dacc73ed ]

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>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
Reviewed-by: default avatarWei Li <liwei391@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent e444dd76
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment