Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp990694ybs; Mon, 25 May 2020 04:35:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFsuUksXLKJWEM8O/XEDlwOcmE1dfq2Z6qCU6bfrQX+gxsnfIk7nXiXoTfC/Fm0K1T4Z+n X-Received: by 2002:a50:fc83:: with SMTP id f3mr15233204edq.138.1590406515755; Mon, 25 May 2020 04:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590406515; cv=none; d=google.com; s=arc-20160816; b=uUHR2xfCAq7aM0eA/GqayyKUpyOiK58SjNFcWVjdOjZ3oS/T6G4lpI54y9l/ga/61e 71LnZVml7uFG02H7fvV6MaIWaO7hNo6zxcfFORNN54MEf0ML1JVh6wBXCdywYFb4ILED kVsPYtmNTvhxBJIbxBVRBNa/iPc5mY8wOKv577YKgCZVAb4pzrhVt+8pVJuJR5rCzU2J bGGzXa3/6RAxQ7ocTdlu/EQTg5uCcODYLhY6RZv0IZ6/3cO2rHJACNogheYleuORwuhy DrRhVAs0C0o5jH6r71L4TXd8xZVnWnQFQFSDIYOJjcJCAi62ddyKudrLaYMeu2nYUKNM aYkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ju83TeQ/a5s++s4zWiPymbSjggIpghIm/3R9cYH8aH8=; b=dROCKNKqZPa3g3mPE7biqx2CupLve0JsJHO3ZCflBMabfcqa+4bidLR76aq1J1bPJC /yXbCDEwD6gRbsJf6c0mMVUJUjHhxkS83UCPs+5cPSAab8FaosZwqNyLmgTvAstMVHGM YgIAfM2suEsPjB1aFwWHrGqMcd1tvj4J8ufYK21ZsKOz5He84554fKCE3aVitrmiGD2d wshWUUGPjpPTWxw+1Q9zxBNiimSiukNF6A3MK23zpw/755ac6AymX2iccCEkE5cVr7QR VvZKvHuKiEsj8zUJj0Y64Iq8JF8EHR7pyruDlg7swCPl8m6zX/usugXVFnGGRDc5Xq86 ShSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZDq8JkNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si9013591eji.493.2020.05.25.04.34.52; Mon, 25 May 2020 04:35:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZDq8JkNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390448AbgEYLbp (ORCPT + 99 others); Mon, 25 May 2020 07:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390264AbgEYLan (ORCPT ); Mon, 25 May 2020 07:30:43 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BECAEC061A0E; Mon, 25 May 2020 04:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Ju83TeQ/a5s++s4zWiPymbSjggIpghIm/3R9cYH8aH8=; b=ZDq8JkNmhMYAQKJ8aZthvN3oNS qYsriW0/RVNjmztjsCls7TmQ63+J/VV/RGXeO8EL7J0v+/vKr944B9pkcoM0PWqLUiAfh1Yyxwyg/ GY7HbaP2ZH4zUCbdZ93RPuGS8TAX3ZmWurweUqN2+hWhRHZoFItfsVD38o3jqCbOv2S94r2SL2lmV SXnEhm2LJoyoeNvH2454sWtGiueam2EABWP69RjdJ+C9GYcETGLz7XYZdy7ZGdl+WxBwE1HWYP0iM dsQoLKQWbO9jB0vKAdETb4sWTBPRfWOOlHGBYhusjx9B7dp0WZuQi3hSUUyMO3bWEhYbpr/rFbrAe IROkxnqw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdBJY-0002SD-Gd; Mon, 25 May 2020 11:30:41 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Konstantin Khlebnikov , Minchan Kim , Nitin Gupta , dm-devel@redhat.com, linux-block@vger.kernel.org, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/16] zram: nvdimm: use bio_{start,end}_io_acct and disk_{start,end}_io_acct Date: Mon, 25 May 2020 13:30:06 +0200 Message-Id: <20200525113014.345997-9-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525113014.345997-1-hch@lst.de> References: <20200525113014.345997-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switch zram to use the nicer bio accounting helpers, and as part of that ensure each bio is counted as a single I/O request. Signed-off-by: Christoph Hellwig --- drivers/block/zram/zram_drv.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index ebb234f36909c..6e2ad90b17a37 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1510,13 +1510,8 @@ static void zram_bio_discard(struct zram *zram, u32 index, static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, int offset, unsigned int op, struct bio *bio) { - unsigned long start_time = jiffies; - struct request_queue *q = zram->disk->queue; int ret; - generic_start_io_acct(q, op, bvec->bv_len >> SECTOR_SHIFT, - &zram->disk->part0); - if (!op_is_write(op)) { atomic64_inc(&zram->stats.num_reads); ret = zram_bvec_read(zram, bvec, index, offset, bio); @@ -1526,8 +1521,6 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, ret = zram_bvec_write(zram, bvec, index, offset, bio); } - generic_end_io_acct(q, op, &zram->disk->part0, start_time); - zram_slot_lock(zram, index); zram_accessed(zram, index); zram_slot_unlock(zram, index); @@ -1548,6 +1541,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) u32 index; struct bio_vec bvec; struct bvec_iter iter; + unsigned long start_time; index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; offset = (bio->bi_iter.bi_sector & @@ -1563,6 +1557,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) break; } + start_time = bio_start_io_acct(bio); bio_for_each_segment(bvec, bio, iter) { struct bio_vec bv = bvec; unsigned int unwritten = bvec.bv_len; @@ -1571,8 +1566,10 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) bv.bv_len = min_t(unsigned int, PAGE_SIZE - offset, unwritten); if (zram_bvec_rw(zram, &bv, index, offset, - bio_op(bio), bio) < 0) - goto out; + bio_op(bio), bio) < 0) { + bio->bi_status = BLK_STS_IOERR; + break; + } bv.bv_offset += bv.bv_len; unwritten -= bv.bv_len; @@ -1580,12 +1577,8 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) update_position(&index, &offset, &bv); } while (unwritten); } - + bio_end_io_acct(bio, start_time); bio_endio(bio); - return; - -out: - bio_io_error(bio); } /* @@ -1633,6 +1626,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, u32 index; struct zram *zram; struct bio_vec bv; + unsigned long start_time; if (PageTransHuge(page)) return -ENOTSUPP; @@ -1651,7 +1645,9 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, bv.bv_len = PAGE_SIZE; bv.bv_offset = 0; + start_time = disk_start_io_acct(bdev->bd_disk, SECTORS_PER_PAGE, op); ret = zram_bvec_rw(zram, &bv, index, offset, op, NULL); + disk_end_io_acct(bdev->bd_disk, op, start_time); out: /* * If I/O fails, just return error(ie, non-zero) without -- 2.26.2