On Mon, Sep 13, 2010 at 08:02:28PM +0100, Stefan Hajnoczi wrote: > On Sun, Sep 12, 2010 at 10:42 PM, Christoph Hellwig <h...@lst.de> wrote: > > Use qemu_blockalign for all allocations in the block layer. ?This allows > > increasing the required alignment, which is need to support O_DIRECT on > > devices with large block sizes. > > > > Signed-off-by: Christoph Hellwig <h...@lst.de> > > I noticed that the backing file may have different alignment > requirements than the image file but qemu_blockalign() currently only > takes into account the image file's requirements. Not necessarily > something for this patch, but since you're in the area I wanted to > mention it. > > It seems safe to take the max alignment (they should both be powers of > two I think) of the image and backing files.
Currently we check the required alignment based on the blocksize we present to the guest, which is set by the driver. That's a bit upside down, but the best we can do. The problem is that the blocksize of the device the image (and it's backing file reside on) are the lower bound of what we can support in the guest without massive read/modify/write cycles. If we use the page cache the kernel does the cycles for us, but for cache=none we would have to do it ourselves in a rather inefficient way.