Avi Kivity wrote:
Qemu sets the sectors-per-track setting of virtual disks to 63. This
seems to be in accordance with the specs; drivers/ide/ide-disk.c says:
/*
* The ATA spec tells large drives to return
* C/H/S = 16383/16/63 independent of their size.
* Some drives can be jumpered to use 15 heads instead of 16.
* Some drives can be jumpered to use 4092 cyls instead of 16383.
*/
if ((id->cyls == 16383
|| (id->cyls == 4092 && id->cur_cyls == 16383)) &&
id->sectors == 63 &&
(id->heads == 15 || id->heads == 16) &&
(id->lba_capacity >= 16383*63*id->heads))
return 1;
That setting has some unfortunate side effects. Partitioning tools will
locate the first partition at the second cylinder, which is at the 63rd
sector. This means that if the guest uses a 4K block filesystem on the
first partition (an incredibly common occurance), then every single
access will not be 4K aligned with respect to the virtual block device.
This will cause fragmentation and read/modify/write cycles with:
Oh, the tales I could tell of big disk hardware vendors that cache their storage
platforms on 4k aligned blocks and have horrible performance for reads across a
block boundary and only provide drivers for Windows to format LUNs with 4k
alignment.
AFAIK, this is actually a relic limitation of the IBM PC-BIOS hard disk geometry
functions and the MS-DOS partitioning scheme. The BIOS provides only five bits
for sector number in a track and zero is invalid. And, sectors have to claim to
be aligned on a cylinder boundary except for the first partition which is
permitted to begin on the second head of the first cylinder (so sectors/track
reserved sectors and the mis-alignment).
- qcow2 (which uses aligned 4K blocks)
- any host filesystem which uses 4K blocks
- any host disk which uses 4K blocks (not yet common)
I can think of a few workarounds, all bad:
- add a partitioning tool (or option to qemu-img) to format the disk,
placing the first partition on the fourth cylinder, aligning it. tell
the users not to wipe the disks out but instead install to one of the
existing parititions
- add a tool to optimize an existing disk by extending it and moving the
partitions around so they are aligned. may break boot loaders.
- make qcow4 use 512 byte sectors. will increase overhead and doesn't
solve problems on the host filesystem and disk.
- have qcow51 detect misaligned accesses and adjust itself somehow.
doesn't help raw and other formats. likely very difficult.
A solution used on another platform I'm familiar with is for the platform's
storage drivers to report disk geometry as having have 32 sectors per track. The
native partitioning tool will then always create partitions with 32 sector
alignment. It's possible a BIOS change could be made to achieve that.
Does anybody know if scsi will have the same problems? Can anyone
suggest other workarounds?
If you are using a guest platform like linux and don't need multiple file
systems on the same [virtual] disk then just format the whole disk rather than
partition it:
# mkfs -t ext3 /dev/sdb
(instead of /dev/sdb1, 2, 3, etc)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html