From patchwork Wed Oct 31 11:34:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="flIN05AQ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lR9P3jxWz9s1c for ; Wed, 31 Oct 2018 22:35:52 +1100 (AEDT) Received: from localhost ([::1]:58715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHomr-0003J8-BS for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:35:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHolv-0003Iv-UH for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:34:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHolr-0001Cc-Qp for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:34:51 -0400 Received: from mail-he1eur01on0118.outbound.protection.outlook.com ([104.47.0.118]:30018 helo=EUR01-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 1gHolr-000175-BX; Wed, 31 Oct 2018 07:34:47 -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=WIkyoWAphUc6o5T3hRkkD2kaNKM0hSf4EKEVI1YAsDo=; b=flIN05AQqyQu5Erpl8yOXlrFo0ScuUbpC+Hl2ekUINCycOz5gJpK/XfWeWreHmtYhVWgUXVRBKcgCdIX7hsWHfksuAkoWambkcpu4QNOGY/n90iQAAyH0YuL3Cj/jfBwVZXsswHfQWO0CROqt9rOPTO9oJiMhuY4H0klJOiIX7w= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3534.eurprd08.prod.outlook.com (20.177.61.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Wed, 31 Oct 2018 11:34:41 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:41 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 1/9] qapi: group BlockDeviceStats fields Thread-Index: AQHUcQ21HveOr6T1qU2gepSfXBNsvw== Date: Wed, 31 Oct 2018 11:34:40 +0000 Message-ID: <20181031113418.29796-2-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3534; 20:+1tgrhanEGpMVgZ+EX6rKmwaCBl9/o+21P1UjSuhKb9J7eBeSQrz2ilR8xNjykDePHPDL94cBlVukbWNzOb4XZKwM0fizgJ8ew/QVtZPe6EXcV2D4JU9qpF47epTtTNCInwU7YPZ0OdLEzIuBk589Q3OAw5GcS65upmXM9sBxv4= x-ms-office365-filtering-correlation-id: f2367021-86d7-4b96-fba2-08d63f24d823 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3534; x-ms-traffictypediagnostic: VI1PR08MB3534: 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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3534; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3534; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(396003)(39850400004)(136003)(199004)(189003)(3846002)(99286004)(386003)(52116002)(107886003)(6436002)(6486002)(14444005)(4326008)(186003)(26005)(6506007)(54906003)(2906002)(102836004)(2501003)(5250100002)(14454004)(478600001)(316002)(1076002)(76176011)(256004)(6116002)(7416002)(97736004)(86362001)(25786009)(11346002)(5660300001)(2616005)(36756003)(66066001)(8936002)(81166006)(476003)(44832011)(8676002)(68736007)(6916009)(5640700003)(7736002)(6512007)(305945005)(71200400001)(446003)(71190400001)(2900100001)(2351001)(53936002)(105586002)(106356001)(81156014)(486006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3534; H:VI1PR08MB3358.eurprd08.prod.outlook.com; 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-antispam-message-info: JjB9xQiAXTR0PbKmd6PUyLVhyZSdHlEkPjmm9yNSQQti/OdlihVmK9+yARameC+2Zwk6h51VDnaJ5T48j1msrjRzUQh7TbWDPHARMmDIdE/YdDxnwVtUc0yWvcjUpAdDFnnzVmnfa/HyM8oWoOqPyt4E7+BGXeJRLczPrqpo8a/FH76WqsBalMQqt9r7zkYAecZdnGhTJA1OKhwOU00ATi9bz4P4NdeU+OKcDDNjBozd762lPqPP82qrqH9QvvOAX2gg3+PdoY87flEScri1ikmvAoAXuY+XgOmneaEl8YRfeD6Er7eByHscMZdDm7aj+6byUrNBwKmMQ1O2h/2muRYtJ2OKtsGrUatLMXNe9Os= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2367021-86d7-4b96-fba2-08d63f24d823 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:40.3007 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3534 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.118 Subject: [Qemu-devel] [PATCH v5 1/9] qapi: group BlockDeviceStats fields 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Make the stat fields definition slightly more readable. Also reorder total_time_ns stats read-write-flush as done elsewhere. Cosmetic change only. Signed-off-by: Anton Nefedov Reviewed-by: Alberto Garcia Reviewed-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 0fc1590c1b..2903b8dfc9 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -784,12 +784,12 @@ # @flush_operations: The number of cache flush operations performed by the # device (since 0.15.0) # -# @flush_total_time_ns: Total time spend on cache flushes in nano-seconds -# (since 0.15.0). +# @rd_total_time_ns: Total time spent on reads in nanoseconds (since 0.15.0). # -# @wr_total_time_ns: Total time spend on writes in nano-seconds (since 0.15.0). +# @wr_total_time_ns: Total time spent on writes in nanoseconds (since 0.15.0). # -# @rd_total_time_ns: Total_time_spend on reads in nano-seconds (since 0.15.0). +# @flush_total_time_ns: Total time spent on cache flushes in nanoseconds +# (since 0.15.0). # # @wr_highest_offset: The offset after the greatest byte written to the # device. The intended use of this information is for @@ -842,14 +842,18 @@ # Since: 0.14.0 ## { 'struct': 'BlockDeviceStats', - 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int', - 'wr_operations': 'int', 'flush_operations': 'int', - 'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int', - 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int', - 'rd_merged': 'int', 'wr_merged': 'int', '*idle_time_ns': 'int', + 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', + 'rd_operations': 'int', 'wr_operations': 'int', + 'flush_operations': 'int', + 'rd_total_time_ns': 'int', 'wr_total_time_ns': 'int', + 'flush_total_time_ns': 'int', + 'wr_highest_offset': 'int', + 'rd_merged': 'int', 'wr_merged': 'int', + '*idle_time_ns': 'int', 'failed_rd_operations': 'int', 'failed_wr_operations': 'int', - 'failed_flush_operations': 'int', 'invalid_rd_operations': 'int', - 'invalid_wr_operations': 'int', 'invalid_flush_operations': 'int', + 'failed_flush_operations': 'int', + 'invalid_rd_operations': 'int', 'invalid_wr_operations': 'int', + 'invalid_flush_operations': 'int', 'account_invalid': 'bool', 'account_failed': 'bool', 'timed_stats': ['BlockDeviceTimedStats'], '*x_rd_latency_histogram': 'BlockLatencyHistogramInfo', From patchwork Wed Oct 31 11:34:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="IO4K8uN0"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lR9Z23scz9s1c for ; Wed, 31 Oct 2018 22:36:02 +1100 (AEDT) Received: from localhost ([::1]:58719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHon1-0003Mn-SC for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHoly-0003J7-Gq for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHols-0001DP-Hx for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:34:54 -0400 Received: from mail-he1eur01on0118.outbound.protection.outlook.com ([104.47.0.118]:30018 helo=EUR01-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 1gHols-000175-8P; Wed, 31 Oct 2018 07:34:48 -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=+UglgYy7+NzPZPlREAJqG/KUfikw6XlsCCPF6JwuU2U=; b=IO4K8uN0jHSPInGbarLbs/VJfFIRCC+RHPQXY5iG68BkSQ/REZ/bKLAK918ETlFwAnHoGMa3C6rkpLAV+iMmRXdQufRbU8dE0pkDBv2jk5HzNZHg2QnuOOUxJEe/FXbw4MyzGG2S7DJ73YiPxLmtMxKOLUZOf5aWXhq0/0+dZvc= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3534.eurprd08.prod.outlook.com (20.177.61.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Wed, 31 Oct 2018 11:34:43 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:43 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 2/9] qapi: add unmap to BlockDeviceStats Thread-Index: AQHUcQ23RPZEbk6IxU2ltH12uejn4Q== Date: Wed, 31 Oct 2018 11:34:43 +0000 Message-ID: <20181031113418.29796-3-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3534; 20:tNN3KXe1LU3G7C+/rlTkv0YbZ5xdKBcQKKj8pdQQsFqZk1eTc+jUTq++mQwHuNskVk3FaFfCdX49Dg9TyQfBd6Jl/vLz2SbpiY+fzEt1lHUKO3ZTmSZ+ZLk7NcMfZ3BW1x4iVcX+ROQMyH6Lsv9Tx6FLbMrHklIS/nZrccCTIEE= x-ms-office365-filtering-correlation-id: 74885b6a-1e37-491f-a062-08d63f24d9cc x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3534; x-ms-traffictypediagnostic: VI1PR08MB3534: 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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3534; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3534; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(396003)(39850400004)(136003)(199004)(189003)(3846002)(99286004)(386003)(52116002)(107886003)(6436002)(6486002)(14444005)(4326008)(186003)(26005)(6506007)(54906003)(2906002)(102836004)(2501003)(5250100002)(14454004)(478600001)(316002)(1076002)(76176011)(256004)(6116002)(7416002)(97736004)(86362001)(25786009)(11346002)(5660300001)(2616005)(36756003)(66066001)(8936002)(81166006)(476003)(44832011)(8676002)(68736007)(6916009)(5640700003)(7736002)(6512007)(305945005)(71200400001)(446003)(71190400001)(2900100001)(2351001)(53936002)(105586002)(106356001)(81156014)(486006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3534; H:VI1PR08MB3358.eurprd08.prod.outlook.com; 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-antispam-message-info: YXATfWIWK02zLMFtJw4XA9EEoAaWpSJrPrmEMg26DRTbE8tX0Z9XW+uGO9nSDDXrv9QezD2CPvQo5lTuqtfgmUhfEPAxRXPLmFQ/jj/BieVytUS1rZ0Bz9QdkNtdy/qWoMjeRXRvmwf/U5JKX05UGeXNLA2wlAFOUuiTCMzNXiKsK+UP+n+xp/EgQ9vKPFTHi3Dsb3SpeEv9v9BXK0FdBjPr28y7QV+sOudGRUaDNAPviPhG65ElrK2g88m7F/KuwZ/8009hefItux1W7PkmPQQ4bgiBbr8V9gnM9s5Zfx2iXVMkiDwxGXUfEH7f8tStl3+vn95ZmmIoxILUFGD4tcbCU4LI1OgbLRbR7pEmmHs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74885b6a-1e37-491f-a062-08d63f24d9cc X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:43.2638 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3534 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.118 Subject: [Qemu-devel] [PATCH v5 2/9] qapi: add unmap to BlockDeviceStats 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Reviewed-by: Eric Blake --- qapi/block-core.json | 29 +++++++++++++++++++++++------ include/block/accounting.h | 1 + block/qapi.c | 6 ++++++ tests/qemu-iotests/227.out | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 2903b8dfc9..01da84cb61 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -777,6 +777,8 @@ # # @wr_bytes: The number of bytes written by the device. # +# @unmap_bytes: The number of bytes unmapped by the device (Since 3.1) +# # @rd_operations: The number of read operations performed by the device. # # @wr_operations: The number of write operations performed by the device. @@ -784,6 +786,9 @@ # @flush_operations: The number of cache flush operations performed by the # device (since 0.15.0) # +# @unmap_operations: The number of unmap operations performed by the device +# (Since 3.1) +# # @rd_total_time_ns: Total time spent on reads in nanoseconds (since 0.15.0). # # @wr_total_time_ns: Total time spent on writes in nanoseconds (since 0.15.0). @@ -791,6 +796,9 @@ # @flush_total_time_ns: Total time spent on cache flushes in nanoseconds # (since 0.15.0). # +# @unmap_total_time_ns: Total time spent on unmap operations in nanoseconds +# (Since 3.1) +# # @wr_highest_offset: The offset after the greatest byte written to the # device. The intended use of this information is for # growable sparse files (like qcow2) that are used on top @@ -802,6 +810,9 @@ # @wr_merged: Number of write requests that have been merged into another # request (Since 2.3). # +# @unmap_merged: Number of unmap requests that have been merged into another +# request (Since 3.1) +# # @idle_time_ns: Time since the last I/O operation, in # nanoseconds. If the field is absent it means that # there haven't been any operations yet (Since 2.5). @@ -815,6 +826,9 @@ # @failed_flush_operations: The number of failed flush operations # performed by the device (Since 2.5) # +# @failed_unmap_operations: The number of failed unmap operations performed +# by the device (Since 3.1) +# # @invalid_rd_operations: The number of invalid read operations # performed by the device (Since 2.5) # @@ -824,6 +838,9 @@ # @invalid_flush_operations: The number of invalid flush operations # performed by the device (Since 2.5) # +# @invalid_unmap_operations: The number of invalid unmap operations performed +# by the device (Since 3.1) +# # @account_invalid: Whether invalid operations are included in the # last access statistics (Since 2.5) # @@ -842,18 +859,18 @@ # Since: 0.14.0 ## { 'struct': 'BlockDeviceStats', - 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', + 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'unmap_bytes' : 'int', 'rd_operations': 'int', 'wr_operations': 'int', - 'flush_operations': 'int', + 'flush_operations': 'int', 'unmap_operations': 'int', 'rd_total_time_ns': 'int', 'wr_total_time_ns': 'int', - 'flush_total_time_ns': 'int', + 'flush_total_time_ns': 'int', 'unmap_total_time_ns': 'int', 'wr_highest_offset': 'int', - 'rd_merged': 'int', 'wr_merged': 'int', + 'rd_merged': 'int', 'wr_merged': 'int', 'unmap_merged': 'int', '*idle_time_ns': 'int', 'failed_rd_operations': 'int', 'failed_wr_operations': 'int', - 'failed_flush_operations': 'int', + 'failed_flush_operations': 'int', 'failed_unmap_operations': 'int', 'invalid_rd_operations': 'int', 'invalid_wr_operations': 'int', - 'invalid_flush_operations': 'int', + 'invalid_flush_operations': 'int', 'invalid_unmap_operations': 'int', 'account_invalid': 'bool', 'account_failed': 'bool', 'timed_stats': ['BlockDeviceTimedStats'], '*x_rd_latency_histogram': 'BlockLatencyHistogramInfo', diff --git a/include/block/accounting.h b/include/block/accounting.h index d1f67b10dd..ba8b04d572 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -36,6 +36,7 @@ enum BlockAcctType { BLOCK_ACCT_READ, BLOCK_ACCT_WRITE, BLOCK_ACCT_FLUSH, + BLOCK_ACCT_UNMAP, BLOCK_MAX_IOTYPE, }; diff --git a/block/qapi.c b/block/qapi.c index c66f949db8..df31f351d2 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -432,24 +432,30 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) ds->rd_bytes = stats->nr_bytes[BLOCK_ACCT_READ]; ds->wr_bytes = stats->nr_bytes[BLOCK_ACCT_WRITE]; + ds->unmap_bytes = stats->nr_bytes[BLOCK_ACCT_UNMAP]; ds->rd_operations = stats->nr_ops[BLOCK_ACCT_READ]; ds->wr_operations = stats->nr_ops[BLOCK_ACCT_WRITE]; + ds->unmap_operations = stats->nr_ops[BLOCK_ACCT_UNMAP]; ds->failed_rd_operations = stats->failed_ops[BLOCK_ACCT_READ]; ds->failed_wr_operations = stats->failed_ops[BLOCK_ACCT_WRITE]; ds->failed_flush_operations = stats->failed_ops[BLOCK_ACCT_FLUSH]; + ds->failed_unmap_operations = stats->failed_ops[BLOCK_ACCT_UNMAP]; ds->invalid_rd_operations = stats->invalid_ops[BLOCK_ACCT_READ]; ds->invalid_wr_operations = stats->invalid_ops[BLOCK_ACCT_WRITE]; ds->invalid_flush_operations = stats->invalid_ops[BLOCK_ACCT_FLUSH]; + ds->invalid_unmap_operations = stats->invalid_ops[BLOCK_ACCT_UNMAP]; ds->rd_merged = stats->merged[BLOCK_ACCT_READ]; ds->wr_merged = stats->merged[BLOCK_ACCT_WRITE]; + ds->unmap_merged = stats->merged[BLOCK_ACCT_UNMAP]; ds->flush_operations = stats->nr_ops[BLOCK_ACCT_FLUSH]; ds->wr_total_time_ns = stats->total_time_ns[BLOCK_ACCT_WRITE]; ds->rd_total_time_ns = stats->total_time_ns[BLOCK_ACCT_READ]; ds->flush_total_time_ns = stats->total_time_ns[BLOCK_ACCT_FLUSH]; + ds->unmap_total_time_ns = stats->total_time_ns[BLOCK_ACCT_UNMAP]; ds->has_idle_time_ns = stats->last_access_time_ns > 0; if (ds->has_idle_time_ns) { diff --git a/tests/qemu-iotests/227.out b/tests/qemu-iotests/227.out index 736f2e3b11..62a9dbaffa 100644 --- a/tests/qemu-iotests/227.out +++ b/tests/qemu-iotests/227.out @@ -15,6 +15,8 @@ Testing: -drive driver=null-co,if=virtio { "device": "virtio0", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -24,13 +26,17 @@ Testing: -drive driver=null-co,if=virtio "wr_bytes": 0, "timed_stats": [ ], + "failed_unmap_operations": 0, "failed_flush_operations": 0, "account_invalid": true, "rd_total_time_ns": 0, + "invalid_unmap_operations": 0, "flush_operations": 0, "wr_operations": 0, + "unmap_bytes": 0, "rd_merged": 0, "rd_bytes": 0, + "unmap_total_time_ns": 0, "invalid_flush_operations": 0, "account_failed": true, "rd_operations": 0, @@ -73,6 +79,8 @@ Testing: -drive driver=null-co,if=none { "device": "none0", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -82,13 +90,17 @@ Testing: -drive driver=null-co,if=none "wr_bytes": 0, "timed_stats": [ ], + "failed_unmap_operations": 0, "failed_flush_operations": 0, "account_invalid": true, "rd_total_time_ns": 0, + "invalid_unmap_operations": 0, "flush_operations": 0, "wr_operations": 0, + "unmap_bytes": 0, "rd_merged": 0, "rd_bytes": 0, + "unmap_total_time_ns": 0, "invalid_flush_operations": 0, "account_failed": true, "rd_operations": 0, @@ -160,6 +172,8 @@ Testing: -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,i { "device": "", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -169,13 +183,17 @@ Testing: -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,i "wr_bytes": 0, "timed_stats": [ ], + "failed_unmap_operations": 0, "failed_flush_operations": 0, "account_invalid": false, "rd_total_time_ns": 0, + "invalid_unmap_operations": 0, "flush_operations": 0, "wr_operations": 0, + "unmap_bytes": 0, "rd_merged": 0, "rd_bytes": 0, + "unmap_total_time_ns": 0, "invalid_flush_operations": 0, "account_failed": false, "rd_operations": 0, From patchwork Wed Oct 31 11:34:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="RtMCTtXi"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRF246PHz9s7T for ; Wed, 31 Oct 2018 22:39:01 +1100 (AEDT) Received: from localhost ([::1]:58733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHopv-0007Fj-Hp for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:38:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHom2-0003Lm-Dl for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHolw-0001HZ-9K for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:34:56 -0400 Received: from mail-he1eur01on0135.outbound.protection.outlook.com ([104.47.0.135]:32158 helo=EUR01-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 1gHolv-0001F2-Pz; Wed, 31 Oct 2018 07:34:52 -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=2+vFrm6AXUDrCekGtpAUWHx9rIQjjDaEjqAAd+aUYsI=; b=RtMCTtXiP5TU7oitrtuqtuMIpUjHTgurUB3czAutsZdlkHNxOl3NfTIe6+guQ+zewVPlGjXrMvZUpqYxLoRMTI//6btTqgPlaX9oZZ/Ki1ojpx+M7CStNRaNCBBlI2Ti4vSDXlUvfOZ8zkQ/RJ/Wm6stpjPJRwOsk4LEAKoFF24= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3534.eurprd08.prod.outlook.com (20.177.61.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.21; Wed, 31 Oct 2018 11:34:48 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:48 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 3/9] block: add empty account cookie type Thread-Index: AQHUcQ26Cth7yg1IKE6Sub97fEUTsQ== Date: Wed, 31 Oct 2018 11:34:48 +0000 Message-ID: <20181031113418.29796-4-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3534; 20:UTE/m6yT0IVfer0GHPr3tjYWYFrB91ebXQaBkJno4SE+0luUu+Cj4tMZP/Ah6/P897j3q2nyCTS/jXVBYN/rG7uDwzXbFWzLxxDGsqlntlmyGikgJ4gpEecmqlMNJQy8aeHT+/U9kVNXkEQHsgzz4Hu2Zv5PdJ9vmEwCukeC9RQ= x-ms-office365-filtering-correlation-id: 52100fc9-ab01-431f-80f3-08d63f24db93 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3534; x-ms-traffictypediagnostic: VI1PR08MB3534: 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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3534; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3534; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(366004)(396003)(39850400004)(136003)(199004)(189003)(3846002)(99286004)(386003)(52116002)(107886003)(6436002)(6486002)(14444005)(4326008)(186003)(26005)(6506007)(54906003)(2906002)(102836004)(15650500001)(2501003)(5250100002)(14454004)(478600001)(316002)(1076002)(76176011)(256004)(6116002)(7416002)(97736004)(86362001)(25786009)(11346002)(5660300001)(2616005)(36756003)(66066001)(8936002)(81166006)(476003)(44832011)(8676002)(68736007)(6916009)(5640700003)(7736002)(6512007)(305945005)(71200400001)(446003)(71190400001)(2900100001)(2351001)(53936002)(105586002)(106356001)(81156014)(486006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3534; H:VI1PR08MB3358.eurprd08.prod.outlook.com; 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-antispam-message-info: dj//pML/suAil76CJGtEEt7cefm9HLaYIPsrxmfv6Wjc2Sh+xbhNqu3z6w8PIB3c5dhtDDFpP/mxzFzMk9sNshTu0jILbVAOtB1i6V7ne2AbauMJ429AuurzCkYH4AxDpPUDs6c68aymr9EdJ2+r+6t6+VhOUF0CNbiRQraLwtIoxyibNWxg1elvv8Iigsnr7GgHJgpxY8gbSh1H1Fhnf0cmkHaUn+rZM4Hf0UIRkxAbagIfo7IXE+YwQQl47fKJH8/Cl2YSGaWs8Iyrbfs2fGX+a7kGDRjv9o1VeEs8IgWIqrUsZLTPs2/ZllqPMBTheulgpXZibO3Y4m08rs8KCAGF5jyZ38FADuxUTL0aa7Q= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52100fc9-ab01-431f-80f3-08d63f24db93 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:48.0991 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3534 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.135 Subject: [Qemu-devel] [PATCH v5 3/9] block: add empty account cookie type 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This adds some protection from accounting unitialized cookie. That is, block_acct_failed/done without previous block_acct_start; in that case, cookie probably holds values from previous operation. (Note: it might also be unitialized holding garbage value and there is still "< BLOCK_MAX_IOTYPE" assertion for that. So block_acct_failed/done without previous block_acct_start should be used with caution.) Currently this is particularly useful in ide code where it's hard to keep track whether the request started accounting or not. For example, trim requests do the accounting separately. Signed-off-by: Anton Nefedov --- include/block/accounting.h | 1 + block/accounting.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/block/accounting.h b/include/block/accounting.h index ba8b04d572..878b4c3581 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -33,6 +33,7 @@ typedef struct BlockAcctTimedStats BlockAcctTimedStats; typedef struct BlockAcctStats BlockAcctStats; enum BlockAcctType { + BLOCK_ACCT_NONE = 0, BLOCK_ACCT_READ, BLOCK_ACCT_WRITE, BLOCK_ACCT_FLUSH, diff --git a/block/accounting.c b/block/accounting.c index 70a3d9a426..8d41c8a83a 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -195,6 +195,10 @@ static void block_account_one_io(BlockAcctStats *stats, BlockAcctCookie *cookie, assert(cookie->type < BLOCK_MAX_IOTYPE); + if (cookie->type == BLOCK_ACCT_NONE) { + return; + } + qemu_mutex_lock(&stats->lock); if (failed) { @@ -217,6 +221,8 @@ static void block_account_one_io(BlockAcctStats *stats, BlockAcctCookie *cookie, } qemu_mutex_unlock(&stats->lock); + + cookie->type = BLOCK_ACCT_NONE; } void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie) From patchwork Wed Oct 31 11:34:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="OcrK2lbe"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lR9r1L4Zz9s1c for ; Wed, 31 Oct 2018 22:36:16 +1100 (AEDT) Received: from localhost ([::1]:58726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHonF-0003eI-Ng for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:36:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHom8-0003O7-4w for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHom1-0001NI-US for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:02 -0400 Received: from mail-eopbgr50092.outbound.protection.outlook.com ([40.107.5.92]:6064 helo=EUR03-VE1-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 1gHoly-0001Ii-Rr; Wed, 31 Oct 2018 07:34:56 -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=dICbEeWDsk31VCBqXVisZH/NqMpUK6TohVwpyS0asfE=; b=OcrK2lbezwyTWag9mexULy5zk2AkkN+LAndSgi1H4I6PZkSvZpj8I5rnnAnGvKIaD+Y9bnODUXWj600JCmUjPkx93LnP5Ud8tGbPEvVOd6l3+IYfwUT4kjPDn/5OXFZJZSW7SIckp32PGY7LznhTq5dIAMTk0j0n4XMyL5lHmxw= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB0413.eurprd08.prod.outlook.com (10.162.12.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.25; Wed, 31 Oct 2018 11:34:51 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:51 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 4/9] ide: account UNMAP (TRIM) operations Thread-Index: AQHUcQ285RQ5iSyWxEibDj36IYeRAA== Date: Wed, 31 Oct 2018 11:34:51 +0000 Message-ID: <20181031113418.29796-5-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB0413; 20:HEIfGp4+H794b6Onicq+q3Hyq4lmT9P5NyGE329j0iUyDh4E0Mfc5ezrvyXrRPBt0ogX0lVl3+53HBS3/lsWnkYHF6YuiJ9jK90pNIWB35Tx51jHTPKF98XNgpMlgpUcMVHNr05cO+8MH+pev1GR/gs/T0tmoZNDbD8uFRvWk1A= x-ms-office365-filtering-correlation-id: b34d9943-115c-4cd3-38df-08d63f24defd x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB0413; x-ms-traffictypediagnostic: VI1PR08MB0413: 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)(5005006)(8121501046)(93006095)(93001095)(3231382)(944501410)(52105095)(3002001)(10201501046)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB0413; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0413; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(346002)(39850400004)(366004)(396003)(189003)(199004)(6486002)(68736007)(76176011)(66066001)(5640700003)(2900100001)(6512007)(6436002)(2616005)(476003)(2501003)(53936002)(44832011)(11346002)(5250100002)(486006)(52116002)(97736004)(5660300001)(478600001)(14454004)(6916009)(6506007)(386003)(107886003)(71200400001)(71190400001)(25786009)(4326008)(1076002)(2906002)(186003)(86362001)(7416002)(316002)(446003)(3846002)(26005)(102836004)(2351001)(305945005)(7736002)(105586002)(106356001)(99286004)(36756003)(6116002)(54906003)(8676002)(256004)(8936002)(81156014)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0413; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: fUWtKGcccdRtiAu6E5QdmF3N0GDsLcklzXmPh/v4aXgMmOThYkmmzbitIl4ERbezK59/IGvEKc2TzOtKsUYK4mCl2HYO/0rCW8kPonXa7zq4nHqosvmbwyytFTt6NIrWFdhMsX8tRhWKKUFR2z02IzTHVq0AT6oK33RwulgUVYPOXcWp35zMkxevAhVTqR5FkD8o59aFYV4KL1ENute1ZiCC3nXTBBt70kKpTiUIDe095KcHhigxelSfL9mjDbb+pUhBhygNsvTHrfbppmiE93pNC3qKjWOgYJllCj34PTlOyFMtRWCoXu3DjG2Xg8a9hHnczW6DzIpWWYSRizaASIftwhvb2NPCtCBTqCxEOc4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b34d9943-115c-4cd3-38df-08d63f24defd X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:51.6977 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0413 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.5.92 Subject: [Qemu-devel] [PATCH v5 4/9] ide: account UNMAP (TRIM) 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/ide/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ide/core.c b/hw/ide/core.c index 04e22e751d..8da77ff3e3 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -441,6 +441,14 @@ static void ide_issue_trim_cb(void *opaque, int ret) TrimAIOCB *iocb = opaque; IDEState *s = iocb->s; + if (iocb->i >= 0) { + if (ret >= 0) { + block_acct_done(blk_get_stats(s->blk), &s->acct); + } else { + block_acct_failed(blk_get_stats(s->blk), &s->acct); + } + } + if (ret >= 0) { while (iocb->j < iocb->qiov->niov) { int j = iocb->j; @@ -458,10 +466,14 @@ static void ide_issue_trim_cb(void *opaque, int ret) } if (!ide_sect_range_ok(s, sector, count)) { + block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_UNMAP); iocb->ret = -EINVAL; goto done; } + block_acct_start(blk_get_stats(s->blk), &s->acct, + count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP); + /* Got an entry! Submit and exit. */ iocb->aiocb = blk_aio_pdiscard(s->blk, sector << BDRV_SECTOR_BITS, From patchwork Wed Oct 31 11:34:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="IZg0pohj"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRJq0ZnDz9s1c for ; Wed, 31 Oct 2018 22:42:19 +1100 (AEDT) Received: from localhost ([::1]:58760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHot6-0001P6-JP for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:42:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHomB-0003QW-Sx for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHom6-0001bW-Qm for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:05 -0400 Received: from mail-eopbgr50092.outbound.protection.outlook.com ([40.107.5.92]:6064 helo=EUR03-VE1-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 1gHom2-0001Ii-T7; Wed, 31 Oct 2018 07:35:01 -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=T7d00VIXJCHusrNm7FzSX6sTHWt2zZbowtGMz0IasEM=; b=IZg0pohj00MRfAPS31pGEHhZzq6aGCyw7cqNx2116TuxVxfxIY7+2etcOKdO+sjryKK2tkLPqKQl/kb72qcEMXi20dWOrE6TRQVvW7pXRfS/JjdhGIDwgOsp74aXvG6GPhMnuhcTaxOd8A+L8OWNSzNrx+VFNEr6A149f6Xvj70= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB0413.eurprd08.prod.outlook.com (10.162.12.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.25; Wed, 31 Oct 2018 11:34:54 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:54 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 5/9] scsi: store unmap offset and nb_sectors in request struct Thread-Index: AQHUcQ2+Xbmu1wESakeKmqeFa8xk7w== Date: Wed, 31 Oct 2018 11:34:54 +0000 Message-ID: <20181031113418.29796-6-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB0413; 20:s15oaen/UXlnvh2uV9xtq7DNuLIeEbiFm2llgm2RaE/unvZA469mnJjQwzlamtTk0fkgw2KV2KnWdlUjXaR/khMGNYYe7JB9qQ1rgbqf9xWrHtJAZ0mHihs2VE+YgQYIN1Dwsb+PmlUE88QOLArlXY9gyb3yA8le6wwXCQksXCU= x-ms-office365-filtering-correlation-id: a5dc7d17-09e8-42d0-1d44-08d63f24e08f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB0413; x-ms-traffictypediagnostic: VI1PR08MB0413: 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)(5005006)(8121501046)(93006095)(93001095)(3231382)(944501410)(52105095)(3002001)(10201501046)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB0413; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0413; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(346002)(39850400004)(366004)(396003)(189003)(199004)(6486002)(68736007)(76176011)(66066001)(5640700003)(2900100001)(6512007)(6436002)(2616005)(476003)(2501003)(53936002)(44832011)(11346002)(5250100002)(486006)(52116002)(97736004)(5660300001)(478600001)(14454004)(6916009)(6506007)(386003)(107886003)(71200400001)(71190400001)(25786009)(4326008)(1076002)(2906002)(186003)(86362001)(7416002)(316002)(446003)(3846002)(26005)(102836004)(2351001)(305945005)(7736002)(105586002)(106356001)(99286004)(36756003)(6116002)(54906003)(8676002)(256004)(8936002)(81156014)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0413; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: O8pJ5KlIvmS71Az9EAeAfqIt++9+gfqNZ60hSxgw027oX2UVVf/ajQmMsfn7MezJMyMXeY2P5i4juRtVdUI+Ne5zP1MOB8DNgDizwowmEA7iwQiI5Irc8wa7RRvxssL6GBrrpNUE19U2k/zORzw4RWNApjr9X6NEMOcyCYqKJTdTPvwGSdA2KA72Iah7j76w0M1DqdZZru0vOmjjFa595RkdpZw3dICEVv8/agtaYuyazi4ctiNm3gTTcUJto+uExaBmsp+s0kzY33ySri5lwNIRT7UtPIIC+EDqj84ljXvG9cwXOLJcc13oBOLXquVL+BampRwbewRXcHzN0msriOB89qbrXDgXjnmCaAusFUw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5dc7d17-09e8-42d0-1d44-08d63f24e08f X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:54.3045 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0413 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.5.92 Subject: [Qemu-devel] [PATCH v5 5/9] scsi: store unmap offset and nb_sectors in request struct 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" it allows to report it in the error handler Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- hw/scsi/scsi-disk.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e2c5408aa2..661228b569 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1656,8 +1656,6 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) { SCSIDiskReq *r = data->r; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); - uint64_t sector_num; - uint32_t nb_sectors; assert(r->req.aiocb == NULL); if (scsi_disk_req_check_error(r, ret, false)) { @@ -1665,16 +1663,16 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) } if (data->count > 0) { - sector_num = ldq_be_p(&data->inbuf[0]); - nb_sectors = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; - if (!check_lba_range(s, sector_num, nb_sectors)) { + r->sector = ldq_be_p(&data->inbuf[0]); + r->sector_count = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; + if (!check_lba_range(s, r->sector, r->sector_count)) { scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); goto done; } r->req.aiocb = blk_aio_pdiscard(s->qdev.conf.blk, - sector_num * s->qdev.blocksize, - nb_sectors * s->qdev.blocksize, + r->sector * s->qdev.blocksize, + r->sector_count * s->qdev.blocksize, scsi_unmap_complete, data); data->count--; data->inbuf += 16; From patchwork Wed Oct 31 11:34:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991358 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="f0HcZeOC"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRK811v1z9s1c for ; Wed, 31 Oct 2018 22:42:36 +1100 (AEDT) Received: from localhost ([::1]:58765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHotN-0001bX-Jf for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:42:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHoml-0003tR-9u for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHomg-0002L3-Nj for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:43 -0400 Received: from mail-eopbgr00117.outbound.protection.outlook.com ([40.107.0.117]:4800 helo=EUR02-AM5-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 1gHomc-0001Pq-Sj; Wed, 31 Oct 2018 07:35:36 -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=mSXjC80FX+5zNt7wKAXpE3bWf7CKk3s5dS53dqGHe1w=; b=f0HcZeOCHNLETbR7vZU6SiAvOJp03nWAeExIcRXkSP+kW4q8fTJWkHoYZqg681vgYq/RmIauokRt+XkWeBBxGgR+hzhW390kbvyfXtwH9ARJDhu9gU+R9XplUJgrR0XFZobxcOAn9ai0b3a5tV6gezG+Fc2D8g+UKYANArP2h1E= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3007.eurprd08.prod.outlook.com (52.133.14.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Wed, 31 Oct 2018 11:34:57 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:57 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 6/9] scsi: move unmap error checking to the complete callback Thread-Index: AQHUcQ2/+ZWUvGjQA0CS+vVEk2lOkQ== Date: Wed, 31 Oct 2018 11:34:56 +0000 Message-ID: <20181031113418.29796-7-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3007; 20:cpCEIkKYNheyce9eerIAjbHLSd/rAsI99QJcx3EBmYN97CHcuL1CWcg4Pwe91c/16Ycyc324oRBS3ualjs3cI9xleGxuyxigXURqG8YaDeIpQsg7NhH6y/9O1rGbGsyIbrCxJfgsuNAAGXFnGv2f8JU9/gadP4Ee4OLnbKfFygA= x-ms-office365-filtering-correlation-id: b32f542c-073d-428b-7318-08d63f24e223 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3007; x-ms-traffictypediagnostic: VI1PR08MB3007: 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)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3007; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3007; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(136003)(39850400004)(346002)(189003)(199004)(256004)(7416002)(5640700003)(6486002)(2900100001)(446003)(11346002)(53936002)(2906002)(14454004)(316002)(68736007)(36756003)(5250100002)(66066001)(86362001)(99286004)(6436002)(54906003)(14444005)(2501003)(5660300001)(2351001)(1076002)(102836004)(106356001)(44832011)(81166006)(81156014)(6916009)(97736004)(8676002)(25786009)(4326008)(52116002)(8936002)(2616005)(6512007)(476003)(26005)(3846002)(386003)(6116002)(486006)(107886003)(7736002)(76176011)(105586002)(6506007)(478600001)(305945005)(71190400001)(71200400001)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3007; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: hy/dS6iju5ZT9MF+jiaICOoGLcjV9OeF/utd+kbN8qzHT7f75AHXkyjCtDm32bx2cFc0leRXO745d8jKY4VMDmFm1BRGVRxraxN8fVBB8FxCey1uhi09wG1tiPAsxIm/2psq0aGqtS7ksQsz9ol6RBz/PloNZ0rfu8tRPrPZ2fo0vQ9Rv6xqcp/Z3M2k7OhxbPGL8vZi6Zi8Du/E94y9DwRBqiYnVa3d2kxoF9VgQsWrCnZ0x29zfvLXaXjSw9XtGKTqrwiELziLWKT1P63BkaOKdXuwwUbSSwIqOkbd6fJVQrKu8nv/XRMqHlAL6CGIVwEnHereypAfGdGb8SwfhqS1OjQD0aWykbjhZEN+6D4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b32f542c-073d-428b-7318-08d63f24e223 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:56.8973 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3007 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.117 Subject: [Qemu-devel] [PATCH v5 6/9] scsi: move unmap error checking to the complete callback 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This will help to account the operation in the following commit. The difference is that we don't call scsi_disk_req_check_error() before the 1st discard iteration anymore. That function also checks if the request is cancelled, however it shouldn't get canceled until it yields in blk_aio() functions anyway. Same approach is already used for emulate_write_same. Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia --- hw/scsi/scsi-disk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 661228b569..e132504913 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1658,9 +1658,6 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); assert(r->req.aiocb == NULL); - if (scsi_disk_req_check_error(r, ret, false)) { - goto done; - } if (data->count > 0) { r->sector = ldq_be_p(&data->inbuf[0]); @@ -1696,7 +1693,12 @@ static void scsi_unmap_complete(void *opaque, int ret) r->req.aiocb = NULL; aio_context_acquire(blk_get_aio_context(s->qdev.conf.blk)); - scsi_unmap_complete_noio(data, ret); + if (scsi_disk_req_check_error(r, ret, false)) { + scsi_req_unref(&r->req); + g_free(data); + } else { + scsi_unmap_complete_noio(data, ret); + } aio_context_release(blk_get_aio_context(s->qdev.conf.blk)); } From patchwork Wed Oct 31 11:34:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="Wc3BlONb"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRNn4bg8z9s1c for ; Wed, 31 Oct 2018 22:45:45 +1100 (AEDT) Received: from localhost ([::1]:58780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHowR-0004pp-9Q for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:45:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHomz-00042E-4W for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHomx-00033T-1y for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:56 -0400 Received: from mail-he1eur02on0727.outbound.protection.outlook.com ([2a01:111:f400:fe05::727]:42496 helo=EUR02-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 1gHomw-0002zQ-N2; Wed, 31 Oct 2018 07:35:54 -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=7StQJ/HmNN/Q5uQQRCgTJeVWn6DBlDHQKvIWVBDPcnI=; b=Wc3BlONbZ7b5UU1NtTO8dCFi/BFnkIbSksXC84uIM6Vy0SmeFWLRBdr/r/WVyfwX9wUSzElDRMZU66mEkMhxk7/rS/+QlOSqTjzOCdjqMvRGCRuRHAvQknrZ00kGrtDAfwIF1xahKWbX70R/jwNqgQrckE/OSy835ESj6ljdNjs= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3007.eurprd08.prod.outlook.com (52.133.14.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Wed, 31 Oct 2018 11:34:59 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:34:59 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 7/9] scsi: account unmap operations Thread-Index: AQHUcQ3BoaXGp6mT2UOXcP/5UHxk2A== Date: Wed, 31 Oct 2018 11:34:59 +0000 Message-ID: <20181031113418.29796-8-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3007; 20:+kD4xrOWj0ksG6d6ThulquIQiQY/8TzLxwkr3gCvqFuggIt4KReVNHyaa1IwY6UJisPSMDjFOPNVgukYbdBDb1zVmnLNBGnlEmEQOFecMIC7nunC4r74icAMAivL6S90j1t2zYroOieFGirhaOE+Vvo3Hcl4Ksrd/CCcu/B2LZI= x-ms-office365-filtering-correlation-id: f90b362a-495a-4fdc-9bb6-08d63f24e3b0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3007; x-ms-traffictypediagnostic: VI1PR08MB3007: 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)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3007; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3007; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(136003)(39850400004)(346002)(189003)(199004)(256004)(7416002)(5640700003)(6486002)(2900100001)(446003)(11346002)(53936002)(2906002)(14454004)(316002)(68736007)(36756003)(5250100002)(66066001)(86362001)(99286004)(6436002)(54906003)(14444005)(2501003)(5660300001)(2351001)(1076002)(102836004)(106356001)(44832011)(81166006)(81156014)(6916009)(97736004)(8676002)(25786009)(4326008)(52116002)(8936002)(2616005)(6512007)(476003)(26005)(3846002)(386003)(6116002)(486006)(107886003)(7736002)(76176011)(105586002)(6506007)(478600001)(305945005)(71190400001)(71200400001)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3007; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: p04/grI3Rq8d3P0MZkRQ+JG6O5JYkGbwoalxvNhBx/BHExZTyvViX4jli9ubLEit82dbkrVBLj53PYB/ESEsOn7uwmYHsFkNES2Sx+6EENdeGG5w19oApqPSlTvssLXXLniRMHN84dzCm8h4TbAeyGiI9xZ0BXh0GTidCpJTmSDQNmQBcIU9pxrTdmfoibPNbdIJuqNAsrPqPpC06nLvRGSFXl3T8RB7yOlMADoy1QhZq4yQbuko6rOEt5gXw9WCUnZMhzIzZvz1u3q9LFDezo7nPOP0X4ICQKMB4T9M8YcBdcE8swk4ATqAbkf/b1P/GoUBIynxDfzxt0/ciNG+kHBEtIxXArwcDW3aRJ5/LjM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f90b362a-495a-4fdc-9bb6-08d63f24e3b0 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:34:59.5171 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3007 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe05::727 Subject: [Qemu-devel] [PATCH v5 7/9] scsi: account unmap 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy --- hw/scsi/scsi-disk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e132504913..dee71f9dde 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1663,10 +1663,16 @@ static void scsi_unmap_complete_noio(UnmapCBData *data, int ret) r->sector = ldq_be_p(&data->inbuf[0]); r->sector_count = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; if (!check_lba_range(s, r->sector, r->sector_count)) { + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), + BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); goto done; } + block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, + r->sector_count * s->qdev.blocksize, + BLOCK_ACCT_UNMAP); + r->req.aiocb = blk_aio_pdiscard(s->qdev.conf.blk, r->sector * s->qdev.blocksize, r->sector_count * s->qdev.blocksize, @@ -1693,10 +1699,11 @@ static void scsi_unmap_complete(void *opaque, int ret) r->req.aiocb = NULL; aio_context_acquire(blk_get_aio_context(s->qdev.conf.blk)); - if (scsi_disk_req_check_error(r, ret, false)) { + if (scsi_disk_req_check_error(r, ret, true)) { scsi_req_unref(&r->req); g_free(data); } else { + block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct); scsi_unmap_complete_noio(data, ret); } aio_context_release(blk_get_aio_context(s->qdev.conf.blk)); @@ -1728,6 +1735,7 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf) } if (blk_is_read_only(s->qdev.conf.blk)) { + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED)); return; } @@ -1743,10 +1751,12 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf) return; invalid_param_len: + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); return; invalid_field: + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); } From patchwork Wed Oct 31 11:35:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="YfKDLN2p"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRFg4WPLz9s1c for ; Wed, 31 Oct 2018 22:39:35 +1100 (AEDT) Received: from localhost ([::1]:58745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHoqT-0007di-5j for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:39:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHomX-0003io-1Y for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHomR-0001y8-0T for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:27 -0400 Received: from mail-eopbgr50114.outbound.protection.outlook.com ([40.107.5.114]:29664 helo=EUR03-VE1-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 1gHomQ-0001co-OB; Wed, 31 Oct 2018 07:35:22 -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=Q17EkUpT94s3oeAgLbTa4+Mlnbp4+nx5VatptCxPFEw=; b=YfKDLN2pT0VrJ7cIJslswHAfk8KR9tBQnvsaCA8kINf/A5l4J7k5MG5wjRKScbowjToZyOHLF6EhdNgDWUS74t7C8oAi6rlvZbpBaBdZh2njq/NYmkihjJDty6kT8t+6dR7NJI3WXrGvExdcksaReUwtFU6SFjgsJO3KPiGPKUU= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB0413.eurprd08.prod.outlook.com (10.162.12.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.25; Wed, 31 Oct 2018 11:35:02 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:35:02 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 8/9] file-posix: account discard operations Thread-Index: AQHUcQ3CtViFMrtHOEGD4I70d9FlKg== Date: Wed, 31 Oct 2018 11:35:02 +0000 Message-ID: <20181031113418.29796-9-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB0413; 20:+y1mH2Q1d2MbFoJGEH7pCG2o2+F5zy1EEDvghbLtTZ1i1dIH5Iv8uskrwDKIIQbim7QJTdnJq7dquysW/wht1WGZv/a3aWZ5+BmyR8rhtApCmYzAIQFHGRel+ozVqhQADXp1zF8reU0TXG1DZDO2Q/tcJTpoJX4Qxrrg9FYqSFU= x-ms-office365-filtering-correlation-id: 3504cdb3-0345-4916-79f5-08d63f24e53b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB0413; x-ms-traffictypediagnostic: VI1PR08MB0413: 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)(5005006)(8121501046)(93006095)(93001095)(3231382)(944501410)(52105095)(3002001)(10201501046)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB0413; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0413; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(346002)(39850400004)(366004)(396003)(189003)(199004)(6486002)(68736007)(76176011)(66066001)(5640700003)(2900100001)(6512007)(6436002)(2616005)(476003)(2501003)(53936002)(44832011)(11346002)(5250100002)(486006)(52116002)(97736004)(5660300001)(478600001)(14454004)(6916009)(6506007)(386003)(107886003)(71200400001)(71190400001)(25786009)(4326008)(1076002)(2906002)(186003)(86362001)(7416002)(316002)(15650500001)(446003)(3846002)(26005)(14444005)(102836004)(2351001)(305945005)(7736002)(105586002)(106356001)(99286004)(36756003)(6116002)(54906003)(8676002)(256004)(8936002)(81156014)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0413; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 3q4dJXmGeqIVPxKomeIW3nzxCLBeBWXihEcrDliia8CE5WdUaPN0tiGgpy8dtmjbGWWaXuknyFdJdgarwKGnTD5EpQlmBEW/o2ShdGnf2XBRF9flOX8pGcQZxxeygnK/GG7JGY1VH3+vpvebF5JfE0Nm4jaA+W3NT3zHRya42UV/OqWevQceIn1cf2Vmyg/61HoPM540QEBtg3pxJQuqNQjaSYl19NP0O7rCkrmaZSn8f2nK1tY1jx7TuTQIe8c9F+6gym5FRp6/Z2xIQ4g+F8fD6J1tRSvGlyfzDO8bsMrX/Wv0he077UUAUr46knVHGQ12X2LPw1/eYE20FQ2ZTFaJvQRc9R4+Tjd+TZmdYOg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3504cdb3-0345-4916-79f5-08d63f24e53b X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:35:02.6293 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0413 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.5.114 Subject: [Qemu-devel] [PATCH v5 8/9] 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Vladimir Sementsov-Ogievskiy --- 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 2da3a76355..1a7126046c 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; @@ -2582,12 +2587,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( @@ -3084,10 +3102,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, From patchwork Wed Oct 31 11:35:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 991355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; 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.b="Cszjc5E/"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lRGB671vz9s1c for ; Wed, 31 Oct 2018 22:40:02 +1100 (AEDT) Received: from localhost ([::1]:58748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHoqu-0007zy-EZ for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2018 07:40:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHomp-0003v5-6q for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHomn-0002iD-29 for qemu-devel@nongnu.org; Wed, 31 Oct 2018 07:35:46 -0400 Received: from mail-eopbgr00117.outbound.protection.outlook.com ([40.107.0.117]:4800 helo=EUR02-AM5-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 1gHomm-0001Pq-L5; Wed, 31 Oct 2018 07:35:44 -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=0VrORBFA74CVkedaKXbfiQrKIJxLlPP5eSqBYyHl6cI=; b=Cszjc5E/b8Oak6PkdLwJYLWg3/iOhlRsjEwnEQaiJhH4kucRwww8MXF6ruBV8kMfmiYtVnIVueM2TAWuWbc7qEhaEvYqlSVXfDbLqOYcSofK8DiqaH23NWj6bcg2msxW0tWTeEEst49Zc7qkGEtXJkMOvHRU2ylAsKr7vHy55Lo= Received: from VI1PR08MB3358.eurprd08.prod.outlook.com (52.134.31.145) by VI1PR08MB3007.eurprd08.prod.outlook.com (52.133.14.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Wed, 31 Oct 2018 11:35:05 +0000 Received: from VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c]) by VI1PR08MB3358.eurprd08.prod.outlook.com ([fe80::614e:e2cd:51e1:a19c%4]) with mapi id 15.20.1273.027; Wed, 31 Oct 2018 11:35:05 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v5 9/9] qapi: query-blockstat: add driver specific file-posix stats Thread-Index: AQHUcQ3EEpawXPtnxEqdd6MeYR5xNw== Date: Wed, 31 Oct 2018 11:35:05 +0000 Message-ID: <20181031113418.29796-10-anton.nefedov@virtuozzo.com> References: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181031113418.29796-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:20b:2e::41) To VI1PR08MB3358.eurprd08.prod.outlook.com (2603:10a6:803:3f::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB3007; 20:3vBFrrkteZwzjn46yGPQEHDoquV7yg+caoR7aGebsLzuL5xqDkKXIi73k47y+OTwsibUUjJiCbN4W69nS6PjIX3Y4/vnGTekp0cad0bMxlLWH8xm72OrCl5xU1D/8lpgMwvH0e6t0OkkXRVxQwdr/CfVTjKprcqV8H12Aqct7MI= x-ms-office365-filtering-correlation-id: 72b00c56-bb67-4fe7-a1d0-08d63f24e71a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3007; x-ms-traffictypediagnostic: VI1PR08MB3007: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(20558992708506); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB3007; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3007; x-forefront-prvs: 084285FC5C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(366004)(396003)(136003)(39850400004)(346002)(189003)(199004)(256004)(7416002)(5640700003)(575784001)(6486002)(2900100001)(446003)(11346002)(53936002)(2906002)(14454004)(316002)(68736007)(36756003)(5250100002)(66066001)(86362001)(99286004)(6436002)(54906003)(14444005)(2501003)(5660300001)(2351001)(1076002)(102836004)(106356001)(44832011)(81166006)(81156014)(6916009)(97736004)(8676002)(25786009)(4326008)(52116002)(8936002)(2616005)(6512007)(476003)(26005)(3846002)(386003)(6116002)(486006)(107886003)(7736002)(76176011)(105586002)(6506007)(478600001)(305945005)(71190400001)(71200400001)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB3007; H:VI1PR08MB3358.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: m6P0twhRI1TvkMFTDY3kNfPcOEs4/y9DSCjohTsDauAhvbRohzKa7tq84vklomsu5nEDEiw0P99P9VSUN82VEiGpdbKzDgO2eikRvs6pFqGow2Z9IkPZYpJ99zVCEqaP1p8GrKFIdVFKin/f1XffwN2Wu5B05H2qCdhWWm3M+wMSizbZwjHSuIe6EJlPlYIFkxjKjceqxLy7h5SLqlr1pi+QOQajipKPBMWsttlvHa01f/Cs1zCA6ZC7OruN+cEHYUQNi63x8Z7ZPEGuyTxnjA9j4tNTxXQNy7MIj4NV9hjjsBCjV8u4P5eY8dodqDH77OY8DktjVi4vxzAQ99xPFux0Xjo78Nuw9lKjELPLaBk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b00c56-bb67-4fe7-a1d0-08d63f24e71a X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2018 11:35:05.8005 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3007 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.117 Subject: [Qemu-devel] [PATCH v5 9/9] qapi: query-blockstat: add driver specific file-posix stats 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" , Vladimir Sementsov-Ogievskiy , "famz@redhat.com" , Denis Lunev , "qemu-block@nongnu.org" , "armbru@redhat.com" , "mreitz@redhat.com" , "berto@igalia.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" A block driver can provide a callback to report driver-specific statistics. file-posix driver now reports discard statistics Signed-off-by: Anton Nefedov --- qapi/block-core.json | 39 +++++++++++++++++++++++++++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 9 +++++++++ block/file-posix.c | 17 +++++++++++++++++ block/qapi.c | 5 +++++ 6 files changed, 72 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 01da84cb61..cd0344435e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -877,6 +877,42 @@ '*x_wr_latency_histogram': 'BlockLatencyHistogramInfo', '*x_flush_latency_histogram': 'BlockLatencyHistogramInfo' } } +## +# @BlockStatsSpecificFile: +# +# File driver statistics +# +# @discard-nb-ok: The number of succeeded discard operations performed by +# the driver. +# +# @discard-nb-failed: The number of failed discard operations performed by +# the driver. +# +# @discard-bytes-ok: The number of bytes discarded by the driver. +# +# Since 3.1 +## +{ 'struct': 'BlockStatsSpecificFile', + 'data': { + 'discard-nb-ok': 'int', + 'discard-nb-failed': 'int', + 'discard-bytes-ok': 'int' + } } + +## +# @BlockStatsSpecific: +# +# Block driver specific statistics +# +# Since: 3.1 +## +{ 'union': 'BlockStatsSpecific', + 'base': { 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + 'file': 'BlockStatsSpecificFile' + } } + ## # @BlockStats: # @@ -892,6 +928,8 @@ # # @stats: A @BlockDeviceStats for the device. # +# @driver-specific: Optional driver-specific stats. (Since 3.1) +# # @parent: This describes the file block device if it has one. # Contains recursively the statistics of the underlying # protocol (e.g. the host file for a qcow2 image). If there is @@ -905,6 +943,7 @@ { 'struct': 'BlockStats', 'data': {'*device': 'str', '*qdev': 'str', '*node-name': 'str', 'stats': 'BlockDeviceStats', + '*driver-specific': 'BlockStatsSpecific', '*parent': 'BlockStats', '*backing': 'BlockStats'} } diff --git a/include/block/block.h b/include/block/block.h index b189cf422e..07a3b31386 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -475,6 +475,7 @@ const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); int bdrv_get_flags(BlockDriverState *bs); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs); +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs); void bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *cluster_offset, diff --git a/include/block/block_int.h b/include/block/block_int.h index f605622216..236d4aceef 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -320,6 +320,7 @@ struct BlockDriver { Error **errp); int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs); + BlockStatsSpecific *(*bdrv_get_specific_stats)(BlockDriverState *bs); int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, diff --git a/block.c b/block.c index 95d8635aa1..1e5bba4ac6 100644 --- a/block.c +++ b/block.c @@ -4244,6 +4244,15 @@ ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs) return NULL; } +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + if (!drv || !drv->bdrv_get_specific_stats) { + return NULL; + } + return drv->bdrv_get_specific_stats(bs); +} + void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event) { if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) { diff --git a/block/file-posix.c b/block/file-posix.c index 1a7126046c..a0a06585ab 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2630,6 +2630,21 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return 0; } +static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_FILE; + stats->u.file = (BlockStatsSpecificFile){ + .discard_nb_ok = s->stats.discard_nb_ok, + .discard_nb_failed = s->stats.discard_nb_failed, + .discard_bytes_ok = s->stats.discard_bytes_ok, + }; + + return stats; +} + static QemuOptsList raw_create_opts = { .name = "raw-create-opts", .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head), @@ -2741,6 +2756,7 @@ BlockDriver bdrv_file = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_get_specific_stats = raw_get_specific_stats, .bdrv_check_perm = raw_check_perm, .bdrv_set_perm = raw_set_perm, .bdrv_abort_perm_update = raw_abort_perm_update, @@ -3226,6 +3242,7 @@ static BlockDriver bdrv_host_device = { .bdrv_get_info = raw_get_info, .bdrv_get_allocated_file_size = raw_get_allocated_file_size, + .bdrv_get_specific_stats = raw_get_specific_stats, .bdrv_check_perm = raw_check_perm, .bdrv_set_perm = raw_set_perm, .bdrv_abort_perm_update = raw_abort_perm_update, diff --git a/block/qapi.c b/block/qapi.c index df31f351d2..74f762ea6c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -535,6 +535,11 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, s->stats->wr_highest_offset = stat64_get(&bs->wr_highest_offset); + s->driver_specific = bdrv_get_specific_stats(bs); + if (s->driver_specific) { + s->has_driver_specific = true; + } + if (bs->file) { s->has_parent = true; s->parent = bdrv_query_bds_stats(bs->file->bs, blk_level);