From patchwork Wed Jun 13 13:51:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10462271 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 108B360348 for ; Wed, 13 Jun 2018 13:52:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00D82288F4 for ; Wed, 13 Jun 2018 13:52:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9FF72891B; Wed, 13 Jun 2018 13:52:18 +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 912A0288F4 for ; Wed, 13 Jun 2018 13:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935697AbeFMNwR (ORCPT ); Wed, 13 Jun 2018 09:52:17 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38290 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935279AbeFMNwQ (ORCPT ); Wed, 13 Jun 2018 09:52:16 -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=psP62MFm+imuUX6vlAYPRuLAI+j312Sm0DIUNFtYfeY=; b=kR2G+u26EOF3XBlVMG9dZECcL tfBQLCRt0djqF11YCzNLahHzcNNFc8cYg2QXBoSUiWkovB7BJJBVV+0PE5PjioW+KG+e/Lgmdnizo oimImBs+JxQvemA0mwnAQGEA6N+2b0LI1YI/p/8M1aMab13QYEVbBXoUMU2HwE4uxyJ+KBviERvMm 8LdSCXVMx9WTGM8hoNwAmM+RTGxhO43eOnNCQHbWMPQkzpd8vVOwYuO3VzbkKItI5vAiBn/Xzpj1C qOw67Fg8LmZNY/bTW7yy2GbisanDaSnB5VkDQGtA9l/E0CZzmHmEMHOrKIjQ5/zTprixebnzmuTa1 3/dQRzKXg==; 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 1fT6C6-0003fE-Sm; Wed, 13 Jun 2018 13:52:15 +0000 From: Christoph Hellwig To: Jens Axboe , Coly Li Cc: Kent Overstreet , linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 4/6] bcache: clean up bio reuse for struct dirty_io Date: Wed, 13 Jun 2018 15:51:56 +0200 Message-Id: <20180613135158.29477-5-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 moves the private data initialization out of dirty_init, which is renamed to suit the remaining functionality. Signed-off-by: Christoph Hellwig --- drivers/md/bcache/writeback.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index ad45ebe1a74b..0b6d07eab87c 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -179,19 +179,12 @@ struct dirty_io { struct bio bio; }; -static void dirty_init(struct keybuf_key *w) +static void dirty_init_prio(struct keybuf_key *w) { struct dirty_io *io = w->private; - struct bio *bio = &io->bio; - bio_init(bio, bio->bi_inline_vecs, - DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)); if (!io->dc->writeback_percent) - bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); - - bio->bi_iter.bi_size = KEY_SIZE(&w->key) << 9; - bio->bi_private = w; - bch_bio_map(bio, NULL); + bio_set_prio(&io->bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); } static void dirty_io_destructor(struct closure *cl) @@ -285,10 +278,12 @@ static void write_dirty(struct closure *cl) * to clean up. */ if (KEY_DIRTY(&w->key)) { - dirty_init(w); - bio_set_op_attrs(&io->bio, REQ_OP_WRITE, 0); + bio_reuse(&io->bio, KEY_SIZE(&w->key) << 9); + dirty_init_prio(w); + io->bio.bi_opf = REQ_OP_WRITE; io->bio.bi_iter.bi_sector = KEY_START(&w->key); bio_set_dev(&io->bio, io->dc->bdev); + io->bio.bi_private = w; io->bio.bi_end_io = dirty_endio; /* I/O request sent to backing device */ @@ -399,13 +394,18 @@ static void read_dirty(struct cached_dev *dc) io->dc = dc; io->sequence = sequence++; - dirty_init(w); - bio_set_op_attrs(&io->bio, REQ_OP_READ, 0); + bio_init(&io->bio, io->bio.bi_inline_vecs, + DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)); + dirty_init_prio(w); + io->bio.bi_opf = REQ_OP_READ; + io->bio.bi_iter.bi_size = KEY_SIZE(&w->key) << 9; io->bio.bi_iter.bi_sector = PTR_OFFSET(&w->key, 0); bio_set_dev(&io->bio, PTR_CACHE(dc->disk.c, &w->key, 0)->bdev); + io->bio.bi_private = w; io->bio.bi_end_io = read_dirty_endio; + bch_bio_map(&io->bio, NULL); if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL)) goto err_free;