From a5b8dd2ce83208cd7d6eb4562339ecf5aae13574 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 23 Jun 2016 16:37:24 -0600 Subject: block: Move request_alignment into BlockLimit It makes more sense to have ALL block size limit constraints in the same struct. Improve the documentation while at it. Simplify a couple of conditionals, now that we have audited and documented that request_alignment is always non-zero. Signed-off-by: Eric Blake Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- include/block/block_int.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'include/block/block_int.h') diff --git a/include/block/block_int.h b/include/block/block_int.h index a3e69fd93a..8f061ebf79 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -324,6 +324,12 @@ struct BlockDriver { }; typedef struct BlockLimits { + /* Alignment requirement, in bytes, for offset/length of I/O + * requests. Must be a power of 2 less than INT_MAX; defaults to + * 1 for drivers with modern byte interfaces, and to 512 + * otherwise. */ + uint32_t request_alignment; + /* maximum number of bytes that can be discarded at once (since it * is signed, it must be < 2G, if set), should be multiple of * pdiscard_alignment, but need not be power of 2. May be 0 if no @@ -332,8 +338,8 @@ typedef struct BlockLimits { /* optimal alignment for discard requests in bytes, must be power * of 2, less than max_pdiscard if that is set, and multiple of - * bs->request_alignment. May be 0 if bs->request_alignment is - * good enough */ + * bl.request_alignment. May be 0 if bl.request_alignment is good + * enough */ uint32_t pdiscard_alignment; /* maximum number of bytes that can zeroized at once (since it is @@ -343,12 +349,12 @@ typedef struct BlockLimits { /* optimal alignment for write zeroes requests in bytes, must be * power of 2, less than max_pwrite_zeroes if that is set, and - * multiple of bs->request_alignment. May be 0 if - * bs->request_alignment is good enough */ + * multiple of bl.request_alignment. May be 0 if + * bl.request_alignment is good enough */ uint32_t pwrite_zeroes_alignment; /* optimal transfer length in bytes (must be power of 2, and - * multiple of bs->request_alignment), or 0 if no preferred size */ + * multiple of bl.request_alignment), or 0 if no preferred size */ uint32_t opt_transfer; /* maximal transfer length in bytes (need not be power of 2, but @@ -356,10 +362,10 @@ typedef struct BlockLimits { * For now, anything larger than INT_MAX is clamped down. */ uint32_t max_transfer; - /* memory alignment so that no bounce buffer is needed */ + /* memory alignment, in bytes so that no bounce buffer is needed */ size_t min_mem_alignment; - /* memory alignment for bounce buffer */ + /* memory alignment, in bytes, for bounce buffer */ size_t opt_mem_alignment; /* maximum number of iovec elements */ @@ -465,8 +471,6 @@ struct BlockDriverState { /* I/O Limits */ BlockLimits bl; - /* Alignment requirement for offset/length of I/O requests */ - unsigned int request_alignment; /* Flags honored during pwrite (so far: BDRV_REQ_FUA) */ unsigned int supported_write_flags; /* Flags honored during pwrite_zeroes (so far: BDRV_REQ_FUA, -- cgit v1.2.3