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 947CFC6FD1D for ; Tue, 14 Mar 2023 22:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbjCNW2d (ORCPT ); Tue, 14 Mar 2023 18:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbjCNW2c (ORCPT ); Tue, 14 Mar 2023 18:28:32 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 275B223679 for ; Tue, 14 Mar 2023 15:28:28 -0700 (PDT) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MF3DM-1pileY16fw-00FUWm; Tue, 14 Mar 2023 23:28:22 +0100 Message-ID: <810b336b-c96e-d676-2e41-09c5316eaea6@gmx.com> Date: Wed, 15 Mar 2023 06:28:18 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 01/12] btrfs: scrub: use dedicated super block verification function to scrub one super block To: Johannes Thumshirn , Qu Wenruo , "linux-btrfs@vger.kernel.org" References: Content-Language: en-US From: Qu Wenruo In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:LlLHB0d+Eo6PBLb+CFDixod2ItShEOo9ZSbvuHi1C8pX+ANkF6n cll/qKP46Tl4M4l9SxxKPuCGzPn/ZKQ0jO10JKG+TqmlaHpFk+3WrsvWJprRSXPJqOqlQJR 87FLPZMjHCSHg6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t0pzu01zPGg gLdIOgHcaJ6Lafz0IhkCQzsMZE0= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/3/14 20:05, Johannes Thumshirn wrote: > On 14.03.23 08:36, Qu Wenruo wrote: >> There is really no need to go through the super complex scrub_sectors() >> to just handle super blocks. >> >> This patch will introduce a dedicated function (less than 50 lines) to >> handle super block scrubing. >> >> This new function will introduce a behavior change, instead of using the >> complex but concurrent scrub_bio system, here we just go >> submit-and-wait. >> >> There is really not much sense to care the performance of super block >> scrubbing. It only has 3 super blocks at most, and they are all scattered >> around the devices already. >> >> Signed-off-by: Qu Wenruo >> --- >> fs/btrfs/scrub.c | 54 +++++++++++++++++++++++++++++++++++++++++------- >> 1 file changed, 46 insertions(+), 8 deletions(-) >> >> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c >> index 3cdf73277e7e..e765eb8b8bcf 100644 >> --- a/fs/btrfs/scrub.c >> +++ b/fs/btrfs/scrub.c >> @@ -4243,18 +4243,59 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, >> return ret; >> } >> >> +static int scrub_one_super(struct scrub_ctx *sctx, struct btrfs_device *dev, >> + struct page *page, u64 physical, u64 generation) >> +{ >> + struct btrfs_fs_info *fs_info = sctx->fs_info; >> + struct bio_vec bvec; >> + struct bio bio; >> + struct btrfs_super_block *sb = page_address(page); >> + int ret; >> + >> + bio_init(&bio, dev->bdev, &bvec, 1, REQ_OP_READ); >> + bio.bi_iter.bi_sector = physical >> SECTOR_SHIFT; >> + bio_add_page(&bio, page, BTRFS_SUPER_INFO_SIZE, 0); >> + ret = submit_bio_wait(&bio); >> + bio_uninit(&bio); >> + > > I don't think bio_uninit() is needed here. You're not attaching any cgroup information, > bio integrity or crypto context to it. Or can that be attached down the stack? > It's mostly to pair with bio_init(). Although the bio has no CGROUP nor crypto context, it's still better to explicitly pair bio_init() with bio_uninit(). Thanks, Qu