From patchwork Mon Jun 20 23:39:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9189049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C40AA6075E for ; Mon, 20 Jun 2016 23:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3D8527CDF for ; Mon, 20 Jun 2016 23:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8A6727E66; Mon, 20 Jun 2016 23:44:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25B1127CDF for ; Mon, 20 Jun 2016 23:44:41 +0000 (UTC) Received: from localhost ([::1]:47108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF8rx-0004NO-0D for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 19:44:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF8nD-0006Sx-Ck for qemu-devel@nongnu.org; Mon, 20 Jun 2016 19:39:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF8n2-0002UN-Lu for qemu-devel@nongnu.org; Mon, 20 Jun 2016 19:39:46 -0400 Received: from resqmta-po-07v.sys.comcast.net ([2001:558:fe16:19:96:114:154:166]:59881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF8n2-0002Ty-H0 for qemu-devel@nongnu.org; Mon, 20 Jun 2016 19:39:36 -0400 Received: from resomta-po-10v.sys.comcast.net ([96.114.154.234]) by resqmta-po-07v.sys.comcast.net with SMTP id F8lHbvZZQa1eGF8n2bRzHO; Mon, 20 Jun 2016 23:39:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1466465976; bh=KHS6iVEzmHOzpZFWNRKwedgKWYKMKz0DZtD363RHH0A=; h=Received:Received:From:To:Subject:Date:Message-Id; b=dLk21gGerNAM4+0uCF9Rsv567O9Utwek6gy3Osd6bgG21NT0n16ILM7ISWPwemifv 2c6D91Wg3EV/YzQMYOZPhVPZJ4+/Gjd/CNjsN4uuwloyrqCbG35FLZKt7PmnWAMsQ7 isycK+OIg7sIlptLGsvTckS+fHC2vaVutPPhqX96ZfNlBucxEhPSGWLo4E7Hn6boR4 BIrxDRVSUXDCuWfxbRWJpejDmUybw02ACLUtZVYyBz7GYkhU7jzFrTKU7g10s7obDm aH110XCs2ak+5S84VD1bSf/vJAAOdaXoWqwKsWkkXrRhGxLMbxRlUR4OriWoG1/QIC fgO3o97v5TQBA== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-10v.sys.comcast.net with comcast id 9BfW1t0022fD5rL01Bfba2; Mon, 20 Jun 2016 23:39:35 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 20 Jun 2016 17:39:27 -0600 Message-Id: <1466465969-25315-4-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466465969-25315-1-git-send-email-eblake@redhat.com> References: <1466465969-25315-1-git-send-email-eblake@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:166 Subject: [Qemu-devel] [PATCH 3/5] raw_bsd: Don't advertise flags not supported by protocol layer 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: kwolf@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The raw format layer supports all flags via passthrough - but it only makes sense to pass through flags that the lower layer actually supports. Thanks to the previous patch, the raw format layer now attempts to fragment writes at the max_transfer limit it inherits from the NBD protocol layer, recently set to 32m. An attempt to do 'w -f 0 40m' to an NBD server that lacks FUA thus changed from flushing once (after NBD fragmented a single 40m write itself) to instead flushing twice (the format layer sees BDRV_REQ_FUA in supported_write_flags, so it sends the flag on to both fragments, and then the block layer emulates FUA by flushing for both the 32m and 8m fragments at the protocol layer). This patch fixes the performance regression (now that the format layer no longer advertises a flag not present at the protocol layer, the flush to emulate FUA is deferred to the last fragment). Note that 'w -f -z 0 40m' does not currently exhibit the same problem, because there, the fragmentation does not occur until at the NBD layer (the raw layer has .bdrv_co_pwrite_zeroes, and the NBD layer doesn't advertise max_pwrite_zeroes to constrain things at the raw layer) - but that problem is latent and would have the same problem with too many flushes without this patch once the NBD layer implements support for using the new NBD_CMD_WRITE_ZEROES and sets max_pwrite_zeroes to the same 32m limit as recommended by the NBD protocol. Signed-off-by: Eric Blake --- block/raw_bsd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/raw_bsd.c b/block/raw_bsd.c index 351ed2a..47a8352 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -197,8 +197,10 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { bs->sg = bs->file->bs->sg; - bs->supported_write_flags = BDRV_REQ_FUA; - bs->supported_zero_flags = BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP; + bs->supported_write_flags = BDRV_REQ_FUA & + bs->file->bs->supported_write_flags; + bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags; if (bs->probed && !bdrv_is_read_only(bs)) { fprintf(stderr,