lkml.org 
[lkml]   [2013]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/5] initmpfs: Move bdi setup from init_rootfs to init_ramfs
From: Rob Landley <rob@landley.net>

Even though ramfs hasn't got a backing device, commit e0bf68ddec4f 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.

Signed-off-by: Rob Landley <rob@landley.net>
---

fs/ramfs/inode.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

--- initold/fs/ramfs/inode.c 2013-06-28 15:12:03.205879730 -0500
+++ initold2/fs/ramfs/inode.c 2013-06-28 15:12:12.425880115 -0500
@@ -277,21 +277,36 @@

static int __init init_ramfs_fs(void)
{
- return register_filesystem(&ramfs_fs_type);
+ static int once;
+ int err;
+
+ if (once)
+ return 0;
+ else
+ once++;
+
+ 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)

int __init init_rootfs(void)
{
- int err;
+ int err = register_filesystem(&rootfs_fs_type);

- err = bdi_init(&ramfs_backing_dev_info);
if (err)
return err;

- err = register_filesystem(&rootfs_fs_type);
+ err = init_ramfs_fs();
if (err)
- bdi_destroy(&ramfs_backing_dev_info);
+ unregister_filesystem(&rootfs_fs_type);

return err;
}

\
 
 \ /
  Last update: 2013-06-29 22:41    [W:0.071 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site