Revert "ANDROID: virtio_blk: Remove BUG_ON for discard/zero ops"

This reverts commit 187c494456.

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 <satyat@google.com>
Cc: Alistair Delva <adelva@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I43339aad3704073d005d2fba91f159c68e099e97
This commit is contained in:
Greg Kroah-Hartman
2021-11-10 12:07:04 +01:00
parent f82ce01c0d
commit 67923a0609
+2 -4
View File
@@ -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));