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 CA88AC46467 for ; Wed, 11 Jan 2023 06:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbjAKGs7 (ORCPT ); Wed, 11 Jan 2023 01:48:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232010AbjAKGs5 (ORCPT ); Wed, 11 Jan 2023 01:48:57 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B950FD13 for ; Tue, 10 Jan 2023 22:48:55 -0800 (PST) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MRmfi-1pLVBN0O8Q-00TGzq; Wed, 11 Jan 2023 07:48:47 +0100 Message-ID: <46641c05-bfc6-018c-c153-4a8e62f59a2c@gmx.com> Date: Wed, 11 Jan 2023 14:48:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 07/10] btrfs: submit the read bios from scrub_assemble_read_bios Content-Language: en-US To: Christoph Hellwig , Chris Mason , Josef Bacik , David Sterba Cc: Qu Wenruo , linux-btrfs@vger.kernel.org References: <20230111062335.1023353-1-hch@lst.de> <20230111062335.1023353-8-hch@lst.de> From: Qu Wenruo In-Reply-To: <20230111062335.1023353-8-hch@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:lBmKrcXjGcjnhavNn7rA1C6ApAQZ9nNj8IL/tkhp41vUJN/p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43sWUNIhJWi23TdDMOuCVrLYKkWm UVuv3+0PRN3mjbu2VDLRQNgoQ0muvxLuk+/MZgmta1letbTnmqGID9HpKnoinZyKp41imYwZ7 3U0Ctp428uJ/I8yYrRZ0MX667Ik= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/1/11 14:23, Christoph Hellwig wrote: > Instead of filling in a bio_list and submitting the bios in the only > caller, do that in scrub_assemble_read_bios. This removes the > need to pass the bio_list, and also makes it clear that the extra > bio_list cleanup in the caller is entirely pointless. Rename the > function to scrub_read_bios to make it clear that the bios are not > only assembled. > > Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Originally the idea of passing bio_list around is reuse the function to submit and wait. But your cleanup has shown it can be smaller and simpler even without reusing the same submit and wait function. Thanks, Qu > --- > fs/btrfs/raid56.c | 36 +++++++++++++----------------------- > 1 file changed, 13 insertions(+), 23 deletions(-) > > diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c > index 88404a6b0b98e7..374c3873169b3f 100644 > --- a/fs/btrfs/raid56.c > +++ b/fs/btrfs/raid56.c > @@ -2668,14 +2668,12 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio) > return ret; > } > > -static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio, > - struct bio_list *bio_list) > +static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio) > { > + struct bio_list bio_list = BIO_EMPTY_LIST; > int total_sector_nr; > int ret = 0; > > - ASSERT(bio_list_size(bio_list) == 0); > - > /* Build a list of bios to read all the missing parts. */ > for (total_sector_nr = 0; total_sector_nr < rbio->nr_sectors; > total_sector_nr++) { > @@ -2704,42 +2702,38 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio, > if (sector->uptodate) > continue; > > - ret = rbio_add_io_sector(rbio, bio_list, sector, stripe, > + ret = rbio_add_io_sector(rbio, &bio_list, sector, stripe, > sectornr, REQ_OP_READ); > - if (ret) > - goto error; > + if (ret) { > + bio_list_put(&bio_list); > + return ret; > + } > } > + > + submit_read_wait_bio_list(rbio, &bio_list); > return 0; > -error: > - bio_list_put(bio_list); > - return ret; > } > > static int scrub_rbio(struct btrfs_raid_bio *rbio) > { > bool need_check = false; > - struct bio_list bio_list; > int sector_nr; > int ret; > > - bio_list_init(&bio_list); > - > ret = alloc_rbio_essential_pages(rbio); > if (ret) > - goto cleanup; > + return ret; > > bitmap_clear(rbio->error_bitmap, 0, rbio->nr_sectors); > > - ret = scrub_assemble_read_bios(rbio, &bio_list); > + ret = scrub_assemble_read_bios(rbio); > if (ret < 0) > - goto cleanup; > - > - submit_read_wait_bio_list(rbio, &bio_list); > + return ret; > > /* We may have some failures, recover the failed sectors first. */ > ret = recover_scrub_rbio(rbio); > if (ret < 0) > - goto cleanup; > + return ret; > > /* > * We have every sector properly prepared. Can finish the scrub > @@ -2757,10 +2751,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio) > } > } > return ret; > - > -cleanup: > - bio_list_put(&bio_list); > - return ret; > } > > static void scrub_rbio_work_locked(struct work_struct *work)