btrfs: expand subpage support to any PAGE_SIZE > 4K
authorQu Wenruo <wqu@suse.com>
Thu, 13 Jan 2022 05:22:10 +0000 (13:22 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:11 +0000 (17:03 +0200)
With the recent change in metadata handling, we can handle metadata in
the following cases:

- nodesize < PAGE_SIZE and sectorsize < PAGE_SIZE
  Go subpage routine for both metadata and data.

- nodesize < PAGE_SIZE and sectorsize >= PAGE_SIZE
  Invalid case for now. As we require nodesize >= sectorsize.

- nodesize >= PAGE_SIZE and sectorsize < PAGE_SIZE
  Go subpage routine for data, but regular page routine for metadata.

- nodesize >= PAGE_SIZE and sectorsize >= PAGE_SIZE
  Go regular page routine for both metadata and data.

Now we can handle any sectorsize < PAGE_SIZE, plus the existing
sectorsize == PAGE_SIZE support.

But here we introduce an artificial limit, any PAGE_SIZE > 4K case, we
will only support 4K and PAGE_SIZE as sector size.

The idea here is to reduce the test combinations, and push 4K as the
default standard in the future.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/sysfs.c

index b4ed0b3..22105c8 100644 (file)
@@ -2835,12 +2835,14 @@ static int validate_super(struct btrfs_fs_info *fs_info,
        }
 
        /*
-        * For 4K page size, we only support 4K sector size.
-        * For 64K page size, we support 64K and 4K sector sizes.
+        * We only support at most two sectorsizes: 4K and PAGE_SIZE.
+        *
+        * We can support 16K sectorsize with 64K page size without problem,
+        * but such sectorsize/pagesize combination doesn't make much sense.
+        * 4K will be our future standard, PAGE_SIZE is supported from the very
+        * beginning.
         */
-       if ((PAGE_SIZE == SZ_4K && sectorsize != PAGE_SIZE) ||
-           (PAGE_SIZE == SZ_64K && (sectorsize != SZ_4K &&
-                                    sectorsize != SZ_64K))) {
+       if (sectorsize > PAGE_SIZE || (sectorsize != SZ_4K && sectorsize != PAGE_SIZE)) {
                btrfs_err(fs_info,
                        "sectorsize %llu not yet supported for page size %lu",
                        sectorsize, PAGE_SIZE);
index ba78ca5..d742330 100644 (file)
@@ -394,11 +394,9 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
 {
        ssize_t ret = 0;
 
-       /* 4K sector size is also supported with 64K page size */
-       if (PAGE_SIZE == SZ_64K)
+       /* An artificial limit to only support 4K and PAGE_SIZE */
+       if (PAGE_SIZE > SZ_4K)
                ret += sysfs_emit_at(buf, ret, "%u ", SZ_4K);
-
-       /* Only sectorsize == PAGE_SIZE is now supported */
        ret += sysfs_emit_at(buf, ret, "%lu\n", PAGE_SIZE);
 
        return ret;