btrfs-progs: mkfs: make 4k sectorsize 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.

As the subpage has stabilized it seems to be safe to do the switch.
This may still affect users that relying on the previous behaviour.

Issue: #604
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Signed-off-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Neal Gompa 2023-11-16 11:02:24 -05:00 committed by David Sterba
parent fdf7f35d3e
commit e3232c2abb
3 changed files with 19 additions and 13 deletions

View File

@ -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 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. 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 Since v6.7, filesystems are created with a 4KiB sectorsize by default,
and mount filesystems with 4KiB sectorsize. This still needs to use option "-s though it remains possible to create filesystems with other page sizes
4k" option for :command:`mkfs.btrfs`. (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 Requirements, limitations
------------------------- -------------------------
The initial subpage support has been added in v5.15, although it's still The initial subpage support has been added in v5.15. Most features are
considered as experimental, most features are already working without problems. already working without problems. On a 64KiB page system, a filesystem with
On a 64KiB page system filesystem with 4KiB sectorsize can be mounted and used 4KiB sectorsize can be mounted and used as long as the initial mount succeeds.
as usual as long as the initial mount succeeds. There are cases a mount will be Subpage support is used by default for systems with a non-4KiB page size since v6.7.
rejected when verifying compatible features.
Please refer to status page of :ref:`status-subpage-block-size` for Please refer to status page of :ref:`status-subpage-block-size` for
compatibility. compatibility.

View File

@ -122,10 +122,15 @@ OPTIONS
-s|--sectorsize <size> -s|--sectorsize <size>
Specify the sectorsize, the minimum data block allocation unit. Specify the sectorsize, the minimum data block allocation unit.
The default value is the page size and is autodetected. If the sectorsize By default, the value is 4KiB, but it can be manually set to match the
differs from the page size, the created filesystem may not be mountable by the system page size. However, if the sector size is different from the page
running kernel. Therefore it is not recommended to use this option unless you size, the resulting filesystem may not be mountable by the current
are going to mount it on a system with the appropriate page size. 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.7 set the sectorsize matching to the page size.
-L|--label <string> -L|--label <string>
Specify a label for the filesystem. The *string* should be less than 256 Specify a label for the filesystem. The *string* should be less than 256

View File

@ -1384,7 +1384,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
} }
if (!sectorsize) if (!sectorsize)
sectorsize = (u32)sysconf(_SC_PAGESIZE); sectorsize = (u32)SZ_4K;
if (btrfs_check_sectorsize(sectorsize)) if (btrfs_check_sectorsize(sectorsize))
goto error; goto error;