[PATCH 1/4] virtio-blk: remove additional check in fast path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function virtblk_setup_cmd() calls
virtblk_setup_discard_write_zeroes() once we process the block layer
request operation setup in the switch. Even though it saves duplicate
call for REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES it adds additional check
in the fast path that is redundent since we already have a switch case
for both REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES.

Move the call virtblk_setup_discard_write_zeroes() into switch case
label of REQ_OP_DISCARD and REQ_OP_WRITE_ZEROES and avoid duplicate
branch in the fast path.

Signed-off-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>
---
 drivers/block/virtio_blk.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 6ccf15253dee..b77711e73422 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -223,10 +223,14 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
 		break;
 	case REQ_OP_DISCARD:
 		type = VIRTIO_BLK_T_DISCARD;
+		if (virtblk_setup_discard_write_zeroes(req, unmap))
+			return BLK_STS_RESOURCE;
 		break;
 	case REQ_OP_WRITE_ZEROES:
 		type = VIRTIO_BLK_T_WRITE_ZEROES;
 		unmap = !(req->cmd_flags & REQ_NOUNMAP);
+		if (virtblk_setup_discard_write_zeroes(req, unmap))
+			return BLK_STS_RESOURCE;
 		break;
 	case REQ_OP_DRV_IN:
 		type = VIRTIO_BLK_T_GET_ID;
@@ -239,11 +243,6 @@ static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
 	vbr->out_hdr.type = cpu_to_virtio32(vdev, type);
 	vbr->out_hdr.ioprio = cpu_to_virtio32(vdev, req_get_ioprio(req));
 
-	if (type == VIRTIO_BLK_T_DISCARD || type == VIRTIO_BLK_T_WRITE_ZEROES) {
-		if (virtblk_setup_discard_write_zeroes(req, unmap))
-			return BLK_STS_RESOURCE;
-	}
-
 	return 0;
 }
 
-- 
2.29.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux