Enforce 4k sectorize by default for mkfs
Subsystems (2)
v2 cover Enforce 4k sectorize by default for mkfs
The Fedora Asahi SIG[0] is working on bringing up support for Apple Silicon Macintosh computers through the Asahi Fedora Remix[1].
Apple Silicon Macs are unusual in that they currently require 16k page sizes, which means that the current default for mkfs.btrfs(8) makes a filesystem that is unreadable on x86 PCs and most other ARM PCs.
Soon, this will be even more of a problem within Apple Silicon Macs as Asahi Lina is working on 4k support to enable x86 emulation[2] and since Linux does not support dynamically switching page sizes at runtime, users will likely regularly switch back and forth depending on their needs.
Thus, I'd like to see us finally make the switchover to 4k sectorsize for new filesystems by default, regardless of page size.
The initial test run by Hector Martin[3] at request of Qu Wenruo looks promising[4], and I hope we can get this to land upstream soon.
=== Changelog ===
v2: Rebased to latest, updated doc references for v6.6
Final v1: Collected Reviewed-by tags for inclusion.
RFC v2: Addressed documentation feedback
RFC v1: Initial submission
[0]: https://fedoraproject.org/wiki/SIGs/Asahi
[1]: https://asahi-fedora-remix.org/
[2]: https://vt.social/@lina/110060963422545117
[3]: https://lore.kernel.org/linux-btrfs/[email protected]/T/#m11d7939de96c43b3a7cdabc7c568d8bcafc7ca83
[4]: https://lore.kernel.org/linux-btrfs/[email protected]/T/#mf382b78a8122b0cb82147a536c85b6a9098a2895
Neal Gompa (1):
btrfs-progs: mkfs: Enforce 4k sectorsize by default
Documentation/Subpage.rst | 15 ++++++++------- Documentation/mkfs.btrfs.rst | 13 +++++++++---- mkfs/main.c | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/1 btrfs-progs: mkfs: Enforce 4k sectorsize by default
We have had working subpage support in Btrfs for many cycles now. Generally, we do not want people creating filesystems by default with non-4k sectorsizes since it creates portability problems.
--- Documentation/Subpage.rst | 17 +++++++++-------- Documentation/mkfs.btrfs.rst | 13 +++++++++---- mkfs/main.c | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-)
Documentation/Subpage.rst +9 -8
@@ -9,18 +9,19 @@ to the exactly same size of the block and page. On x86_64 this is typically pages, like 64KiB on 64bit ARM or PowerPC. This means filesystems created with 64KiB sector size cannot be mounted on a system with 4KiB page size. -While with subpage support systems with 64KiB page size can create -and mount filesystems with 4KiB sectorsize. This still needs to use option "-s -4k" option for :command:`mkfs.btrfs`. +Since v6.6, filesystems are created with a 4KiB sectorsize by default, +though it remains possible to create filesystems with other page sizes +(such as 64KiB with the "-s 64k" option for :command:`mkfs.btrfs`). This +ensures that new filesystems are compatible across other architecture +variants using larger page sizes. Requirements, limitations ------------------------- -The initial subpage support has been added in v5.15, although it's still -considered as experimental, most features are already working without problems. -On a 64KiB page system filesystem with 4KiB sectorsize can be mounted and used -as usual as long as the initial mount succeeds. There are cases a mount will be -rejected when verifying compatible features. +The initial subpage support has been added in v5.15. Most features are +already working without problems. On a 64KiB page system, a filesystem with +4KiB sectorsize can be mounted and used as long as the initial mount succeeds. +Subpage support is used by default for systems with a non-4KiB page size since v6.6. Please refer to status page of :ref:`status-subpage-block-size` for compatibility.
Documentation/mkfs.btrfs.rst +9 -4
@@ -122,10 +122,15 @@ OPTIONS -s|--sectorsize <size> Specify the sectorsize, the minimum data block allocation unit. - The default value is the page size and is autodetected. If the sectorsize - differs from the page size, the created filesystem may not be mountable by the - running kernel. Therefore it is not recommended to use this option unless you - are going to mount it on a system with the appropriate page size. + By default, the value is 4KiB, but it can be manually set to match the + system page size. However, if the sector size is different from the page + size, the resulting filesystem may not be mountable by the current + kernel, apart from the default 4KiB. Hence, using this option is not + advised unless you intend to mount it on a system with the suitable + page size. + + .. note:: + Versions prior to 6.6 set the sectorsize matching to the page size. -L|--label <string> Specify a label for the filesystem. The *string* should be less than 256
mkfs/main.c +1 -1
@@ -1204,7 +1204,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv) }if (!sectorsize) - sectorsize = (u32 )sysconf (_SC_PAGESIZE); + sectorsize = (u32 )SZ_4K ;if (btrfs_check_sectorsize (sectorsize)) goto error;
Signature · 1 line
2.41.0