[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20111205170244.GA16014@golden.localdomain>
Date: Mon, 5 Dec 2011 17:02:45 +0000
From: Andrew Walrond <andrew@...rond.org>
To: linux-kernel@...r.kernel.org
Subject: [RFC][PATCH] Use tmpfs rather tham ramfs for rootfs when available
Make rootfs an instance of tmpfs instead of ramfs when tmpfs is available.
Documentation/filesystems/ramfs-rootfs-initramfs.txt says:
"Rootfs is a special instance of ramfs (or tmpfs, if that's enabled)"
but it has always been a lie, until now.
This patch is based upon one proposed by Bodo Eggert in 2008.
---
fs/ramfs/inode.c | 6 ++++++
mm/shmem.c | 31 +++++++++++++++++++++++++++----
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 462ceb3..e8a5c7f 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -260,11 +260,13 @@ struct dentry *ramfs_mount(struct file_system_type *fs_type,
return mount_nodev(fs_type, flags, data, ramfs_fill_super);
}
+#if !(defined CONFIG_SHMEM && defined CONFIG_TMPFS)
static struct dentry *rootfs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return mount_nodev(fs_type, flags|MS_NOUSER, data, ramfs_fill_super);
}
+#endif
static void ramfs_kill_sb(struct super_block *sb)
{
@@ -277,11 +279,13 @@ static struct file_system_type ramfs_fs_type = {
.mount = ramfs_mount,
.kill_sb = ramfs_kill_sb,
};
+#if !(defined CONFIG_SHMEM && defined CONFIG_TMPFS)
static struct file_system_type rootfs_fs_type = {
.name = "rootfs",
.mount = rootfs_mount,
.kill_sb = kill_litter_super,
};
+#endif
static int __init init_ramfs_fs(void)
{
@@ -289,6 +293,7 @@ static int __init init_ramfs_fs(void)
}
module_init(init_ramfs_fs)
+#if !(defined CONFIG_SHMEM && defined CONFIG_TMPFS)
int __init init_rootfs(void)
{
int err;
@@ -303,3 +308,4 @@ int __init init_rootfs(void)
return err;
}
+#endif
diff --git a/mm/shmem.c b/mm/shmem.c
index d672250..9b7af22 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2220,7 +2220,7 @@ failed:
return err;
}
-static struct kmem_cache *shmem_inode_cachep;
+static struct kmem_cache *shmem_inode_cachep = NULL;
static struct inode *shmem_alloc_inode(struct super_block *sb)
{
@@ -2253,9 +2253,11 @@ static void shmem_init_inode(void *foo)
static int shmem_init_inodecache(void)
{
- shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
- sizeof(struct shmem_inode_info),
- 0, SLAB_PANIC, shmem_init_inode);
+ if (!shmem_inode_cachep)
+ shmem_inode_cachep =
+ kmem_cache_create("shmem_inode_cache",
+ sizeof(struct shmem_inode_info),
+ 0, SLAB_PANIC, shmem_init_inode);
return 0;
}
@@ -2407,6 +2409,27 @@ out4:
return error;
}
+#ifdef CONFIG_TMPFS
+static struct dentry *rootfs_mount(struct file_system_type *fs_type,
+ int flags, const char *dev_name, void *data)
+{
+ return mount_nodev(fs_type, flags|MS_NOUSER, data, shmem_fill_super);
+}
+
+static struct file_system_type rootfs_fs_type = {
+ .name = "rootfs",
+ .mount = rootfs_mount,
+ .kill_sb = kill_litter_super,
+};
+
+int __init init_rootfs(void)
+{
+ if (shmem_init_inodecache())
+ panic("Rootfs - Can't initialize shm inode cache");
+ return register_filesystem(&rootfs_fs_type);
+}
+#endif
+
#else /* !CONFIG_SHMEM */
/*
--
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists