I'd like to understand how (modern) filesystems are implemented and having trouble to fully understand superblocks and their backups. I reference ext4 and btrfs, but the questions may also apply to other filesystems.
Ext4 stores a couple of superblocks (my fs for example has one primary and seven backup SBs). I do understand that, since the superblock defines important characteristics of the filesystem, an inline backup makes sense. But I don't get why so many backups, so:
- Why store so many superblocks? What's the benefit of having 7 backup SBs versus e.g just one?
According to ext4 documentation ext4 stores a "write time" within the SB (last write since epoch). That would imply that every write-transaction also consists of a write to the SB. Given my system, having 7 backup SBs, each write-transaction would consist of 8 SB writes. That seems a ridiculous amount of non-sequential metadata writes for a single transaction, leading to the question:
- Am I correct that on ext4 SBs are written that often?
The same questions basically apply to btrfs where SBs are distributed among static address blocks (primary block at 0x10000) and only in SSD mode (due to wear leveling concerns) only one is written per commit.
- Is there a benefit for btrfs to store the primary superblock at 0x10000 instead of 0x0?
The documentation of btrfs also states: Note that btrfs only recognizes disks with a valid 0x10000 superblock; otherwise, there would be confusion with other filesystems. This is even more confusing since a broken SB at 0x10000 would lead to an invalid filesystem, even if there're other valid SBs at other locations.
- How does btrfs benefit from superblock backups, if the filesystem is invalid on a broken primary superblock?