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 BDFF3EC875E for ; Fri, 8 Sep 2023 01:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234945AbjIHB3b (ORCPT ); Thu, 7 Sep 2023 21:29:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjIHB3a (ORCPT ); Thu, 7 Sep 2023 21:29:30 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443291BD2 for ; Thu, 7 Sep 2023 18:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.com; s=s31663417; t=1694136561; x=1694741361; i=quwenruo.btrfs@gmx.com; bh=PN204SaJtHg17ACHuGmq8xsL/XLzLtxKhG1IUHZcreI=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=TbccNOOk49LZugODdS7KcMHuencpFX09FtSB+JmNEiPcZB6nm7afe6AIX3xEv3jhDdZuua7 ZSsoN+wPD2fhvUxkYVZYNljgzfA6WdiJ++hfCmsRytKc+WZ2yRn5RaNlfvsw5X/Sfe2Y0Ehuf /fKLJ9S1tTtmdoklwqueBuHqe5/jX+D3eCHkrmZb7Wjay4B5LqfcOSljCxcn/iqvFiqmDyTre 1Uq09Z0BT/JjElO4F2vKnplOpWasXS4owEM7fA485IG9DxUQnPyieuUhmmUvtQqwcqZJKZVo/ eeHdRqf0xDKk2YuhsdhKSq7mtQd7C7BbAtjxPZFYtxNP1BOK0yjQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M9Fjb-1qaq4V0x8x-006R40; Fri, 08 Sep 2023 03:29:20 +0200 Message-ID: Date: Fri, 8 Sep 2023 09:29:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/10] btrfs: move extent_buffer::lock_owner to debug section To: dsterba@suse.cz Cc: David Sterba , linux-btrfs@vger.kernel.org References: <3f96e9c3d06ed846b19b63cd9001cb0c66bd8a00.1694126893.git.dsterba@suse.com> <20230908005605.GV3159@twin.jikos.cz> Content-Language: en-US From: Qu Wenruo Autocrypt: addr=quwenruo.btrfs@gmx.com; keydata= xsBNBFnVga8BCACyhFP3ExcTIuB73jDIBA/vSoYcTyysFQzPvez64TUSCv1SgXEByR7fju3o 8RfaWuHCnkkea5luuTZMqfgTXrun2dqNVYDNOV6RIVrc4YuG20yhC1epnV55fJCThqij0MRL 1NxPKXIlEdHvN0Kov3CtWA+R1iNN0RCeVun7rmOrrjBK573aWC5sgP7YsBOLK79H3tmUtz6b 9Imuj0ZyEsa76Xg9PX9Hn2myKj1hfWGS+5og9Va4hrwQC8ipjXik6NKR5GDV+hOZkktU81G5 gkQtGB9jOAYRs86QG/b7PtIlbd3+pppT0gaS+wvwMs8cuNG+Pu6KO1oC4jgdseFLu7NpABEB AAHNIlF1IFdlbnJ1byA8cXV3ZW5ydW8uYnRyZnNAZ214LmNvbT7CwJQEEwEIAD4CGwMFCwkI BwIGFQgJCgsCBBYCAwECHgECF4AWIQQt33LlpaVbqJ2qQuHCPZHzoSX+qAUCY00iVQUJDToH pgAKCRDCPZHzoSX+qNKACACkjDLzCvcFuDlgqCiS4ajHAo6twGra3uGgY2klo3S4JespWifr BLPPak74oOShqNZ8yWzB1Bkz1u93Ifx3c3H0r2vLWrImoP5eQdymVqMWmDAq+sV1Koyt8gXQ XPD2jQCrfR9nUuV1F3Z4Lgo+6I5LjuXBVEayFdz/VYK63+YLEAlSowCF72Lkz06TmaI0XMyj jgRNGM2MRgfxbprCcsgUypaDfmhY2nrhIzPUICURfp9t/65+/PLlV4nYs+DtSwPyNjkPX72+ LdyIdY+BqS8cZbPG5spCyJIlZonADojLDYQq4QnufARU51zyVjzTXMg5gAttDZwTH+8LbNI4 mm2YzsBNBFnVga8BCACqU+th4Esy/c8BnvliFAjAfpzhI1wH76FD1MJPmAhA3DnX5JDORcga CbPEwhLj1xlwTgpeT+QfDmGJ5B5BlrrQFZVE1fChEjiJvyiSAO4yQPkrPVYTI7Xj34FnscPj /IrRUUka68MlHxPtFnAHr25VIuOS41lmYKYNwPNLRz9Ik6DmeTG3WJO2BQRNvXA0pXrJH1fN GSsRb+pKEKHKtL1803x71zQxCwLh+zLP1iXHVM5j8gX9zqupigQR/Cel2XPS44zWcDW8r7B0 q1eW4Jrv0x19p4P923voqn+joIAostyNTUjCeSrUdKth9jcdlam9X2DziA/DHDFfS5eq4fEv ABEBAAHCwHwEGAEIACYCGwwWIQQt33LlpaVbqJ2qQuHCPZHzoSX+qAUCY00ibgUJDToHvwAK CRDCPZHzoSX+qK6vB/9yyZlsS+ijtsvwYDjGA2WhVhN07Xa5SBBvGCAycyGGzSMkOJcOtUUf tD+ADyrLbLuVSfRN1ke738UojphwkSFj4t9scG5A+U8GgOZtrlYOsY2+cG3R5vjoXUgXMP37 INfWh0KbJodf0G48xouesn08cbfUdlphSMXujCA8y5TcNyRuNv2q5Nizl8sKhUZzh4BascoK DChBuznBsucCTAGrwPgG4/ul6HnWE8DipMKvkV9ob1xJS2W4WJRPp6QdVrBWJ9cCdtpR6GbL iQi22uZXoSPv/0oUrGU+U5X4IvdnvT+8viPzszL5wXswJZfqfy8tmHM85yjObVdIG6AlnrrD In-Reply-To: <20230908005605.GV3159@twin.jikos.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:eo1jYT9Y4gL98SpRX+uMNyrHoAD/cGBb1ZDyyCTJs7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L7nHrUd/MmasSaIQtQxCVfxU0ThOACd oAKKSsyPwGoqZ7Z6gW02ZBhE+c+X7vq/t/xNbc3jIUXWtkDm5pAJS6JZbuT4NfNeYlZ+SBXyj ZZdDgh877/YD+sgGz0T5ZvHC8uU= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/9/8 08:56, David Sterba wrote: > On Fri, Sep 08, 2023 at 08:11:43AM +0800, Qu Wenruo wrote: >> >> >> On 2023/9/8 07:09, David Sterba wrote: >>> The lock_owner is used for a rare corruption case and we haven't seen >>> any reports in years. Move it to the debugging section of eb. To clos= e >>> the holes also move log_index so the final layout looks like: >> >> Just found some extra space we can squish out: > > Yeah I have a few more patches to reduce extent buffer size. > >>> struct extent_buffer { >>> u64 start; /* 0 = 8 */ >>> long unsigned int len; /* 8 = 8 */ >> >> u32 is definitely enough. >> (u16 is not enough for 64K nodesize, unfortunately) > > One idea is to store the bit shift and then calculate the length on each > use but then we can simply not store the length in extent buffer at all > because it's always fs_info->nodesize. In some functions it can be > directly replaced by that, elsewhere it's needed to do > eb->fs_info->nodesize. One more pointer dereference but from likely a > cached memory, gaining 8 bytes. Oh, that's way better. We used to use dummy extent buffer with fixed size (4K) for sys chunk array read, but since commit e959d3c1df3a ("btrfs: use dummy extent buffer for super block sys chunk array read") we just use nodesize and leave the extra space untouched. But it may be better to dig deeper, as I'm not 100% sure if every (including dummy ones) extent buffer goes nodesize. > >> >>> long unsigned int bflags; /* 16 = 8 */ >> >> For now we don't need 64bit for bflags, 32bit is enough, but >> unfortunately that's what the existing test/set/clear_bit() requires... > > Indeed, and it's not just here, in the inode or some other structures > taht store a few flags an u32 would suffice. I have a prototype to add > atomic bit manipulations for a u32 type, but this requires manually > written assembly so for now it's just x86. This could be useful outside > of btrfs so I'd need to make it a proper API and get some feedback from > wider audience. > >>> struct btrfs_fs_info * fs_info; /* 24 = 8 */ >>> spinlock_t refs_lock; /* 32 = 4 */ >>> atomic_t refs; /* 36 = 4 */ >>> int read_mirror; /* 40 = 4 */ >> >> We don't really need int for read_mirror, but that would be another >> patch(set) to change them. > > Yeah that's another potential space saved, I tried to track down all the > use of mirror values but it's passed around to bios and back. My current plan is to go s8, which still gives us 127 mirrors. Which should be enough for RAID6 rebuilds. Although we may need extra attention to prevent incorrect width truncation/padding, as we're going to support minus number for scrub_logical ioctl to grab P/Q stripes directly. Thanks, Qu > >>> s8 log_index; /* 44 = 1 */ > > And log_index takes 3 values, this can be encoded into the flags, also a > prototype but the code becomes ugly.