All of lore.kernel.org
 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 10/24] init: handle ubi/mtd root mounting like all other root types
Date: Tue, 23 May 2023 09:45:21 +0200	[thread overview]
Message-ID: <20230523074535.249802-11-hch@lst.de> (raw)
In-Reply-To: <20230523074535.249802-1-hch@lst.de>

Assign a Root_Generic magic value for UBI/MTD root and handle the root
mounting in mount_root like all other root types.  Besides making the
code more clear this also means that UBI/MTD root can be used together
with an initrd (not that anyone should care).

Also factor parsing of the root name into a helper now that it can
be easily done and will get more complicated with subsequent patches.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/root_dev.h |  1 +
 init/do_mounts.c         | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/linux/root_dev.h b/include/linux/root_dev.h
index ed3ea8da642972..847c9a06101b76 100644
--- a/include/linux/root_dev.h
+++ b/include/linux/root_dev.h
@@ -9,6 +9,7 @@
 enum {
 	Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
 	Root_CIFS = MKDEV(UNNAMED_MAJOR, 254),
+	Root_Generic = MKDEV(UNNAMED_MAJOR, 253),
 	Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
 };
 
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 74cc96bffbdd71..be6d14733ba02f 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -591,6 +591,10 @@ void __init mount_root(char *root_device_name)
 	case Root_CIFS:
 		mount_cifs_root();
 		break;
+	case Root_Generic:
+		mount_root_generic(root_device_name, root_device_name,
+				   root_mountflags);
+		break;
 	case 0:
 		if (root_device_name && root_fs_names &&
 		    mount_nodev_root(root_device_name) == 0)
@@ -602,6 +606,14 @@ void __init mount_root(char *root_device_name)
 	}
 }
 
+static dev_t __init parse_root_device(char *root_device_name)
+{
+	if (!strncmp(root_device_name, "mtd", 3) ||
+	    !strncmp(root_device_name, "ubi", 3))
+		return Root_Generic;
+	return name_to_dev_t(root_device_name);
+}
+
 /*
  * Prepare the namespace - decide what/where to mount, load ramdisks, etc.
  */
@@ -624,15 +636,8 @@ void __init prepare_namespace(void)
 
 	md_run_setup();
 
-	if (saved_root_name[0]) {
-		if (!strncmp(saved_root_name, "mtd", 3) ||
-		    !strncmp(saved_root_name, "ubi", 3)) {
-			mount_root_generic(saved_root_name, saved_root_name,
-					   root_mountflags);
-			goto out;
-		}
-		ROOT_DEV = name_to_dev_t(saved_root_name);
-	}
+	if (saved_root_name[0])
+		ROOT_DEV = parse_root_device(saved_root_name);
 
 	if (initrd_load(saved_root_name))
 		goto out;
-- 
2.39.2


WARNING: multiple messages have this Message-ID (diff)
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 10/24] init: handle ubi/mtd root mounting like all other root types
Date: Tue, 23 May 2023 09:45:21 +0200	[thread overview]
Message-ID: <20230523074535.249802-11-hch@lst.de> (raw)
In-Reply-To: <20230523074535.249802-1-hch@lst.de>

Assign a Root_Generic magic value for UBI/MTD root and handle the root
mounting in mount_root like all other root types.  Besides making the
code more clear this also means that UBI/MTD root can be used together
with an initrd (not that anyone should care).

Also factor parsing of the root name into a helper now that it can
be easily done and will get more complicated with subsequent patches.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/root_dev.h |  1 +
 init/do_mounts.c         | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/linux/root_dev.h b/include/linux/root_dev.h
index ed3ea8da642972..847c9a06101b76 100644
--- a/include/linux/root_dev.h
+++ b/include/linux/root_dev.h
@@ -9,6 +9,7 @@
 enum {
 	Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
 	Root_CIFS = MKDEV(UNNAMED_MAJOR, 254),
+	Root_Generic = MKDEV(UNNAMED_MAJOR, 253),
 	Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
 };
 
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 74cc96bffbdd71..be6d14733ba02f 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -591,6 +591,10 @@ void __init mount_root(char *root_device_name)
 	case Root_CIFS:
 		mount_cifs_root();
 		break;
+	case Root_Generic:
+		mount_root_generic(root_device_name, root_device_name,
+				   root_mountflags);
+		break;
 	case 0:
 		if (root_device_name && root_fs_names &&
 		    mount_nodev_root(root_device_name) == 0)
@@ -602,6 +606,14 @@ void __init mount_root(char *root_device_name)
 	}
 }
 
+static dev_t __init parse_root_device(char *root_device_name)
+{
+	if (!strncmp(root_device_name, "mtd", 3) ||
+	    !strncmp(root_device_name, "ubi", 3))
+		return Root_Generic;
+	return name_to_dev_t(root_device_name);
+}
+
 /*
  * Prepare the namespace - decide what/where to mount, load ramdisks, etc.
  */
@@ -624,15 +636,8 @@ void __init prepare_namespace(void)
 
 	md_run_setup();
 
-	if (saved_root_name[0]) {
-		if (!strncmp(saved_root_name, "mtd", 3) ||
-		    !strncmp(saved_root_name, "ubi", 3)) {
-			mount_root_generic(saved_root_name, saved_root_name,
-					   root_mountflags);
-			goto out;
-		}
-		ROOT_DEV = name_to_dev_t(saved_root_name);
-	}
+	if (saved_root_name[0])
+		ROOT_DEV = parse_root_device(saved_root_name);
 
 	if (initrd_load(saved_root_name))
 		goto out;
-- 
2.39.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-pm@vger.kernel.org, Joern Engel <joern@lazybastard.org>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	Richard Weinberger <richard@nod.at>,
	dm-devel@redhat.com, Mike Snitzer <snitzer@kernel.org>,
	Pavel Machek <pavel@ucw.cz>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	linux-mtd@lists.infradead.org
Subject: [dm-devel] [PATCH 10/24] init: handle ubi/mtd root mounting like all other root types
Date: Tue, 23 May 2023 09:45:21 +0200	[thread overview]
Message-ID: <20230523074535.249802-11-hch@lst.de> (raw)
In-Reply-To: <20230523074535.249802-1-hch@lst.de>

Assign a Root_Generic magic value for UBI/MTD root and handle the root
mounting in mount_root like all other root types.  Besides making the
code more clear this also means that UBI/MTD root can be used together
with an initrd (not that anyone should care).

Also factor parsing of the root name into a helper now that it can
be easily done and will get more complicated with subsequent patches.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/root_dev.h |  1 +
 init/do_mounts.c         | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/linux/root_dev.h b/include/linux/root_dev.h
index ed3ea8da642972..847c9a06101b76 100644
--- a/include/linux/root_dev.h
+++ b/include/linux/root_dev.h
@@ -9,6 +9,7 @@
 enum {
 	Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
 	Root_CIFS = MKDEV(UNNAMED_MAJOR, 254),
+	Root_Generic = MKDEV(UNNAMED_MAJOR, 253),
 	Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
 };
 
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 74cc96bffbdd71..be6d14733ba02f 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -591,6 +591,10 @@ void __init mount_root(char *root_device_name)
 	case Root_CIFS:
 		mount_cifs_root();
 		break;
+	case Root_Generic:
+		mount_root_generic(root_device_name, root_device_name,
+				   root_mountflags);
+		break;
 	case 0:
 		if (root_device_name && root_fs_names &&
 		    mount_nodev_root(root_device_name) == 0)
@@ -602,6 +606,14 @@ void __init mount_root(char *root_device_name)
 	}
 }
 
+static dev_t __init parse_root_device(char *root_device_name)
+{
+	if (!strncmp(root_device_name, "mtd", 3) ||
+	    !strncmp(root_device_name, "ubi", 3))
+		return Root_Generic;
+	return name_to_dev_t(root_device_name);
+}
+
 /*
  * Prepare the namespace - decide what/where to mount, load ramdisks, etc.
  */
@@ -624,15 +636,8 @@ void __init prepare_namespace(void)
 
 	md_run_setup();
 
-	if (saved_root_name[0]) {
-		if (!strncmp(saved_root_name, "mtd", 3) ||
-		    !strncmp(saved_root_name, "ubi", 3)) {
-			mount_root_generic(saved_root_name, saved_root_name,
-					   root_mountflags);
-			goto out;
-		}
-		ROOT_DEV = name_to_dev_t(saved_root_name);
-	}
+	if (saved_root_name[0])
+		ROOT_DEV = parse_root_device(saved_root_name);
 
 	if (initrd_load(saved_root_name))
 		goto out;
-- 
2.39.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


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

Thread overview: 143+ 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 ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45 ` Christoph Hellwig
2023-05-23  7:45 ` [PATCH 01/24] driver core: return bool from driver_probe_done Christoph Hellwig
2023-05-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 16:34   ` Greg Kroah-Hartman
2023-05-23 16:34     ` [dm-devel] " Greg Kroah-Hartman
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 18:25   ` Rafael J. Wysocki
2023-05-23 18:25     ` [dm-devel] " Rafael J. Wysocki
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 18:30   ` Rafael J. Wysocki
2023-05-23 18:30     ` [dm-devel] " Rafael J. Wysocki
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 18:33   ` Rafael J. Wysocki
2023-05-23 18:33     ` [dm-devel] " Rafael J. Wysocki
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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` 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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23  7:45 ` [PATCH 07/24] init: refactor mount_root Christoph Hellwig
2023-05-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23  7:45 ` [PATCH 08/24] init: pass root_device_name explicitly Christoph Hellwig
2023-05-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23  7:45 ` Christoph Hellwig [this message]
2023-05-23  7:45   ` [dm-devel] [PATCH 10/24] init: handle ubi/mtd root mounting like all other root types Christoph Hellwig
2023-05-23  7:45   ` 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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` 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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` 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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23  7:45 ` [PATCH 14/24] init: clear root_wait on all invalid root= strings Christoph Hellwig
2023-05-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-06-21 21:07   ` Guenter Roeck
2023-06-21 21:07     ` [dm-devel] " Guenter Roeck
2023-06-21 21:07     ` Guenter Roeck
2023-06-22  3:51     ` Christoph Hellwig
2023-06-22  3:51       ` [dm-devel] " Christoph Hellwig
2023-06-22  3:51       ` Christoph Hellwig
2023-06-22  4:28       ` Guenter Roeck
2023-06-22  4:28         ` [dm-devel] " Guenter Roeck
2023-06-22  4:28         ` Guenter Roeck
2023-06-22  6:00         ` Christoph Hellwig
2023-06-22  6:00           ` [dm-devel] " Christoph Hellwig
2023-06-22  6:00           ` Christoph Hellwig
2023-06-22 13:54           ` Guenter Roeck
2023-06-22 13:54             ` [dm-devel] " Guenter Roeck
2023-06-22 13:54             ` Guenter Roeck
2023-06-22 14:40             ` Christoph Hellwig
2023-06-22 14:40               ` [dm-devel] " Christoph Hellwig
2023-06-22 14:40               ` Christoph Hellwig
2023-06-22 14:57               ` Guenter Roeck
2023-06-22 14:57                 ` [dm-devel] " Guenter Roeck
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-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-24  4:58   ` Randy Dunlap
2023-05-24  4:58     ` [dm-devel] " Randy Dunlap
2023-05-24  4:58     ` Randy Dunlap
2023-05-24  4:59     ` Randy Dunlap
2023-05-24  4:59       ` [dm-devel] " Randy Dunlap
2023-05-24  4:59       ` Randy Dunlap
2023-05-24  6:08       ` Christoph Hellwig
2023-05-24  6:08         ` [dm-devel] " Christoph Hellwig
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   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` 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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 16:56   ` Mike Snitzer
2023-05-23 16:56     ` [dm-devel] " Mike Snitzer
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 16:57   ` Mike Snitzer
2023-05-23 16:57     ` Mike Snitzer
2023-05-23 16:57     ` [dm-devel] " Mike Snitzer
2023-05-23  7:45 ` [PATCH 19/24] dm: remove dm_get_dev_t Christoph Hellwig
2023-05-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 16:49   ` Mike Snitzer
2023-05-23 16:49     ` [dm-devel] " Mike Snitzer
2023-05-23 16:49     ` Mike Snitzer
2023-05-24  6:06     ` Christoph Hellwig
2023-05-24  6:06       ` [dm-devel] " Christoph Hellwig
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 16:59   ` Mike Snitzer
2023-05-23 16:59     ` [dm-devel] " Mike Snitzer
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23 18:36   ` Rafael J. Wysocki
2023-05-23 18:36     ` [dm-devel] " Rafael J. Wysocki
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23  9:32   ` Miquel Raynal
2023-05-23  9:32     ` [dm-devel] " Miquel Raynal
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  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-23  9:34   ` Miquel Raynal
2023-05-23  9:34     ` [dm-devel] " Miquel Raynal
2023-05-23  9:34     ` Miquel Raynal
2023-05-23  7:45 ` [PATCH 24/24] block: mark early_lookup_bdev as __init Christoph Hellwig
2023-05-23  7:45   ` [dm-devel] " Christoph Hellwig
2023-05-23  7:45   ` Christoph Hellwig
2023-05-31 12:55 fix the name_to_dev_t mess v2 Christoph Hellwig
2023-05-31 12:55 ` [PATCH 10/24] init: handle ubi/mtd root mounting like all other root types Christoph Hellwig
2023-05-31 12:55   ` Christoph Hellwig

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-11-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.