* Re: [patch-2.4.0-test13-pre3] rootfs boot param. support
@ 2000-12-18 14:17 Andries.Brouwer
2000-12-18 15:22 ` Peter Samuelson
0 siblings, 1 reply; 8+ messages in thread
From: Andries.Brouwer @ 2000-12-18 14:17 UTC (permalink / raw)
To: tigran, torvalds; +Cc: linux-kernel
From: Tigran Aivazian <tigran@veritas.com>
+ rootfs= [KNL] Use filesystem type specified (e.g. rootfs=ext2) for root.
(i) I prefer "rootfstype". Indeed, "rootfs" is ambiguous.
It gives some property of the root filesystem, but which?
+static char rootfs[128] __initdata = "ext2";
(ii) It is a bad idea to arbitrarily select "ext2".
Moreover, we want to recognize the case where a boot option was given,
see below.
+ fs_type = get_fs_type(rootfs);
+ if (fs_type) {
+ sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1);
+ if (sb)
+ goto mount_it;
+ }
(iii) I probably give the rootfstype explicitly because bad things
(like disk corruption) happen when the kernel misrecognizes some
filesystem, and perhaps starts updating access times or so.
Thus, if the boot option rootfstype is given, I prefer a boot failure
over a kernel attempt to try all filesystems it knows about, just like
mount(8) only will start guessing when no explicit type was given.
Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [patch-2.4.0-test13-pre3] rootfs boot param. support 2000-12-18 14:17 [patch-2.4.0-test13-pre3] rootfs boot param. support Andries.Brouwer @ 2000-12-18 15:22 ` Peter Samuelson 2000-12-18 15:36 ` Tigran Aivazian 2000-12-18 16:00 ` [patch-2.4.0-test13-pre3] rootfs (2nd attempt) Tigran Aivazian 0 siblings, 2 replies; 8+ messages in thread From: Peter Samuelson @ 2000-12-18 15:22 UTC (permalink / raw) To: Andries.Brouwer; +Cc: tigran, torvalds, linux-kernel [Andries Brouwer] > (i) I prefer "rootfstype". Indeed, "rootfs" is ambiguous. > It gives some property of the root filesystem, but which? > (ii) It is a bad idea to arbitrarily select "ext2". > (iii) [...] Thus, if the boot option rootfstype is given, I prefer a > boot failure over a kernel attempt to try all filesystems it knows Agreed on all counts. Peter --- test13pre3+rootfs/fs/super.c~ Mon Dec 18 09:06:47 2000 +++ test13pre3+rootfs/fs/super.c Mon Dec 18 09:18:02 2000 @@ -18,7 +18,7 @@ * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996. * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998 * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000 - * Added rootfs boot param. used by mount_root(): Tigran Aivazian. Dec 2000. + * Added rootfstype boot param. used by mount_root(): Tigran Aivazian. Dec 2000. */ #include <linux/config.h> @@ -59,11 +59,11 @@ /* this is initialized in init/main.c */ kdev_t ROOT_DEV; -/* this can be set at boot time, e.g. rootfs=ext2 +/* this can be set at boot time, e.g. rootfstype=ext2 * if set to invalid value or if read_super() fails on the specified * filesystem type then mount_root() will go through all registered filesystems. */ -static char rootfs[128] __initdata = "ext2"; +static char rootfstype[32] __initdata = ""; int nr_super_blocks; int max_super_blocks = NR_SUPER; @@ -90,11 +90,11 @@ int n = strlen(line) + 1; if (n > 1 && n < 128) - strncpy(rootfs, line, n); + strncpy(rootfstype, line, n); return 1; } -__setup("rootfs=", rootfs_setup); +__setup("rootfstype=", rootfs_setup); /* WARNING: This can be used only if we _already_ own a reference */ static void get_filesystem(struct file_system_type *fs) @@ -1479,7 +1479,7 @@ void __init mount_root(void) { - struct file_system_type * fs_type; + struct file_system_type * fs_type = NULL; struct super_block * sb; struct vfsmount *vfsmnt; struct block_device *bdev = NULL; @@ -1597,11 +1597,15 @@ goto mount_it; } - fs_type = get_fs_type(rootfs); - if (fs_type) { - sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1); - if (sb) - goto mount_it; + if (*rootfstype) { + fs_type = get_fs_type(rootfstype); + if (fs_type) { + sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1); + if (sb) + goto mount_it; + } + /* do NOT try all filesystems - user explicitly wanted this one */ + goto fail; } read_lock(&file_systems_lock); for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { @@ -1617,6 +1621,7 @@ put_filesystem(fs_type); } read_unlock(&file_systems_lock); +fail: panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); mount_it: - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch-2.4.0-test13-pre3] rootfs boot param. support 2000-12-18 15:22 ` Peter Samuelson @ 2000-12-18 15:36 ` Tigran Aivazian 2000-12-18 16:00 ` [patch-2.4.0-test13-pre3] rootfs (2nd attempt) Tigran Aivazian 1 sibling, 0 replies; 8+ messages in thread From: Tigran Aivazian @ 2000-12-18 15:36 UTC (permalink / raw) To: Peter Samuelson; +Cc: Andries.Brouwer, torvalds, linux-kernel Ok, the version below doesn't look too bad, except a couple things, see below: On Mon, 18 Dec 2000, Peter Samuelson wrote: > -__setup("rootfs=", rootfs_setup); > +__setup("rootfstype=", rootfs_setup); this is wrong. If the parameter is "rootfstype" then the function is rootfstype_setup(). Too long. No, "rootfs" was a good idea to beging with (ask any kernel hacker who wrote UW7 BCP support -- they knew what they were calling their variables :) > { > - struct file_system_type * fs_type; > + struct file_system_type * fs_type = NULL; this is not needed. Why did you put it there? > + if (*rootfstype) { > + fs_type = get_fs_type(rootfstype); > + if (fs_type) { > + sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1); > + if (sb) > + goto mount_it; > + } > + /* do NOT try all filesystems - user explicitly wanted this one */ > + goto fail; > ... > +fail: > panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); we should also print out the filesystem type, so instead of having a fail label I would put the panic() inside the code above. I will redo the patch with your and Andries' comments in place and re-send to Linus. Namely, the useful things, imho, from your suggestions are: a) the space allocated for it should be 32 bytes and not 128 b) we should check if user passed any value and only then activate the code c) default value "" is ok (ok, fine, the extra line of code to check for it is not too bad). d) but the variable should still be called "rootfs" and not "rootfstype". rootfstype is too long, too confusing and not obvious. Whilst "rootfs" immediately tells you "it's the name of the filesystem in the namespace defined by file_system_type->name" Oh, btw you changed one place from 128 to 32 but forgot another -- never mind :) Regards, Tigran - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch-2.4.0-test13-pre3] rootfs (2nd attempt) 2000-12-18 15:22 ` Peter Samuelson 2000-12-18 15:36 ` Tigran Aivazian @ 2000-12-18 16:00 ` Tigran Aivazian 2000-12-18 16:03 ` Oops " Tigran Aivazian 2000-12-18 18:23 ` Andreas Dilger 1 sibling, 2 replies; 8+ messages in thread From: Tigran Aivazian @ 2000-12-18 16:00 UTC (permalink / raw) To: torvalds; +Cc: Andries.Brouwer, Peter Samuelson, linux-kernel Hi Linus, Thanks to suggestions from Andries and Peter I enhanced the rootfs patch to do the same it did before + panic when rootfs= is given but failed to match the userspace mount(8) behaviour. Also other cleanups mentioned in the thread are all incorporated (well, at least the sensible ones). Now, everyone is (hopefully) happy. Tested under 2.4.0-test13-pre3. Regards, Tigran diff -urN -X dontdiff linux/Documentation/kernel-parameters.txt rootfs/Documentation/kernel-parameters.txt --- linux/Documentation/kernel-parameters.txt Tue Sep 5 21:51:14 2000 +++ rootfs/Documentation/kernel-parameters.txt Mon Dec 18 09:04:06 2000 @@ -473,7 +473,10 @@ ro [KNL] Mount root device read-only on boot. - root= [KNL] root filesystem. + root= [KNL] Mount root filesystem on specified (as hex or "/dev/XXX") device. + + rootfs= [KNL] Use filesystem type specified (e.g. rootfs=ext2) for root. + rw [KNL] Mount root device read-write on boot. diff -urN -X dontdiff linux/fs/super.c rootfs/fs/super.c --- linux/fs/super.c Tue Dec 12 09:25:22 2000 +++ rootfs/fs/super.c Mon Dec 18 14:49:08 2000 @@ -18,6 +18,7 @@ * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996. * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998 * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000 + * Added rootfs boot param. used by mount_root(): Tigran Aivazian. Dec 2000. */ #include <linux/config.h> @@ -58,6 +59,12 @@ /* this is initialized in init/main.c */ kdev_t ROOT_DEV; +/* this can be set at boot time, e.g. rootfs=ext2 + * if set to invalid value or if read_super() fails on the specified + * filesystem type then mount_root() will go through all registered filesystems. + */ +static char rootfs[32] __initdata = ""; + int nr_super_blocks; int max_super_blocks = NR_SUPER; LIST_HEAD(super_blocks); @@ -78,6 +85,17 @@ static struct file_system_type *file_systems; static rwlock_t file_systems_lock = RW_LOCK_UNLOCKED; +static int __init rootfs_setup(char *line) +{ + int n = strlen(line) + 1; + + if (n > 1 && n < 32) + strncpy(rootfs, line, n); + return 1; +} + +__setup("rootfs=", rootfs_setup); + /* WARNING: This can be used only if we _already_ own a reference */ static void get_filesystem(struct file_system_type *fs) { @@ -1579,6 +1597,16 @@ goto mount_it; } + if (*rootfs) { + fs_type = get_fs_type(rootfs); + if (fs_type) { + sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1); + if (sb) + goto mount_it; + } + /* don't try others if type given explicitly, same behaviour as mount(8) */ + goto fail; + } read_lock(&file_systems_lock); for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { if (!(fs_type->fs_flags & FS_REQUIRES_DEV)) @@ -1593,6 +1621,7 @@ put_filesystem(fs_type); } read_unlock(&file_systems_lock); +fail: panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); mount_it: - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Oops Re: [patch-2.4.0-test13-pre3] rootfs (2nd attempt) 2000-12-18 16:00 ` [patch-2.4.0-test13-pre3] rootfs (2nd attempt) Tigran Aivazian @ 2000-12-18 16:03 ` Tigran Aivazian 2000-12-18 18:23 ` Andreas Dilger 1 sibling, 0 replies; 8+ messages in thread From: Tigran Aivazian @ 2000-12-18 16:03 UTC (permalink / raw) To: torvalds; +Cc: Andries.Brouwer, Peter Samuelson, linux-kernel just a typo in the comment, sorry. Corrected version below. diff -urN -X dontdiff linux/Documentation/kernel-parameters.txt rootfs/Documentation/kernel-parameters.txt --- linux/Documentation/kernel-parameters.txt Tue Sep 5 21:51:14 2000 +++ rootfs/Documentation/kernel-parameters.txt Mon Dec 18 09:04:06 2000 @@ -473,7 +473,10 @@ ro [KNL] Mount root device read-only on boot. - root= [KNL] root filesystem. + root= [KNL] Mount root filesystem on specified (as hex or "/dev/XXX") device. + + rootfs= [KNL] Use filesystem type specified (e.g. rootfs=ext2) for root. + rw [KNL] Mount root device read-write on boot. diff -urN -X dontdiff linux/fs/super.c rootfs/fs/super.c --- linux/fs/super.c Tue Dec 12 09:25:22 2000 +++ rootfs/fs/super.c Mon Dec 18 15:03:44 2000 @@ -18,6 +18,7 @@ * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996. * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998 * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000 + * Added rootfs boot param. used by mount_root(): Tigran Aivazian. Dec 2000. */ #include <linux/config.h> @@ -58,6 +59,12 @@ /* this is initialized in init/main.c */ kdev_t ROOT_DEV; +/* this can be set at boot time, e.g. rootfs=ext2 + * if set to invalid value or if read_super() fails on the specified + * filesystem type then mount_root() will panic + */ +static char rootfs[32] __initdata = ""; + int nr_super_blocks; int max_super_blocks = NR_SUPER; LIST_HEAD(super_blocks); @@ -78,6 +85,17 @@ static struct file_system_type *file_systems; static rwlock_t file_systems_lock = RW_LOCK_UNLOCKED; +static int __init rootfs_setup(char *line) +{ + int n = strlen(line) + 1; + + if (n > 1 && n < 32) + strncpy(rootfs, line, n); + return 1; +} + +__setup("rootfs=", rootfs_setup); + /* WARNING: This can be used only if we _already_ own a reference */ static void get_filesystem(struct file_system_type *fs) { @@ -1579,6 +1597,16 @@ goto mount_it; } + if (*rootfs) { + fs_type = get_fs_type(rootfs); + if (fs_type) { + sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1); + if (sb) + goto mount_it; + } + /* don't try others if type given explicitly, same behaviour as mount(8) */ + goto fail; + } read_lock(&file_systems_lock); for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { if (!(fs_type->fs_flags & FS_REQUIRES_DEV)) @@ -1593,6 +1621,7 @@ put_filesystem(fs_type); } read_unlock(&file_systems_lock); +fail: panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); mount_it: - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch-2.4.0-test13-pre3] rootfs (2nd attempt) 2000-12-18 16:00 ` [patch-2.4.0-test13-pre3] rootfs (2nd attempt) Tigran Aivazian 2000-12-18 16:03 ` Oops " Tigran Aivazian @ 2000-12-18 18:23 ` Andreas Dilger 2000-12-18 18:31 ` [final] " Tigran Aivazian 1 sibling, 1 reply; 8+ messages in thread From: Andreas Dilger @ 2000-12-18 18:23 UTC (permalink / raw) To: Tigran Aivazian; +Cc: torvalds, Andries.Brouwer, Peter Samuelson, linux-kernel Tigran, you write: > Thanks to suggestions from Andries and Peter I enhanced the rootfs patch > to do the same it did before + panic when rootfs= is given but failed to If I could add one thing here (we have had a 2.2 patch like this for testing with ext3) - if you specify the rootfstype parameter don't use the "quiet" option to read_super, so you know why it couldn't mount a specific filesystem as root, and/or print rootfs type in the panic message. This is especially useful if you have something in LILO that you forgot about... Cheers, Andreas ============================================================================= diff -urN -X dontdiff linux/fs/super.c rootfs/fs/super.c --- linux/fs/super.c Tue Dec 12 09:25:22 2000 +++ rootfs/fs/super.c Mon Dec 18 14:49:08 2000 @@ -1600,7 +1600,7 @@ if (*rootfs) { fs_type = get_fs_type(rootfs); if (fs_type) { - sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,1); + sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,0); if (sb) goto mount_it; } @@ -1622,7 +1622,8 @@ } read_unlock(&file_systems_lock); fail: - panic("VFS: Unable to mount root fs on %s", kdevname(ROOT_DEV)); + panic("VFS: Unable to mount root %s on %s", *rootfs ? rootfs : "fs", + kdevname(ROOT_DEV)); mount_it: printk ("VFS: Mounted root (%s filesystem)%s.\n", -- Andreas Dilger \ "If a man ate a pound of pasta and a pound of antipasto, \ would they cancel out, leaving him still hungry?" http://www-mddsp.enel.ucalgary.ca/People/adilger/ -- Dogbert - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* [final] Re: [patch-2.4.0-test13-pre3] rootfs (2nd attempt) 2000-12-18 18:23 ` Andreas Dilger @ 2000-12-18 18:31 ` Tigran Aivazian 2000-12-19 7:03 ` Is there a devfs patch for 2.2.18? Tri D. Hoang 0 siblings, 1 reply; 8+ messages in thread From: Tigran Aivazian @ 2000-12-18 18:31 UTC (permalink / raw) To: Andreas Dilger; +Cc: torvalds, Andries.Brouwer, Peter Samuelson, linux-kernel On Mon, 18 Dec 2000, Andreas Dilger wrote: > If I could add one thing here (we have had a 2.2 patch like this for testing > with ext3) - if you specify the rootfstype parameter don't use the "quiet" > option to read_super, so you know why it couldn't mount a specific filesystem > as root, and/or print rootfs type in the panic message. Agree completely. Here is the hopefully final version. Sorry, Linus, I thought the first version was final :) Looks like I have missed a couple of very useful things... Thanks to all who commented! Regards, Tigran diff -urN -X dontdiff linux/Documentation/kernel-parameters.txt rootfs/Documentation/kernel-parameters.txt --- linux/Documentation/kernel-parameters.txt Tue Sep 5 21:51:14 2000 +++ rootfs/Documentation/kernel-parameters.txt Mon Dec 18 09:04:06 2000 @@ -473,7 +473,10 @@ ro [KNL] Mount root device read-only on boot. - root= [KNL] root filesystem. + root= [KNL] Mount root filesystem on specified (as hex or "/dev/XXX") device. + + rootfs= [KNL] Use filesystem type specified (e.g. rootfs=ext2) for root. + rw [KNL] Mount root device read-write on boot. diff -urN -X dontdiff linux/fs/super.c rootfs/fs/super.c --- linux/fs/super.c Tue Dec 12 09:25:22 2000 +++ rootfs/fs/super.c Mon Dec 18 15:03:44 2000 @@ -18,6 +18,7 @@ * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996. * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998 * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000 + * Added rootfs boot param. used by mount_root(): Tigran Aivazian. Dec 2000. */ #include <linux/config.h> @@ -58,6 +59,12 @@ /* this is initialized in init/main.c */ kdev_t ROOT_DEV; +/* this can be set at boot time, e.g. rootfs=ext2 + * if set to invalid value or if read_super() fails on the specified + * filesystem type then mount_root() will panic + */ +static char rootfs[32] __initdata = ""; + int nr_super_blocks; int max_super_blocks = NR_SUPER; LIST_HEAD(super_blocks); @@ -78,6 +85,17 @@ static struct file_system_type *file_systems; static rwlock_t file_systems_lock = RW_LOCK_UNLOCKED; +static int __init rootfs_setup(char *line) +{ + int n = strlen(line) + 1; + + if (n > 1 && n < 32) + strncpy(rootfs, line, n); + return 1; +} + +__setup("rootfs=", rootfs_setup); + /* WARNING: This can be used only if we _already_ own a reference */ static void get_filesystem(struct file_system_type *fs) { @@ -1579,6 +1597,16 @@ goto mount_it; } + if (*rootfs) { + fs_type = get_fs_type(rootfs); + if (fs_type) { + sb = read_super(ROOT_DEV,bdev,fs_type,root_mountflags,NULL,0); + if (sb) + goto mount_it; + } + /* don't try others if type given explicitly, same behaviour as mount(8) */ + goto fail; + } read_lock(&file_systems_lock); for (fs_type = file_systems ; fs_type ; fs_type = fs_type->next) { if (!(fs_type->fs_flags & FS_REQUIRES_DEV)) @@ -1593,6 +1621,7 @@ put_filesystem(fs_type); } read_unlock(&file_systems_lock); +fail: panic("VFS: Unable to mount root %s on %s", *rootfs ? rootfs : "fs", kdevname(ROOT_DEV)); mount_it: - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Is there a devfs patch for 2.2.18? 2000-12-18 18:31 ` [final] " Tigran Aivazian @ 2000-12-19 7:03 ` Tri D. Hoang 0 siblings, 0 replies; 8+ messages in thread From: Tri D. Hoang @ 2000-12-19 7:03 UTC (permalink / raw) To: linux-kernel Hi, Is there a devfs patch for 2.2.18 or how do I get devfs to work with 2.2.18? Tri tdhoang@mindspring.com - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2000-12-19 7:21 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2000-12-18 14:17 [patch-2.4.0-test13-pre3] rootfs boot param. support Andries.Brouwer 2000-12-18 15:22 ` Peter Samuelson 2000-12-18 15:36 ` Tigran Aivazian 2000-12-18 16:00 ` [patch-2.4.0-test13-pre3] rootfs (2nd attempt) Tigran Aivazian 2000-12-18 16:03 ` Oops " Tigran Aivazian 2000-12-18 18:23 ` Andreas Dilger 2000-12-18 18:31 ` [final] " Tigran Aivazian 2000-12-19 7:03 ` Is there a devfs patch for 2.2.18? Tri D. Hoang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox