[Devel] [PATCH rh7 08/38] ploop: fix iblk-to-sector calculations

Andrey Smetanin asmetanin at virtuozzo.com
Fri May 15 09:48:09 PDT 2015


iblk stands for image-file block number. Its size is the same as u32. The size
of 'sector' is the same as long. While converting the former to the latter
like this: sec = iblk << shift, we must always cast 'iblk' to long. And we
actually do in most cases. The patch fixes a place in io_direct module where
it was forgotten.

https://jira.sw.ru/browse/PSBM-22961

Signed-off-by: Maxim Patlasov <MPatlasov at parallels.com>
---
 drivers/block/ploop/io_direct.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index ab74849..56b9f37 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -119,8 +119,8 @@ dio_submit(struct ploop_io *io, struct ploop_request * preq,
 		goto out_em_err;
 
 	if (write && em->block_start == BLOCK_UNINIT) {
-		sector_t end = (iblk + 1) << preq->plo->cluster_log;
-		sec = iblk << preq->plo->cluster_log;
+		sector_t end = (sector_t)(iblk + 1) << preq->plo->cluster_log;
+		sec = (sector_t)iblk << preq->plo->cluster_log;
 
 		if (em->start <= sec)
 			sec = em->end;
-- 
1.9.3




More information about the Devel mailing list