fix bdrv_check_request for byte-granularity requests
PATCH 1/1 fix bdrv_check_request for byte-granularity requests
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.
block.c +5 -5
@@ -542,15 +542,15 @@ static int bdrv_check_byte_request(Blockstatic 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 */
Quoted 3 lines · Christoph Hellwig
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:
block.c +1 -9
@@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Blockstatic 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 */
Quoted 11 lines · Christoph Hellwig
Quoted 4 lines · Christoph Hellwig
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_requestinstead:
Needs a SoB.
Regards,
Anthony Liguori
Quoted 25 lines
Index:
qemu/block.c
===================================================================block.c +1
-9@@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Blockstatic 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 */
PATCH 1/1 remove dead code in bdrv_check_request
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.
block.c +1 -9
@@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Blockstatic 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 */
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH] remove dead code in bdrv_check_request
Quoted 9 lines · Christoph Hellwig
Remove code dealing with negative sector numbers for byte access in
bdrv_check_requestas 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 <[email protected]>
Applied. Thanks for resending this.
Regards,
Anthony Liguori
Quoted 25 lines
Index:
qemu/block.c
===================================================================block.c +1
-9@@ -546,15 +546,7 @@ static int bdrv_check_byte_request(Blockstatic 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 */