[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/16] blkio: Respect memory-alignment for bounce buffer allocatio
From: |
Kevin Wolf |
Subject: |
[PULL 12/16] blkio: Respect memory-alignment for bounce buffer allocations |
Date: |
Wed, 7 Feb 2024 22:56:02 +0100 |
blkio_alloc_mem_region() requires that the requested buffer size is a
multiple of the memory-alignment property. If it isn't, the allocation
fails with a return value of -EINVAL.
Fix the call in blkio_resize_bounce_pool() to make sure the requested
size is properly aligned.
I observed this problem with vhost-vdpa, which requires page aligned
memory. As the virtio-blk device behind it still had 512 byte blocks, we
got bs->bl.request_alignment = 512, but actually any request that needed
a bounce buffer and was not aligned to 4k would fail without this fix.
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20240131173140.42398-1-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/blkio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/blkio.c b/block/blkio.c
index bc2f21784c..882e1c297b 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -89,6 +89,9 @@ static int blkio_resize_bounce_pool(BDRVBlkioState *s,
int64_t bytes)
/* Pad size to reduce frequency of resize calls */
bytes += 128 * 1024;
+ /* Align the pool size to avoid blkio_alloc_mem_region() failure */
+ bytes = QEMU_ALIGN_UP(bytes, s->mem_region_alignment);
+
WITH_QEMU_LOCK_GUARD(&s->blkio_lock) {
int ret;
--
2.43.0
- [PULL 04/16] virtio-blk: declare VirtIOBlock::rq with a type, (continued)
- [PULL 04/16] virtio-blk: declare VirtIOBlock::rq with a type, Kevin Wolf, 2024/02/07
- [PULL 05/16] monitor: use aio_co_reschedule_self(), Kevin Wolf, 2024/02/07
- [PULL 07/16] scsi: Await request purging, Kevin Wolf, 2024/02/07
- [PULL 01/16] virtio-blk: enforce iothread-vq-mapping validation, Kevin Wolf, 2024/02/07
- [PULL 03/16] virtio-blk: add vq_rq[] bounds check in virtio_blk_dma_restart_cb(), Kevin Wolf, 2024/02/07
- [PULL 06/16] block-backend: Allow concurrent context changes, Kevin Wolf, 2024/02/07
- [PULL 08/16] iotests: fix leak of tmpdir in dry-run mode, Kevin Wolf, 2024/02/07
- [PULL 09/16] iotests: give tempdir an identifying name, Kevin Wolf, 2024/02/07
- [PULL 10/16] virtio-blk: do not use C99 mixed declarations, Kevin Wolf, 2024/02/07
- [PULL 11/16] scsi: Don't ignore most usb-storage properties, Kevin Wolf, 2024/02/07
- [PULL 12/16] blkio: Respect memory-alignment for bounce buffer allocations,
Kevin Wolf <=
- [PULL 13/16] virtio-scsi: Attach event vq notifier with no_poll, Kevin Wolf, 2024/02/07
- [PULL 14/16] virtio: Re-enable notifications after drain, Kevin Wolf, 2024/02/07
- [PULL 15/16] virtio-blk: Use ioeventfd_attach in start_ioeventfd, Kevin Wolf, 2024/02/07
- [PULL 16/16] virtio-blk: avoid using ioeventfd state in irqfd conditional, Kevin Wolf, 2024/02/07
- Re: [PULL 00/16] Block layer patches, Peter Maydell, 2024/02/09