From patchwork Tue Dec 13 08:41:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13071804 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 5AC09C4332F for ; Tue, 13 Dec 2022 08:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234465AbiLMIlh (ORCPT ); Tue, 13 Dec 2022 03:41:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233881AbiLMIlg (ORCPT ); Tue, 13 Dec 2022 03:41:36 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F2D115816 for ; Tue, 13 Dec 2022 00:41:35 -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=hJLkD2xrwVeqp1AyJ0jwe3uPPV4ZhZt7yoNkacRyKl0=; b=U89SNHmcHncq3tYtFyal/PBzcf M+Dh24mOrZlsRY95b6y56B5kKPk1obsljmVMwsWVfBuZD4i1p1uXdmclBPQoULyKy+6xpGBzxWm4w WHZVE/fuPlL5sRUwCiYSWQYKdE/c/K06AT9nP6whiTGzYsXq5KV65Hi5MJSvUg7m9xtGSrxDQ4hM8 WjaZcSONVGzROUowMEDGWWzoTLRjnGo8o8vrTnWDFh9WVvzI+3EaULZ8TWLtDf+t00hJBRHXSpxv7 BrKrM2osbTPSfzaK0eoYBJmCVJVMhZLlcSsLOnjm8CYkgou62bMWApoNXopNXIgppyhz/gky9VFpp 96mNZihA==; 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 1p50qx-00E0n9-Vr; Tue, 13 Dec 2022 08:41:32 +0000 From: Christoph Hellwig To: Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenruo , linux-btrfs@vger.kernel.org Subject: [PATCH 2/8] btrfs: cleanup rmw_rbio Date: Tue, 13 Dec 2022 09:41:17 +0100 Message-Id: <20221213084123.309790-3-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 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 Remove the write goto label by moving the data page allocation and data read into the branch. Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo --- fs/btrfs/raid56.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 5603ba1af55584..5035e2b20a5e02 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -2293,24 +2293,22 @@ static int rmw_rbio(struct btrfs_raid_bio *rbio) * Either full stripe write, or we have every data sector already * cached, can go to write path immediately. */ - if (rbio_is_full(rbio) || !need_read_stripe_sectors(rbio)) - goto write; - - /* - * Now we're doing sub-stripe write, also need all data stripes to do - * the full RMW. - */ - ret = alloc_rbio_data_pages(rbio); - if (ret < 0) - return ret; + if (!rbio_is_full(rbio) && need_read_stripe_sectors(rbio)) { + /* + * Now we're doing sub-stripe write, also need all data stripes + * to do the full RMW. + */ + ret = alloc_rbio_data_pages(rbio); + if (ret < 0) + return ret; - index_rbio_pages(rbio); + index_rbio_pages(rbio); - ret = rmw_read_wait_recover(rbio); - if (ret < 0) - return ret; + ret = rmw_read_wait_recover(rbio); + if (ret < 0) + return ret; + } -write: /* * At this stage we're not allowed to add any new bios to the * bio list any more, anyone else that wants to change this stripe