Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 10/10] btrfs: move extent_buffer::lock_owner to debug section
Date: Fri, 8 Sep 2023 09:29:17 +0800	[thread overview]
Message-ID: <e48b6243-212c-4eac-97db-5e89dd6e2c13@gmx.com> (raw)
In-Reply-To: <20230908005605.GV3159@twin.jikos.cz>



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 close
>>> 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.

      reply	other threads:[~2023-09-08  1:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 23:09 [PATCH 00/10] Cleanups and struct packing David Sterba
2023-09-07 23:09 ` [PATCH 01/10] btrfs: move functions comments from qgroup.h to qgroup.c David Sterba
2023-09-07 23:47   ` Qu Wenruo
2023-09-07 23:09 ` [PATCH 02/10] btrfs: reformat remaining kdoc style comments David Sterba
2023-09-07 23:51   ` Qu Wenruo
2023-09-08  0:14     ` David Sterba
2023-09-07 23:09 ` [PATCH 03/10] btrfs: drop __must_check annotations David Sterba
2023-09-07 23:56   ` Qu Wenruo
2023-09-08  0:34     ` David Sterba
2023-09-08 12:33       ` David Sterba
2023-09-07 23:09 ` [PATCH 04/10] btrfs: reduce parameters of btrfs_pin_reserved_extent David Sterba
2023-09-07 23:57   ` Qu Wenruo
2023-09-07 23:09 ` [PATCH 05/10] btrfs: reduce parameters of btrfs_pin_extent_for_log_replay David Sterba
2023-09-07 23:57   ` Qu Wenruo
2023-09-07 23:09 ` [PATCH 06/10] btrfs: reduce arguments of helpers space accounting root item David Sterba
2023-09-07 23:59   ` Qu Wenruo
2023-09-07 23:09 ` [PATCH 07/10] btrfs: reduce size of prelim_ref::level David Sterba
2023-09-08  0:01   ` Qu Wenruo
2023-09-07 23:09 ` [PATCH 08/10] btrfs: reduce size and reorder compression members in struct btrfs_inode David Sterba
2023-09-08  0:02   ` Qu Wenruo
2023-09-07 23:09 ` [PATCH 09/10] btrfs: reduce size of struct btrfs_ref David Sterba
2023-09-08  0:06   ` Qu Wenruo
2023-09-08  0:46     ` David Sterba
2023-09-07 23:09 ` [PATCH 10/10] btrfs: move extent_buffer::lock_owner to debug section David Sterba
2023-09-08  0:11   ` Qu Wenruo
2023-09-08  0:56     ` David Sterba
2023-09-08  1:29       ` Qu Wenruo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e48b6243-212c-4eac-97db-5e89dd6e2c13@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox