Skip to content

Commit 9a53eb1

Browse files
LiBaokun96kawasaki
authored andcommitted
bdev: add hint prints in sb_set_blocksize() for LBS dependency on THP
Support for block sizes greater than the page size depends on large folios, which in turn require CONFIG_TRANSPARENT_HUGEPAGE to be enabled. Because the code is wrapped in multiple layers of abstraction, this dependency is rather obscure, so users may not realize it and may be unsure how to enable LBS. As suggested by Theodore, I have added hint messages in sb_set_blocksize so that users can distinguish whether a mount failure with block size larger than page size is due to lack of filesystem support or the absence of CONFIG_TRANSPARENT_HUGEPAGE. Suggested-by: Theodore Ts'o <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Baokun Li <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Zhang Yi <[email protected]>
1 parent 6099a4d commit 9a53eb1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

block/bdev.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,26 @@ int set_blocksize(struct file *file, int size)
217217

218218
EXPORT_SYMBOL(set_blocksize);
219219

220+
static int sb_validate_large_blocksize(struct super_block *sb, int size)
221+
{
222+
const char *err_str = NULL;
223+
224+
if (!(sb->s_type->fs_flags & FS_LBS))
225+
err_str = "not supported by filesystem";
226+
else if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
227+
err_str = "is only supported with CONFIG_TRANSPARENT_HUGEPAGE";
228+
229+
if (!err_str)
230+
return 0;
231+
232+
pr_warn_ratelimited("%s: block size(%d) > page size(%lu) %s\n",
233+
sb->s_type->name, size, PAGE_SIZE, err_str);
234+
return -EINVAL;
235+
}
236+
220237
int sb_set_blocksize(struct super_block *sb, int size)
221238
{
222-
if (!(sb->s_type->fs_flags & FS_LBS) && size > PAGE_SIZE)
239+
if (size > PAGE_SIZE && sb_validate_large_blocksize(sb, size))
223240
return 0;
224241
if (set_blocksize(sb->s_bdev_file, size))
225242
return 0;

0 commit comments

Comments
 (0)