[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/17] block: default physical block size to host bl
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 16/17] block: default physical block size to host block size |
Date: |
Tue, 13 Dec 2011 13:37:19 +0100 |
Hopefully, this will help operating systems and they will make less
misaligned I/O operations. Or on Linux, at least fdisk will tell the
user that they should try and align partitions.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block.c | 17 +++++++++++++++++
block.h | 15 ++-------------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/block.c b/block.c
index 44f5d83..1bfadaf 100644
--- a/block.c
+++ b/block.c
@@ -4041,3 +4041,20 @@ out:
return ret;
}
+
+unsigned int get_physical_block_exp(BlockConf *conf)
+{
+ unsigned int exp = 0, size;
+
+ if (conf->bs && !conf->physical_block_size) {
+ size = conf->bs->host_block_size;
+ } else {
+ size = conf->physical_block_size;
+ }
+
+ for (; size > conf->logical_block_size; size >>= 1) {
+ exp++;
+ }
+
+ return exp;
+}
diff --git a/block.h b/block.h
index e088146..67594d4 100644
--- a/block.h
+++ b/block.h
@@ -401,25 +401,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.1
- [Qemu-devel] [PATCH 03/17] block: pass protocol flags up to the format, (continued)
- [Qemu-devel] [PATCH 03/17] block: pass protocol flags up to the format, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 04/17] block: non-raw protocols never cache, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 06/17] block: move flag bits together, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 07/17] raw: remove the aligned_buf, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 08/17] block: rename buffer_alignment to guest_block_size, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 09/17] block: add host_block_size, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 11/17] iscsi: save host block size, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 12/17] block: allow waiting only for overlapping writes, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 10/17] raw: probe host_block_size, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 16/17] block: default physical block size to host block size,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 14/17] block: protect against "torn reads" for guest_block_size > host_block_size, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 15/17] block: align and serialize I/O when guest_block_size < host_block_size, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 13/17] block: allow waiting at arbitrary granularity, Paolo Bonzini, 2011/12/13
- [Qemu-devel] [PATCH 17/17] qemu-io: add blocksize argument to open, Paolo Bonzini, 2011/12/13
- Re: [Qemu-devel] [PATCH 00/17] Support mismatched host and guest logical block sizes, Kevin Wolf, 2011/12/14