Skip to contentSkip to conversation

qemu-io: Fix discard command

PATCH In review Kevin Wolf 2 participants 2 messages Jan 27, 2011 – Jan 28, 2011

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qemu-io: Fix discard command

qemu-io passed bytes where it's supposed to pass sectors, so discard requests were off.

---
 qemu-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-io.c +1 -1
index 5b24c5e..4470e49 100644
@@ -1465,7 +1465,7 @@ discard_f(int argc, char **argv)
 	}
 
 	gettimeofday(&t1, NULL);
-	ret = bdrv_discard(bs, offset, count);
+	ret = bdrv_discard(bs, offset >> BDRV_SECTOR_BITS, count >> BDRV_SECTOR_BITS);
 	gettimeofday(&t2, NULL);
 
 	if (ret < 0) {
Signature · 1 line
1.7.2.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Kevin Wolf

qemu-io passed bytes where it's supposed to pass sectors, so discard requests were off.

---
 qemu-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-io.c +0 -0
index 5b24c5e..4470e49 100644

qemu-io.c discard_f(int argc, char **argv) · line 1468

Quoted 5 lines
qemu-io.c +1 -1
@@ -1465,7 +1465,7 @@ discard_f(int argc, char **argv)
 	}
 
 	gettimeofday(&t1, NULL);
-	ret = bdrv_discard(bs, offset, count);
+	ret = bdrv_discard(bs, offset >> BDRV_SECTOR_BITS, count >> BDRV_SECTOR_BITS);

Oops, thanks for the fix.