From patchwork Tue Oct 10 15:54:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 9996657 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 F1F7D60216 for ; Tue, 10 Oct 2017 15:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2AA62867F for ; Tue, 10 Oct 2017 15:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D768C28684; Tue, 10 Oct 2017 15:56:48 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 99A822867F for ; Tue, 10 Oct 2017 15:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932363AbdJJP4R (ORCPT ); Tue, 10 Oct 2017 11:56:17 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36374 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392AbdJJPy6 (ORCPT ); Tue, 10 Oct 2017 11:54:58 -0400 Received: by mail-qt0-f196.google.com with SMTP id 24so5628219qts.3; Tue, 10 Oct 2017 08:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=s8cQ7qZlLnT3u97479j/qaYcqJHEF3x1Ow6EducHLA0=; b=cPAIfdqX3as3p5Qx1RdtINV+P9l2JZmacLg4AUg/85S9q7hJfrKvjQ8TT1hqpfdNO5 O6uUB2gZkBk+Hdc34qAnxzOlU39VeuvE39Ro0BbFFYuwV0UBaBcAF0XZvqoVqPor68gJ Lyv/zOr86GTpAc0LLHWqk2LlolVY+geD4DnYSRXa5D36ZdfbgJtEm3Q4UNP9S6ldKZaT n+l1EgtVVlrvQN/d7hNF+CnzhTMWgt3KBwjHN+nyKAgb/H3/doBBxjAHjYmitG9YHjmO 16o7Z8fxCp6Zh9j/XADYdCyxThrGLsjh7koR8zp3vTqVKU/80oOdFuPLYYwmpa2YTb78 IbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=s8cQ7qZlLnT3u97479j/qaYcqJHEF3x1Ow6EducHLA0=; b=T8TULp0GdxrWOKljKhumnUtspNqSJVyRDMoYCaLwLVbK8eMsmrhYeqLA9oqwiSPs1X ZYoEG2G8LklJJ0QKTBK42TzHC8cE+OzdD9UacA08ciZZQSwGBkux+VvIvxMqvQw9AF+B 17Xelbs64uEdh3Eo80VDEhamFxYP+2Qq49vkPObOE7d0kkpfHAsamnVce9scexdGzRIH 2HtMzWCPj+xUOehzaa0dI/CalL07uAFregbAYWKcwBeG74yiR81Aqs2Vi/g1d++dC9eg A3H50vajs6yzqCRGiuZeQA5v4/FRaO+yA/SWKIhR5gjJ1MOUNrWkMs+YPX5k2oyMGiO9 cfdg== X-Gm-Message-State: AMCzsaV1QP0navbp4tCSh9Pmpm0RR0s8hHt8oujQs5OiKu5BXvYxDRNp 9YWJTBAXURuvO4V1++PTBDE= X-Google-Smtp-Source: AOwi7QAPL9E0rjhdZ2YtyzJLKJXrtmjUIZP1oH8q59G7DwAE4+Zj5N8d8RwlRMZ+OEoD0Wka2dA0Pg== X-Received: by 10.55.66.139 with SMTP id p133mr15169742qka.44.1507650897910; Tue, 10 Oct 2017 08:54:57 -0700 (PDT) Received: from localhost (dhcp-ec-8-6b-ed-7a-cf.cpe.echoes.net. [72.28.5.223]) by smtp.gmail.com with ESMTPSA id j19sm6485098qtk.87.2017.10.10.08.54.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 08:54:57 -0700 (PDT) From: Tejun Heo To: jack@suse.cz, axboe@kernel.dk, clm@fb.com, jbacik@fb.com Cc: kernel-team@fb.com, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, Tejun Heo Subject: [PATCH 3/5] buffer_head: separate out create_bh_bio() from submit_bh_wbc() Date: Tue, 10 Oct 2017 08:54:39 -0700 Message-Id: <20171010155441.753966-4-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171010155441.753966-1-tj@kernel.org> References: <20171010155441.753966-1-tj@kernel.org> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP submit_bh_wbc() creates a bio matching the specific @bh and submits it at the end. This patch separates out the bio creation part to its own function, create_bh_bio(), and reimplement submit_bh[_wbc]() using the function. As bio can now be manipulated before submitted, we can move out @wbc handling into submit_bh_wbc() and similarly this will make adding more submit_bh variants straight-forward. This patch is pure refactoring and doesn't cause any functional changes. Signed-off-by: Tejun Heo Suggested-by: Jan Kara Reviewed-by: Jan Kara --- fs/buffer.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 170df85..b4b2169 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3086,8 +3086,8 @@ void guard_bio_eod(int op, struct bio *bio) } } -static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, - enum rw_hint write_hint, struct writeback_control *wbc) +struct bio *create_bh_bio(int op, int op_flags, struct buffer_head *bh, + enum rw_hint write_hint) { struct bio *bio; @@ -3109,11 +3109,6 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, */ bio = bio_alloc(GFP_NOIO, 1); - if (wbc) { - wbc_init_bio(wbc, bio); - wbc_account_io(wbc, bh->b_page, bh->b_size); - } - bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); bio_set_dev(bio, bh->b_bdev); bio->bi_write_hint = write_hint; @@ -3133,13 +3128,32 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, op_flags |= REQ_PRIO; bio_set_op_attrs(bio, op, op_flags); + return bio; +} + +static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, + enum rw_hint write_hint, struct writeback_control *wbc) +{ + struct bio *bio; + + bio = create_bh_bio(op, op_flags, bh, write_hint); + + if (wbc) { + wbc_init_bio(wbc, bio); + wbc_account_io(wbc, bh->b_page, bh->b_size); + } + submit_bio(bio); return 0; } int submit_bh(int op, int op_flags, struct buffer_head *bh) { - return submit_bh_wbc(op, op_flags, bh, 0, NULL); + struct bio *bio; + + bio = create_bh_bio(op, op_flags, bh, 0); + submit_bio(bio); + return 0; } EXPORT_SYMBOL(submit_bh);