From 67923a0609972b55147e04a25e068e68a1a00457 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 10 Nov 2021 12:07:04 +0100 Subject: [PATCH] Revert "ANDROID: virtio_blk: Remove BUG_ON for discard/zero ops" This reverts commit 187c494456303568b470d2cb05d934f7ec84d2a4. This commit conflicts with other virtio_blk changes that are coming in 5.16-rc1 so needs to be reverted. Also, if this really has been an issue since the 4.20 kernel release (i.e. Feb 2017), and not resolved yet, upstream should be told about it to resolve it as this has been a long time. Bug: 144592287 Cc: Satya Tangirala Cc: Alistair Delva Signed-off-by: Greg Kroah-Hartman Change-Id: I43339aad3704073d005d2fba91f159c68e099e97 --- drivers/block/virtio_blk.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 65e08802c7e4..fc4fc951dba7 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -228,6 +228,8 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx, bool unmap = false; u32 type; + BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems); + switch (req_op(req)) { case REQ_OP_READ: case REQ_OP_WRITE: @@ -251,10 +253,6 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx, return BLK_STS_IOERR; } - BUG_ON(type != VIRTIO_BLK_T_DISCARD && - type != VIRTIO_BLK_T_WRITE_ZEROES && - (req->nr_phys_segments + 2 > vblk->sg_elems)); - vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, type); vbr->out_hdr.sector = type ? 0 : cpu_to_virtio64(vblk->vdev, blk_rq_pos(req));