qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ari Sundholm <ari@tuxera.com>
To: qemu-devel@nongnu.org
Cc: Ari Sundholm <ari@tuxera.com>, Kevin Wolf <kwolf@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	"open list:blklogwrites" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH v4 09/10] block/blklogwrites: Use block limits from the backend block configuration
Date: Fri, 8 Jun 2018 15:32:27 +0300	[thread overview]
Message-ID: <1528461148-17925-10-git-send-email-ari@tuxera.com> (raw)
In-Reply-To: <1528461148-17925-1-git-send-email-ari@tuxera.com>

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 <ari@tuxera.com>
---
 block/blklogwrites.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 1b969b0..216367f 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -173,6 +173,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)
@@ -370,6 +389,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

  parent reply	other threads:[~2018-06-08 12:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 12:32 [Qemu-devel] [PATCH v4 00/10] New block driver: blklogwrites Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 01/10] block: Move two block permission constants to the relevant enum Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 02/10] block: Add blklogwrites Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 03/10] block: Add a mechanism for passing a block driver a block configuration Ari Sundholm
2018-06-11 15:06   ` Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 04/10] hw/scsi/scsi-disk: Always apply block configuration to block driver Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 05/10] hw/ide/qdev: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 06/10] hw/block/virtio-blk: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 07/10] hw/block/nvme: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 08/10] hw/block/fdc: " Ari Sundholm
2018-06-08 12:32 ` Ari Sundholm [this message]
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 10/10] block/blklogwrites: Use the block device logical sector size when logging writes Ari Sundholm
2018-06-18 15:36   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-06-18 15:53     ` Ari Sundholm
2018-06-19 11:22       ` Alberto Garcia
2018-06-14 22:23 ` [Qemu-devel] [PATCH v4 00/10] New block driver: blklogwrites Ari Sundholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1528461148-17925-10-git-send-email-ari@tuxera.com \
    --to=ari@tuxera.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).