[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 09/10] block/blklogwrites: Use block limits from
From: |
Ari Sundholm |
Subject: |
[Qemu-block] [PATCH v3 09/10] block/blklogwrites: Use block limits from the backend block configuration |
Date: |
Thu, 7 Jun 2018 18:38:13 +0300 |
This is to ensure that writes are aligned properly for logging writes
to the virtual block device. This is important because the
dm-log-writes log format has a granularity of one sector for both the
offset and the size of each write. By using the logical sector size
for alignment, the log records the writes more faithfully for those
devices that have a non-512 logical sector size.
Note that even with this patch, blklogwrites still uses
BDRV_SECTOR_SIZE for logging. This will change in a subsequent patch
which will introduce support for non-512 sector sizes.
Signed-off-by: Ari Sundholm <address@hidden>
---
block/blklogwrites.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 0e60449..8b09e12 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -168,6 +168,25 @@ static void blk_log_writes_refresh_limits(BlockDriverState
*bs, Error **errp)
}
}
+static void blk_log_writes_apply_blkconf(BlockDriverState *bs, BlockConf *conf)
+{
+ assert(bs && conf && conf->blk);
+
+ bs->bl.request_alignment = conf->logical_block_size;
+ if (conf->discard_granularity != (uint32_t)-1) {
+ bs->bl.pdiscard_alignment = conf->discard_granularity;
+ }
+
+ if (bs->bl.pdiscard_alignment &&
+ bs->bl.pdiscard_alignment < bs->bl.request_alignment) {
+ bs->bl.pdiscard_alignment = bs->bl.request_alignment;
+ }
+ if (bs->bl.pwrite_zeroes_alignment &&
+ bs->bl.pwrite_zeroes_alignment < bs->bl.request_alignment) {
+ bs->bl.pwrite_zeroes_alignment = bs->bl.request_alignment;
+ }
+}
+
static int coroutine_fn
blk_log_writes_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
QEMUIOVector *qiov, int flags)
@@ -364,6 +383,7 @@ static BlockDriver bdrv_blk_log_writes = {
.bdrv_refresh_filename = blk_log_writes_refresh_filename,
.bdrv_child_perm = blk_log_writes_child_perm,
.bdrv_refresh_limits = blk_log_writes_refresh_limits,
+ .bdrv_apply_blkconf = blk_log_writes_apply_blkconf,
.bdrv_co_preadv = blk_log_writes_co_preadv,
.bdrv_co_pwritev = blk_log_writes_co_pwritev,
--
2.7.4
- [Qemu-block] [PATCH v3 00/10] New block driver: blklogwrites, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 06/10] hw/block/virtio-blk: Always apply block configuration to block driver, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 07/10] hw/block/nvme: Always apply block configuration to block driver, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 10/10] block/blklogwrites: Use the block device logical sector size when logging writes, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 01/10] block: Move two block permission constants to the relevant enum, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 08/10] hw/block/fdc: Always apply block configuration to block driver, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 05/10] hw/ide/qdev: Always apply block configuration to block driver, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 09/10] block/blklogwrites: Use block limits from the backend block configuration,
Ari Sundholm <=
- [Qemu-block] [PATCH v3 02/10] block: Add blklogwrites, Ari Sundholm, 2018/06/07
- [Qemu-block] [PATCH v3 03/10] block: Add a mechanism for passing a block driver a block configuration, Ari Sundholm, 2018/06/07
- Re: [Qemu-block] [Qemu-devel] [PATCH v3 00/10] New block driver: blklogwrites, no-reply, 2018/06/07