qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fix bdrv_check_request for byte-granularity requests
@ 2009-03-14 13:00 Christoph Hellwig
  2009-03-14 13:35 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-03-14 13:00 UTC (permalink / raw)
  To: qemu-devel

We never allow the offset to be byte-granularity for the sector-based
interface, instead the negative value for byte values applied to the
request length.


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

Index: qemu/block.c
===================================================================
--- qemu.orig/block.c	2009-03-11 11:50:27.000000000 +0100
+++ qemu/block.c	2009-03-11 11:51:42.000000000 +0100
@@ -542,15 +542,15 @@ static int bdrv_check_byte_request(Block
 static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
                               int nb_sectors)
 {
-    int64_t offset;
+    size_t len;
 
     /* Deal with byte accesses */
-    if (sector_num < 0)
-        offset = -sector_num;
+    if (nb_sectors < 0)
+        len = -nb_sectors;
     else
-        offset = sector_num * 512;
+        len = nb_sectors * 512;
 
-    return bdrv_check_byte_request(bs, offset, nb_sectors * 512);
+    return bdrv_check_byte_request(bs, sector_num * 512, len);
 }
 
 /* return < 0 if error. See bdrv_write() for the return codes */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] fix bdrv_check_request for byte-granularity requests
  2009-03-14 13:00 [Qemu-devel] [PATCH] fix bdrv_check_request for byte-granularity requests Christoph Hellwig
@ 2009-03-14 13:35 ` Christoph Hellwig
  2009-03-28 16:21   ` Anthony Liguori
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-03-14 13:35 UTC (permalink / raw)
  To: qemu-devel

On Sat, Mar 14, 2009 at 02:00:03PM +0100, Christoph Hellwig wrote:
> We never allow the offset to be byte-granularity for the sector-based
> interface, instead the negative value for byte values applied to the
> request length.

Actually - looking over the updates that happened during the week that
I was away it looks like the whole negative length hack is gone now,
so we can simplify bdrv_check_request instead:

Index: qemu/block.c
===================================================================
--- qemu.orig/block.c	2009-03-14 14:34:49.000000000 +0100
+++ qemu/block.c	2009-03-14 14:35:12.000000000 +0100
@@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Block
 static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
                               int nb_sectors)
 {
-    int64_t offset;
-
-    /* Deal with byte accesses */
-    if (sector_num < 0)
-        offset = -sector_num;
-    else
-        offset = sector_num * 512;
-
-    return bdrv_check_byte_request(bs, offset, nb_sectors * 512);
+    return bdrv_check_byte_request(bs, sector_num * 512, nb_sectors * 512);
 }
 
 /* return < 0 if error. See bdrv_write() for the return codes */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] fix bdrv_check_request for byte-granularity requests
  2009-03-14 13:35 ` Christoph Hellwig
@ 2009-03-28 16:21   ` Anthony Liguori
  2009-03-28 18:31     ` [Qemu-devel] [PATCH] remove dead code in bdrv_check_request Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Anthony Liguori @ 2009-03-28 16:21 UTC (permalink / raw)
  To: qemu-devel

Christoph Hellwig wrote:
> On Sat, Mar 14, 2009 at 02:00:03PM +0100, Christoph Hellwig wrote:
>   
>> We never allow the offset to be byte-granularity for the sector-based
>> interface, instead the negative value for byte values applied to the
>> request length.
>>     
>
> Actually - looking over the updates that happened during the week that
> I was away it looks like the whole negative length hack is gone now,
> so we can simplify bdrv_check_request instead:
>   

Needs a SoB.

Regards,

Anthony Liguori

> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c	2009-03-14 14:34:49.000000000 +0100
> +++ qemu/block.c	2009-03-14 14:35:12.000000000 +0100
> @@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Block
>  static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
>                                int nb_sectors)
>  {
> -    int64_t offset;
> -
> -    /* Deal with byte accesses */
> -    if (sector_num < 0)
> -        offset = -sector_num;
> -    else
> -        offset = sector_num * 512;
> -
> -    return bdrv_check_byte_request(bs, offset, nb_sectors * 512);
> +    return bdrv_check_byte_request(bs, sector_num * 512, nb_sectors * 512);
>  }
>  
>  /* return < 0 if error. See bdrv_write() for the return codes */
>
>
>
>   

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH] remove dead code in bdrv_check_request
  2009-03-28 16:21   ` Anthony Liguori
@ 2009-03-28 18:31     ` Christoph Hellwig
  2009-03-29  1:33       ` Anthony Liguori
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-03-28 18:31 UTC (permalink / raw)
  To: qemu-devel

Remove code dealing with negative sector numbers for byte access in
bdrv_check_request as sector numbers can't ever be negative.

Previously we supported negative sector counts for byte access, but
never sector numbers.


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

Index: qemu/block.c
===================================================================
--- qemu.orig/block.c	2009-03-14 14:34:49.000000000 +0100
+++ qemu/block.c	2009-03-14 14:35:12.000000000 +0100
@@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Block
 static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
                               int nb_sectors)
 {
-    int64_t offset;
-
-    /* Deal with byte accesses */
-    if (sector_num < 0)
-        offset = -sector_num;
-    else
-        offset = sector_num * 512;
-
-    return bdrv_check_byte_request(bs, offset, nb_sectors * 512);
+    return bdrv_check_byte_request(bs, sector_num * 512, nb_sectors * 512);
 }
 
 /* return < 0 if error. See bdrv_write() for the return codes */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] remove dead code in bdrv_check_request
  2009-03-28 18:31     ` [Qemu-devel] [PATCH] remove dead code in bdrv_check_request Christoph Hellwig
@ 2009-03-29  1:33       ` Anthony Liguori
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony Liguori @ 2009-03-29  1:33 UTC (permalink / raw)
  To: qemu-devel

Christoph Hellwig wrote:
> Remove code dealing with negative sector numbers for byte access in
> bdrv_check_request as sector numbers can't ever be negative.
>
> Previously we supported negative sector counts for byte access, but
> never sector numbers.
>
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>   

Applied.  Thanks for resending this.

Regards,

Anthony Liguori

> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c	2009-03-14 14:34:49.000000000 +0100
> +++ qemu/block.c	2009-03-14 14:35:12.000000000 +0100
> @@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Block
>  static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
>                                int nb_sectors)
>  {
> -    int64_t offset;
> -
> -    /* Deal with byte accesses */
> -    if (sector_num < 0)
> -        offset = -sector_num;
> -    else
> -        offset = sector_num * 512;
> -
> -    return bdrv_check_byte_request(bs, offset, nb_sectors * 512);
> +    return bdrv_check_byte_request(bs, sector_num * 512, nb_sectors * 512);
>  }
>  
>  /* return < 0 if error. See bdrv_write() for the return codes */
>
>
>
>   

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-29  1:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-14 13:00 [Qemu-devel] [PATCH] fix bdrv_check_request for byte-granularity requests Christoph Hellwig
2009-03-14 13:35 ` Christoph Hellwig
2009-03-28 16:21   ` Anthony Liguori
2009-03-28 18:31     ` [Qemu-devel] [PATCH] remove dead code in bdrv_check_request Christoph Hellwig
2009-03-29  1:33       ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).