From nobody Tue Apr 15 21:45:26 2025 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570710187; cv=none; d=zoho.com; s=zohoarc; b=gb7rPbvSfgkVfHASwvOwJrbfWhDDVzG/65P6xeEQRzEnFALv2XrmsPezQ6fXZZcOFyguu+wnX9v2Sikg4j4cHfsKSewiSjYYNo1iPFk9EFwPFGWpdwJFtuXIsCYVlVLPYZ2UDL/Awq0fxV30kujBlf9xM9cDVBRaOsP+MJs+W1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570710187; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eR3hu9ENTXFSSaDB42fKbhTTqS316c8wKBdHAZ6ETVQ=; b=W5H5K+EJV+qYdp5mZYiHnlrAIQplESc5zyuZEQ9UAMvqW8YAApbmxsbWBmokE4ngS6TyOoOHGQIxRLCTymYraXkwKtQVgq2m46AQVj03gKs68WbVm0S7MVSn3AnK8JHDpj5M9Wn5xVpIIdusJyGOighJ6c72z1orN+AUN8BzK+k= 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 15707101877401010.0518195575678; Thu, 10 Oct 2019 05:23:07 -0700 (PDT) Received: from localhost ([::1]:37134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIXTG-0001ke-3A for importer@patchew.org; Thu, 10 Oct 2019 08:23:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52031) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIWrH-0006sk-EG for qemu-devel@nongnu.org; Thu, 10 Oct 2019 07:43:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIWrG-0008J4-Bx for qemu-devel@nongnu.org; Thu, 10 Oct 2019 07:43:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIWrD-0008HR-Vn; Thu, 10 Oct 2019 07:43:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3599918C4262; Thu, 10 Oct 2019 11:43:47 +0000 (UTC) Received: from localhost (unknown [10.36.118.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB89460A9F; Thu, 10 Oct 2019 11:43:46 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 20/36] ide: account UNMAP (TRIM) operations Date: Thu, 10 Oct 2019 13:42:44 +0200 Message-Id: <20191010114300.7746-21-mreitz@redhat.com> In-Reply-To: <20191010114300.7746-1-mreitz@redhat.com> References: <20191010114300.7746-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Thu, 10 Oct 2019 11:43:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Anton Nefedov Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190923121737.83281-5-anton.nefedov@virtuozzo.com Signed-off-by: Max Reitz --- 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.21.0