Skip to contentSkip to conversation

+ initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Jul 19, 2013

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Fri, 19 Jul 2013 12:57:52 -0700

The patch titled
Subject: initmpfs: make rootfs use tmpfs when CONFIG_TMPFS enabled
has been added to the -mm tree. Its filename is
initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Rob Landley <[email protected]>
Subject: initmpfs: make rootfs use tmpfs when CONFIG_TMPFS enabled

Conditionally call the appropriate fs_init function and fill_super functions. Add a use once guard to shmem_init() to simply succeed on a second call.

(Note that IS_ENABLED() is a compile time constant so dead code elimination removes unused function calls when CONFIG_TMPFS is disabled.)

Cc Jeff Layton <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Rusty Russell <[email protected]>
Cc Jim Cromie <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc Alexander Viro <[email protected]>
Cc "H. Peter Anvin" <[email protected]>

---

 init/do_mounts.c |   10 ++++++++--
 mm/shmem.c       |    4 ++++
 2 files changed, 12 insertions(+), 2 deletions(-)
init/do_mounts.c renamed from init/do_mounts.c~initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled +8 -2
diff -puN init/do_mounts.c~initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled init/do_mounts.c
@@ -27,6 +27,7 @@
 #include <linux/fs_struct.h>
 #include <linux/slab.h>
 #include <linux/ramfs.h>
+#include <linux/shmem_fs.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -598,7 +599,8 @@ static struct dentry *rootfs_mount(struc
 	if (test_and_set_bit(0, &once))
 		return ERR_PTR(-ENODEV);
 
-	return mount_nodev(fs_type, flags, data, ramfs_fill_super);
+	return mount_nodev(fs_type, flags, data,
+		IS_ENABLED(CONFIG_TMPFS) ? shmem_fill_super : ramfs_fill_super);
 }
 
 static struct file_system_type rootfs_fs_type = {
@@ -614,7 +616,11 @@ int __init init_rootfs(void)
 	if (err)
 		return err;
 
-	err = init_ramfs_fs();
+	if (IS_ENABLED(CONFIG_TMPFS))
+		err = shmem_init();
+	else
+		err = init_ramfs_fs();
+
 	if (err)
 		unregister_filesystem(&rootfs_fs_type);
 
mm/shmem.c renamed from mm/shmem.c~initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled +4 -0
diff -puN mm/shmem.c~initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled mm/shmem.c
@@ -2817,6 +2817,10 @@ int __init shmem_init(void)
 {
 	int error;
 
+	/* If rootfs called this, don't re-init */
+	if (shmem_inode_cachep)
+		return 0;
+
 	error = bdi_init(&shmem_backing_dev_info);
 	if (error)
 		goto out4;

_

Patches currently in -mm which might be from [email protected] are

x86-make-mem=-option-to-work-for-efi-platform.patch initmpfs-replace-ms_nouser-in-initramfs.patch initmpfs-move-bdi-setup-from-init_rootfs-to-init_ramfs.patch initmpfs-move-bdi-setup-from-init_rootfs-to-init_ramfs-fix.patch initmpfs-move-rootfs-code-from-fs-ramfs-to-init.patch initmpfs-make-rootfs-use-tmpfs-when-config_tmpfs-enabled.patch initmpfs-use-initramfs-if-rootfstype=-or-root=-specified.patch