[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/9] dma-helpers: Do not truncate small qiovs
From: |
Alex Pyrgiotis |
Subject: |
[Qemu-devel] [PATCH 3/9] dma-helpers: Do not truncate small qiovs |
Date: |
Wed, 16 Dec 2015 18:55:11 +0200 |
If the size of the qiov is smaller than the sector size, do not truncate
the qiov, which would effectively make it empty. Instead, allow it to
pass as is.
This is necessary for SCSI requests like READ CAPACITY which have small
buffers, e.g. 32 bytes.
Signed-off-by: Alex Pyrgiotis <address@hidden>
Signed-off-by: Dimitris Aragiorgis <address@hidden>
diff --git a/dma-helpers.c b/dma-helpers.c
index e1ea7b3..b8f2ae0 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -162,7 +162,16 @@ static void dma_map_sg(DMAAIOCB *dbs)
return;
}
- if (dbs->iov.size & ~BDRV_SECTOR_MASK) {
+ /*
+ * If the size of the qiov is not a multiple of the sector size, truncate
+ * the qiov.
+ *
+ * NOTE: If the qiov is less than a sector, we can assume that there is a
+ * reason for it, e.g., a SCSI request such as READ CAPACITY, and we should
+ * not truncate it.
+ */
+ if (dbs->iov.size & ~BDRV_SECTOR_MASK &&
+ dbs->iov.size > BDRV_SECTOR_SIZE) {
qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK);
}
}
--
2.6.2
[Qemu-devel] [PATCH 5/9] scsi-generic: Separate `sg_io_hdr' initializations, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 4/9] scsi-generic: Add common functions, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 3/9] dma-helpers: Do not truncate small qiovs,
Alex Pyrgiotis <=
[Qemu-devel] [PATCH 7/9] scsi-generic: Make data-copying logic clearer, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 6/9] scsi-generic: Make request execution buf-specific, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 2/9] dma-helpers: Add support for ioctl operations, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 1/9] dma-helpers: Expose the sg mapping logic, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 8/9] scsi-generic: Factor out response interception, Alex Pyrgiotis, 2015/12/16
[Qemu-devel] [PATCH 9/9] scsi-generic: Allow full scatter-gather support, Alex Pyrgiotis, 2015/12/16