From 75af1f34cd5b07c3c7fcf86dfc99a42de48a600d Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Fri, 6 Feb 2015 11:54:11 +0100 Subject: block: introduce BDRV_REQUEST_MAX_SECTORS we check and adjust request sizes at several places with sometimes inconsistent checks or default values: INT_MAX INT_MAX >> BDRV_SECTOR_BITS UINT_MAX >> BDRV_SECTOR_BITS SIZE_MAX >> BDRV_SECTOR_BITS This patches introdocues a macro for the maximal allowed sectors per request and uses it at several places. Signed-off-by: Peter Lieven Reviewed-by: Denis V. Lunev Signed-off-by: Kevin Wolf --- include/block/block.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 3082d2b80e..25a6d62d1b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -83,6 +83,9 @@ typedef enum { #define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS) #define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) +#define BDRV_REQUEST_MAX_SECTORS MIN(SIZE_MAX >> BDRV_SECTOR_BITS, \ + INT_MAX >> BDRV_SECTOR_BITS) + /* * Allocation status flags * BDRV_BLOCK_DATA: data is read from bs->file or another file -- cgit v1.2.3