From mboxrd@z Thu Jan 1 00:00:00 1970 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 ABD0DC6FD20 for ; Fri, 24 Mar 2023 09:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbjCXJ7N (ORCPT ); Fri, 24 Mar 2023 05:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbjCXJ7M (ORCPT ); Fri, 24 Mar 2023 05:59:12 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F020FF24 for ; Fri, 24 Mar 2023 02:59:11 -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 1MIdif-1picKn2hu9-00Ehtf; Fri, 24 Mar 2023 10:59:01 +0100 Message-ID: <0ee1de5c-9cb2-cecf-c4be-02cc16bd505c@gmx.com> Date: Fri, 24 Mar 2023 17:58:57 +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 v3 02/12] btrfs: introduce a new helper to submit bio for scrub Content-Language: en-US To: Christoph Hellwig , Qu Wenruo Cc: linux-btrfs@vger.kernel.org References: From: Qu Wenruo In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:moUHsGYiSPhw7LdmfKTK8ciK0O9pt165aTUdjS5bt8M52aukV5a WUmsbZvV7rqELyYmzRR+SFIw277zDVneRboegRQQGpgBYKaasPSymo18aA7CvQERr+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cOMUHds2/IQvoCKIFvSrxUsPLMg/Qvze7PmJMSEWaIY 4thxrZ6d4oL84iH8vjh669pQ/w0= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/3/21 20:02, Christoph Hellwig wrote: >> @@ -39,6 +39,8 @@ void btrfs_bio_init(struct btrfs_bio *bbio, struct btrfs_inode *inode, >> bbio->end_io = end_io; >> bbio->private = private; >> atomic_set(&bbio->pending_ios, 1); >> + if (inode) >> + bbio->fs_info = inode->root->fs_info; >> } > > Please split modifications to the btrfs_bio infrastructure into > separate patches. And we'll need a proper helper to allocate these > non-bio inodes that ensures fs_info is always set. > >> struct btrfs_bio *bbio = btrfs_bio(bio); >> struct btrfs_device *dev = bio->bi_private; >> - struct btrfs_fs_info *fs_info = bbio->inode->root->fs_info; >> + struct btrfs_fs_info *fs_info = bbio->inode ? >> + bbio->inode->root->fs_info : bbio->fs_info; > > .. and all places that just need the fs_info need to just use > bbio->fs_info instead of these complicated constructs. > I have updated the branch, with a dedicated btrfs_bio::fs_info, btrfs_scrub_bio_alloc() and always populate that new fs_info. Mind to have a pre-check? https://github.com/adam900710/linux/commit/0f6a419f035787546eec6f51b0430a05a345d4c5 Although the next two patches are also slightly updated to take the advantage of that always populated fs_info: Since the modification, I'm a little more dependent on that always populated fs_info now, thus not sure if going back to a union and conditionally grabbing that fs_info is a good idea. Although I'm more interested why there is a super big gap between work and bio (32 bytes), while the compiler still refuses to put the pointer into that hole... Thanks, Qu