Patchwork qemu-io: Fix discard command

login
register
mail settings
Submitter Kevin Wolf
Date Jan. 27, 2011, 12:36 p.m.
Message ID <1296131772-9880-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/80666/
State New
Headers show

Comments

Kevin Wolf - Jan. 27, 2011, 12:36 p.m.
qemu-io passed bytes where it's supposed to pass sectors, so discard requests
were off.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Stefan Hajnoczi - Jan. 28, 2011, 9:56 a.m.
On Thu, Jan 27, 2011 at 01:36:12PM +0100, Kevin Wolf wrote:
> qemu-io passed bytes where it's supposed to pass sectors, so discard requests
> were off.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qemu-io.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/qemu-io.c b/qemu-io.c
> index 5b24c5e..4470e49 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -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.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Patch

diff --git a/qemu-io.c b/qemu-io.c
index 5b24c5e..4470e49 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -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) {