Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE8EAC4332F for ; Tue, 13 Dec 2022 08:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234318AbiLMIld (ORCPT ); Tue, 13 Dec 2022 03:41:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233881AbiLMIlc (ORCPT ); Tue, 13 Dec 2022 03:41:32 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0DB517E1C for ; Tue, 13 Dec 2022 00:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=uVOfn/rtn+PuhD8CeUaAHMEoLYogfXJAB0Tn2vcMO6M=; b=feug3iRrpofEaQWRYp2kYdNYyl /VXnkMLL3eRoo7eBmAqVrjrKhKvP430T6L1EMfUTX84L4NZX6+rEMeTu7pNsNXEIT/fKdbx0ign+I nv/Cs92S1Uz1n/nlBeUovqdTrHFj6mWAMRoOga5OXdz/YCa3g4MpJB/R5eQbStI5OYTWk1taH8O52 oAEgip0qxY0ifI42bGlBvCpEFEmhDa5H3H/2lB84my/rznjI1tKkebU3OrrJthgAstSkA/b7LiK1Z p+aiwLm/eV7aEB6LYUnnGgcqYUrGIv3sU2Mh1lO5M6a8eILoMl1p8I3RHAdXjFVBSTlTe0pDjrRSQ THyZjIZQ==; Received: from [2001:4bb8:192:2f53:30b:ddad:22aa:f9f9] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p50qv-00E0kp-Ac; Tue, 13 Dec 2022 08:41:29 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenruo , linux-btrfs@vger.kernel.org Subject: [PATCH 1/8] btrfs: cleanup raid56_parity_write Date: Tue, 13 Dec 2022 09:41:16 +0100 Message-Id: <20221213084123.309790-2-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221213084123.309790-1-hch@lst.de> References: <20221213084123.309790-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Handle the error return on alloc_rbio failure directly instead of using a goto, and remove the queue_rbio goto label by moving the plugged check into the if branch. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo --- fs/btrfs/raid56.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 2d90a6b5eb00e3..5603ba1af55584 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1660,12 +1660,12 @@ void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc) struct btrfs_raid_bio *rbio; struct btrfs_plug_cb *plug = NULL; struct blk_plug_cb *cb; - int ret = 0; rbio = alloc_rbio(fs_info, bioc); if (IS_ERR(rbio)) { - ret = PTR_ERR(rbio); - goto fail; + bio->bi_status = errno_to_blk_status(PTR_ERR(rbio)); + bio_endio(bio); + return; } rbio->operation = BTRFS_RBIO_WRITE; rbio_add_bio(rbio, bio); @@ -1674,31 +1674,24 @@ void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc) * Don't plug on full rbios, just get them out the door * as quickly as we can */ - if (rbio_is_full(rbio)) - goto queue_rbio; - - cb = blk_check_plugged(raid_unplug, fs_info, sizeof(*plug)); - if (cb) { - plug = container_of(cb, struct btrfs_plug_cb, cb); - if (!plug->info) { - plug->info = fs_info; - INIT_LIST_HEAD(&plug->rbio_list); + if (!rbio_is_full(rbio)) { + cb = blk_check_plugged(raid_unplug, fs_info, sizeof(*plug)); + if (cb) { + plug = container_of(cb, struct btrfs_plug_cb, cb); + if (!plug->info) { + plug->info = fs_info; + INIT_LIST_HEAD(&plug->rbio_list); + } + list_add_tail(&rbio->plug_list, &plug->rbio_list); + return; } - list_add_tail(&rbio->plug_list, &plug->rbio_list); - return; } -queue_rbio: + /* * Either we don't have any existing plug, or we're doing a full stripe, - * can queue the rmw work now. + * queue the rmw work now. */ start_async_work(rbio, rmw_rbio_work); - - return; - -fail: - bio->bi_status = errno_to_blk_status(ret); - bio_endio(bio); } static int verify_one_sector(struct btrfs_raid_bio *rbio, -- 2.35.1