Commit 4bbee76b authored by Rob Landley's avatar Rob Landley Committed by Linus Torvalds

initmpfs: move bdi setup from init_rootfs to init_ramfs

Even though ramfs hasn't got a backing device, commit e0bf68dd ("mm:
bdi init hooks") added one anyway, and put the initialization in
init_rootfs() since that's the first user, leaving it out of init_ramfs()
to avoid duplication.

But initmpfs uses init_tmpfs() instead, so move the init into the
filesystem's init function, add a "once" guard to prevent duplicate
initialization, and call the filesystem init from rootfs init.

This goes part of the way to allowing ramfs to be built as a module.

[akpm@linux-foundation.org; using bit 1 was odd]
Signed-off-by: default avatarRob Landley <rob@landley.net>
Cc: Jeff Layton <jlayton@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jim Cromie <jim.cromie@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 137fdcc1
...@@ -249,7 +249,7 @@ static struct dentry *rootfs_mount(struct file_system_type *fs_type, ...@@ -249,7 +249,7 @@ static struct dentry *rootfs_mount(struct file_system_type *fs_type,
{ {
static unsigned long once; static unsigned long once;
if (test_and_set_bit(1, &once)) if (test_and_set_bit(0, &once))
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
return mount_nodev(fs_type, flags, data, ramfs_fill_super); return mount_nodev(fs_type, flags, data, ramfs_fill_super);
...@@ -275,21 +275,34 @@ static struct file_system_type rootfs_fs_type = { ...@@ -275,21 +275,34 @@ static struct file_system_type rootfs_fs_type = {
static int __init init_ramfs_fs(void) static int __init init_ramfs_fs(void)
{ {
return register_filesystem(&ramfs_fs_type); static unsigned long once;
int err;
if (test_and_set_bit(0, &once))
return 0;
err = bdi_init(&ramfs_backing_dev_info);
if (err)
return err;
err = register_filesystem(&ramfs_fs_type);
if (err)
bdi_destroy(&ramfs_backing_dev_info);
return err;
} }
module_init(init_ramfs_fs) module_init(init_ramfs_fs)
int __init init_rootfs(void) int __init init_rootfs(void)
{ {
int err; int err = register_filesystem(&rootfs_fs_type);
err = bdi_init(&ramfs_backing_dev_info);
if (err) if (err)
return err; return err;
err = register_filesystem(&rootfs_fs_type); err = init_ramfs_fs();
if (err) if (err)
bdi_destroy(&ramfs_backing_dev_info); unregister_filesystem(&rootfs_fs_type);
return err; return err;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment