From patchwork Mon Jun 11 19:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10458733 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 3235B60467 for ; Mon, 11 Jun 2018 19:48:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2150F26CFC for ; Mon, 11 Jun 2018 19:48:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1663727BA5; Mon, 11 Jun 2018 19:48:23 +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 B27D326CFC for ; Mon, 11 Jun 2018 19:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934438AbeFKTsV (ORCPT ); Mon, 11 Jun 2018 15:48:21 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48610 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934347AbeFKTsU (ORCPT ); Mon, 11 Jun 2018 15:48:20 -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=/PJdGL1CX7CZ+HenztGatPPBrqHwhva1cLr3qo5mZcE=; b=OaPuR1z2FiQPHMfdnVjd+9c7/ 14wayxJ5lQ3iEOncJ+du/Yhp3muignLAMs5PjQqGyAHsjbBdwXoxCrLXoq3rc6dp/Hj6Q/6BHMmPn m97SFr8ZSlNmCI5jBMdE7TS5g5iLFmpD9z6cm1AEpzUgtmXanbk8Ge60z/uZxxWT+XlGr5U8bvMNs 8Ya/OFFz6mtlfkISuFlKGp+15uA4YDfXkiMYjrFpuWM6Frv5yeqhAJ77pYCHMT7UlGYKIDE7ZVUxp YX/F+Bekqj4PitsU51v0wT10RrANjPlnuNKArxXmkrDTArPGUwSL7RlgwvmAIlF8fXJFkdik/VA2o UpDzR5ucw==; Received: from 213-225-7-72.nat.highway.a1.net ([213.225.7.72] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSSna-0004A9-Sc; Mon, 11 Jun 2018 19:48:19 +0000 From: Christoph Hellwig To: Jens Axboe , Coly Li Cc: 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: Mon, 11 Jun 2018 21:48:02 +0200 Message-Id: <20180611194806.13222-3-hch@lst.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180611194806.13222-1-hch@lst.de> References: <20180611194806.13222-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..cd2505b9bee9 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->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..cd27eabbab24 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); 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); bio_set_dev(bio, ca->bdev); bio->bi_end_io = write_super_endio; bio->bi_private = ca;