From nobody Sun Apr 28 12:48:52 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=1567785965; cv=none; d=zoho.com; s=zohoarc; b=kTJUkahOciyMxEdK+ciiv91DV+uC8wemQ+8lfFTrV9QAbziT1jjtYiCY+Imzf0zYANL5DK52DK6UyoHF3N3vOTjCazprP83EUKBxeYfWciAnRlE1wnI88sJx7qRTRZCKTOE2vamg2+iSm2VfECVOyp/9e19BYH7sHnuMuAOd6Xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567785965; 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=d3KCJiIKcG3eHKIQ53VLIVyVTwASJ7S4p6N9SLfXfg0aYaVv4ODcsbe+SuUlwkbaZQNscKAriLbXvG3jADViazt3Y9RTaN+KPvpngnnYDg+g7AbaBABQp1K4j9wPD86jN4h9Ky3myuqBrJQLpO7MRkrKFIE8Og8cexSHsxAGh2I= 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 1567785965741789.8858290765953; Fri, 6 Sep 2019 09:06:05 -0700 (PDT) Received: from localhost ([::1]:58032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GkI-0005F2-U5 for importer@patchew.org; Fri, 06 Sep 2019 12:05:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51320) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgC-0002Jh-H0 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgB-0004yD-C3 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:44 -0400 Received: from relay.sw.ru ([185.231.240.75]:37874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6Gg8-0004iv-9t; Fri, 06 Sep 2019 12:01:40 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6Gg6-0005vz-AZ; Fri, 06 Sep 2019 19:01:38 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:12 +0300 Message-Id: <20190906160120.70239-2-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 1/9] qapi: group BlockDeviceStats fields 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 Sun Apr 28 12:48:52 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=1567786419; cv=none; d=zoho.com; s=zohoarc; b=ive3iZQwxbLphVhFYgaxKxcQnuveYkJjloffhpXfnN4ROx8VyzgNEQzBjgIwrzlE4WGaGYIQwBAumBW74261VgBt/2AQ5HaWomVBZVkvffcYup7n0TVKJf1tVrr5Iw7qjJsWz6XiH/kb90CL419LSOHv6AL1SayKEuGsexi+fZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786419; 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=ro6nKwUClev6j/u3dUQpJHcJ8qoOaPJ7Mw8pX0jZfqQ=; b=JY5VZcfrXzWNFq754q5LIEBwEkVJB+gp9tjswKCnAJJuE886EtnwUuKTo1D4niPNQQXK+FAvuhQl3fnFOeC/OfYqPaqRjHxe3FriSLCw2cS0APlZT0t2sACvDqT5fIg6RjdHe1BTSRjYBbB2k6Gz0aor1qQFc4OzVBisch4MR/Q= 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 1567786419811145.61611084660478; Fri, 6 Sep 2019 09:13:39 -0700 (PDT) Received: from localhost ([::1]:58158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Gri-0006Ik-Jt for importer@patchew.org; Fri, 06 Sep 2019 12:13:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51378) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgF-0002ON-4n for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgD-00052G-2o for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:46 -0400 Received: from relay.sw.ru ([185.231.240.75]:37876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6Gg9-0004nI-2b; Fri, 06 Sep 2019 12:01:41 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6Gg7-0005vz-Nf; Fri, 06 Sep 2019 19:01:39 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:13 +0300 Message-Id: <20190906160120.70239-3-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 2/9] qapi: add unmap to BlockDeviceStats 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 15f1030264..3356a1dc59 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 Sun Apr 28 12:48:52 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=1567786545; cv=none; d=zoho.com; s=zohoarc; b=SNrRbUMrC0VuUa7SzHuUEqCtAp0JI7x+mstUKtUG3b6WpJ5hDm0VRupIeBLtRyw0YfSuRq8YEHVYtpZh+yhJYvbLC7yu9SXBiaBREhKqpPt6ieejpXi94WROBZWrnGXI12SddDec+3wmmPHxiogav0AN+oeetVCbYJWAqMLQGuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786545; 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=giwCHqu9e/Eoy8uz4JYUa9cHU/L5+p/jHAETAbQ17u8=; b=ZG4XrxZygynSQH7alMPfWDRMCCZsg3GBOpp3v0PU4zRzAtrGQU9Wf3+6qnI1SKG/RDfxaBe4HqyDEGrMF06qQ2HHOj+d3wBKSdH+5t/48l42F2bNQDXJcPwFPkxkKhwglVQ28XkKiLNYRyV2EUo61DIruraDI4GuCJSyIkA3OFQ= 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 156778654507024.415558044160548; Fri, 6 Sep 2019 09:15:45 -0700 (PDT) Received: from localhost ([::1]:58176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Gtj-0008Fl-7r for importer@patchew.org; Fri, 06 Sep 2019 12:15:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51388) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgF-0002On-Qh for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgE-00054y-8y for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:47 -0400 Received: from relay.sw.ru ([185.231.240.75]:37890) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgB-0004wW-A0; Fri, 06 Sep 2019 12:01:43 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgA-0005vz-1b; Fri, 06 Sep 2019 19:01:42 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:14 +0300 Message-Id: <20190906160120.70239-4-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 3/9] block: add empty account cookie type 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 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 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 Sun Apr 28 12:48:52 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=1567786265; cv=none; d=zoho.com; s=zohoarc; b=K2nA+uc/NpbMD9aNJlt3dClGhExytkvsCgoe5ZBj/KdAJILTlVTTab5q1M2uZTtPZzgMuHIGVdNhQidqQ8q5vKk3NQ0oYZqXf8LVZORiK04+aoSTZNU1+iEF+DEVjnqNh95/RlCi+w9YmGJqAMJmToo1knIIRpTkTr1xkljPtRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786265; 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=HdC4T6/qomY1765GBuRCZGu6y0Ki1IeHuHqwxsc6L2eux9Fz/tMi/aNk8KvBf80WVOxmY5FcaWZTZ5K+jdfvMY1D1hD+qjHjyqrv5ysbKO94JC3A1WOkYGsAQ67PdpztUIR0S9SxKW834Hva6j2XwvyfObUn+uldLPf9iaHqdVo= 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 1567786265733977.5448252248082; Fri, 6 Sep 2019 09:11:05 -0700 (PDT) Received: from localhost ([::1]:58136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GpC-0003ef-QM for importer@patchew.org; Fri, 06 Sep 2019 12:11:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51405) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgG-0002PZ-BE for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgF-000562-2i for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:48 -0400 Received: from relay.sw.ru ([185.231.240.75]:37896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgC-0004xn-9X; Fri, 06 Sep 2019 12:01:44 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgA-0005vz-TQ; Fri, 06 Sep 2019 19:01:42 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:15 +0300 Message-Id: <20190906160120.70239-5-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 4/9] ide: account UNMAP (TRIM) operations 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 Sun Apr 28 12:48:52 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=1567785976; cv=none; d=zoho.com; s=zohoarc; b=cWV5MiWje3PwYCsDH6kiDgZZC0jltvY7q0mLpIZGKbGy04CDic1qqcUrT0MNdapGOVHJQbgYK/x4ZGw28xEa3M7lsCHNVUcKRJRhqvpkMTlKC46uS1OSPCxr1ZqtkiT6QAGKvkvY3ZK5T3pVYQpzZim/iSdSExNA7Cp8qWN4ZHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567785976; 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=XKl1zAuaLY4tGbCyvgdHe82TI2x3OyLlQuF3szLV8CiXawIk1xd7gG9rtkrbscFqLCHRhAngTu/9cdJoOhitZ1lStZvrD+i+IHa94oyAT3XF6paKjWLQo0QZpm3XHujAiery6/a3DYnmvkGJS/wilIIoOD65ULqJwaMlTN/0Ab4= 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 156778597639998.75997228251481; Fri, 6 Sep 2019 09:06:16 -0700 (PDT) Received: from localhost ([::1]:58036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GkW-0005Hi-Uk for importer@patchew.org; Fri, 06 Sep 2019 12:06:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51445) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgH-0002R7-NO for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgG-00058M-8D for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:49 -0400 Received: from relay.sw.ru ([185.231.240.75]:37904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgD-00051V-6a; Fri, 06 Sep 2019 12:01:45 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgB-0005vz-RN; Fri, 06 Sep 2019 19:01:43 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:16 +0300 Message-Id: <20190906160120.70239-6-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 5/9] scsi: store unmap offset and nb_sectors in request struct 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 Sun Apr 28 12:48:52 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=1567786406; cv=none; d=zoho.com; s=zohoarc; b=jfpeggNDh7+0o/ui1/CkW/T0UQx3WznwryzKv1gZ6QRjPe9fipGLiFArnPp3h9P8pQCOd/SqEWcJClQCy93zIZLL1vtCrIHcunnjidwXH85F64xq5N29/EfG3Dl0ew4P0IQVby3lfR2csxJ/EsvfNssvGzVXr0/jRivm2nlRWnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786406; 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=DVsm8PEf5qqOG6Wmmof4qvF+RzdXaW9IpyeHdwyEV5MUrD/D3hgqFxUAIhawleApk76H7VcwRM94DmRw4y3yoRrn7O5/gyeU6hvb8YJ/QjCy7rZ2JJJOrnFzgOth3nEeOsPnd0DiQDwr9wcf89FgB7VG4nFKjPkX2IOz8u+m6FU= 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 1567786406368549.6385191827873; Fri, 6 Sep 2019 09:13:26 -0700 (PDT) Received: from localhost ([::1]:58156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GrS-0005yk-8K for importer@patchew.org; Fri, 06 Sep 2019 12:13:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgI-0002S0-Q6 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgH-00059h-4O for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:37910) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgD-000529-Sr; Fri, 06 Sep 2019 12:01:46 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgC-0005vz-LQ; Fri, 06 Sep 2019 19:01:44 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:17 +0300 Message-Id: <20190906160120.70239-7-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 6/9] scsi: move unmap error checking to the complete callback 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 Sun Apr 28 12:48:52 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=1567786522; cv=none; d=zoho.com; s=zohoarc; b=HTDpI2UCIbEUt8pc/83oONyAQskCp4p2/0ZeO2+Dq4vihmA2vsU6rzqhS5usJer+iEQo56p3BLP0vwIX2gg8h4R/gdQmqjbMprhTgPQ2zvexskQGvfz4q1fjDafNJVQMMMNyLDrP8hOK9/MOwXvKjSERoqH7bovDQMEj+Tzw/ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786522; 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=OObTO3JzhxB3nNhF805zvJwvjj1kWsj8GdZxqFCnT/M=; b=ob4YjcW0Esy3dIZ2jGxhL9AqZIv6PCJH75Vqo091z684xL7pvkJRr8mtv2Pthg66LfhPJmtFhdBfxux0Ku0XvRvo2Zv0SYJ8iH+cb9x+9oPj+IMHA/0adzaepQbHvlhfq/Yq0F6CqPdJPUVsg0qRhiQfmQcfJQakgtzwfeQDMI8= 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 1567786522743603.7871085279976; Fri, 6 Sep 2019 09:15:22 -0700 (PDT) Received: from localhost ([::1]:58168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GtN-0007pE-6R for importer@patchew.org; Fri, 06 Sep 2019 12:15:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51483) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgJ-0002SW-A7 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgH-0005AX-Qy for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:37916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgE-00054c-Qa; Fri, 06 Sep 2019 12:01:47 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgD-0005vz-Hp; Fri, 06 Sep 2019 19:01:45 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:18 +0300 Message-Id: <20190906160120.70239-8-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 7/9] scsi: account unmap operations 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 Sun Apr 28 12:48:52 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=1567786136; cv=none; d=zoho.com; s=zohoarc; b=jNeXqv5/GsDBIApx95a7BhkmBQSTCXjDHneJaSW7v0cK/7KNj9Iy1sfRQc8oqKe9AAYV9ClPuaw3A7F14qYFETuGG1BzX75qUzHEqGiOMDUvExQzb9BS+0JYp/2DTQlmCWYXKdXtub3efYcDZrfFVZtcVM6g87aqB5MTG+NQ2Ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786136; 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=k4m4TtHaOHnxFOjbxybbm2dcMxxqU2Mz/0My+R1tkPo=; b=XHCizEvEE0imc1nsh+wDxC0NKhpMo92roC9a+UzJQViCQmswBzQ1lq/WHY0zFiGk/+XHrAkAfbrALt8f4njQOoSFQRGMonknKtXnrPj/nDu1maey8Z4vaY+bPNeLw9wgBzkXmlqzyHZWGBRTZvTwurBG3j3QOvgOnc0dOt5PMQE= 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 1567786136480965.4946887848891; Fri, 6 Sep 2019 09:08:56 -0700 (PDT) Received: from localhost ([::1]:58082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Gn8-0000Ut-GY for importer@patchew.org; Fri, 06 Sep 2019 12:08:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51511) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgK-0002UN-Hy for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgJ-0005DB-8z for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:52 -0400 Received: from relay.sw.ru ([185.231.240.75]:37926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgF-00055L-HX; Fri, 06 Sep 2019 12:01:47 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgE-0005vz-8X; Fri, 06 Sep 2019 19:01:46 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:19 +0300 Message-Id: <20190906160120.70239-9-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 8/9] file-posix: account discard operations 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 71f168ee2f..6548dda309 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; @@ -2728,11 +2733,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, @@ -2746,7 +2762,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 @@ -3369,10 +3387,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 Sun Apr 28 12:48:52 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=1567786282; cv=none; d=zoho.com; s=zohoarc; b=DC9Ws8UKHe6zq/jKzfgjBSKOgGIPMVvtMivLK4f/RbI6xzNwDBiHBq1RFp4Z3yBYD0jo+a+7CEJ8pPfiFxPvTXzj8GwARAxGUBuwCKcy6Sd97+WCg1wB412A3AS7R7STBVQ8X8AJE68ElXlgthpcxDDAiOdsqW6ReSYlTfTd+5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567786282; 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=qk5gbLNFlpJ6pm0tJjTWxdYYd4SjLEFBP7FlbsboC/Y=; b=WBkNSOXAkgm22IcGqeWaGrKgpQxXJY5j3lZ/7dcrXsju2XGM4evDMwdA4h6RfomuUWh1kI1Y5k62SgMhhTkiDD5ODRh1bR4/tcQlcSMimJyYdTgnWFbQ9URLkPcBRgZgk1kR4aah4aJPDaGFOVlp3s1gAEGsCSNcoL84/aL234A= 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 1567786282983721.2366559832094; Fri, 6 Sep 2019 09:11:22 -0700 (PDT) Received: from localhost ([::1]:58138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GpT-0003rt-Uu for importer@patchew.org; Fri, 06 Sep 2019 12:11:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GgM-0002WP-C8 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GgK-0005Dv-Rd for qemu-devel@nongnu.org; Fri, 06 Sep 2019 12:01:54 -0400 Received: from relay.sw.ru ([185.231.240.75]:37934) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GgG-00057O-O0; Fri, 06 Sep 2019 12:01:48 -0400 Received: from [172.16.25.154] (helo=xantnef-ws.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i6GgF-0005vz-Bq; Fri, 06 Sep 2019 19:01:47 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Date: Fri, 6 Sep 2019 19:01:20 +0300 Message-Id: <20190906160120.70239-10-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> References: <20190906160120.70239-1-anton.nefedov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v9 9/9] qapi: query-blockstat: add driver specific file-posix stats 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 124ad40809..6c5279da99 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -503,6 +503,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 6548dda309..767feadc21 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2821,6 +2821,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), @@ -3028,6 +3058,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, @@ -3506,6 +3537,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 3356a1dc59..54b4810efd 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