From patchwork Tue Aug 21 09:46:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10571317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7314A921 for ; Tue, 21 Aug 2018 09:57:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6128229D44 for ; Tue, 21 Aug 2018 09:57:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 555DF29D4C; Tue, 21 Aug 2018 09:57:03 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 BFFE729D50 for ; Tue, 21 Aug 2018 09:57:02 +0000 (UTC) Received: from localhost ([::1]:52027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3PK-0005Oy-56 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Aug 2018 05:57:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fs3Fc-0003zQ-Ih for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fs3FX-00084J-OJ for qemu-devel@nongnu.org; Tue, 21 Aug 2018 05:47:00 -0400 Received: from mail-eopbgr40111.outbound.protection.outlook.com ([40.107.4.111]:59296 helo=EUR03-DB5-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 1fs3FX-00083k-8j; Tue, 21 Aug 2018 05:46:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R3NFtSriKbaSY3WjKqAnepDtbfCyoeSTwhmxmRAz8To=; b=d58J0OMJjIy94XBYvjpgvKBsB6zdvmDd6eKuTzViV7Mcdwm2dvN6gFHpfoy9nDcopFIkwaorkMYpYjDXRdr1rOogKJ2d0QC9b69YMu/LbZA60SFbXb8a/Ahnb3ITM478Rpy6Rd1bcwRR5INwb7YejA1Au+UEfjerezWz+y+SIok= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (185.231.240.5) by AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.22; Tue, 21 Aug 2018 09:46:52 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 12:46:18 +0300 Message-Id: <1534844779-118784-8-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534844779-118784-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1534844779-118784-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: HE1PR08CA0076.eurprd08.prod.outlook.com (2603:10a6:7:2a::47) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f53f7cf-66a8-442c-78a5-08d6074b0690 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3347; X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 3:gHkLBMB5wKRFkr4QUGWwV845sLEZxxVRc/+ZvrhOic9wiXGHOBdCuiouJ52T9dwWXQjnB3RWtx/pU5R0I3oYygmvpkS+ShrCbEFifrHl8kbOwjYOf8H+RJ9vvBIBMRHVae8RkGHylbVLgbSYIeg1ttXfo1LbJT0EhyFYJBN0G68s8o3QbBc55fbJaxizTxYh6xVFc+hKo8ZB+2YXHFcOTBD2/2V/6YSv6Efe3woSwkJStDeLhWNXENwl6QTu8gr/; 25:eK/JUoxlcVJHuCu8bt9C9d5T3XWLw569Oc1A1PDqxqRDFLG9YvtjYhkr2cQwI6X59GErkFm+6aY9mK76Q25E7H3rFLk/IfP27I7SC/hE6AYKUxJGUdz7nFACuQ6jKfVo31CjdpPl5HWQA9epZsDyrQ/IAPjWRPJCXpmWxDUmh2fVNJrOrJSWf77p5yi7vLI2h1+bpwQjb+VRcekmXHRC2s9JvKhK2qWSSc/pV9M4gpma0cOfoQyj78msezC9I2X3KpsTpmCPhg7kJxcH/OuP2UuCA6kLt7rkKr1kUk8gTrbSCi7Om6bsHPJZeLZIesLWF6wzLF/T4NVGf6f+l37boQ==; 31:JRvBHivRH0gS1CE6YClt0DaFyy3W3D44tqmKJ2q2hVgURMNNLMnsWw2q/8OseO7VsHYYl3est85qn93X0Mgo5ogHo1z1dLvADEEBB47uJo5TLmiHMLMHEmwOKtSPLfrMekf2leg+OHFWtJUTIPWmRJY1x0x0Oktmr3vji9Suf/2jnheZ4nD8u+fw9sAphSQiEH+HRTduzW8L+MxFxo4NFv/o/W44zBKayY/uG99hFbI= X-MS-TrafficTypeDiagnostic: AM0PR08MB3347: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:E5rYDpXHEwdlFhxIS0ph0GeqqUKwrniFY1M0ePZOtLOTv8aORt9qz6iSEc/igX4ToRiB8Yx+sCf2PTaB9+n4ep6MIT/rn8XuLEMQGpDNait5DWvxuKCtdi/9sYUKbaHrHuaBSeCKleKLubGMn4UK9BlXTfD7R+tvcg7qfg01Kltki3yckAdDA12NwHNIVE8I9SQ2/d8XPbChlBFKNJMCLVWHKTHVQIA7oynIcn89fzCzpg2tDuwecc8ofhqMRl5eFAlPS3YHuTu2F/bQglpzgouAZu7qu0W17rP5EgsDINYDS5jsG09G3i3eIUbNGnChjzH2x+a+je+e9pzKXcrbGtnIad8uGiyDDofI3MdcjXGHVhyjH96+r9gi3t4mX//F9OHzorrXqzeKeGFTN75shQVOKaaASBgQ5lPPxcQLmKx3xGPVLouI9qUDmAJWXwb2CjPl13r9SfcX0ZmY+ICJWWQlgbkhcbsBGT7f6OpOPunxqTinRjSmdsw4igsmyxZf; 4:b1nv7PbhktECJWxXoOzBdLVKWN1B2WQi6xW8Kl0qJZoz7ugp01r6gQr0Dc5153oFHyK1khIx92XVxKuF3e1lNByxjPKsp3r3U7DJFC8wCRI4QoVYMn0wm+IL9al1+4+1FK72OmmT9tnf6hlEqE+rxkxbuQl0OYzEGp9IoSakOKqCyjrgAFIxB7XlKCHsWhfkTfvXUu8MpXYEIB0cvdR/ob+meDT/NfA0ABcIqJZa9H69lQfDg9P2xB8fui0DbyO/OtiZ0FRaOjkPg2VvIo/hsA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201708071742011)(7699016); SRVR:AM0PR08MB3347; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3347; X-Forefront-PRVS: 0771670921 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39850400004)(136003)(396003)(376002)(366004)(346002)(199004)(189003)(36756003)(305945005)(53416004)(105586002)(51416003)(48376002)(50226002)(8936002)(6116002)(7736002)(956004)(3846002)(69596002)(50466002)(68736007)(186003)(106356001)(2616005)(16526019)(16586007)(47776003)(486006)(476003)(52116002)(446003)(66066001)(86362001)(14444005)(107886003)(76176011)(2351001)(4326008)(316002)(5660300001)(25786009)(15650500001)(53936002)(478600001)(2361001)(6506007)(386003)(2906002)(6916009)(6486002)(6512007)(81156014)(81166006)(97736004)(6666003)(11346002)(8676002)(26005)(7416002)(44832011); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3347; H:xantnef-ws.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR08MB3347; 23:JPAsjYno6RSahFa3C4NLDxS6Uz4hPp1U2oxfXTIx8?= qttIwQUsytN7TMRuyhcW3bv9S4YCaMGtJqO9cesmGU4tGWkt1Mkx8LYZ/qS3TwG+/0jyYcDXAJ3J35b1wRoCAQgZRKTby1Wr84l/jh+EVoGHCVCDxgZOQrZ+NBUSI96HF+bkEXP35DRYOCQnrIge1zfpJn6EmKDgVJKPjmdEoSGkwP4RsKt/ClLhlMhLKEW7QwHGpX1DC0+eUTXQermXSyqcPVW6gWxZIo1VYEHQLLMaUGLjfZBAiMl6Ls+LzgODf5KVw0k0znMLaQmPBhzqGu/XPOnTgjPAQB8iy9UK3Wd4VZ9lAqMJfSYA2LgvPV1mYia1yBe8CSn4z4BL0Cv0ZShOXWG7SPxXZ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JK/R70WBfpTO/YSxsmtrBF/mloloDPhohAy1ZluEmkqSCbuXXoFdJdxNWHmipLuHmBuD6xJWRlG6+AZp6zNZI/57ShlUo6zFyXtb7nlb27hse475MBLfZeLxw7k/GWLkleoPWU9cqibQFKLtPaXTnpRJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3347; 20:NI9XVSCf5lbnXl4NMk9Ibi97drHBReVpr6d4QqTdoaaYssMDZvvRbasLcfiNyQl7qLXEd76ga+5DU8g13fPrppn1Dq8s/Cethtd2lnLssxL4uSs70+LaS64QDBEbRhynvTO/s/68c55OkkYBuYXNiUAJUjDDMU/Vqxrnzm98elU= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2018 09:46:52.2639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f53f7cf-66a8-442c-78a5-08d6074b0690 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3347 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.4.111 Subject: [Qemu-devel] [PATCH v4 7/8] file-posix: account discard operations 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, Anton Nefedov , famz@redhat.com, den@virtuozzo.com, qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.com, berto@igalia.com, pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This will help to identify how many of the user-issued discard operations (accounted on a device level) have actually suceeded down on the host file (even though the numbers will not be exactly the same if non-raw format driver is used (e.g. qcow2 sending metadata discards)). Note that these numbers will not include discards triggered by write-zeroes + MAY_UNMAP calls. Signed-off-by: Anton Nefedov --- block/file-posix.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index fe83cbf..c420f76 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -163,6 +163,11 @@ typedef struct BDRVRawState { bool has_fallocate; bool needs_alignment; bool check_cache_dropped; + struct { + int64_t discard_nb_ok; + int64_t discard_nb_failed; + int64_t discard_bytes_ok; + } stats; PRManager *pr_mgr; } BDRVRawState; @@ -2575,12 +2580,25 @@ static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs, #endif /* !__linux__ */ } +static void raw_account_discard(BDRVRawState *s, uint64_t nbytes, int ret) +{ + if (ret) { + s->stats.discard_nb_failed++; + } else { + s->stats.discard_nb_ok++; + s->stats.discard_bytes_ok += nbytes; + } +} + static coroutine_fn int raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { BDRVRawState *s = bs->opaque; + int ret; - return paio_submit_co(bs, s->fd, offset, NULL, bytes, QEMU_AIO_DISCARD); + ret = paio_submit_co(bs, s->fd, offset, NULL, bytes, QEMU_AIO_DISCARD); + raw_account_discard(s, bytes, ret); + return ret; } static int coroutine_fn raw_co_pwrite_zeroes( @@ -3077,10 +3095,14 @@ hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) ret = fd_open(bs); if (ret < 0) { + raw_account_discard(s, bytes, ret); return ret; } - return paio_submit_co(bs, s->fd, offset, NULL, bytes, - QEMU_AIO_DISCARD | QEMU_AIO_BLKDEV); + + ret = paio_submit_co(bs, s->fd, offset, NULL, bytes, + QEMU_AIO_DISCARD | QEMU_AIO_BLKDEV); + raw_account_discard(s, bytes, ret); + return ret; } static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs,