Skip to content

Commit 4021e68

Browse files
hsiangkaobrauner
authored andcommitted
fs/super.c: introduce get_tree_bdev_flags()
As Allison reported [1], currently get_tree_bdev() will store "Can't lookup blockdev" error message. Although it makes sense for pure bdev-based fses, this message may mislead users who try to use EROFS file-backed mounts since get_tree_nodev() is used as a fallback then. Add get_tree_bdev_flags() to specify extensible flags [2] and GET_TREE_BDEV_QUIET_LOOKUP to silence "Can't lookup blockdev" message since it's misleading to EROFS file-backed mounts now. [1] https://lore.kernel.org/r/CAOYeF9VQ8jKVmpy5Zy9DNhO6xmWSKMB-DO8yvBB0XvBE7=3Ugg@mail.gmail.com [2] https://lore.kernel.org/r/[email protected] Suggested-by: Christoph Hellwig <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 42f7652 commit 4021e68

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

fs/super.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,13 +1596,14 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
15961596
EXPORT_SYMBOL_GPL(setup_bdev_super);
15971597

15981598
/**
1599-
* get_tree_bdev - Get a superblock based on a single block device
1599+
* get_tree_bdev_flags - Get a superblock based on a single block device
16001600
* @fc: The filesystem context holding the parameters
16011601
* @fill_super: Helper to initialise a new superblock
1602+
* @flags: GET_TREE_BDEV_* flags
16021603
*/
1603-
int get_tree_bdev(struct fs_context *fc,
1604-
int (*fill_super)(struct super_block *,
1605-
struct fs_context *))
1604+
int get_tree_bdev_flags(struct fs_context *fc,
1605+
int (*fill_super)(struct super_block *sb,
1606+
struct fs_context *fc), unsigned int flags)
16061607
{
16071608
struct super_block *s;
16081609
int error = 0;
@@ -1613,10 +1614,10 @@ int get_tree_bdev(struct fs_context *fc,
16131614

16141615
error = lookup_bdev(fc->source, &dev);
16151616
if (error) {
1616-
errorf(fc, "%s: Can't lookup blockdev", fc->source);
1617+
if (!(flags & GET_TREE_BDEV_QUIET_LOOKUP))
1618+
errorf(fc, "%s: Can't lookup blockdev", fc->source);
16171619
return error;
16181620
}
1619-
16201621
fc->sb_flags |= SB_NOSEC;
16211622
s = sget_dev(fc, dev);
16221623
if (IS_ERR(s))
@@ -1644,6 +1645,19 @@ int get_tree_bdev(struct fs_context *fc,
16441645
fc->root = dget(s->s_root);
16451646
return 0;
16461647
}
1648+
EXPORT_SYMBOL_GPL(get_tree_bdev_flags);
1649+
1650+
/**
1651+
* get_tree_bdev - Get a superblock based on a single block device
1652+
* @fc: The filesystem context holding the parameters
1653+
* @fill_super: Helper to initialise a new superblock
1654+
*/
1655+
int get_tree_bdev(struct fs_context *fc,
1656+
int (*fill_super)(struct super_block *,
1657+
struct fs_context *))
1658+
{
1659+
return get_tree_bdev_flags(fc, fill_super, 0);
1660+
}
16471661
EXPORT_SYMBOL(get_tree_bdev);
16481662

16491663
static int test_bdev_super(struct super_block *s, void *data)

include/linux/fs_context.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ extern int get_tree_keyed(struct fs_context *fc,
160160

161161
int setup_bdev_super(struct super_block *sb, int sb_flags,
162162
struct fs_context *fc);
163+
164+
#define GET_TREE_BDEV_QUIET_LOOKUP 0x0001
165+
int get_tree_bdev_flags(struct fs_context *fc,
166+
int (*fill_super)(struct super_block *sb,
167+
struct fs_context *fc), unsigned int flags);
168+
163169
extern int get_tree_bdev(struct fs_context *fc,
164170
int (*fill_super)(struct super_block *sb,
165171
struct fs_context *fc));

0 commit comments

Comments
 (0)