diff mbox series

[v4,42/68] btrfs: allow RO mount of 4K sector size fs on 64K page system

Message ID 20201021062554.68132-43-wqu@suse.com
State New, archived
Headers show
Series btrfs: add basic rw support for subpage sector size | expand

Commit Message

Qu Wenruo Oct. 21, 2020, 6:25 a.m. UTC
This adds the basic RO mount ability for 4K sector size on 64K page
system.

Currently we only plan to support 4K and 64K page system.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/disk-io.c | 24 +++++++++++++++++++++---
 fs/btrfs/super.c   |  7 +++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

Comments

David Sterba Oct. 29, 2020, 8:11 p.m. UTC | #1
On Wed, Oct 21, 2020 at 02:25:28PM +0800, Qu Wenruo wrote:
> This adds the basic RO mount ability for 4K sector size on 64K page
> system.
> 
> Currently we only plan to support 4K and 64K page system.

This should cover the most common page sizes, though there's still SPARC
with 8K pages and there were people reporting some problems in the past.
There are more arches with other page sizes but I don't think they're
actively used.
Michał Mirosław Oct. 29, 2020, 11:34 p.m. UTC | #2
On Wed, Oct 21, 2020 at 02:25:28PM +0800, Qu Wenruo wrote:
> This adds the basic RO mount ability for 4K sector size on 64K page
> system.
> 
> Currently we only plan to support 4K and 64K page system.
[...]

Why this restriction? I briefly looked at this patch and some of the
previous and it looks like the code doesn't really care about anything
more than order(PAGE_SIZE) >= order(sectorsize).

Best Regards,
Michał Mirosław
Qu Wenruo Oct. 29, 2020, 11:56 p.m. UTC | #3
On 2020/10/30 上午7:34, Michał Mirosław wrote:
> On Wed, Oct 21, 2020 at 02:25:28PM +0800, Qu Wenruo wrote:
>> This adds the basic RO mount ability for 4K sector size on 64K page
>> system.
>>
>> Currently we only plan to support 4K and 64K page system.
> [...]
> 
> Why this restriction? I briefly looked at this patch and some of the
> previous and it looks like the code doesn't really care about anything
> more than order(PAGE_SIZE) >= order(sectorsize).

The restriction comes from the metadata operations.

Currently for subpage case, we expect one page to contain all of the
subpage tree block.

For things like 32K, 16K or 8K page size, we need more pages to handle them.
That needs extra work to handle unaligned tree start (already done for
current subpage support) and multi-page case (not for current subpage,
but only for sectorsize == PAGE_SIZE yet).

Another problem is testing.

Currently the only (cheap) way to test 64K page size is using ARM64 SBC.
(My current setup is with RK3399 since it's cheap and has full x4 lane
NVME support)

For 8K or 32K, I don't find widely available device to test.

Anyway, my current focus is to add balance support and remove all small
bugs exposed so far.
We may support 16K in the future, but only after we have finished
current 64K subpage support.

Thanks,
Qu

> 
> Best Regards,
> Michał Mirosław
>
diff mbox series

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 97c44f518a49..e0dc7b92411e 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2565,13 +2565,21 @@  static int validate_super(struct btrfs_fs_info *fs_info,
 		btrfs_err(fs_info, "invalid sectorsize %llu", sectorsize);
 		ret = -EINVAL;
 	}
-	/* Only PAGE SIZE is supported yet */
-	if (sectorsize != PAGE_SIZE) {
+
+	/*
+	 * For 4K page size, we only support 4K sector size.
+	 * For 64K page size, we support RW for 64K sector size, and RO for
+	 * 4K sector size.
+	 */
+	if ((PAGE_SIZE == SZ_4K && sectorsize != PAGE_SIZE) ||
+	    (PAGE_SIZE == SZ_64K && (sectorsize != SZ_4K &&
+				     sectorsize != SZ_64K))) {
 		btrfs_err(fs_info,
-			"sectorsize %llu not supported yet, only support %lu",
+			"sectorsize %llu not supported yet for page size %lu",
 			sectorsize, PAGE_SIZE);
 		ret = -EINVAL;
 	}
+
 	if (!is_power_of_2(nodesize) || nodesize < sectorsize ||
 	    nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) {
 		btrfs_err(fs_info, "invalid nodesize %llu", nodesize);
@@ -3219,6 +3227,16 @@  int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 		goto fail_alloc;
 	}
 
+	/* For 4K sector size support, it's only read-only yet */
+	if (PAGE_SIZE == SZ_64K && sectorsize == SZ_4K) {
+		if (!sb_rdonly(sb) || btrfs_super_log_root(disk_super)) {
+			btrfs_err(fs_info,
+				"subpage sector size only support RO yet");
+			err = -EINVAL;
+			goto fail_alloc;
+		}
+	}
+
 	ret = btrfs_init_workqueues(fs_info, fs_devices);
 	if (ret) {
 		err = ret;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 25967ecaaf0a..743a2fadf4ee 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1922,6 +1922,13 @@  static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 			ret = -EINVAL;
 			goto restore;
 		}
+		if (btrfs_is_subpage(fs_info)) {
+			btrfs_warn(fs_info,
+	"read-write mount is not yet allowed for sector size %u page size %lu",
+				   fs_info->sectorsize, PAGE_SIZE);
+			ret = -EINVAL;
+			goto restore;
+		}
 
 		ret = btrfs_cleanup_fs_roots(fs_info);
 		if (ret)