linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Mike Snitzer <snitzer@kernel.org>,
	Joern Engel <joern@lazybastard.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Pavel Machek <pavel@ucw.cz>,
	dm-devel@redhat.com, linux-kernel@vger.kernel.org,
	linux-block@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-pm@vger.kernel.org
Subject: [PATCH 08/24] init: pass root_device_name explicitly
Date: Tue, 23 May 2023 09:45:19 +0200	[thread overview]
Message-ID: <20230523074535.249802-9-hch@lst.de> (raw)
In-Reply-To: <20230523074535.249802-1-hch@lst.de>

Instead of declaring root_device_name as a global variable pass it as an
argument to the funtions using it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 init/do_mounts.c        | 29 ++++++++++++++++-------------
 init/do_mounts.h        | 14 +++++++-------
 init/do_mounts_initrd.c | 11 ++++++-----
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index e708b02d9d6566..1405ee7218bf00 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -28,7 +28,6 @@
 #include "do_mounts.h"
 
 int root_mountflags = MS_RDONLY | MS_SILENT;
-static char * __initdata root_device_name;
 static char __initdata saved_root_name[64];
 static int root_wait;
 
@@ -391,7 +390,7 @@ static int __init do_mount_root(const char *name, const char *fs,
 	return ret;
 }
 
-void __init mount_root_generic(char *name, int flags)
+void __init mount_root_generic(char *name, char *pretty_name, int flags)
 {
 	struct page *page = alloc_page(GFP_KERNEL);
 	char *fs_names = page_address(page);
@@ -425,7 +424,7 @@ void __init mount_root_generic(char *name, int flags)
 		 * and give them a list of the available devices
 		 */
 		printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",
-				root_device_name, b, err);
+				pretty_name, b, err);
 		printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
 
 		printk_all_partitions();
@@ -541,7 +540,7 @@ static bool __init fs_is_nodev(char *fstype)
 	return ret;
 }
 
-static int __init mount_nodev_root(void)
+static int __init mount_nodev_root(char *root_device_name)
 {
 	char *fs_names, *fstype;
 	int err = -EINVAL;
@@ -569,21 +568,21 @@ static int __init mount_nodev_root(void)
 }
 
 #ifdef CONFIG_BLOCK
-static void __init mount_block_root(void)
+static void __init mount_block_root(char *root_device_name)
 {
 	int err = create_dev("/dev/root", ROOT_DEV);
 
 	if (err < 0)
 		pr_emerg("Failed to create /dev/root: %d\n", err);
-	mount_root_generic("/dev/root", root_mountflags);
+	mount_root_generic("/dev/root", root_device_name, root_mountflags);
 }
 #else
-static inline void mount_block_root(void)
+static inline void mount_block_root(char *root_device_name)
 {
 }
 #endif /* CONFIG_BLOCK */
 
-void __init mount_root(void)
+void __init mount_root(char *root_device_name)
 {
 	switch (ROOT_DEV) {
 	case Root_NFS:
@@ -593,11 +592,12 @@ void __init mount_root(void)
 		mount_cifs_root();
 		break;
 	case 0:
-		if (root_device_name && root_fs_names && mount_nodev_root() == 0)
+		if (root_device_name && root_fs_names &&
+		    mount_nodev_root(root_device_name) == 0)
 			break;
 		fallthrough;
 	default:
-		mount_block_root();
+		mount_block_root(root_device_name);
 		break;
 	}
 }
@@ -607,6 +607,8 @@ void __init mount_root(void)
  */
 void __init prepare_namespace(void)
 {
+	char *root_device_name;
+
 	if (root_delay) {
 		printk(KERN_INFO "Waiting %d sec before mounting root device...\n",
 		       root_delay);
@@ -628,7 +630,8 @@ void __init prepare_namespace(void)
 		root_device_name = saved_root_name;
 		if (!strncmp(root_device_name, "mtd", 3) ||
 		    !strncmp(root_device_name, "ubi", 3)) {
-			mount_root_generic(root_device_name, root_mountflags);
+			mount_root_generic(root_device_name, root_device_name,
+					   root_mountflags);
 			goto out;
 		}
 		ROOT_DEV = name_to_dev_t(root_device_name);
@@ -636,7 +639,7 @@ void __init prepare_namespace(void)
 			root_device_name += 5;
 	}
 
-	if (initrd_load())
+	if (initrd_load(root_device_name))
 		goto out;
 
 	/* wait for any asynchronous scanning to complete */
@@ -649,7 +652,7 @@ void __init prepare_namespace(void)
 		async_synchronize_full();
 	}
 
-	mount_root();
+	mount_root(root_device_name);
 out:
 	devtmpfs_mount();
 	init_mount(".", "/", NULL, MS_MOVE, NULL);
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 33623025f6951a..15e372b00ce704 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -10,8 +10,8 @@
 #include <linux/root_dev.h>
 #include <linux/init_syscalls.h>
 
-void  mount_root_generic(char *name, int flags);
-void  mount_root(void);
+void  mount_root_generic(char *name, char *pretty_name, int flags);
+void  mount_root(char *root_device_name);
 extern int root_mountflags;
 
 static inline __init int create_dev(char *name, dev_t dev)
@@ -33,11 +33,11 @@ static inline int rd_load_image(char *from) { return 0; }
 #endif
 
 #ifdef CONFIG_BLK_DEV_INITRD
-
-bool __init initrd_load(void);
-
+bool __init initrd_load(char *root_device_name);
 #else
-
-static inline bool initrd_load(void) { return false; }
+static inline bool initrd_load(char *root_device_name)
+{
+	return false;
+	}
 
 #endif
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 686d1ff3af4bb1..425f4bcf4b77e0 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -83,7 +83,7 @@ static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)
 	return 0;
 }
 
-static void __init handle_initrd(void)
+static void __init handle_initrd(char *root_device_name)
 {
 	struct subprocess_info *info;
 	static char *argv[] = { "linuxrc", NULL, };
@@ -95,7 +95,8 @@ static void __init handle_initrd(void)
 	real_root_dev = new_encode_dev(ROOT_DEV);
 	create_dev("/dev/root.old", Root_RAM0);
 	/* mount initrd on rootfs' /root */
-	mount_root_generic("/dev/root.old", root_mountflags & ~MS_RDONLY);
+	mount_root_generic("/dev/root.old", root_device_name,
+			   root_mountflags & ~MS_RDONLY);
 	init_mkdir("/old", 0700);
 	init_chdir("/old");
 
@@ -117,7 +118,7 @@ static void __init handle_initrd(void)
 
 	init_chdir("/");
 	ROOT_DEV = new_decode_dev(real_root_dev);
-	mount_root();
+	mount_root(root_device_name);
 
 	printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
 	error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
@@ -133,7 +134,7 @@ static void __init handle_initrd(void)
 	}
 }
 
-bool __init initrd_load(void)
+bool __init initrd_load(char *root_device_name)
 {
 	if (mount_initrd) {
 		create_dev("/dev/ram", Root_RAM0);
@@ -145,7 +146,7 @@ bool __init initrd_load(void)
 		 */
 		if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
 			init_unlink("/initrd.image");
-			handle_initrd();
+			handle_initrd(root_device_name);
 			return true;
 		}
 	}
-- 
2.39.2


  parent reply	other threads:[~2023-05-23  7:46 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23  7:45 fix the name_to_dev_t mess Christoph Hellwig
2023-05-23  7:45 ` [PATCH 01/24] driver core: return bool from driver_probe_done Christoph Hellwig
2023-05-23 16:34   ` Greg Kroah-Hartman
2023-05-23  7:45 ` [PATCH 02/24] PM: hibernate: factor out a helper to find the resume device Christoph Hellwig
2023-05-23 18:25   ` Rafael J. Wysocki
2023-05-23  7:45 ` [PATCH 03/24] PM: hibernate: remove the global snapshot_test variable Christoph Hellwig
2023-05-23 18:30   ` Rafael J. Wysocki
2023-05-23  7:45 ` [PATCH 04/24] PM: hibernate: move finding the resume device out of software_resume Christoph Hellwig
2023-05-23 18:33   ` Rafael J. Wysocki
2023-05-23  7:45 ` [PATCH 05/24] init: remove pointless Root_* values Christoph Hellwig
2023-05-23  7:45 ` [PATCH 06/24] init: rename mount_block_root to mount_root_generic Christoph Hellwig
2023-05-23  7:45 ` [PATCH 07/24] init: refactor mount_root Christoph Hellwig
2023-05-23  7:45 ` Christoph Hellwig [this message]
2023-05-23  7:45 ` [PATCH 09/24] init: don't remove the /dev/ prefix from error messages Christoph Hellwig
2023-05-23  7:45 ` [PATCH 10/24] init: handle ubi/mtd root mounting like all other root types Christoph Hellwig
2023-05-23  7:45 ` [PATCH 11/24] init: factor the root_wait logic in prepare_namespace into a helper Christoph Hellwig
2023-05-23  7:45 ` [PATCH 12/24] init: move the nfs/cifs/ram special cases out of name_to_dev_t Christoph Hellwig
2023-05-23  7:45 ` [PATCH 13/24] init: improve the name_to_dev_t interface Christoph Hellwig
2023-05-23  7:45 ` [PATCH 14/24] init: clear root_wait on all invalid root= strings Christoph Hellwig
2023-06-21 21:07   ` Guenter Roeck
2023-06-22  3:51     ` Christoph Hellwig
2023-06-22  4:28       ` Guenter Roeck
2023-06-22  6:00         ` Christoph Hellwig
2023-06-22 13:54           ` Guenter Roeck
2023-06-22 14:40             ` Christoph Hellwig
2023-06-22 14:57               ` Guenter Roeck
2023-05-23  7:45 ` [PATCH 15/24] block: move the code to do early boot lookup of block devices to block/ Christoph Hellwig
2023-05-24  4:58   ` Randy Dunlap
2023-05-24  4:59     ` Randy Dunlap
2023-05-24  6:08       ` Christoph Hellwig
2023-05-23  7:45 ` [PATCH 16/24] block: move more code to early-lookup.c Christoph Hellwig
2023-05-23  7:45 ` [PATCH 17/24] dm-snap: simplify the origin_dev == cow_dev check in snapshot_ctr Christoph Hellwig
2023-05-23 16:56   ` Mike Snitzer
2023-05-23  7:45 ` [PATCH 18/24] dm: open code dm_get_dev_t in dm_init_init Christoph Hellwig
2023-05-23 16:57   ` Mike Snitzer
2023-05-23  7:45 ` [PATCH 19/24] dm: remove dm_get_dev_t Christoph Hellwig
2023-05-23 16:49   ` Mike Snitzer
2023-05-24  6:06     ` Christoph Hellwig
2023-05-23  7:45 ` [PATCH 20/24] dm: only call early_lookup_bdev from early boot context Christoph Hellwig
2023-05-23 16:59   ` Mike Snitzer
2023-05-23  7:45 ` [PATCH 21/24] PM: hibernate: don't use early_lookup_bdev in resume_store Christoph Hellwig
2023-05-23 18:36   ` Rafael J. Wysocki
2023-05-23  7:45 ` [PATCH 22/24] mtd: block2mtd: factor the early block device open logic into a helper Christoph Hellwig
2023-05-23  9:32   ` Miquel Raynal
2023-05-23  7:45 ` [PATCH 23/24] mtd: block2mtd: don't call early_lookup_bdev after the system is running Christoph Hellwig
2023-05-23  9:34   ` Miquel Raynal
2023-05-23  7:45 ` [PATCH 24/24] block: mark early_lookup_bdev as __init Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2023-05-31 12:55 fix the name_to_dev_t mess v2 Christoph Hellwig
2023-05-31 12:55 ` [PATCH 08/24] init: pass root_device_name explicitly Christoph Hellwig
2023-06-24  0:08   ` Guenter Roeck
2023-06-26  7:53     ` Christoph Hellwig
2023-06-26 14:50       ` Guenter Roeck
2023-06-27 10:38         ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230523074535.249802-9-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joern@lazybastard.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=richard@nod.at \
    --cc=snitzer@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).