[sheepdog] [PATCH] collie: ensure images size always are a multiple of 512 bytes

Christoph Hellwig hch at infradead.org
Wed May 30 17:14:08 CEST 2012


Sheepdog provides a block devices interface with a sector size of 512 bytes,
ensure we never set image sized not a multiple of 512 bytes, as that would
confuse consumer with the worst case beeing that the size gets truncated down
when doing the naive shift down to get the sector count.

Signed-off-by: Christoph Hellwig <hch at lst.de>

diff --git a/collie/vdi.c b/collie/vdi.c
index 0365015..8700ace 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -432,7 +432,7 @@ static int do_vdi_create(char *vdiname, int64_t vdi_size, uint32_t base_vid,
 
 	hdr.vdi.base_vdi_id = base_vid;
 	hdr.vdi.snapid = snapshot;
-	hdr.vdi.vdi_size = vdi_size;
+	hdr.vdi.vdi_size = roundup(vdi_size, 512);
 
 	ret = exec_req(fd, &hdr, buf, &wlen, &rlen);
 



More information about the sheepdog mailing list