diff options
author | Eric Blake <eblake@redhat.com> | 2016-06-23 16:37:19 -0600 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-07-05 16:46:25 +0200 |
commit | 5def6b80e1eca696c1fc6099e7f4d36729686402 (patch) | |
tree | 5948b16242a3b57bb1dffa6c650ef05e9154f59e /block/raw-posix.c | |
parent | 79ba8c986adb9ca07f52abd0b3d33c3aee8e6ff9 (diff) |
block: Switch transfer length bounds to byte-based
Sector-based limits are awkward to think about; in our on-going
quest to move to byte-based interfaces, convert max_transfer_length
and opt_transfer_length. Rename them (dropping the _length suffix)
so that the compiler will help us catch the change in semantics
across any rebased code, and improve the documentation. Use unsigned
values, so that we don't have to worry about negative values and
so that bit-twiddling is easier; however, we are still constrained
by 2^31 of signed int in most APIs.
When a value comes from an external source (iscsi and raw-posix),
sanitize the results to ensure that opt_transfer is a power of 2.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/raw-posix.c')
-rw-r--r-- | block/raw-posix.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/raw-posix.c b/block/raw-posix.c index bef7a671a6..8da2f94ec4 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -745,8 +745,8 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp) if (!fstat(s->fd, &st)) { if (S_ISBLK(st.st_mode)) { int ret = hdev_get_max_transfer_length(s->fd); - if (ret >= 0) { - bs->bl.max_transfer_length = ret; + if (ret > 0 && ret <= BDRV_REQUEST_MAX_SECTORS) { + bs->bl.max_transfer = pow2floor(ret << BDRV_SECTOR_BITS); } } } |