On Wed, Feb 23, 2022 at 09:36:27PM +0800, Xie Yongji wrote: > Currently we have a BUG_ON() to make sure the number of sg list > does not exceed queue_max_segments() in virtio_queue_rq(). > However, the block layer uses queue_max_discard_segments() > instead of queue_max_segments() to limit the sg list for > discard requests. So the BUG_ON() might be triggered if > virtio-blk device reports a larger value for max discard > segment than queue_max_segments(). To fix it, this patch > checks the max discard segment for the discard request > in the BUG_ON() instead. This looks god, but jut removing the BUG_ON might be even better.