From patchwork Mon Sep 23 12:17:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 1166018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46cNyZ47VTz9s4Y for ; Mon, 23 Sep 2019 22:33:10 +1000 (AEST) Received: from localhost ([::1]:55940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNWe-0000n3-5j for incoming@patchwork.ozlabs.org; Mon, 23 Sep 2019 08:33:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48172) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCNIF-0006th-S8 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-0001nA-AP for qemu-devel@nongnu.org; Mon, 23 Sep 2019 08:18:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:59126) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCNI7-0001hc-8w; 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 1iCNI1-0007xx-O8; Mon, 23 Sep 2019 15:18:02 +0300 From: Anton Nefedov To: qemu-block@nongnu.org Subject: [PATCH v10 0/9] discard blockstats Date: Mon, 23 Sep 2019 15:17:28 +0300 Message-Id: <20190923121737.83281-1-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.17.1 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" v10: - patch 3 commit message updated v9: https://lists.nongnu.org/archive/html/qemu-devel/2019-09/msg01190.html ---- qmp query-blockstats provides stats info for write/read/flush ops. Patches 1-7 implement the similar for discard (unmap) command for scsi and ide disks. Discard stat "unmap_ops / unmap_bytes" is supposed to account the ops that have completed without an error. However, discard operation is advisory. Specifically, - common block layer ignores ENOTSUP error code. That might be returned if the block driver does not support discard, or discard has been configured to be ignored. - format drivers such as qcow2 may ignore discard if they were configured to ignore that, or if the corresponding area is already marked unused (unallocated / zero clusters). And what is actually useful is the number of bytes actually discarded down on the host filesystem. To achieve that, driver-specific statistics has been added to blockstats (patch 9). With patch 8, file-posix driver accounts discard operations on its level too. query-blockstat result: (note the difference between blockdevice unmap and file discard stats. qcow2 sends fewer ops down to the file as the clusters are actually unallocated on qcow2 level) { "device": "drive-scsi0-0-0-0", "node-name": "#block159", "stats": { > "invalid_unmap_operations": 0, > "failed_unmap_operations": 0, "wr_highest_offset": 13411688448, "rd_total_time_ns": 2859566315, "rd_bytes": 103182336, "rd_merged": 0, "flush_operations": 19, "invalid_wr_operations": 0, "flush_total_time_ns": 23111608, "failed_rd_operations": 0, "failed_flush_operations": 0, "invalid_flush_operations": 0, "timed_stats": [ ], "wr_merged": 0, "wr_bytes": 1702912, > "unmap_bytes": 11954954240, > "unmap_operations": 865, "idle_time_ns": 2669508623, "account_invalid": true, > "unmap_total_time_ns": 19698002, "wr_operations": 143, "failed_wr_operations": 0, "rd_operations": 4816, "account_failed": true, > "unmap_merged": 0, "wr_total_time_ns": 1262686124, "invalid_rd_operations": 0 }, "parent": { > "driver-specific": { > "discard-nb-failed": 0, > "discard-bytes-ok": 720896, > "driver": "file", > "discard-nb-ok": 8 > }, "node-name": "#block009", "stats": { [..] } } }, { "device": "floppy0", Anton Nefedov (9): qapi: group BlockDeviceStats fields qapi: add unmap to BlockDeviceStats block: add empty account cookie type ide: account UNMAP (TRIM) operations scsi: store unmap offset and nb_sectors in request struct scsi: move unmap error checking to the complete callback scsi: account unmap operations file-posix: account discard operations qapi: query-blockstat: add driver specific file-posix stats qapi/block-core.json | 81 ++++++++++++++++++++++++++++++++------ include/block/accounting.h | 2 + include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 9 +++++ block/accounting.c | 6 +++ block/file-posix.c | 54 ++++++++++++++++++++++++- block/qapi.c | 11 ++++++ hw/ide/core.c | 12 ++++++ hw/scsi/scsi-disk.c | 34 ++++++++++------ tests/qemu-iotests/227.out | 18 +++++++++ 11 files changed, 206 insertions(+), 23 deletions(-)