From patchwork Tue May 14 12:10:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 10942787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC46213AD for ; Tue, 14 May 2019 12:12:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C979286E3 for ; Tue, 14 May 2019 12:12:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90A2228658; Tue, 14 May 2019 12:12:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B172286C1 for ; Tue, 14 May 2019 12:12:34 +0000 (UTC) Received: from localhost ([127.0.0.1]:47271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQWIL-0004h7-CB for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 May 2019 08:12:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQWGp-0003Lq-46 for qemu-devel@nongnu.org; Tue, 14 May 2019 08:10:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQWGn-00022i-EW for qemu-devel@nongnu.org; Tue, 14 May 2019 08:10:58 -0400 Received: from mail-eopbgr10138.outbound.protection.outlook.com ([40.107.1.138]:29223 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQWGh-0001va-M3; Tue, 14 May 2019 08:10:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gt0hMf9ZBXik+jmEEgrHy5mPCOkpE2mno2OKBrXALZI=; b=AUSrP4e2+5epaejg2i6+e5FgrrX1iQx4Wf56KdX/54y2LHdzvODrmJVlEtJyfkR1cxaFHSgWstqTUrSvakHa7klwRVrCYUkMJiK00ZWSeVv46rkyDURn27f4Z8nBEUnVv54WMtz3Z+XnUfHUFWdejijDok+qe3+Ip8FmJcoEqwk= Received: from VI1PR08MB4078.eurprd08.prod.outlook.com (20.178.127.92) by VI1PR08MB4573.eurprd08.prod.outlook.com (20.178.126.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.16; Tue, 14 May 2019 12:10:45 +0000 Received: from VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::8ce8:ffb4:fe9:4900]) by VI1PR08MB4078.eurprd08.prod.outlook.com ([fe80::8ce8:ffb4:fe9:4900%3]) with mapi id 15.20.1878.024; Tue, 14 May 2019 12:10:45 +0000 From: Anton Nefedov To: "qemu-block@nongnu.org" Thread-Topic: [PATCH v7 4/9] ide: account UNMAP (TRIM) operations Thread-Index: AQHVCk4OQluzFK8n80WAwbR9XUOfMQ== Date: Tue, 14 May 2019 12:10:44 +0000 Message-ID: <20190514121015.32190-5-anton.nefedov@virtuozzo.com> References: <20190514121015.32190-1-anton.nefedov@virtuozzo.com> In-Reply-To: <20190514121015.32190-1-anton.nefedov@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0701CA0057.eurprd07.prod.outlook.com (2603:10a6:3:9e::25) To VI1PR08MB4078.eurprd08.prod.outlook.com (2603:10a6:803:e5::28) authentication-results: spf=none (sender IP is ) smtp.mailfrom=anton.nefedov@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [185.231.240.5] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1c29e3bd-1c47-40c6-28be-08d6d865311d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR08MB4573; x-ms-traffictypediagnostic: VI1PR08MB4573: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:51; x-forefront-prvs: 0037FD6480 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39850400004)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(386003)(6506007)(102836004)(305945005)(5640700003)(6436002)(66946007)(26005)(316002)(7736002)(6512007)(64756008)(66446008)(66556008)(107886003)(66476007)(73956011)(76176011)(11346002)(446003)(2906002)(6486002)(476003)(2616005)(3846002)(6916009)(25786009)(4326008)(2351001)(186003)(53936002)(6116002)(44832011)(486006)(86362001)(71190400001)(71200400001)(52116002)(50226002)(256004)(66066001)(2501003)(1076003)(5660300002)(68736007)(8676002)(99286004)(14454004)(478600001)(36756003)(8936002)(81156014)(81166006)(54906003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB4573; H:VI1PR08MB4078.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Eg8lXzqGvfwXy7S5wFJ/ARKGLHWxshL1WoaEUTXSgIU+7S4NMF9MBr9Z+RkD3Irdi6ws3ZAJ7F10RtSEDX5ZY2QOwWYPpNyJpbMkKroozVDNG7GXKrf8c0FbXQHkKCKSNtGTAMCiMtTvGNFL+0PzUvGN5o6cLfS78b0Z07MLW6eqtQOpIGU8LVq1SmFafuLWsCvBz0ptINtOYzayL9bSQ3e+UYrUeZqk4f6imMaaL4p6ux3Qj2NYIhiQojWAbTmGYzov4Ww3fsk6viIwC/9dCIA8CgKFCm0UCMfDkMltS4Au+7YfHYuUm3xjhndYu210ix8J/Wf11Zb105rT4NO+6nqewWcfphbMyHHMhZ/oINw7QpouNONV0xkL96QxMR3HmXgQPHlkcLei5xRx1sbAjAr1tmI6rsCBl8ASsCLbRQ4= MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c29e3bd-1c47-40c6-28be-08d6d865311d X-MS-Exchange-CrossTenant-originalarrivaltime: 14 May 2019 12:10:44.9356 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4573 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.1.138 Subject: [Qemu-devel] [PATCH v7 4/9] ide: account UNMAP (TRIM) operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "kwolf@redhat.com" , Vladimir Sementsov-Ogievskiy , "berto@igalia.com" , Denis Lunev , "qemu-devel@nongnu.org" , "mreitz@redhat.com" , Anton Nefedov , "pbonzini@redhat.com" , "jsnow@redhat.com" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 6afadf894f..3a7ac93777 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -441,6 +441,14 @@ static void ide_issue_trim_cb(void *opaque, int ret) TrimAIOCB *iocb = opaque; IDEState *s = iocb->s; + if (iocb->i >= 0) { + if (ret >= 0) { + block_acct_done(blk_get_stats(s->blk), &s->acct); + } else { + block_acct_failed(blk_get_stats(s->blk), &s->acct); + } + } + if (ret >= 0) { while (iocb->j < iocb->qiov->niov) { int j = iocb->j; @@ -458,10 +466,14 @@ static void ide_issue_trim_cb(void *opaque, int ret) } if (!ide_sect_range_ok(s, sector, count)) { + block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_UNMAP); iocb->ret = -EINVAL; goto done; } + block_acct_start(blk_get_stats(s->blk), &s->acct, + count << BDRV_SECTOR_BITS, BLOCK_ACCT_UNMAP); + /* Got an entry! Submit and exit. */ iocb->aiocb = blk_aio_pdiscard(s->blk, sector << BDRV_SECTOR_BITS,