mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
implement qemu_blockalign (Stefano Stabellini)
this patch adds a buffer_alignment field to BlockDriverState and implements a qemu_blockalign function that uses that field to allocate a memory aligned buffer to be used by the block driver. buffer_alignment is initialized to 512 but each block driver can set a different value (at the moment none of them do). This patch modifies ide.c, block-qcow.c, block-qcow2.c and block.c to use qemu_blockalign instead of qemu_memalign. There is only one place left that still uses qemu_memalign to allocate buffers used by block drivers that is posix-aio-compat:handle_aiocb_rw because it is not possible to get the BlockDriverState from that function. However I think it is not important because posix-aio-compat already deals with driver specific code so it is supposed to know its own needs. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7229 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
94909d9fd9
commit
e268ca5232
6 changed files with 18 additions and 6 deletions
9
block.c
9
block.c
|
@ -362,6 +362,8 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
|
|||
bs->is_temporary = 0;
|
||||
bs->encrypted = 0;
|
||||
bs->valid_key = 0;
|
||||
/* buffer_alignment defaulted to 512, drivers can change this value */
|
||||
bs->buffer_alignment = 512;
|
||||
|
||||
if (flags & BDRV_O_SNAPSHOT) {
|
||||
BlockDriverState *bs1;
|
||||
|
@ -1390,7 +1392,7 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
|
|||
acb = qemu_aio_get(bs, cb, opaque);
|
||||
acb->is_write = is_write;
|
||||
acb->qiov = qiov;
|
||||
acb->bounce = qemu_memalign(512, qiov->size);
|
||||
acb->bounce = qemu_blockalign(bs, qiov->size);
|
||||
|
||||
if (!acb->bh)
|
||||
acb->bh = qemu_bh_new(bdrv_aio_bh_cb, acb);
|
||||
|
@ -1640,3 +1642,8 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
|
|||
return drv->bdrv_aio_ioctl(bs, req, buf, cb, opaque);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *qemu_blockalign(BlockDriverState *bs, size_t size)
|
||||
{
|
||||
return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue