From patchwork Fri Jan 19 12:50:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10175239 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 B0EEA60392 for ; Fri, 19 Jan 2018 12:59:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A087B28685 for ; Fri, 19 Jan 2018 12:59:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9523428696; Fri, 19 Jan 2018 12:59:07 +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=BAD_ENC_HEADER,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 D188228685 for ; Fri, 19 Jan 2018 12:59:06 +0000 (UTC) Received: from localhost ([::1]:47679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecWGA-0005kj-2T for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 07:59:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecW7x-0006uG-47 for qemu-devel@nongnu.org; Fri, 19 Jan 2018 07:50:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecW7v-0003Au-Qs for qemu-devel@nongnu.org; Fri, 19 Jan 2018 07:50:37 -0500 Received: from mail-db5eur01on070e.outbound.protection.outlook.com ([2a01:111:f400:fe02::70e]:26048 helo=EUR01-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 1ecW7v-0003A7-GH; Fri, 19 Jan 2018 07:50:35 -0500 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; bh=tTpj6RSHEb46TbUuxgUyqBn6eyQqKtS5Mj1dkUQDvzE=; b=b5T/BtQByH+yXnba6uPp7qxCizNSLJ2+eew5fmS0YvWbrsusoydWlIDJumgGsu50AapOZzR/gAVusGpWEBsjqXgR2w0zfVbP/BZt7jp0jBpq8F1bGE5mgxL2iDTW/jV0x+7zuhMw1RJW+1cl5kIOE4Izi8rgcEwheZq/w/prF7E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Fri, 19 Jan 2018 12:50:32 +0000 From: Anton Nefedov To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 15:50:06 +0300 Message-Id: <1516366207-109842-8-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516366207-109842-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1516366207-109842-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR0202CA0008.eurprd02.prod.outlook.com (2603:10a6:4:29::18) To VI1PR0801MB1999.eurprd08.prod.outlook.com (2603:10a6:800:8a::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 502496b1-0710-4c14-b152-08d55f3b3a9f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0801MB1999; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 3:3LVIfvfuK59DKQzvbafIua2vaREYuWK2f2DqDpC499cNa3dIKgYmghU8DmcZlDwuocR46o1hh2RkXxqaavu0owuACvu+F5X7Vd3ziPXEF2xGxJ5IsPXvpJSNqqcmZ4MGp9w22VZSs331LeY1TCXA8uvfUsvreUHEznRY+/ozP58SXwatEDiwIqThIv0ZgNXgb9Uou8KHSu02YWmE5FisnBjW3dQzb692qUEcQr+29Pb4KieBBLkMISG0XrUb0bxQ; 25:vAizoyJrW0ncn2F91LdZv6+YrETXj01ctvBXf37YBpuxpTzI+xXa0wWdmwQim5rWV2xmuuDy5XNwexji4npsq+QIuatFV+xt+wbS+pkIcY+r1t4yxnuzrmiD262k8U9vZ5JX/knZldtgZ3/tlGpzkxir/jR0ytsMbtyMTuDWiYKr6fNebfFAZTo2A+0LwkawP7jzmk6sIsh2oUAPCMEgOGlH2n16LZo6nZ0xXBBrRtDz1KwN1DCAMDq8DZAU82HRnRZOiAt9nc5bXRKTASP5JOwX4WBIhZd7Pkm+JVSn+upbybpSPwRoecpZrOcM+olJ9rZ8yHIuYv50tDZ7Ay+WWQ==; 31:/tk4vhhXH8LqYOIxVNJX38evupem0GgVuk3qFT1wXHehAYS4F0hsLUXeImjK/k1k6Pokq/g4g0pbpG78ew1x94pSH/3oRFGoaIt/mjLczo4oOWVdbV+oRerqF6ksWik38jDJgC7u4XhLlr0UqCa6WCYqTtqZssGqRn9C6L7X8ENhTVdhK+HtyKfQr4G5jvNP1JjGEwcjemJLtHINGd1oi6liFQGTzrHVzvcKrZSHygA= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1999: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1999; 20:9GES22oHz703V12yzHsL7AtTMSD0/f4aaCdJsLgEvycXxsQoxZIrGXXfDzrzAQECLWCBIa1EomNEKLALzmyDPWXqGGDiF9Chc2yAFT3QdMX8mK35fdQskp7MF8uGhCL2eyatrxtlEQEVgHeH3JkjDdDNtGbZ8tUWoWuYzQNWmBEy2Nfcfw6GirhjIm54P8O1p/k8QqYoTa/hNyOj4YGAjwUUVWsZ9uL5ffXTR4ML/o3OFg2z1iZgS9HYFuwZ1hi2PgBsnS01iv9mqeHg48Dm49qQJ3RstCT0xYLQYPQKhbMXfSDzFBQErW9WkNxB6YlqIWPs9t0CxNFBkO7YvWlw60r+cY+2jAIzVa1ld/QBLOEf/1WoVnhG4PQDW5yyYy147GPCwRvosyjcK/5QPOq5eNGbMWJ39ixOMh29W34ADdA=; 4:WLEajSL8UzRy+bN6kRL/Dt5l7ti8DMULV1A+67KKLPOJso1/8lz3n+smzSLbYKNoTE9yIwv6l1kzLBkPzV1WLsJr9EjsPFQyZUW2wxWn1j6/wPnefpN3Vm4cByUpcstvQvu6Inmfrm3ercUJwUe1iiw6sTGX4AevhzCNee/TgoUyg1dYKGxgk4Jg2uhYS1xlorB1XahYPEDGnlIlFIvw7kXXAgPhmRQ9bAX7Npv4x/+aZ0mkqyEs2m+bJOgC7yip6wI2ctxIDOJu/Pf+wOqmtg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231023)(2400077)(944501161)(10201501046)(6041268)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:VI1PR0801MB1999; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR0801MB1999; X-Forefront-PRVS: 0557CBAD84 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(346002)(39850400004)(376002)(396003)(39380400002)(189003)(199004)(16586007)(5660300001)(53936002)(6666003)(6916009)(6512007)(36756003)(2950100002)(53416004)(6116002)(69596002)(105586002)(6486002)(50466002)(48376002)(2361001)(3846002)(52116002)(81166006)(106356001)(2351001)(66066001)(305945005)(47776003)(107886003)(59450400001)(7736002)(15650500001)(81156014)(86362001)(6506007)(478600001)(8676002)(386003)(316002)(2906002)(16526018)(76176011)(4326008)(25786009)(50226002)(68736007)(51416003)(26005)(97736004)(8936002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1999; H:xantnef-ws.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1999; 23:xobwrPYb6DwHlVA9wMEsAmQGIoY08CIyk/bH7G3?= =?us-ascii?Q?N7Ojy41S7/Hnp/iYIcdED8CqlbNSaUPWWwE2WVlkFSz7LdkgcWmFY4xb647y?= =?us-ascii?Q?d71NDcdwwxKN+65c/kbmjdKqlTmJ2UwsPapeRlVOWpZWLkLO+ZRsowig5dtD?= =?us-ascii?Q?e1B1AVR0gu5kKixi4S0J9BdBYIdQREcFp4h3K2ZsAElJl3x1JId2MXsvkGMt?= =?us-ascii?Q?fPQa7emVA2GpOoKh/LuPm8Lgp+aiYLgZrcCj+faSmnP851n46kbIaxpN59XT?= =?us-ascii?Q?/l4LnC3oRbbj698XZAJhEYcUlDH4rcwKf6jnguRn3e/nY0NYjupecXNaAMiC?= =?us-ascii?Q?n7rkdPVc83yDpi+agQ9Zom5Z09WRtntwwF7qUamcED707HnjIJ3c2rS0JrGT?= =?us-ascii?Q?e9P6wAYty8Xyw7SKhBlxNDToZ8Jhdc2U5jCOSJ42UnaUMb8eofjykDFJbVns?= =?us-ascii?Q?Jg9kOhs3rUYKDVtLwRfRdnBOZna/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HaDED5b48RxszWknzXkk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 12:50:32.2327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 502496b1-0710-4c14-b152-08d55f3b3a9f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1999 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe02::70e Subject: [Qemu-devel] [PATCH v2 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 , den@virtuozzo.com, qemu-block@nongnu.org, armbru@redhat.com, mreitz@redhat.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)). Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- block/file-posix.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 36ee89e..544ae58 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -158,6 +158,11 @@ typedef struct BDRVRawState { bool page_cache_inconsistent:1; bool has_fallocate; bool needs_alignment; + struct { + int64_t discard_nb_ok; + int64_t discard_nb_failed; + int64_t discard_bytes_ok; + } stats; PRManager *pr_mgr; } BDRVRawState; @@ -1458,6 +1463,16 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData *aiocb) return ret; } +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 int aio_worker(void *arg) { RawPosixAIOData *aiocb = arg; @@ -1494,6 +1509,7 @@ static int aio_worker(void *arg) break; case QEMU_AIO_DISCARD: ret = handle_aiocb_discard(aiocb); + raw_account_discard(aiocb->bs->opaque, aiocb->aio_nbytes, ret); break; case QEMU_AIO_WRITE_ZEROES: ret = handle_aiocb_write_zeroes(aiocb); @@ -2654,8 +2670,9 @@ static coroutine_fn BlockAIOCB *hdev_aio_pdiscard(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; - - if (fd_open(bs) < 0) { + int ret = fd_open(bs); + if (ret < 0) { + raw_account_discard(s, bytes, ret); return NULL; } return paio_submit(bs, s->fd, offset, NULL, bytes,