From patchwork Fri Jul 8 22:36:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9221853 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 86AF06089D for ; Fri, 8 Jul 2016 22:36:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 779A2285E0 for ; Fri, 8 Jul 2016 22:36:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BF4B285E9; Fri, 8 Jul 2016 22:36:55 +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 B3E2A285E0 for ; Fri, 8 Jul 2016 22:36:54 +0000 (UTC) Received: from localhost ([::1]:48065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLeOC-0002kM-Em for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Jul 2016 18:36:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLeNa-0002Y9-Sz for qemu-devel@nongnu.org; Fri, 08 Jul 2016 18:36:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLeNX-0006dX-Rc for qemu-devel@nongnu.org; Fri, 08 Jul 2016 18:36:13 -0400 Received: from resqmta-po-08v.sys.comcast.net ([2001:558:fe16:19:96:114:154:167]:51424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLeNX-0006d9-NX for qemu-devel@nongnu.org; Fri, 08 Jul 2016 18:36:11 -0400 Received: from resomta-po-17v.sys.comcast.net ([96.114.154.241]) by resqmta-po-08v.sys.comcast.net with SMTP id LeNUb4rquB1Y8LeNXbF0YA; Fri, 08 Jul 2016 22:36:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1468017371; bh=tG0kUt2TT0R+55/G3V9Nd0ssKX4x7LvHWqj3qt/XcUw=; h=Received:Received:From:To:Subject:Date:Message-Id; b=pX6AZgHNTh4yMOgXYzSWUwNubnB0a1EMcaGtIz8ESTaptvI1wG6AtPnJU0mejXZIi sZrYKrl2h1fZ+AGJR0UgW0r3tS4ZvW18Wa64RvwAQHfegbM0MnnIF0SITO9KadXxbu XcHzWD3pX2ZWD6PuHRCzrLDNaL0bgjN0z383z1SNori5gMOE6ieim0Qw24C9IbFLM1 RIXTtZ+ZZnNth5hB7w/pL0Tvo9LUvwFSIfi7+Ft72XDQ98ZvLV+McFV4jtKOWiqwsR CobtftInjvFDISjZf7CnD8+NCYHz4UBIHmnwQdj1wwSfqleh8qczj9rJ+nizBzGSZN cz1rJxaA7zRFQ== Received: from red.redhat.com ([24.10.254.122]) by comcast with SMTP id LeNQbet4p7kaYLeNWbedck; Fri, 08 Jul 2016 22:36:11 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 8 Jul 2016 16:36:00 -0600 Message-Id: <1468017364-25980-3-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1468017364-25980-1-git-send-email-eblake@redhat.com> References: <1468017364-25980-1-git-send-email-eblake@redhat.com> X-CMAE-Envelope: MS4wfM5NXNx8+5QbptLXME4SENoyIuJNYa8zM1Lgru6mnVLJWaUUlOaN9H8yjm+tigx9L36ZMWfYiwjHd8E7wk3Lk6sUylslRroTxQ2E9ahOMGZqYrJpGOi5 7wTvgLNYSJMam77lBC+P04I48hSSrW3x/GpI2M5KnRtU82wI25j9Mfb/AhJ+fIocvMkc0CEAL+Dl8v3/1m6dr7MnW0k6YbhWzAR2KNf+cfnw4iHTkPmNIsvU AJMo2VyTdR1X28e3P7gnS1s93rPEwspBaPL/Eb2g0R4DWBnwIp0/uWPZC5E5huvt X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:167 Subject: [Qemu-devel] [PATCH v2 2/6] 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, famz@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. The next patch gives stronger reasoning for why this is correct. At the moment, the raw format layer ignores the max_transfer limit of its protocol layer, and an attempt to do the qemu-io 'w -f 0 40m' to an NBD server that lacks FUA will pass the entire 40m request to the NBD driver, which then fragments the request itself into a 32m write, 8m write, and flush. But once the block layer starts honoring limits and fragmenting packets, the raw driver will hand the NBD driver two separate requests; if both requests have BDRV_REQ_FUA set, then this would result in a 32m write, flush, 8m write, and second flush. By having the raw layer no longer advertise FUA support when the protocol layer lacks it, we are back to a single flush at the block layer for the overall 40m request. 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 the problem is latent and we would again have too many flushes without this patch once the NBD layer implements support for the new NBD_CMD_WRITE_ZEROES command, if it sets max_pwrite_zeroes to the same 32m limit as recommended by the NBD protocol. Signed-off-by: Eric Blake Reviewed-by: Fam Zheng --- v2: no code change, but hoist earlier in series and reword commit --- 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 5f9dd29..d767413 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -192,8 +192,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,