From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241837; cv=none; d=zoho.com; s=zohoarc; b=Z57wBYDDWYqv4xUbFvg2PKMKkQfH7b2L6SAuG55VFHQD2KJdLdUdEnbYVpRvV2NqIAnsEevpL+N8wNqLBRRaeNKNl22e/YHegzHsQI9J6nWSyerLSI8ubmNgY1qk459Fb9RpOl/Po5D6bK+6KAxNn+w5maTyo+Eie/Utge4XuR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241837; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4NBVgf6HKIrgh0I6GEgrezRBn3MLxrVYmjCeFruky54=; b=YyGAkfC5/vJFhYu7YzkcsHd0l09ZyggqT/t72ETUq4yElt0uM/CJNfwB6PXxHRZ/D+Q8JQdHBKjDcW7VrQHT8s6UwLRjyvDKeQwtjUph1nDiXalCDqH261rKdzF+5KCYvGSU4Mu+O3ZovbZQXdmBQurtU8m0cLUIanGelKgi9VY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241837180750.1810173961055; Mon, 23 Sep 2019 05:30:37 -0700 (PDT) Received: from localhost ([::1]:55926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNUB-0007r9-Gf for importer@patchew.org; Mon, 23 Sep 2019 08:30:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48177) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006tm-UN for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001nV-A2 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59134) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001hd-Kc; Mon, 23 Sep 2019 08:18:08 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI2-0007xx-IA; Mon, 23 Sep 2019 15:18:02 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 1/9] qapi: group BlockDeviceStats fields Date: Mon, 23 Sep 2019 15:17:29 +0300 Message-Id: <20190923121737.83281-2-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 e6edd641f1..5ab554b54a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -867,12 +867,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.1= 5.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 @@ -925,14 +925,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': 'in= t', + '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'], '*rd_latency_histogram': 'BlockLatencyHistogramInfo', --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569242251; cv=none; d=zoho.com; s=zohoarc; b=jLBcE/u8hODGAWlxmLTxAo1933VUxugzaX+YBZ7StcXhgzJnX7w4tk209YSKUe7fh+kIkwDKxzNiN+4PEHT8CdkXbUdeKH9xyZ2ud/tFTwtxfCtlsywcEc2kRvvechoEnboaoMxaQXLji6sxHdNOhgqZOtm/YT7SHofUh8PTLrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569242251; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=84GF017aPQRxnhcgf+ejqaFWZhSBVaK2Whp22Cjgf5s=; b=BzuxCj7OOzioigdvPM54t8DjUbkbgfpGh9D/P+WuiPL0lXf32fUz0pZeiCUtWl+t0DzxQUp803ZfHY9YV0w0omN9nBdHNqyPPC6GvipzqhXb+Hns/t9Wu89rQdUQ822bphQfj1sp1nPCIJfT5djwRvoSsnBnqcTr0LvBmCiEjR8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569242251352567.9838983926027; Mon, 23 Sep 2019 05:37:31 -0700 (PDT) Received: from localhost ([::1]:55988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNas-0004cM-5j for importer@patchew.org; Mon, 23 Sep 2019 08:37:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48243) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIH-0006uk-TM for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNIE-0001nv-5b for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:17 -0400 Received: from relay.sw.ru ([185.231.240.75]:59127) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001hb-Kl; Mon, 23 Sep 2019 08:18:08 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI3-0007xx-2Q; Mon, 23 Sep 2019 15:18:03 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 2/9] qapi: add unmap to BlockDeviceStats Date: Mon, 23 Sep 2019 15:17:30 +0300 Message-Id: <20190923121737.83281-3-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 5ab554b54a..7d3e05891c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -860,6 +860,8 @@ # # @wr_bytes: The number of bytes written by the device. # +# @unmap_bytes: The number of bytes unmapped by the device (Since 4.2) +# # @rd_operations: The number of read operations performed by the device. # # @wr_operations: The number of write operations performed by the device. @@ -867,6 +869,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.2) +# # @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). @@ -874,6 +879,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.2) +# # @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 @@ -885,6 +893,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 anoth= er +# request (Since 4.2) +# # @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). @@ -898,6 +909,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.2) +# # @invalid_rd_operations: The number of invalid read operations # performed by the device (Since 2.5) # @@ -907,6 +921,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 perfor= med +# by the device (Since 4.2) +# # @account_invalid: Whether invalid operations are included in the # last access statistics (Since 2.5) # @@ -925,18 +942,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': 'i= nt', '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'], '*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, }; =20 diff --git a/block/qapi.c b/block/qapi.c index 7ee2ee065d..69c35c4196 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -440,24 +440,30 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds= , BlockBackend *blk) =20 ds->rd_bytes =3D stats->nr_bytes[BLOCK_ACCT_READ]; ds->wr_bytes =3D stats->nr_bytes[BLOCK_ACCT_WRITE]; + ds->unmap_bytes =3D stats->nr_bytes[BLOCK_ACCT_UNMAP]; ds->rd_operations =3D stats->nr_ops[BLOCK_ACCT_READ]; ds->wr_operations =3D stats->nr_ops[BLOCK_ACCT_WRITE]; + ds->unmap_operations =3D stats->nr_ops[BLOCK_ACCT_UNMAP]; =20 ds->failed_rd_operations =3D stats->failed_ops[BLOCK_ACCT_READ]; ds->failed_wr_operations =3D stats->failed_ops[BLOCK_ACCT_WRITE]; ds->failed_flush_operations =3D stats->failed_ops[BLOCK_ACCT_FLUSH]; + ds->failed_unmap_operations =3D stats->failed_ops[BLOCK_ACCT_UNMAP]; =20 ds->invalid_rd_operations =3D stats->invalid_ops[BLOCK_ACCT_READ]; ds->invalid_wr_operations =3D stats->invalid_ops[BLOCK_ACCT_WRITE]; ds->invalid_flush_operations =3D stats->invalid_ops[BLOCK_ACCT_FLUSH]; + ds->invalid_unmap_operations =3D stats->invalid_ops[BLOCK_ACCT_UNMAP]; =20 ds->rd_merged =3D stats->merged[BLOCK_ACCT_READ]; ds->wr_merged =3D stats->merged[BLOCK_ACCT_WRITE]; + ds->unmap_merged =3D stats->merged[BLOCK_ACCT_UNMAP]; ds->flush_operations =3D stats->nr_ops[BLOCK_ACCT_FLUSH]; ds->wr_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_WRITE]; ds->rd_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_READ]; ds->flush_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_FLUSH]; + ds->unmap_total_time_ns =3D stats->total_time_ns[BLOCK_ACCT_UNMAP]; =20 ds->has_idle_time_ns =3D 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 3dd3ca5708..9c09ee3917 100644 --- a/tests/qemu-iotests/227.out +++ b/tests/qemu-iotests/227.out @@ -15,6 +15,8 @@ Testing: -drive driver=3Dnull-co,read-zeroes=3Don,if=3Dvi= rtio { "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=3Dnull-co,read-zeroes=3Don,if=3D= 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, @@ -74,6 +80,8 @@ Testing: -drive driver=3Dnull-co,if=3Dnone { "device": "none0", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -83,13 +91,17 @@ Testing: -drive driver=3Dnull-co,if=3Dnone "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, @@ -163,6 +175,8 @@ Testing: -blockdev driver=3Dnull-co,read-zeroes=3Don,no= de-name=3Dnull -device virtio-b { "device": "", "stats": { + "unmap_operations": 0, + "unmap_merged": 0, "flush_total_time_ns": 0, "wr_highest_offset": 0, "wr_total_time_ns": 0, @@ -172,13 +186,17 @@ Testing: -blockdev driver=3Dnull-co,read-zeroes=3Don,= node-name=3Dnull -device virtio-b "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, --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241586; cv=none; d=zoho.com; s=zohoarc; b=LD+HH72nsQO2iQv9zGxjvBPFbkMEwhzygvgmcz64Jm4YkoiK0lHH+e4Oeg4gTQQ9rxdfYUE7+aTGz+LQJssmuflh81f+pBa7mJjTAhXDiEjj7aMNDOsg+VuHnuFOGugwLcJHfJd827jC2jTJ9RTpDbwQkyIkhdexDEhQrQU4xZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241586; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=L7woUZ/tGRUDml7w8w2u8fJkmZ4Ie1OxzIP3Wwe/ugc=; b=b757N8sSxfcKEdvtXhK9ZiJZRgWaHxVp//yLHOwklIXRmvZIvv85DIsMX9PT2JIGjEYbiE/0yxAeAGNVyRgimpZImxXzuX2TdCm9xwSUCUJhlFZoDSiyZYMsUM/kgtcm0hxOusXQc9ftOAnQgITndyhi/QNFbVGWZTWQyZhPTjU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241586431728.4978748645592; Mon, 23 Sep 2019 05:26:26 -0700 (PDT) Received: from localhost ([::1]:55898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNQ8-0004q9-Oz for importer@patchew.org; Mon, 23 Sep 2019 08:26:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48171) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006tg-SO for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001nJ-A8 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001he-Qd; Mon, 23 Sep 2019 08:18:08 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI3-0007xx-NA; Mon, 23 Sep 2019 15:18:03 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 3/9] block: add empty account cookie type Date: Mon, 23 Sep 2019 15:17:31 +0300 Message-Id: <20190923121737.83281-4-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Each block_acct_done/failed call is designed to correspond to a previous block_acct_start call, which initializes the stats cookie. However sometimes it is not the case, e.g. some error paths might report the same cookie twice because it is hard to accurately track if the cookie was reported yet or not. This patch cleans the cookie after report. (Note: block_acct_failed/done without a previous block_acct_start at all should be avoided. Uninitialized cookie might hold a garbage value and there is still "< BLOCK_MAX_IOTYPE" assertion for that) It will be particularly useful in ide code where it's hard to keep track whether the request done its accounting or not: in the following patch of the series, trim requests will do the accounting separately. Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy --- 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; =20 enum BlockAcctType { + BLOCK_ACCT_NONE =3D 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, =20 assert(cookie->type < BLOCK_MAX_IOTYPE); =20 + if (cookie->type =3D=3D BLOCK_ACCT_NONE) { + return; + } + qemu_mutex_lock(&stats->lock); =20 if (failed) { @@ -217,6 +221,8 @@ static void block_account_one_io(BlockAcctStats *stats,= BlockAcctCookie *cookie, } =20 qemu_mutex_unlock(&stats->lock); + + cookie->type =3D BLOCK_ACCT_NONE; } =20 void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie) --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241340; cv=none; d=zoho.com; s=zohoarc; b=Vs2GbljJV7pODVkY4jKgYZq17M7jAY/rfE8P5BwWKSpFehUJKp9e5yQhQRQpFlkr8OoiwVHAiOf8+KLt09iJ6B8uA7sWdLM3C7VyFbmhfWdqUuOrYrv7osupm9HDW+gAxLoHoEWe+e12lLdQAiw03+3nLVMjdje2RGtgYa0AE4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241340; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FcQEDyfiK9Xp4d1j7pKn/+KwDlYZxB6gmlrnZZyzRGY=; b=TIcdwMisypK9rV9kqsZavtXjCMEScHHPuUPbSxqxXcxOe6VJUtnZf2o5naKEuzdrxZ7wSWqEI4IZLjpGPfvENngxojDtN7dooeJwZWtjF0HDCLTdLvHQzpf/gdQZmijhyiTnAHAM9wpU2f1yrN7JCuHv86ALOBzPcBSMhYd2Gp4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241340454119.45928893427424; Mon, 23 Sep 2019 05:22:20 -0700 (PDT) Received: from localhost ([::1]:55848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNM9-0000sR-Os for importer@patchew.org; Mon, 23 Sep 2019 08:22:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48174) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006tj-S8 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001nB-A2 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59142) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001hn-KT; Mon, 23 Sep 2019 08:18:07 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI4-0007xx-7U; Mon, 23 Sep 2019 15:18:04 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 4/9] ide: account UNMAP (TRIM) operations Date: Mon, 23 Sep 2019 15:17:32 +0300 Message-Id: <20190923121737.83281-5-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 e6e54c6c9a..754ff4dc34 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -442,6 +442,14 @@ static void ide_issue_trim_cb(void *opaque, int ret) TrimAIOCB *iocb =3D opaque; IDEState *s =3D iocb->s; =20 + if (iocb->i >=3D 0) { + if (ret >=3D 0) { + block_acct_done(blk_get_stats(s->blk), &s->acct); + } else { + block_acct_failed(blk_get_stats(s->blk), &s->acct); + } + } + if (ret >=3D 0) { while (iocb->j < iocb->qiov->niov) { int j =3D iocb->j; @@ -459,10 +467,14 @@ static void ide_issue_trim_cb(void *opaque, int ret) } =20 if (!ide_sect_range_ok(s, sector, count)) { + block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_U= NMAP); iocb->ret =3D -EINVAL; goto done; } =20 + block_acct_start(blk_get_stats(s->blk), &s->acct, + count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNM= AP); + /* Got an entry! Submit and exit. */ iocb->aiocb =3D blk_aio_pdiscard(s->blk, sector << BDRV_SECTOR_BITS, --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241596; cv=none; d=zoho.com; s=zohoarc; b=aO96WI6maRCmiHVpfF4EWOjb+sV/ioI8B1x25oxa9cBhY3dzSLM+1qcoeep5Bmms3PEAE2DZxmBMtQkxG7CoB+TLS9CblgPpx2SuPRcZ0CZIBaW180HLalzxtqYqOw4o+hvh9bVu1TN+trXCuzv5MgxfndxpPZh/Xb5iSVGSC2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241596; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yZGsq84XxyPsPnjlSDs6eceE/nZLB8DMDWSD5oeqPms=; b=be1Nk0zVG8Ii+x6gJuAYOE1KlMJe5l5tNpG0kLv6/txfhbpUWh65kfz28Jjkpx2Jv6cTD6ZvGz5QB91pVRnVGgea89LdFluMjMME44+I01NVMJ3Vr9XKJrEV1U5ZgBkT9IqiOFJCDJtUFJpW6yeEzA+cOc2PGL3+cmrbpWrzLi0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241596306576.8040671431972; Mon, 23 Sep 2019 05:26:36 -0700 (PDT) Received: from localhost ([::1]:55902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNQG-00052i-Re for importer@patchew.org; Mon, 23 Sep 2019 08:26:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48173) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006ti-Rj for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001nT-B8 for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59146) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001hp-Km; Mon, 23 Sep 2019 08:18:08 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI4-0007xx-MB; Mon, 23 Sep 2019 15:18:04 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 5/9] scsi: store unmap offset and nb_sectors in request struct Date: Mon, 23 Sep 2019 15:17:33 +0300 Message-Id: <20190923121737.83281-6-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" it allows to report it in the error handler Signed-off-by: Anton Nefedov --- hw/scsi/scsi-disk.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 915641a0f1..b3dd21800d 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1608,8 +1608,6 @@ static void scsi_unmap_complete_noio(UnmapCBData *dat= a, int ret) { SCSIDiskReq *r =3D data->r; SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req.dev); - uint64_t sector_num; - uint32_t nb_sectors; =20 assert(r->req.aiocb =3D=3D NULL); if (scsi_disk_req_check_error(r, ret, false)) { @@ -1617,16 +1615,18 @@ static void scsi_unmap_complete_noio(UnmapCBData *d= ata, int ret) } =20 if (data->count > 0) { - sector_num =3D ldq_be_p(&data->inbuf[0]); - nb_sectors =3D ldl_be_p(&data->inbuf[8]) & 0xffffffffULL; - if (!check_lba_range(s, sector_num, nb_sectors)) { + r->sector =3D ldq_be_p(&data->inbuf[0]) + * (s->qdev.blocksize / BDRV_SECTOR_SIZE); + r->sector_count =3D (ldl_be_p(&data->inbuf[8]) & 0xffffffffULL) + * (s->qdev.blocksize / BDRV_SECTOR_SIZE); + if (!check_lba_range(s, r->sector, r->sector_count)) { scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); goto done; } =20 r->req.aiocb =3D blk_aio_pdiscard(s->qdev.conf.blk, - sector_num * s->qdev.blocksize, - nb_sectors * s->qdev.blocksize, + r->sector * BDRV_SECTOR_SIZE, + r->sector_count * BDRV_SECTOR_SIZE, scsi_unmap_complete, data); data->count--; data->inbuf +=3D 16; --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241352; cv=none; d=zoho.com; s=zohoarc; b=kYT+mvOcrV2hSM0aExDA1oxeiq0eIgNBZKc5LDRCwSygu/ccBPfXhWg1kilkdlvgZK8XUhc3kkrSjrhf1Dh0agtXhL1h+TTEFmHb+Z4YddmIkrzpTTdKE6OVG1dYT4tSvHOIkIBcjIVwhAE+UZjwS4hlty5L9QS8kKuzGGLbzzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241352; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rxHMi5p1WcWws0g4z/vVtjhq1K+Ihc1SWzm9rjWBQRk=; b=l5DeWNKgxbBXIR7NqOlX/OADUmLhmbfej22blDONgFLrpcInvAqSKapRdJ/SbLFiteA8JcPUDgscPaMjbeXCcuGWO6HNcp+aQGSHQVecoXf7VHpIPL/qoAVToADtQwhzr5nNbKy2sIrFycGbLxJlf7RkVYqnwQZXQMfP1CQClFk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241352645765.8221590932459; Mon, 23 Sep 2019 05:22:32 -0700 (PDT) Received: from localhost ([::1]:55850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNMM-0001Bb-P1 for importer@patchew.org; Mon, 23 Sep 2019 08:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48170) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006tf-SG for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001nb-DN for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59148) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001hr-EX; Mon, 23 Sep 2019 08:18:07 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI5-0007xx-0t; Mon, 23 Sep 2019 15:18:05 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 6/9] scsi: move unmap error checking to the complete callback Date: Mon, 23 Sep 2019 15:17:34 +0300 Message-Id: <20190923121737.83281-7-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 b3dd21800d..a002fdabe8 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1610,9 +1610,6 @@ static void scsi_unmap_complete_noio(UnmapCBData *dat= a, int ret) SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req.dev); =20 assert(r->req.aiocb =3D=3D NULL); - if (scsi_disk_req_check_error(r, ret, false)) { - goto done; - } =20 if (data->count > 0) { r->sector =3D ldq_be_p(&data->inbuf[0]) @@ -1650,7 +1647,12 @@ static void scsi_unmap_complete(void *opaque, int re= t) r->req.aiocb =3D NULL; =20 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)); } =20 --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569242182; cv=none; d=zoho.com; s=zohoarc; b=U/JApOPRW/TdIp6klLE9KsT0zx57ZVW0dnzX+PJZpcnwaxdknde9ejLUgYGeyoEui8yeWhuDPGfNS+O8bKBFUBIbgAQ4MjzrsbVWfU2yRUsLQhH7U6pHqlUW2bxbsS7qRrCS7XGMVTX9cLA8GgwcBevN1XXmYxMJnnyXrfte0gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569242182; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zfG44J/N/9v0YVNYhsnVyOy4bNLEbG8ZNIuWrjFhaSw=; b=IRusdMRL1U0oNUbC3z/xjw0vCZVraGJuWSJH0X0cgZ2SpwVzFMbNXR1gyCzdYMiGrfHQC021npaOaise2YlwPyumhAFuASq7waR6+gwNJinwTMAG4ulzFb73ccXDqu464cpWOONcNYaaKJVtEvHtaQNAIWougRTaj2b/TT+eQA0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156924218239028.075698149915752; Mon, 23 Sep 2019 05:36:22 -0700 (PDT) Received: from localhost ([::1]:55970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNZj-0003Xt-C7 for importer@patchew.org; Mon, 23 Sep 2019 08:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006tl-UQ for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001n2-9O for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001i2-5y; Mon, 23 Sep 2019 08:18:07 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI5-0007xx-Bm; Mon, 23 Sep 2019 15:18:05 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 7/9] scsi: account unmap operations Date: Mon, 23 Sep 2019 15:17:35 +0300 Message-Id: <20190923121737.83281-8-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 a002fdabe8..68b1675fd9 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1617,10 +1617,16 @@ static void scsi_unmap_complete_noio(UnmapCBData *d= ata, int ret) r->sector_count =3D (ldl_be_p(&data->inbuf[8]) & 0xffffffffULL) * (s->qdev.blocksize / BDRV_SECTOR_SIZE); 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; } =20 + block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, + r->sector_count * BDRV_SECTOR_SIZE, + BLOCK_ACCT_UNMAP); + r->req.aiocb =3D blk_aio_pdiscard(s->qdev.conf.blk, r->sector * BDRV_SECTOR_SIZE, r->sector_count * BDRV_SECTOR_SIZE, @@ -1647,10 +1653,11 @@ static void scsi_unmap_complete(void *opaque, int r= et) r->req.aiocb =3D NULL; =20 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)); @@ -1682,6 +1689,7 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, u= int8_t *inbuf) } =20 if (blk_is_read_only(s->qdev.conf.blk)) { + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNM= AP); scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED)); return; } @@ -1697,10 +1705,12 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r,= uint8_t *inbuf) return; =20 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; =20 invalid_field: + block_acct_invalid(blk_get_stats(s->qdev.conf.blk), BLOCK_ACCT_UNMAP); scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); } =20 --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241587; cv=none; d=zoho.com; s=zohoarc; b=LMn2Gl5XwcdoqleUFAMXFbiFDjJKtpLeu2MwvD1l758Vhle22nOOvqgmVSpxysUqIF7CsqsFTlI6J6xpXVISgD6DH0RTVpBN2xZe8UnFR0ARDGI41C8iAk4yzgg7eksT8lXfN6PWn/VoV02lRXhqijl/QURjplCWFt7Y6aCnTbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241587; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=stC8wD9lZdOoLlphAZs0KI3JsidsRQgOX4Gerekts2U=; b=Ax5ubNIuwPADVc5nCq3q4YFD8b2OxNJbR7zPKztFcCNT+8KN9xnpnCMgg06Pv6BZkqDOFaDtAG5Ua3QW4BFNVxURoxxLRjoRtuzG02qAiYceApRIF5/pSjAR9PPF7mC1UF7M4rsDd6nYfLtAvGR71Ne0j0aRUtxSvPYH5tGUjMU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241587559384.4052614642477; Mon, 23 Sep 2019 05:26:27 -0700 (PDT) Received: from localhost ([::1]:55900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNQ9-0004rn-RU for importer@patchew.org; Mon, 23 Sep 2019 08:26:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48175) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006tk-SP for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNID-0001nE-Ab for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001iF-6P; Mon, 23 Sep 2019 08:18:07 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI5-0007xx-OV; Mon, 23 Sep 2019 15:18:05 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 8/9] file-posix: account discard operations Date: Mon, 23 Sep 2019 15:17:36 +0300 Message-Id: <20190923121737.83281-9-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index f12c06de2d..f3934c4e10 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -161,6 +161,11 @@ typedef struct BDRVRawState { bool needs_alignment; bool drop_cache; bool check_cache_dropped; + struct { + uint64_t discard_nb_ok; + uint64_t discard_nb_failed; + uint64_t discard_bytes_ok; + } stats; =20 PRManager *pr_mgr; } BDRVRawState; @@ -2660,11 +2665,22 @@ static void coroutine_fn raw_co_invalidate_cache(Bl= ockDriverState *bs, #endif /* !__linux__ */ } =20 +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 +=3D nbytes; + } +} + static coroutine_fn int raw_do_pdiscard(BlockDriverState *bs, int64_t offset, int bytes, bool blkd= ev) { BDRVRawState *s =3D bs->opaque; RawPosixAIOData acb; + int ret; =20 acb =3D (RawPosixAIOData) { .bs =3D bs, @@ -2678,7 +2694,9 @@ raw_do_pdiscard(BlockDriverState *bs, int64_t offset,= int bytes, bool blkdev) acb.aio_type |=3D QEMU_AIO_BLKDEV; } =20 - return raw_thread_pool_submit(bs, handle_aiocb_discard, &acb); + ret =3D raw_thread_pool_submit(bs, handle_aiocb_discard, &acb); + raw_account_discard(s, bytes, ret); + return ret; } =20 static coroutine_fn int @@ -3301,10 +3319,12 @@ static int fd_open(BlockDriverState *bs) static coroutine_fn int hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { + BDRVRawState *s =3D bs->opaque; int ret; =20 ret =3D fd_open(bs); if (ret < 0) { + raw_account_discard(s, bytes, ret); return ret; } return raw_do_pdiscard(bs, offset, bytes, true); --=20 2.17.1 From nobody Fri May 3 16:34:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1569241814; cv=none; d=zoho.com; s=zohoarc; b=ohh6Kf8zOEgdswCpsEK6PNXwDxUOO4v79PgCrRmb8Pgxz2b2J77FMUQK5suAlszTUy3V4VO9bcoU5Ee0w7EtLExxnVgSuBOoGbEh0N2jKJfUYW9L9lZr5AIyzQtQ7Q3pTiln71hwh0w+L6MTZ4j7Ytod0tc28u1lrIdS37XF/I0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569241814; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7YAZWGKoqMdFsPLpa7NV43YjwHizOQkgdP3itoa2rec=; b=Om3y57TgTNw32BOF2AU9OQgxNKWGAXx4I09BIgRC9hfMeSCn5ZGkyDhK/bIGSW/r/LsyeYXGWJAfUI4W0/QkWtY3Bso4eDVIuiu7Qw/S5XEtVzAIXYEBEpfjitab27Lb5VD1lIaAMAxb2DthM87PAdVlTVmy3wzSxjj9Ne3OH5U= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569241814313142.8927709112362; Mon, 23 Sep 2019 05:30:14 -0700 (PDT) Received: from localhost ([::1]:55924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNTl-0007gT-0Q for importer@patchew.org; Mon, 23 Sep 2019 08:30:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48179) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006to-Ts for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCNIE-0001nq-4y for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001iP-Kz; Mon, 23 Sep 2019 08:18:08 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCNI6-0007xx-3k; Mon, 23 Sep 2019 15:18:06 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 9/9] qapi: query-blockstat: add driver specific file-posix stats Date: Mon, 23 Sep 2019 15:17:37 +0300 Message-Id: <20190923121737.83281-10-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> References: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, berto@igalia.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, Anton Nefedov , pbonzini@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 7d3e05891c..859acea014 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -960,6 +960,41 @@ '*wr_latency_histogram': 'BlockLatencyHistogramInfo', '*flush_latency_histogram': 'BlockLatencyHistogramInfo' } } =20 +## +# @BlockStatsSpecificFile: +# +# File driver statistics +# +# @discard-nb-ok: The number of successful 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.2 +## +{ 'struct': 'BlockStatsSpecificFile', + 'data': { + 'discard-nb-ok': 'uint64', + 'discard-nb-failed': 'uint64', + 'discard-bytes-ok': 'uint64' } } + +## +# @BlockStatsSpecific: +# +# Block driver specific statistics +# +# Since: 4.2 +## +{ 'union': 'BlockStatsSpecific', + 'base': { 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + 'file': 'BlockStatsSpecificFile', + 'host_device': 'BlockStatsSpecificFile' } } + ## # @BlockStats: # @@ -975,6 +1010,8 @@ # # @stats: A @BlockDeviceStats for the device. # +# @driver-specific: Optional driver-specific stats. (Since 4.2) +# # @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 @@ -988,6 +1025,7 @@ { 'struct': 'BlockStats', 'data': {'*device': 'str', '*qdev': 'str', '*node-name': 'str', 'stats': 'BlockDeviceStats', + '*driver-specific': 'BlockStatsSpecific', '*parent': 'BlockStats', '*backing': 'BlockStats'} } =20 diff --git a/include/block/block.h b/include/block/block.h index 37c9de7446..792bb826db 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -501,6 +501,7 @@ int bdrv_get_flags(BlockDriverState *bs); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs, Error **errp); +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 0422acdf1c..2b113eb3c7 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -366,6 +366,7 @@ struct BlockDriver { int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi); ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs, Error **errp); + BlockStatsSpecific *(*bdrv_get_specific_stats)(BlockDriverState *bs); =20 int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov, diff --git a/block.c b/block.c index 5944124845..5d3a5a6b95 100644 --- a/block.c +++ b/block.c @@ -5155,6 +5155,15 @@ ImageInfoSpecific *bdrv_get_specific_info(BlockDrive= rState *bs, return NULL; } =20 +BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs) +{ + BlockDriver *drv =3D 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 f3934c4e10..695fcf740d 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2753,6 +2753,36 @@ static int raw_get_info(BlockDriverState *bs, BlockD= riverInfo *bdi) return 0; } =20 +static BlockStatsSpecificFile get_blockstats_specific_file(BlockDriverStat= e *bs) +{ + BDRVRawState *s =3D bs->opaque; + return (BlockStatsSpecificFile) { + .discard_nb_ok =3D s->stats.discard_nb_ok, + .discard_nb_failed =3D s->stats.discard_nb_failed, + .discard_bytes_ok =3D s->stats.discard_bytes_ok, + }; +} + +static BlockStatsSpecific *raw_get_specific_stats(BlockDriverState *bs) +{ + BlockStatsSpecific *stats =3D g_new(BlockStatsSpecific, 1); + + stats->driver =3D BLOCKDEV_DRIVER_FILE; + stats->u.file =3D get_blockstats_specific_file(bs); + + return stats; +} + +static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs) +{ + BlockStatsSpecific *stats =3D g_new(BlockStatsSpecific, 1); + + stats->driver =3D BLOCKDEV_DRIVER_HOST_DEVICE; + stats->u.host_device =3D get_blockstats_specific_file(bs); + + return stats; +} + static QemuOptsList raw_create_opts =3D { .name =3D "raw-create-opts", .head =3D QTAILQ_HEAD_INITIALIZER(raw_create_opts.head), @@ -2960,6 +2990,7 @@ BlockDriver bdrv_file =3D { .bdrv_get_info =3D raw_get_info, .bdrv_get_allocated_file_size =3D raw_get_allocated_file_size, + .bdrv_get_specific_stats =3D raw_get_specific_stats, .bdrv_check_perm =3D raw_check_perm, .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, @@ -3438,6 +3469,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_get_info =3D raw_get_info, .bdrv_get_allocated_file_size =3D raw_get_allocated_file_size, + .bdrv_get_specific_stats =3D hdev_get_specific_stats, .bdrv_check_perm =3D raw_check_perm, .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, diff --git a/block/qapi.c b/block/qapi.c index 69c35c4196..9a5d0c9b27 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -543,6 +543,11 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverSta= te *bs, =20 s->stats->wr_highest_offset =3D stat64_get(&bs->wr_highest_offset); =20 + s->driver_specific =3D bdrv_get_specific_stats(bs); + if (s->driver_specific) { + s->has_driver_specific =3D true; + } + if (bs->file) { s->has_parent =3D true; s->parent =3D bdrv_query_bds_stats(bs->file->bs, blk_level); --=20 2.17.1