From patchwork Wed Jun 13 13:51:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10462267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4ACCC60234 for ; Wed, 13 Jun 2018 13:52:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39BE728914 for ; Wed, 13 Jun 2018 13:52:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BCFD2892E; Wed, 13 Jun 2018 13:52:13 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA73A28914 for ; Wed, 13 Jun 2018 13:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935348AbeFMNwL (ORCPT ); Wed, 13 Jun 2018 09:52:11 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38240 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935279AbeFMNwL (ORCPT ); Wed, 13 Jun 2018 09:52:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EsavpCROS23tN5KC4v/VS1dhXdOTLCJPOUdk7KXF4Ks=; b=p152YLNLYDoSIzh6yhrvjfSM7 1+mXVzo/TRHW8IaVsmt89fJjRXWcsiGaHzq93mjPvobuncGUzFGoPOV6SoupGA2MoVceT8+Pb2U7d 8QocaVlXDCiUvzJgO18ALssO6FE3ySg/ZS0qCtftNb0WOnAMewjJFUWDpmxuOYenPdLKnJsESW7gR GLXE9HjNllHd841tbndcwBr+/bCitzyTPA+8dDMddUloL/Hj6q1wDVknYsgiIpllTkojkaZxSlHrP xzaBGzTJah2UkiapLqsMK6jMvgNi7WhmhUf89dgZQ4e+B9BVrO885QGcqLB6Jmi4EBQdG5BODBv2O Q7EWd1kJQ==; Received: from 089144194215.atnat0003.highway.a1.net ([89.144.194.215] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fT6C1-0003Zt-52; Wed, 13 Jun 2018 13:52:09 +0000 From: Christoph Hellwig To: Jens Axboe , Coly Li Cc: Kent Overstreet , linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 2/6] bcache: use bio_reuse instead of bio_reinit where applicable Date: Wed, 13 Jun 2018 15:51:54 +0200 Message-Id: <20180613135158.29477-3-hch@lst.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613135158.29477-1-hch@lst.de> References: <20180613135158.29477-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the bio_reuse helper instead of rebuilding the bio_vecs and size for bios that get reused for the same data. Signed-off-by: Christoph Hellwig --- drivers/md/bcache/request.c | 5 +---- drivers/md/bcache/super.c | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index ae67f5fa8047..3e699be2e79b 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -810,12 +810,9 @@ static void cached_dev_read_done(struct closure *cl) */ if (s->iop.bio) { - bio_reset(s->iop.bio); + bio_reuse(s->iop.bio, s->insert_bio_sectors << 9); s->iop.bio->bi_iter.bi_sector = s->cache_miss->bi_iter.bi_sector; bio_copy_dev(s->iop.bio, s->cache_miss); - s->iop.bio->bi_iter.bi_size = s->insert_bio_sectors << 9; - bch_bio_map(s->iop.bio, NULL); - bio_copy_data(s->cache_miss, s->iop.bio); bio_put(s->cache_miss); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index a31e55bcc4e5..56692a451aeb 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -205,9 +205,7 @@ static void __write_super(struct cache_sb *sb, struct bio *bio) unsigned i; bio->bi_iter.bi_sector = SB_SECTOR; - bio->bi_iter.bi_size = SB_SIZE; bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC|REQ_META); - bch_bio_map(bio, NULL); out->offset = cpu_to_le64(sb->offset); out->version = cpu_to_le64(sb->version); @@ -249,7 +247,7 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent) down(&dc->sb_write_mutex); closure_init(cl, parent); - bio_reset(bio); + bio_reuse(bio, SB_SIZE); bio_set_dev(bio, dc->bdev); bio->bi_end_io = write_bdev_super_endio; bio->bi_private = dc; @@ -298,7 +296,7 @@ void bcache_write_super(struct cache_set *c) SET_CACHE_SYNC(&ca->sb, CACHE_SYNC(&c->sb)); - bio_reset(bio); + bio_reuse(bio, SB_SIZE); bio_set_dev(bio, ca->bdev); bio->bi_end_io = write_super_endio; bio->bi_private = ca;