On Mon, Aug 17, 2020 at 05:52:40PM +0800, Ming Lei wrote: > 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support") starts > to support multi-range discard for virtio-blk. However, the virtio-blk > disk may report max discard segment as 1, at least that is exactly what > qemu is doing. > > So far, block layer switches to normal request merge if max discard segment > limit is 1, and multiple bios can be merged to single segment. This way may > cause memory corruption in virtblk_setup_discard_write_zeroes(). > > Fix the issue by handling single max discard segment in straightforward > way. > > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > Fixes: 1f23816b8eb8 ("virtio_blk: add discard and write zeroes support") > Reviewed-by: Christoph Hellwig <hch@xxxxxx> > Cc: Changpeng Liu <changpeng.liu@xxxxxxxxx> > Cc: Daniel Verkamp <dverkamp@xxxxxxxxxxxx> > Cc: Michael S. Tsirkin <mst@xxxxxxxxxx> > Cc: Stefan Hajnoczi <stefanha@xxxxxxxxxx> > Cc: Stefano Garzarella <sgarzare@xxxxxxxxxx> > --- > drivers/block/virtio_blk.c | 31 +++++++++++++++++++++++-------- > 1 file changed, 23 insertions(+), 8 deletions(-) Thanks for fixing this! Stefan
Attachment:
signature.asc
Description: PGP signature