From patchwork Wed Jun 13 13:51:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10462269 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 37A4B60348 for ; Wed, 13 Jun 2018 13:52:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27BAF28914 for ; Wed, 13 Jun 2018 13:52:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C8842892E; Wed, 13 Jun 2018 13:52:16 +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 B48EB28914 for ; Wed, 13 Jun 2018 13:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935679AbeFMNwO (ORCPT ); Wed, 13 Jun 2018 09:52:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38270 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935279AbeFMNwN (ORCPT ); Wed, 13 Jun 2018 09:52:13 -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=/MObeOJy3/veWoR7HyW2NlZ7eYdyNcSBzFqV2ASmYn8=; b=Ggbc+ez+B41sUrWrcrEFM6mRp N0IfxNrGg7BncodU9HpV4Y6u3rUxk0lGuIHu9wjk8/00m2MsloxdwWWrGkzuJb2jQ9lFiCNvjyqAI +E8NHxQ+kkk0CfVCM1nqCghfkYtlAvdliUJjHXGS+eUf8x8G4Po8al5LNOC4rgyCgGLgqcXVQHA0R E+ufNgc2cnwXrJLcrdqJGc/t1hWHqSKUsP/il6bLoyVNcWjkjyvf2waVohrCkiANGwXXUyiBvvMrP t+aWKqGp116xvuuv+hThqpxPb5cl2kvONf5/ZxCRv+R68oThUHm0gyRG7cGzzbpxHNrYVTGiZG7X3 jBAK3nBUg==; 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 1fT6C4-0003cc-22; Wed, 13 Jun 2018 13:52:12 +0000 From: Christoph Hellwig To: Jens Axboe , Coly Li Cc: Kent Overstreet , linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 3/6] bcache: clean up bio reuse for struct moving_io Date: Wed, 13 Jun 2018 15:51:55 +0200 Message-Id: <20180613135158.29477-4-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 Instead of reinitializing the bio everytime we can call bio_reuse when reusing it. Also removes the remainder of the moving_init helper to improve readability. Signed-off-by: Christoph Hellwig --- drivers/md/bcache/movinggc.c | 40 +++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index a24c3a95b2c0..890c055eb589 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c @@ -74,29 +74,20 @@ static void read_moving_endio(struct bio *bio) bch_bbio_endio(io->op.c, bio, bio->bi_status, "reading data to move"); } -static void moving_init(struct moving_io *io) -{ - struct bio *bio = &io->bio.bio; - - bio_init(bio, bio->bi_inline_vecs, - DIV_ROUND_UP(KEY_SIZE(&io->w->key), PAGE_SECTORS)); - bio_get(bio); - bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); - - bio->bi_iter.bi_size = KEY_SIZE(&io->w->key) << 9; - bio->bi_private = &io->cl; - bch_bio_map(bio, NULL); -} - static void write_moving(struct closure *cl) { struct moving_io *io = container_of(cl, struct moving_io, cl); struct data_insert_op *op = &io->op; if (!op->status) { - moving_init(io); + struct bio *bio = &io->bio.bio; + + bio_reuse(bio, KEY_SIZE(&io->w->key) << 9); + bio_get(bio); + bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); + bio->bi_private = &io->cl; + bio->bi_iter.bi_sector = KEY_START(&io->w->key); - io->bio.bio.bi_iter.bi_sector = KEY_START(&io->w->key); op->write_prio = 1; op->bio = &io->bio.bio; @@ -156,12 +147,19 @@ static void read_moving(struct cache_set *c) io->op.c = c; io->op.wq = c->moving_gc_wq; - moving_init(io); bio = &io->bio.bio; - - bio_set_op_attrs(bio, REQ_OP_READ, 0); - bio->bi_end_io = read_moving_endio; - + bio_init(bio, bio->bi_inline_vecs, + DIV_ROUND_UP(KEY_SIZE(&io->w->key), PAGE_SECTORS)); + bio_get(bio); + + bio->bi_iter.bi_size = KEY_SIZE(&io->w->key) << 9; + bio->bi_iter.bi_sector = KEY_START(&io->w->key); + bio->bi_opf = REQ_OP_READ; + bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); + bio->bi_private = &io->cl; + bio->bi_end_io = read_moving_endio; + + bch_bio_map(bio, NULL); if (bch_bio_alloc_pages(bio, GFP_KERNEL)) goto err;