From patchwork Fri Jun 8 12:32:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ari Sundholm X-Patchwork-Id: 926708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tuxera.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 412MSC2fJ1z9s0W for ; Fri, 8 Jun 2018 22:39:55 +1000 (AEST) Received: from localhost ([::1]:35374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRGgK-0005hw-Su for incoming@patchwork.ozlabs.org; Fri, 08 Jun 2018 08:39:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRGZV-0000m3-TH for qemu-devel@nongnu.org; Fri, 08 Jun 2018 08:32:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRGZS-0005ze-PW for qemu-devel@nongnu.org; Fri, 08 Jun 2018 08:32:49 -0400 Received: from mx2.mpynet.fi ([82.197.21.85]:56616) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fRGZM-0005uL-ED; Fri, 08 Jun 2018 08:32:40 -0400 From: Ari Sundholm To: Date: Fri, 8 Jun 2018 15:32:27 +0300 Message-ID: <1528461148-17925-10-git-send-email-ari@tuxera.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528461148-17925-1-git-send-email-ari@tuxera.com> References: <1528461148-17925-1-git-send-email-ari@tuxera.com> MIME-Version: 1.0 X-ClientProxiedBy: tuxera-exch.ad.tuxera.com (10.20.48.11) To tuxera-exch.ad.tuxera.com (10.20.48.11) Received-SPF: none X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 82.197.21.85 Subject: [Qemu-devel] [PATCH v4 09/10] block/blklogwrites: Use block limits from the backend block configuration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "open list:blklogwrites" , Ari Sundholm , Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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,