Skip to contentSkip to conversation

init: boot to device-mapper targets without an initr*

RFC PATCH In review Will Drewry 2 participants 3 messages May 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 init: boot to device-mapper targets without an initr*

This change adds a dm= kernel parameter modeled after the md= parameter from do_mounts_md. It allows for simple device-mapper targets to be configured at boot time for use early in the boot process (as the root device or otherwise).

The format is dm=minor,rwmode,begin,length,target,target,params,with,commas And may be used as root with dm.major=MAJOR root=MAJOR:minor.

Ideally, the prototypes from dm.h in do_mounts_dm.c could reside in include/linux/device-mapper.h, or do_mounts_dm.c could pull in drivers/md/dm.h. Any preferences there or thoughts on how likely this is to be an acceptable addition to the boot path are appreciated.

---
 init/Makefile       |    1 +
 init/do_mounts.c    |    1 +
 init/do_mounts.h    |   10 +++
 init/do_mounts_dm.c |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 215 insertions(+), 0 deletions(-)
 create mode 100644 init/do_mounts_dm.c
init/Makefile +1 -0
index 0bf677a..1677baa 100644
@@ -14,6 +14,7 @@ mounts-y			:= do_mounts.o
 mounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
 mounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o
 mounts-$(CONFIG_BLK_DEV_MD)	+= do_mounts_md.o
+mounts-$(CONFIG_BLK_DEV_DM)	+= do_mounts_dm.o
 
 # dependencies on generated files need to be listed explicitly
 $(obj)/version.o: include/generated/compile.h
init/do_mounts.c +1 -0
index 02e3ca4..0848a5b 100644
@@ -383,6 +383,7 @@ void __init prepare_namespace(void)
 	wait_for_device_probe();
 
 	md_run_setup();
+	dm_run_setup();
 
 	if (saved_root_name[0]) {
 		root_device_name = saved_root_name;
init/do_mounts.h +10 -0
index f5b978a..09d2286 100644
@@ -74,3 +74,13 @@ void md_run_setup(void);
 static inline void md_run_setup(void) {}
 
 #endif
+
+#ifdef CONFIG_BLK_DEV_DM
+
+void dm_run_setup(void);
+
+#else
+
+static inline void dm_run_setup(void) {}
+
+#endif
init/do_mounts_dm.c new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 1 line · Will Drewry

The format is dm=minor,rwmode,begin,length,target,target,params,with,commas

1. If we go down this route, pick a format that gives access to the full set of allowed table formats (or which can be extended trivially to do so in future). So cope with multi-line tables e.g. with a marker (empty field?) to start a new table line.

2. It would be wise to define a name and optional uuid too, so the device is fully visible and accessible from userspace through existing mechanisms. Originally the name+uuid were decoupled from the mapped device itself, but that got changed, though the code layout (dm-ioctl.c vs. dm.c) still makes them appear to be separate.

init/do_mounts_dm.c line 27

Quoted 2 lines
init/do_mounts_dm.c new file +2 -0
+	char target[24];
+	char target_params[256];

I'm never a fan of hard-coded restrictions, but at least make them explicit as #defines, so people can see at a glance what to change if they get errors for exceeding them.

Quoted 1 line

+static void __init dm_setup_drive(void)

Arguably most of this code could be a helper function exported from drivers/md.

Alasdair

#2 lore raw
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Will Drewry

The format is dm=minor,rwmode,begin,length,target,target,params,with,commas

1. If we go down this route, pick a format that gives access to the full set of allowed table formats (or which can be extended trivially to do so in future).  So cope with multi-line tables e.g. with a marker (empty field?) to start a new table line.

Sounds good. That shouldn't add any serious code complexity either. An empty field (,,) would probably work nicely.

Quoted 5 lines

2. It would be wise to define a name and optional uuid too, so the device is fully visible and accessible from userspace through existing mechanisms. Originally the name+uuid were decoupled from the mapped device itself, but that got changed, though the code layout (dm-ioctl.c vs. dm.c) still makes them appear to be separate.

It wasn't clear how I could define those externally to the dm-ioctl code.

Quoted 6 lines
Quoted 2 lines

+     char target[24];
+     char target_params[256];

I'm never a fan of hard-coded restrictions, but at least make them explicit as #defines, so people can see at a glance what to change if they get errors for exceeding them.

Agreed. I'll add defines or see if I can use the existing ones. (Alternately, it might be possible to use the passed in string in place
depending on the changes.)

Quoted 3 lines
Quoted 1 line

+static void __init dm_setup_drive(void)

Arguably most of this code could be a helper function exported from drivers/md.

True, or I could follow the do_mounts_md model and just use the ioctl interface. Would a parallel function to ctl_ioctl which behaved the same but didn't expect user-sourced dm_ioctl struct be a reasonable compromise?

That'd limit the code to parsing the parameter line and calling through without duplicating the code in dev_create and table_load to yield the same behavior.

thanks!
will