Use tmpfs rather tham ramfs for rootfs when available
Subsystems (2)
RFC PATCH 1/1 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(-)
fs/ramfs/inode.c +6 -0
@@ -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 !(definedCONFIG_SHMEM && definedCONFIG_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 !(definedCONFIG_SHMEM && definedCONFIG_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 !(definedCONFIG_SHMEM && definedCONFIG_TMPFS )int __init init_rootfs (void ) {int err;
@@ -303,3 +308,4 @@ int __init init_rootfs(void) return err; } +#endif
mm/shmem.c +27 -4
@@ -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 */ /*
Signature · 1 line
1.7.2.3