Skip to content

Commit 6f93e83

Browse files
asjkdave
authored andcommitted
btrfs: fix upper limit for max_inline for page size 64K
The mount option max_inline ranges from 0 to the sectorsize (which is now equal to page size). But we parse the mount options too early and before the actual sectorsize is read from the superblock. So the upper limit of max_inline is unaware of the actual sectorsize and is limited by the temporary sectorsize 4096, even on a system where the default sectorsize is 64K. Fix this by reading the superblock sectorsize before the mount option parse. Reported-by: Alexander Tsvetkov <[email protected]> CC: [email protected] # 5.4+ Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0d977e0 commit 6f93e83

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

fs/btrfs/disk-io.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,6 +3314,30 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
33143314
*/
33153315
fs_info->compress_type = BTRFS_COMPRESS_ZLIB;
33163316

3317+
/*
3318+
* Flag our filesystem as having big metadata blocks if they are bigger
3319+
* than the page size.
3320+
*/
3321+
if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) {
3322+
if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA))
3323+
btrfs_info(fs_info,
3324+
"flagging fs with big metadata feature");
3325+
features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA;
3326+
}
3327+
3328+
/* Set up fs_info before parsing mount options */
3329+
nodesize = btrfs_super_nodesize(disk_super);
3330+
sectorsize = btrfs_super_sectorsize(disk_super);
3331+
stripesize = sectorsize;
3332+
fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids));
3333+
fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids));
3334+
3335+
fs_info->nodesize = nodesize;
3336+
fs_info->sectorsize = sectorsize;
3337+
fs_info->sectorsize_bits = ilog2(sectorsize);
3338+
fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size;
3339+
fs_info->stripesize = stripesize;
3340+
33173341
ret = btrfs_parse_options(fs_info, options, sb->s_flags);
33183342
if (ret) {
33193343
err = ret;
@@ -3340,30 +3364,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
33403364
if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
33413365
btrfs_info(fs_info, "has skinny extents");
33423366

3343-
/*
3344-
* flag our filesystem as having big metadata blocks if
3345-
* they are bigger than the page size
3346-
*/
3347-
if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) {
3348-
if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA))
3349-
btrfs_info(fs_info,
3350-
"flagging fs with big metadata feature");
3351-
features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA;
3352-
}
3353-
3354-
nodesize = btrfs_super_nodesize(disk_super);
3355-
sectorsize = btrfs_super_sectorsize(disk_super);
3356-
stripesize = sectorsize;
3357-
fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids));
3358-
fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids));
3359-
3360-
/* Cache block sizes */
3361-
fs_info->nodesize = nodesize;
3362-
fs_info->sectorsize = sectorsize;
3363-
fs_info->sectorsize_bits = ilog2(sectorsize);
3364-
fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size;
3365-
fs_info->stripesize = stripesize;
3366-
33673367
/*
33683368
* mixed block groups end up with duplicate but slightly offset
33693369
* extent buffers for the same range. It leads to corruptions

0 commit comments

Comments
 (0)