From patchwork Fri Nov 30 14:47:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005980 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="XLUXSuLk"; 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 435y5R1MfXz9s3Z for ; Sat, 1 Dec 2018 01:51:39 +1100 (AEDT) Received: from localhost ([::1]:60532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk8m-0000qt-PN for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:51:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4k-0005LY-RE for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4g-0003zU-6S for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:26 -0500 Received: from mail-eopbgr00109.outbound.protection.outlook.com ([40.107.0.109]:64560 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 1gSk4f-0003yU-Vp; Fri, 30 Nov 2018 09:47:22 -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:X-MS-Exchange-SenderADCheck; bh=6+M8rkdGKJ7yFb8GeuEuOKPa1uqdK7dDYERleIDxEzY=; b=XLUXSuLk0BnuculLfLqjbujVrLs3Ha3NQO18HDELags0/gOAP8YPbPUwPO3s3I3i90207cm9Jnj+3YvH5i6FQU9ey2Ma1ygW8l8DG1PG6QHLddjpy12WYtrf9CQ2I42tirEylkdqLHckdTjqmcb20drm5C5xG9Jt7oAaJ6M6zy8= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3891.eurprd08.prod.outlook.com (20.178.82.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.18; Fri, 30 Nov 2018 14:47:18 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:18 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 1/9] qapi: group BlockDeviceStats fields Thread-Index: AQHUiLuXCCPLZ10RPEGshUBb93Ex/g== Date: Fri, 30 Nov 2018 14:47:18 +0000 Message-ID: <20181130144705.77454-2-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB3891; 20:Y9wBovPxSr2uXJPCNq5BIYn4FVLHANGLJq35+4Pwog74oZUfVefUJISD4c0+/75aDBMNq3vmxkRuEkJnusAW36EFRmueb+fmQsqzRD/G7DQzyKzVHzyVbXIterJ6ZspvxNVji5w1q0afKNMX4X6gr1IfzJVjZDyMpfO9WNApSSE= x-ms-office365-filtering-correlation-id: adae8b8c-03bc-45d7-c715-08d656d2b9de x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3891; x-ms-traffictypediagnostic: AM0PR08MB3891: authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501466)(52105112)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3891; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3891; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(346002)(39850400004)(376002)(366004)(199004)(189003)(6436002)(26005)(68736007)(52116002)(106356001)(3846002)(1076002)(2906002)(6916009)(6116002)(186003)(478600001)(99286004)(316002)(6506007)(102836004)(54906003)(256004)(25786009)(486006)(2501003)(386003)(44832011)(11346002)(76176011)(476003)(2616005)(446003)(7736002)(81166006)(8676002)(7416002)(305945005)(6512007)(36756003)(5660300001)(8936002)(81156014)(4326008)(66066001)(14444005)(53936002)(107886003)(14454004)(97736004)(105586002)(6486002)(71200400001)(71190400001)(86362001)(2351001)(5640700003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3891; H:AM0PR08MB3347.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: YlC0iwjuYrtt7KV6gpsntnNNz4GIXEJMhCnJeOSoL9nPCZ6/NbOLdKXkXDm9Xkhg2bcrH5x6jd12XGbWu9+RzceB3hNombnfxldzuAMcD1V5ONgmDJ3X1MbV52JEUAsQoBis+ijiH9G1DVNwTEF0nWWJNac+Snnlfj1yjElUad9GQnSGWzJ3iczPeDlN54lvCNbt11vvYBUajXVdMd2IBnDMCtvuY7NJI8STNN7JPoGUery2QlKx1phTr/QXZToR6mRwBQIdyMuzQk7Oze63ZJ0PvWKqugPS7DJySuThfcPFHI1jhrhxl6LQIHP9vI11foTYMpe7DHAv4AVo1NILJi9d36pj6uNIwR61+Hj6M5M= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: adae8b8c-03bc-45d7-c715-08d656d2b9de X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:18.3161 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3891 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.109 Subject: [Qemu-devel] [PATCH v6 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 d4fe710836..0fa0743833 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 Fri Nov 30 14:47:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005984 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="SizTx/Wf"; 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 435y8p03XHz9s3Z for ; Sat, 1 Dec 2018 01:54:34 +1100 (AEDT) Received: from localhost ([::1]:60544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkBb-0003Jk-G2 for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:54:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4l-0005Lb-2R for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4g-0003zp-PA for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:26 -0500 Received: from mail-eopbgr10133.outbound.protection.outlook.com ([40.107.1.133]:33403 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 1gSk4g-0003z5-Bn; Fri, 30 Nov 2018 09:47:22 -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:X-MS-Exchange-SenderADCheck; bh=NJ5bXt/ijq1OP8aE/gwvWzsRJrFL25Hh63tMslArVd0=; b=SizTx/WfC+sqHyeG+iMoMBJpAyHONlsCkiFArvAkISXB4MbN6W+EyDHnmZ52LwvUYgosBlZW59WfdN/TbBKUW7tB0FGp4+u2SdetPf7qcWELh0k3Y96SowD6Wc9l3uD6Fs42IZ2JGi5icA07z0S2k7oBKXTisMDeZ343m5106kQ= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:19 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:19 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 2/9] qapi: add unmap to BlockDeviceStats Thread-Index: AQHUiLuYZsE4pnWWjE+Qz4fbtWdUbA== Date: Fri, 30 Nov 2018 14:47:19 +0000 Message-ID: <20181130144705.77454-3-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:Y9V5lidBvpd9h0eqjUETmC7TY9Nb8Z7danyf/rgq88ebwntTx71CN64NkD2o/sJeomlYyRgR894qZsxRV5KvOFyCrluVi62V9YrKwFjaRODr09A50WemIqCcqQBOQbgafb42e45WPeTiNhMmt4G6ilSRFC8kFESi4cTzBxY6LRQ= x-ms-office365-filtering-correlation-id: 286bf16f-90ca-4791-fe8b-08d656d2ba83 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(14444005)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: 8LUI4XYKsvPWB0yFqRKpDdglv3OXbPUUQBD9FhXG7gb0sxeV4fC90EQu/p7fkIMYtS6oaSVUeE1N643ApfSJymDTRqGwNzg9vIHG35cBYWQYJprnjMsUHGSWJKDCmRGApP1HA860l+uBHAiK0nyfbejcTXv1egKTin9saK6WgBQGK4K8lJ12KMCUcMCDv2Cce8K6iWfjjFdhXt52SBv4c4gV8C61SqoFNkyTjYzgTxtsM5dxkhG7oKXb7NBrfj89UmgTlyN2TZo84fwpR69pmFYdkJC6z7bXS+2AtPT1SS3gdt+aNSWp/wVkC1Nif4CduB1xFVJELkbBG9NJL5KQWlsm4u/2dWkNHoFHuc0USZE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 286bf16f-90ca-4791-fe8b-08d656d2ba83 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:19.4719 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.133 Subject: [Qemu-devel] [PATCH v6 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 0fa0743833..959358ccc4 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 4.0) +# # @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 4.0) +# # @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 4.0) +# # @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 4.0) +# # @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 4.0) +# # @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 4.0) +# # @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 Fri Nov 30 14:47:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005974 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="QU+Ckg8G"; 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 435y1n12lCz9sB7 for ; Sat, 1 Dec 2018 01:48:29 +1100 (AEDT) Received: from localhost ([::1]:60514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk5e-0005ML-1r for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:48:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4k-0005LX-RD for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4g-0003zi-JC for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:26 -0500 Received: from mail-eopbgr00109.outbound.protection.outlook.com ([40.107.0.109]:64560 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 1gSk4g-0003yU-Co; Fri, 30 Nov 2018 09:47:22 -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:X-MS-Exchange-SenderADCheck; bh=boctwga0cMr1ykg6OQOpOEW1SBVt3Ox9UZFfyqbzmvU=; b=QU+Ckg8GOzp0NoMdaN/0/w848P7lGxuL0ERNwMvS76xSY4+A76kMz1xeft2H5UUkY7q1qh1RLSFDPrAM12JW+4dGZEtY9Dk2mJ/RMZVQwTS6pk0llkL9vieY7OPJw2GI7q2kFT9jjnqL8eHwBJc82bUMbyxDdy4ae7SPo2A1tZo= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3891.eurprd08.prod.outlook.com (20.178.82.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.18; Fri, 30 Nov 2018 14:47:20 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:20 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 3/9] block: add empty account cookie type Thread-Index: AQHUiLuYMduKMsU4CEu03pbXXNLaFQ== Date: Fri, 30 Nov 2018 14:47:20 +0000 Message-ID: <20181130144705.77454-4-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB3891; 20:fatbSB4WcTXPOMXhewmJooDkYzFFSg4GNLX9yB3ayjiVFmzS3TSzYvEFD7j42v8xvgTNHtuW4CpZtzZJdo3UUvS497YVy3E0/3gj5NN61C0icWDpBdo4LIV1DZy3piMD4PopFrm1Yp8ISyFev2VxhAwrzhelwjE0cztC4bCSe1Y= x-ms-office365-filtering-correlation-id: d28c6fa8-6ea6-42c6-0d43-08d656d2bb34 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3891; x-ms-traffictypediagnostic: AM0PR08MB3891: authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501466)(52105112)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3891; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3891; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(346002)(39850400004)(376002)(366004)(199004)(189003)(6436002)(26005)(68736007)(52116002)(106356001)(15650500001)(3846002)(1076002)(2906002)(6916009)(6116002)(186003)(478600001)(99286004)(316002)(6506007)(102836004)(54906003)(256004)(25786009)(486006)(2501003)(386003)(44832011)(11346002)(76176011)(476003)(2616005)(446003)(7736002)(81166006)(8676002)(7416002)(305945005)(6512007)(36756003)(5660300001)(8936002)(81156014)(4326008)(66066001)(14444005)(53936002)(107886003)(14454004)(97736004)(105586002)(6486002)(71200400001)(71190400001)(86362001)(2351001)(5640700003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3891; H:AM0PR08MB3347.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: IHkRvZgd02QFOyxI1DdlQiTs6cRxY3sRq64XQI362aySxky85qFdiuTFZQlaXapFnELzbRB49BEB+0LptBD1gB0rcOb4mExNfAqBHL7uY3HXLxfJLcT1hGtFqWHq2+0LGKQRe1jqGYP0WIKQRKwPp13oDVW/E4IIdIBc8MUaPSPWPWApP98NYebGZL0EwJnWpXjm5VMgjEEY58qzXYOEauEJIFhhkXgKW3bAGf4uF+AEWBGqByx32mu+zgKn3JEQLF8hNAkpJibxkPRU6gWbiSNqseRAA+yjqvGEdOe5dtdQOCCjyiI18Y014HtDUEPsci6Q1Ly/hGv84tp6DPppeIipYktvamtWPmuLenQi36s= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d28c6fa8-6ea6-42c6-0d43-08d656d2bb34 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:20.5546 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3891 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.109 Subject: [Qemu-devel] [PATCH v6 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 uninitialized 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 uninitialized 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 Fri Nov 30 14:47:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005975 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="Evor+vM4"; 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 435y1q2CLgz9sB7 for ; Sat, 1 Dec 2018 01:48:31 +1100 (AEDT) Received: from localhost ([::1]:60515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk5k-0005OA-RU for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:48:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4n-0005Lq-99 for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4i-00040Q-OW for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:29 -0500 Received: from mail-eopbgr10124.outbound.protection.outlook.com ([40.107.1.124]:20992 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 1gSk4i-000400-GQ; Fri, 30 Nov 2018 09:47:24 -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:X-MS-Exchange-SenderADCheck; bh=xA9ybs7jCik30pPXXwwqs6Te04NyBthYSL1zeW/KCtc=; b=Evor+vM4t9XyL0iI3WZBSdiG0Flrs74DhaKpK9PwkVejrooDH4/k4wGHA+BdQfYPEgiviy3drSdKRBuM2E+Yw0fVlyopdN3Ytl9FBEa/0SAlsdyng0zTDgPqyfSxSKsefzT8huq4hhDcrRhrHMgq40T19uEWax4BXdNkVdPJEZ4= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:21 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:21 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 4/9] ide: account UNMAP (TRIM) operations Thread-Index: AQHUiLuZnkwjigsYvU6qcdRZrTL9rA== Date: Fri, 30 Nov 2018 14:47:21 +0000 Message-ID: <20181130144705.77454-5-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:fSmV0zURn2hNyQahQy0cteAlqRjFGWpORyLEOsDGc78RUpluXm3vrJPzL+BTvv+XbmilZ2/ygvKgWHwdeY/qRVMqCil7PSIv798mKNTfIHivNpiJJhxyu5xRIZ9zuAFtzEYeS+ng7eQdUIsKKRHIkVe2/719tobYrgz5i6JqnvQ= x-ms-office365-filtering-correlation-id: fb707be4-476f-4b7d-32fe-08d656d2bbd8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: +mvjwoM1Hjrypc4QadbKdYWLJPyK6k7Ek8QvQ6AD7dXz4Bi+HNud2G+mdFzroeUA6WCp3ygFyqKEBpC8N9USkDjLRIDAcjaH0klXpNB7r4PWp9ioC6iSVIHwi1flygry5VKLqrto2Gvbr1wEEdclE32nVNby68lo26f32uhyQonFLV1QlFOdtAX7NRxqpQItDGVhgN4gvJPMmBdP4jsNb/qbcI0j940oMS1tI4A5vt0wWaktZVuYwqvP4rGKxBSJqvaw61RPoGbC1geInCszSGUYS4mQsbG4RRJYyaIvWFp0ObTc07FYTPtk/llB6hTP/z1en9pQPRRYUHj/VXrBkK4U8YMYqtJNiXaLchJNMTs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb707be4-476f-4b7d-32fe-08d656d2bbd8 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:21.6434 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.124 Subject: [Qemu-devel] [PATCH v6 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 Fri Nov 30 14:47:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005981 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="ClgrVHXP"; 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 435y5k0nbQz9s3Z for ; Sat, 1 Dec 2018 01:51:54 +1100 (AEDT) Received: from localhost ([::1]:60536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk91-0000zk-OP for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:51:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4q-0005O6-LL for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4l-00041K-RM for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:32 -0500 Received: from mail-eopbgr10122.outbound.protection.outlook.com ([40.107.1.122]:9818 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 1gSk4l-00040d-Fu; Fri, 30 Nov 2018 09:47:27 -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:X-MS-Exchange-SenderADCheck; bh=DkOqU1DyDlHK6JW4A6sk8maRkyy/ocl+4g4LyztTaxg=; b=ClgrVHXPAfxrvI48XxeKKg7YT3BNSp3a08bYWXaTUjdA/QSyBpwnxWj3qy9dwQT6b+VJQUu3iGLprq18lGM+SUlon3C+gvUDtOxord6tgkUFVsY7OOT3AuhemSZI2dCrLlp/auJ+auF8XhCWwFhkdIMDHsoS0KAcyhfBMxr+t8E= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:22 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:22 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 5/9] scsi: store unmap offset and nb_sectors in request struct Thread-Index: AQHUiLuaYuu4HwBWN0SSc8Rqxnbjyw== Date: Fri, 30 Nov 2018 14:47:22 +0000 Message-ID: <20181130144705.77454-6-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:0+fND0ifs8ecy8z6placOn7Ei+/HYzxALhAGkuAIhA4EkvHmN8sumlQF4DmdyCLr3zvUa1KgpOizlSi4neIXfcwSsv8+TDaWvlmHsSEppD9n0NfxY9Zsl+6oQDVXozAZ8S0xgPoNHsuKcyqYmGz7WZVCYBV72J24pD/HhBJwE/c= x-ms-office365-filtering-correlation-id: 427dd198-b452-4e86-8d81-08d656d2bc7f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: 6sXNi4eW7AcCbjaZsqwLYiPolia8YVM1yOXk5Uv5M8UujITUI6G2PmCYWDs6c5Uwuyx5/Y14rEaHrCtZa7PobQAguD4srS5eFuu2xd8KhNc5oW1CcMdpcfWiTDEbQUZU3p3m6F/9LWQI1F0EXrwIVi65I857RK/3im5LWHfTEo7QVWtgWElaMb5vEk8H6uS+NeP3fYLN7gbXtqBclUOtSIKJr5BC1expKo0QRlGOHCteMeizVDnLeObNAqpWxnEhB39Fq2iCi/RViUY2ZA1Jpo1q+McQf4N9CE/vU4MRz3aYhnWISAzjfaVYhDtF+t4kkYNgMSh7cLYkrVU1eygcL5zbBWJ/LWYjPl0aVcwKNKk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 427dd198-b452-4e86-8d81-08d656d2bc7f X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:22.7252 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.122 Subject: [Qemu-devel] [PATCH v6 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 0e9027c8f3..b1133e6293 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1604,8 +1604,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)) { @@ -1613,16 +1611,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 Fri Nov 30 14:47:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005986 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="S1LygEzX"; 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 435yFZ2kB2z9s9J for ; Sat, 1 Dec 2018 01:58:42 +1100 (AEDT) Received: from localhost ([::1]:60696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkFb-0006Vk-D6 for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:58:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4q-0005OI-SC for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4m-00041c-Mx for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:32 -0500 Received: from mail-eopbgr10122.outbound.protection.outlook.com ([40.107.1.122]:9818 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 1gSk4m-00040d-AN; Fri, 30 Nov 2018 09:47:28 -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:X-MS-Exchange-SenderADCheck; bh=ueGUcMVhSA/HG5+1SBXjZriBsQjwLDy72BGLaR3I5cc=; b=S1LygEzXTCZHRm/fr8J4/TmmrfXW9jiCE61BgfpOnXcxY35GGdCJj1j7Mh1TCYT725Ob9j/1kdRlTC3FgFl7funKm4DHSOFKCgF0LQD+4O+G5VZ1YyT6JvYWCTI9e5KyhcuGJYS4n/GaPaMvRoPsACGjx3QWyIkkCS4XnTP/yxY= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:24 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:24 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 6/9] scsi: move unmap error checking to the complete callback Thread-Index: AQHUiLua34prJwKpDUGelD8A7rbe8g== Date: Fri, 30 Nov 2018 14:47:23 +0000 Message-ID: <20181130144705.77454-7-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:S6IE/ifVc8l0GXvAByGHFyE0ROsnsOmagF43nXdDF8xJG5MX/hHDWZfAymgHgc8HTtLZv5uf7ZxcddpPm3TcZ+JzTc0/eq+75rbZzwq4uFDDnZyTVyICHz2A27f8znGt7RH94dzjzSo/i8CloYetTzDkDBuV+8fX0dxkI0IDzPg= x-ms-office365-filtering-correlation-id: 060ef9b5-4532-4b44-b359-08d656d2bd23 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(14444005)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: Q8lx1O3gpfmusHKIubgxyPVd/NNP5AwuSdVrLxioXAj/31C5L0EwLJArxe7C81zIqkTgHWgVGqpvEDdtWpMCeZ7TBE/jbVB/k8kIuzhvjMy3eZmGCyTUS7o5KBljqhs7Lw+XoV7KK0HiWkL475mou/FjlAQzmzwVyL5fn7lPAzMbPqUxa8TMrf6PGTDCJ6soAn4epxSAJTzdCPUxcPaYW4ERMKjYjfcDQ6CfX/SLBcRw5+g5wFOQVQNmqUaQXUJJYK4kUNU9+1cOr7s41RuKQIZL2Toe+S6ZdGVTOR5NlBYAVk9gD37jbrOOl0NTfoqlMSlhvrOnyvWiTEfFiRwBJeJySBhwMslVIfO3kYd4t/4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 060ef9b5-4532-4b44-b359-08d656d2bd23 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:23.8400 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.122 Subject: [Qemu-devel] [PATCH v6 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 b1133e6293..daf37d117c 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1606,9 +1606,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]); @@ -1644,7 +1641,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 Fri Nov 30 14:47:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005982 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="cpT8UFAT"; 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 435y5n5lcjz9s3Z for ; Sat, 1 Dec 2018 01:51:57 +1100 (AEDT) Received: from localhost ([::1]:60537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk95-00013I-5D for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:51:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4r-0005PA-GU for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4n-00042A-Ln for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:33 -0500 Received: from mail-eopbgr10122.outbound.protection.outlook.com ([40.107.1.122]:9818 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 1gSk4n-00040d-9s; Fri, 30 Nov 2018 09:47:29 -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:X-MS-Exchange-SenderADCheck; bh=IE1pVJVe79SrnnRg1bcViM58M9zLm2NZE5RNrEq+AdY=; b=cpT8UFATRK+CL8p5nzfDh6TbMHauRPXNwhRoGjVNAz1SI5XTCVflSWsQhJO1gKEa5Rj+7B+X0IH4uwVwgu87Vkb2duZijEpKF2IJ/v+zHugbaLllWUvOrQnwc6SPb+04jVxmFxaf51ZTGh+G6p4x5aoeSj/bhSNaRMUF6e73fT8= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:25 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:25 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 7/9] scsi: account unmap operations Thread-Index: AQHUiLub6RjF8cvmTEiXDcb636VdXQ== Date: Fri, 30 Nov 2018 14:47:24 +0000 Message-ID: <20181130144705.77454-8-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:oIhIejxLu3vNvvrm2jrFAw6C7f01jnplVik6TgfxTfgtcbu+8FjvsDLfTuBeLUpTc9B9Nlk3f3JfLAYGAtsmI3lxazFEOpx+VsDYKstT3fGLx4WwC8kuPWxiUwMbZB9grSQQu9VPv7cq5qt2M1VcNtzMzheJU2fZ9WsndVL8V80= x-ms-office365-filtering-correlation-id: 766d8933-9ba7-45b2-cda5-08d656d2bdcd x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(14444005)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: qRXxV6i5avWGrqTCzTa4JwOq1DulXxpx0WtxHq9qz2deexRFZrtHLUFgjNnzuQsRX7YEiJLPWZQRGpvdmPHpz4h1TXRyWnDpXNqyW7lpSmUdGvBYHJgePug24KpInaQHW6+anaMdL0YqBS0MXUMDEO6J6TjwiykGZMsa2TaXUApTjnSLeKDwTQ7suUUC65CeAaZbB/jS82hYvxLXpNaPoGeKuf4/yLsrAuQgFJ50Newulx6iI6IAgKNUXvRI76S8DE6K1Cltzx1ANzNf4yzBv+ZzJWIUATM1YCjVOBMiM0K7rRFDzNQUxKandpZMnYH+Gv4s4VVLiCk1BMK+czYkub5oA56e1mQSxyhga8ASQ1U= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 766d8933-9ba7-45b2-cda5-08d656d2bdcd X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:24.9297 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.122 Subject: [Qemu-devel] [PATCH v6 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 daf37d117c..3968fc6fac 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1611,10 +1611,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, @@ -1641,10 +1647,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)); @@ -1676,6 +1683,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; } @@ -1691,10 +1699,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 Fri Nov 30 14:47:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005985 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="C3crMUvF"; 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 435yCB6zbDz9sBh for ; Sat, 1 Dec 2018 01:56:38 +1100 (AEDT) Received: from localhost ([::1]:60627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkDc-00050Y-JH for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:56:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4r-0005P8-Fv for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4o-00042f-Iv for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:33 -0500 Received: from mail-eopbgr10122.outbound.protection.outlook.com ([40.107.1.122]:9818 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 1gSk4o-00040d-4q; Fri, 30 Nov 2018 09:47:30 -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:X-MS-Exchange-SenderADCheck; bh=nwPCCGfAcxZwDlf5g+FZRsT+/JGdbf3P3Ziw3oDqzmM=; b=C3crMUvFR/CoeGyapQu0BJKg8jcfZk5Y+H/bnXMEKeI9xNQdalaTJwMz8d9EmS0xYrMi+F3iCENRQMPERbVC8E5yE0GpTA3mhE0QI4PvGTmWJlrr1yinqsoOTJJxIF9svbcJKlgwaPQZhEpIUNPQ5gpBPXmCSTr3W9eWa28RY3I= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:26 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:26 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 8/9] file-posix: account discard operations Thread-Index: AQHUiLuc8HWIQNBWUkCtasKHiB3i1g== Date: Fri, 30 Nov 2018 14:47:26 +0000 Message-ID: <20181130144705.77454-9-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:XTBgjggvHO46nwAjLNKe7NDJ0j0UassogzW75OJNCTpFhaeGEUCzfXhceAxQNGoc9I2Da24wWR8jUdW+3mYoK9KaQqPJjFJ8CB+2znBgLyP9V3+BC6vJlxQ1n0aqIAY4a8gLOYMCe5VhhWjSqgkRGloUqTn5GdALT7CsCrPcUaA= x-ms-office365-filtering-correlation-id: db2cfe13-9b99-4e4b-4f38-08d656d2be75 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(14444005)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001)(15650500001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: NJfXPnJ8cmddtFPIjt1ZfD2pwDXZe4imTa5EOS1z4EcdpqPp41BzR1k09IOZtYp/+qsIndsxja7/FYWRVgPSA8cGi8P4X/r+rWtvv83nz5WVP5Yd3fqFmvusGpHn1uD2sv6c6hs3S1wBiCViKmuy4E2xf22bttObHlGfqH4NlBVU4oLjPj3NotmsgeuL6cO8TmaheTJT48W+fkHAE3pTQk+7AJUstZQtGD9lmaxmcBvuAaahJMwU6kpQx9YgZ2YCY0ke71kSFqn9202XBBaiKc7x22tGkoJ+R24GKrYTIEVmhYBXo1w39ckN7TFbf5xy8DnJPPe1m6IrZJBlsWdW4Drk6gRepjQsUIPNoyXwc5Y= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: db2cfe13-9b99-4e4b-4f38-08d656d2be75 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:26.0105 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.122 Subject: [Qemu-devel] [PATCH v6 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 07bbdab953..1589dbf3ab 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -167,6 +167,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; @@ -2612,12 +2617,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( @@ -3114,10 +3132,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 Fri Nov 30 14:47:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1005977 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="F4S9Xshe"; 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 435y224rqCz9s9J for ; Sat, 1 Dec 2018 01:48:42 +1100 (AEDT) Received: from localhost ([::1]:60517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk5w-0005hv-58 for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2018 09:48:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSk4r-0005PB-GZ for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSk4p-00043N-IJ for qemu-devel@nongnu.org; Fri, 30 Nov 2018 09:47:33 -0500 Received: from mail-eopbgr10122.outbound.protection.outlook.com ([40.107.1.122]:9818 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 1gSk4p-00040d-4K; Fri, 30 Nov 2018 09:47:31 -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:X-MS-Exchange-SenderADCheck; bh=7ybzCbGM4RqwyyAAzITqWmdMU3yX7G/YfY8YJVDD4Hk=; b=F4S9XshesXwICie9ZthFup8OXDczb1+1RbzYEYDD29TWTWfmQ51fJMT4pWHfYpQ14KmV3j2gGtpbOYOaIGJivzvOz6Rw0sKBZChvZ4/kKlI16rBB1PBBKMoSJo67WojM0TM4EzMKttBFGDj39V/G2OYHCW6cxo9wDJhRwWmEmTs= Received: from AM0PR08MB3347.eurprd08.prod.outlook.com (52.134.94.148) by AM0PR08MB3410.eurprd08.prod.outlook.com (20.177.109.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 30 Nov 2018 14:47:27 +0000 Received: from AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01]) by AM0PR08MB3347.eurprd08.prod.outlook.com ([fe80::a0bd:dda4:d9e4:1d01%2]) with mapi id 15.20.1361.022; Fri, 30 Nov 2018 14:47:27 +0000 From: Anton Nefedov To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v6 9/9] qapi: query-blockstat: add driver specific file-posix stats Thread-Index: AQHUiLucluubp+yu+0GkR1cxAnlIFA== Date: Fri, 30 Nov 2018 14:47:27 +0000 Message-ID: <20181130144705.77454-10-anton.nefedov@virtuozzo.com> References: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20181130144705.77454-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0208.eurprd05.prod.outlook.com (2603:10a6:3:f9::32) To AM0PR08MB3347.eurprd08.prod.outlook.com (2603:10a6:208:5f::20) 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; AM0PR08MB3410; 20:yX2FEM+/v5zGx0AM/mtp3iLjWCnYC/BxV40BQ4kgV541zaWuDmXPIqdVbw1g3lpvb2D7uDVAtvnlPfMwyVe7Ixt3aSaAX8kJSz3VOEEATyv6s6vwvgNQs4q6z4pO6EF0j7SRB/URaAxwLudWGIoUHVWJU1W5EiCL2cb3BAjqrhc= x-ms-office365-filtering-correlation-id: 954cab5d-9b33-45e5-ea49-08d656d2bf19 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3410; x-ms-traffictypediagnostic: AM0PR08MB3410: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231453)(999002)(944501410)(52105112)(10201501046)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3410; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3410; x-forefront-prvs: 087223B4DA x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(1076002)(66066001)(52116002)(106356001)(6116002)(3846002)(7416002)(14444005)(26005)(105586002)(25786009)(256004)(102836004)(2351001)(386003)(186003)(97736004)(99286004)(76176011)(5660300001)(36756003)(6506007)(14454004)(44832011)(2906002)(6436002)(5640700003)(6512007)(6486002)(478600001)(8936002)(68736007)(8676002)(7736002)(2501003)(81166006)(446003)(486006)(11346002)(305945005)(2616005)(81156014)(107886003)(476003)(53936002)(6916009)(4326008)(54906003)(316002)(86362001)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3410; H:AM0PR08MB3347.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: flJVhgsIGxPzZHg30+zG8pHTR8iVg/T1kAxjkjRVLJXli2rQQIK3L1ZdmuP8qYypCVM8ITY5cSlhCE1sNvqQl+59CzK66syOuzsEkRaCOA/irVAaJXSWlpM+f3qvV9YRaxrojVagP2arirO2YWxmvwwW9tRySvE9qoM7lJDmHaZ5xylxpyu+Q/tE3fDVBseORw9lbHQojjwZOIVZ8gD0AIaF2vzUXK4a3Ee36JE2XflhUUlkOW5abUEOywJ75usS69Y1U7CD7W7Lhe+AiOQja86URaoiHRHEGEc04cL0q15GrtCzRxphEJEc6BCXxNOQewWG/jKULEuuzUZ8km7tBmuPzIDzfA2+i++6mgEwAJc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 954cab5d-9b33-45e5-ea49-08d656d2bf19 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2018 14:47:27.1093 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3410 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.122 Subject: [Qemu-devel] [PATCH v6 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 Reviewed-by: Vladimir Sementsov-Ogievskiy Acked-by: Markus Armbruster --- qapi/block-core.json | 38 ++++++++++++++++++++++++++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 9 +++++++++ block/file-posix.c | 32 ++++++++++++++++++++++++++++++++ block/qapi.c | 5 +++++ 6 files changed, 86 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 959358ccc4..b100e852c7 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -877,6 +877,41 @@ '*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: 4.0 +## +{ 'struct': 'BlockStatsSpecificFile', + 'data': { + 'discard-nb-ok': 'int', + 'discard-nb-failed': 'int', + 'discard-bytes-ok': 'int' } } + +## +# @BlockStatsSpecific: +# +# Block driver specific statistics +# +# Since: 4.0 +## +{ 'union': 'BlockStatsSpecific', + 'base': { 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + 'file': 'BlockStatsSpecificFile', + 'host_device': 'BlockStatsSpecificFile' } } + ## # @BlockStats: # @@ -892,6 +927,8 @@ # # @stats: A @BlockDeviceStats for the device. # +# @driver-specific: Optional driver-specific stats. (Since 4.0) +# # @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 +942,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 7f5453b45b..d6ee3e99c9 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -478,6 +478,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 811239ca23..5540f4f187 100644 --- a/block.c +++ b/block.c @@ -4327,6 +4327,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 1589dbf3ab..9c686961bc 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2660,6 +2660,36 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return 0; } +static BlockStatsSpecificFile get_blockstats_specific_file(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + return (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, + }; +} + +static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs) +{ + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_FILE; + stats->u.file = get_blockstats_specific_file(bs); + + return stats; +} + +static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs) +{ + BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1); + + stats->driver = BLOCKDEV_DRIVER_HOST_DEVICE; + stats->u.host_device = get_blockstats_specific_file(bs); + + return stats; +} + static QemuOptsList raw_create_opts = { .name = "raw-create-opts", .head = QTAILQ_HEAD_INITIALIZER(raw_create_opts.head), @@ -2771,6 +2801,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, @@ -3255,6 +3286,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 = hdev_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);