From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqT3G-0005oE-14 for qemu-devel@nongnu.org; Thu, 26 Jan 2012 12:24:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqT31-0003V2-2Y for qemu-devel@nongnu.org; Thu, 26 Jan 2012 12:23:55 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:60416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqT30-0003D7-Mq for qemu-devel@nongnu.org; Thu, 26 Jan 2012 12:23:42 -0500 Received: by mail-iy0-f173.google.com with SMTP id k25so1227300iah.4 for ; Thu, 26 Jan 2012 09:23:41 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 26 Jan 2012 18:22:47 +0100 Message-Id: <1327598569-5199-17-git-send-email-pbonzini@redhat.com> In-Reply-To: <1327598569-5199-1-git-send-email-pbonzini@redhat.com> References: <1327598569-5199-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 16/18] block: default physical block size to host block size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com Hopefully, this will help operating systems in making less misaligned I/O operations. Not really true for Linux, but why not try. Signed-off-by: Paolo Bonzini --- block.c | 17 +++++++++++++++++ block.h | 15 ++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/block.c b/block.c index 33ccc23..0fce655 100644 --- a/block.c +++ b/block.c @@ -4136,3 +4136,20 @@ bool block_job_is_cancelled(BlockJob *job) { return job->cancelled; } + +unsigned int get_physical_block_exp(BlockConf *conf) +{ + unsigned int exp = 0, size; + + if (conf->physical_block_size || !conf->bs) { + size = conf->physical_block_size; + } else { + size = conf->bs->host_block_size; + } + + for (; size > conf->logical_block_size; size >>= 1) { + exp++; + } + + return exp; +} diff --git a/block.h b/block.h index 34dc925..4270f67 100644 --- a/block.h +++ b/block.h @@ -405,25 +405,14 @@ typedef struct BlockConf { uint32_t discard_granularity; } BlockConf; -static inline unsigned int get_physical_block_exp(BlockConf *conf) -{ - unsigned int exp = 0, size; - - for (size = conf->physical_block_size; - size > conf->logical_block_size; - size >>= 1) { - exp++; - } - - return exp; -} +unsigned int get_physical_block_exp(BlockConf *conf); #define DEFINE_BLOCK_PROPERTIES(_state, _conf) \ DEFINE_PROP_DRIVE("drive", _state, _conf.bs), \ DEFINE_PROP_UINT16("logical_block_size", _state, \ _conf.logical_block_size, 512), \ DEFINE_PROP_UINT16("physical_block_size", _state, \ - _conf.physical_block_size, 512), \ + _conf.physical_block_size, 0), \ DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \ DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1), \ -- 1.7.7.6