Skip to contentSkip to conversation

dm2md: activate dmraid arrays with md

RFC PATCH New Dan Williams 1 participant 1 message Jan 26, 2009

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

RFC PATCH 1/1 dm2md: activate dmraid arrays with md

Subject: dm2md: activate dmraid arrays with md

From: Dan Williams <[email protected]>

dm2md parses dmraid/dmsetup table entries and creates md devices with matching parameters. For example:

# dmraid -tay
isw_ifgbgihac_vol0: 0 613248 raid45 core 2 128 nosync raid5_la 1 128 4 4232814 /dev/sdb 0 /dev/sdc 0 /dev/sdd 0 /dev/sde 0
# dmraid -tay | dm2md
# ls -l /dev/md/isw_ifgbgihac_vol0
lrwxrwxrwx 1 root root 8 Jan 23 08:53 /dev/md/isw_ifgbgihac_vol0 -> ../md127
# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [raid10] [raid1] [raid0]
md127 : active (read-only) raid5 sde[3] sdd[2] sdc[1] sdb[0]
      306624 blocks super non-persistent level 5, 64k chunk, algorithm 0 [4/4] [UUUU]

The key difference between this and the upcoming external-metadata support in mdadm-3.0 is that the metadata-type is set to 'non-persistent' rather than 'external'. Non-persistent md arrays have two caveats compared to external-metadata arrays:
1/ The kernel still notifies userspace on metadata events, but it does not
wait for a response before continuing (this is similar to the current dmraid eventing implementation)
2/ Member devices can not be shared between multiple volumes. This
could be addressed in the kernel, but as dm2md is meant as a transitional tool the fix is to transition to mdadm.

Completing the example with mdadm's external metadata support: When the raid5 array is assembled mdmon is launched to manage an Intel container and process metadata events on behalf of the kernel.

# mdadm -Ebs > mdadm.conf
# mdadm -Asc mdadm.conf
mdadm: Container /dev/md/imsm0 has been assembled with 4 drives
mdadm: Started /dev/md/vol0 with 4 devices
# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [raid10] [raid1] [raid0]
md_d127 : active (auto-read-only) raid5 sdb[3] sdc[2] sdd[1] sde[0]
      307200 blocks super external:/md127/0 level 5, 64k chunk, algorithm 0 [4/4] [UUUU]

md127 : inactive sde[3](S) sdb[2](S) sdc[1](S) sdd[0](S)
9028 blocks super external:imsm

---
The goal of dm2md is to address the relative gaps in mdadm and dmraid. While mdadm now has support for Intel and DDF metadata formats it lacks the other formats supported by dmraid. While dmraid has an out of tree raid5 implementation it is lacking some of the features, and all of the community's testing that has gone into the md raid5 driver.

dm2md affords dmraid the option to leverage the md raid kernel infrastructure. It is a step towards unifying the dmraid and mdraid efforts.

This code is also available via git at:

git://git.kernel.org/pub/scm/linux/kernel/git/djbw/mdadm.git dm2md

It has only been lightly tested against a raid10 and raid5 Intel metadata array, please consider this the initial proof-of-concept. It currently accesses /sys/dev/block which requires a kernel >= 2.6.27.

Regards,
Dan

 Makefile |   13 +
 dm2md.c  |  617 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 628 insertions(+), 2 deletions(-)
 create mode 100644 dm2md.c
Makefile +11 -2
index 7f27aa4..ac746f2 100644
@@ -91,6 +91,10 @@ MON_OBJS = mdmon.o monitor.o managemon.o util.o mdstat.o sysfs.o config.o \
 	super-ddf.o sha1.o crc32.o msg.o Monitor.o bitmap.o \
 	platform-intel.o probe_roms.o
 
+DM2MD_OBJS = dm2md.o mdopen.o util.o mdstat.o super0.o super1.o super-intel.o \
+	     super-ddf.o sha1.o crc32.o msg.o platform-intel.o probe_roms.o \
+	     sysfs.o config.o sg_io.o dlink.o ReadMe.o mapfile.o Kill.o \
+	     bitmap.o
 
 STATICSRC = pwgr.c
 STATICOBJS = pwgr.o
@@ -105,7 +109,7 @@ ASSEMBLE_SRCS += $(ASSEMBLE_AUTO_SRCS)
 ASSEMBLE_FLAGS += -DMDASSEMBLE_AUTO
 endif
 
-all : mdadm mdmon mdadm.man md.man mdadm.conf.man
+all : mdadm mdmon mdadm.man md.man mdadm.conf.man dm2md
 
 everything: all mdadm.static swap_super test_stripe \
 	mdassemble mdassemble.auto mdassemble.static mdassemble.man \
@@ -139,6 +143,9 @@ mdmon : $(MON_OBJS)
 	$(CC) $(LDFLAGS) -o mdmon $(MON_OBJS) $(LDLIBS)
 msg.o: msg.c msg.h
 
+dm2md : $(DM2MD_OBJS) mdadm.h
+	$(CC) $(LDFLAGS) -o dm2md $(DM2MD_OBJS) $(LDLIBS)
+
 test_stripe : restripe.c mdadm.h
 	$(CC) $(CXFLAGS) $(LDFLAGS) -o test_stripe -DMAIN restripe.c
 
@@ -185,6 +192,7 @@ sha1.o : sha1.c sha1.h md5.h
 install : mdadm mdmon install-man install-udev
 	$(INSTALL) -D $(STRIP) -m 755 mdadm $(DESTDIR)$(BINDIR)/mdadm
 	$(INSTALL) -D $(STRIP) -m 755 mdmon $(DESTDIR)$(BINDIR)/mdmon
+	$(INSTALL) -D $(STRIP) -m 755 dm2md $(DESTDIR)$(BINDIR)/dm2md
 
 install-static : mdadm.static install-man
 	$(INSTALL) -D $(STRIP) -m 755 mdadm.static $(DESTDIR)$(BINDIR)/mdadm
@@ -213,7 +221,8 @@ test: mdadm test_stripe swap_super
 	@echo "Please run 'sh ./test' as root"
 
 clean : 
-	rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) core *.man \
+	rm -f mdadm mdmon $(OBJS) $(MON_OBJS) $(STATICOBJS) $(DM2MD_OBJS) \
+	core *.man dm2md \
 	mdadm.tcc mdadm.uclibc mdadm.static *.orig *.porig *.rej *.alt \
 	mdadm.Os mdadm.O2 \
 	mdassemble mdassemble.static mdassemble.auto mdassemble.uclibc \
dm2md.c new file +617 -0

617 lines not on this page · raw message