From patchwork Wed Apr 1 15:01:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 1265224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=virtuozzo.com header.i=@virtuozzo.com header.a=rsa-sha256 header.s=selector2 header.b=nrxs55oc; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48sqK41nXrz9sSM for ; Thu, 2 Apr 2020 02:06:16 +1100 (AEDT) Received: from localhost ([::1]:33386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJewY-0003g4-60 for incoming@patchwork.ozlabs.org; Wed, 01 Apr 2020 11:06:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38992) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJes9-0006ca-VN for qemu-devel@nongnu.org; Wed, 01 Apr 2020 11:01:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJes4-0004Em-Pu for qemu-devel@nongnu.org; Wed, 01 Apr 2020 11:01:41 -0400 Received: from mail-eopbgr70115.outbound.protection.outlook.com ([40.107.7.115]:27679 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJes1-0004BA-Kz; Wed, 01 Apr 2020 11:01:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nyiyzipJ6xQdl2Fha6DZ2lPVoLYeP1mO5uU7rUbN+U2Ef6/zKBnH1Wo9cu40yRNl6cvT38w4AukikX7PtiyWkybCBy5jEDjqj91wb/LlAhHAaeP+3A0RxJmHb5pDi03u3vKcwI97auNJyGE8usCE22Ywi6vtEbfJgJfQujvF37Lmnid1W3yrH/NrMFoCg6tpaHdw28c5Po7jOkO8ntmJ02geovz1U1EeUa9GGaJhxcwtReitVh1jvgqPg3cwpOebhQQQc+3Ekm73klT7opB5w6/F2pVDZyUTpzrsf+i/bbAKnh4IzXyWlzFz2MMMXdVlbB0pJnm/ySEqjpOXEJJwUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E4vPecfMUyhEoG30258jqBVf60UprGH5VzrhO5ZBM64=; b=bEdLYBBLcazrJePsCQ+0a37xVtMvOERE35niwALnEfDunOWkIEtmONDaONzG+QKSeJpDgPjqFZRIVpePNcnWzz2TyUD7BrtTwmvq+8B08a6Yx5X/p0ZBh4iGHodQ5VIWahKUPx7t6XsMKzO/SCPnORQNL/1/C0gQS6wJeL3YaWqVdkZKFllvtaxcsbGMLo44SLIF+UV+xUYnDFxNZtZ+u2UNeciK+skRol88HeDgnT7LpQAHCDxM7jhf2Qr+2k3LECp8IFoAbplps5kRQSVDe5jq0ePTdnloI3cugv4knT9WA4Ezs8/wVv7QHseBR8Q6McxqZpXOVh7mljicG5flMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E4vPecfMUyhEoG30258jqBVf60UprGH5VzrhO5ZBM64=; b=nrxs55ocefnhIZccTrfue1sH80aGwuUcPJlIr0VCYBXtmimqD764BA+AJqNqiw9aQPKOeWP5wV+d9Hsfcx1n9xNqgAaT6r50Y9jPtp/wBpSLFlYXaXlyDEbfMVUyqOqr+1+qq0CBbMCAl/SZozZ/43qLCih1G99QcKGYhdN3W70= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=vsementsov@virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (10.141.175.15) by AM7PR08MB5397.eurprd08.prod.outlook.com (10.141.175.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18; Wed, 1 Apr 2020 15:01:30 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::3944:477e:1562:cfcf]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::3944:477e:1562:cfcf%8]) with mapi id 15.20.2878.014; Wed, 1 Apr 2020 15:01:30 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v2 6/6] block/io: auto-no-fallback for write-zeroes Date: Wed, 1 Apr 2020 18:01:12 +0300 Message-ID: <20200401150112.9557-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200401150112.9557-1-vsementsov@virtuozzo.com> References: <20200401150112.9557-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM4P190CA0012.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::22) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.23) by AM4P190CA0012.EURP190.PROD.OUTLOOK.COM (2603:10a6:200:56::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20 via Frontend Transport; Wed, 1 Apr 2020 15:01:30 +0000 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.23] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ffa17d9-234d-44d4-a261-08d7d64d8f94 X-MS-TrafficTypeDiagnostic: AM7PR08MB5397: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:381; X-Forefront-PRVS: 03607C04F0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(4636009)(396003)(366004)(136003)(39840400004)(346002)(376002)(956004)(2616005)(81156014)(6916009)(6666004)(478600001)(5660300002)(86362001)(66946007)(186003)(4326008)(6512007)(16526019)(6486002)(66556008)(6506007)(81166006)(26005)(36756003)(52116002)(66476007)(2906002)(8676002)(8936002)(1076003)(107886003)(316002); DIR:OUT; SFP:1102; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gmUaylRB7TfZOJA+aMStz5/0fFrB7vkLLpPC5uB6ED8t9JJr/qAKpoSfVFKIwY/bve9mTv8fbtufvzCD2fTI1Jfbzo1bCGQjQ4/FB/1hrPaBJy51FHQFUgM9GsxCuy9vDXC7jlnkJ1MWttZWMAoYof5J9EyX7Dmy1cvNB1msD8PC9Yb4YulldGFsNWN3nC6LNbdPTSCY6YpITpOzun3/umWoGJr+o8sefdtuf8qEFZKvihqyfoQ5wuBltVRhoogavPu6YZTusG4XTcVL8Zceu0V98pN7pxr2TAxi/+BleEYdjFWRRIfgFtHCuyb0bovHo4TP7nCA8GhmCn2tnPt52yikrZN4Iwexd6NeRLbyD6gDlv4Q5v4uUj+KynnN+KeRNA1ZASpjVuXVWWSGkaep2Ig2CKT02Ihdp5YteQ1wKCPwlVdC59Bw+uGc5H+4NbeZ X-MS-Exchange-AntiSpam-MessageData: LZ21QJlFsIP9P1g6lrnn4TqZBpIpAOjVp2dD5ZxtStAqpBR6ZNnxUFUNBm0sqCH4GkunwADhJg2/ysKeEOJ51wBT/0DStaCDuSARo50q4QIlcS/O58955H94Rn1+hTsRK2J1Xl4+alOFSvsDSa/vMA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ffa17d9-234d-44d4-a261-08d7d64d8f94 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2020 15:01:30.7545 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 78T60hqTfjadlbM5dxY6uGPxNBmFgrMkKA+6xA5UPbakAoxeo3lmqauHUCNstch1B1SxuDhOZiMMmJ4yp4uC/8xvF7zD0xR5mXS0GxBvvMo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5397 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.7.115 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When BDRV_REQ_NO_FALLBACK is supported, the NBD driver supports a larger request size. Add code to try large zero requests with a NO_FALLBACK request prior to having to split a request into chunks according to max_pwrite_zeroes. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/io.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block/io.c b/block/io.c index f8335e7212..425314a221 100644 --- a/block/io.c +++ b/block/io.c @@ -1755,6 +1755,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int alignment = MAX(bs->bl.pwrite_zeroes_alignment, bs->bl.request_alignment); int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER); + bool auto_no_fallback; assert(alignment % bs->bl.request_alignment == 0); @@ -1762,6 +1763,16 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, return -ENOMEDIUM; } + if (!(flags & BDRV_REQ_NO_FALLBACK) && + (bs->supported_zero_flags & BDRV_REQ_NO_FALLBACK) && + bs->bl.max_pwrite_zeroes && bs->bl.max_pwrite_zeroes < bytes && + bs->bl.max_pwrite_zeroes < bs->bl.max_pwrite_zeroes_fast) + { + assert(drv->bdrv_co_pwrite_zeroes); + flags |= BDRV_REQ_NO_FALLBACK; + auto_no_fallback = true; + } + if ((flags & ~bs->supported_zero_flags) & BDRV_REQ_NO_FALLBACK) { return -ENOTSUP; } @@ -1806,6 +1817,13 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, if (drv->bdrv_co_pwrite_zeroes) { ret = drv->bdrv_co_pwrite_zeroes(bs, offset, num, flags & bs->supported_zero_flags); + if (ret == -ENOTSUP && auto_no_fallback) { + flags &= ~BDRV_REQ_NO_FALLBACK; + max_write_zeroes = + QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pwrite_zeroes, + INT_MAX), alignment); + continue; + } if (ret != -ENOTSUP && (flags & BDRV_REQ_FUA) && !(bs->supported_zero_flags & BDRV_REQ_FUA)) { need_flush = true;