mdadm/Start-kpartx-for-imsm-devices.patch

132 lines
3.6 KiB
Diff

From 057fb70bf4e4b284cc06299853122273815b1d6e Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Fri, 7 Nov 2008 22:22:41 +1100
Subject: [PATCH] Start kpartx for imsm devices.
This probably wont get into mainline, but is need on SLES
to create partitions that the YaST partitioner has a chance
of recognising.
Signed-off-by: NeilBrown <neilb@suse.de>
---
Assemble.c | 4 +++-
Create.c | 3 +++
Manage.c | 4 ++++
mdadm.h | 1 +
super-intel.c | 2 +-
util.c | 25 +++++++++++++++++++++++++
6 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 20c4be7..c597526 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1251,8 +1251,10 @@ int assemble_container_content(struct supertype *st, int mdfd,
fprintf(stderr, " (%d new)", working);
fprintf(stderr, "\n");
}
- wait_for(chosen_name);
close(mdfd);
+ wait_for(chosen_name);
+ if (st->ss->match_metadata_desc("imsm"))
+ run_kpartx('a', chosen_name);
return 0;
/* FIXME should have an O_EXCL and wait for read-auto */
} else {
diff --git a/Create.c b/Create.c
index 783ab09..4368107 100644
--- a/Create.c
+++ b/Create.c
@@ -780,7 +780,10 @@ int Create(struct supertype *st, char *mddev,
ping_monitor(devnum2devname(st->container_dev));
close(container_fd);
}
+ close(mdfd);
wait_for(chosen_name);
+ if (st->ss->match_metadata_desc("imsm"))
+ run_kpartx('a', chosen_name);
} else {
fprintf(stderr, Name ": not starting array - not enough devices.\n");
}
diff --git a/Manage.c b/Manage.c
index 9424650..06f9e05 100644
--- a/Manage.c
+++ b/Manage.c
@@ -219,8 +219,12 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
if (mdi &&
mdi->array.level > 0 &&
is_subarray(mdi->text_version)) {
+ struct map_ent *me = map_by_devnum(&map, devnum);
/* This is mdmon managed. */
close(fd);
+
+ /* Delete any kpartx partitions */
+ run_kpartx('d', me->path);
if (sysfs_set_str(mdi, NULL,
"array_state", "inactive") < 0) {
if (quiet == 0)
diff --git a/mdadm.h b/mdadm.h
index 2b34acf..9d819f9 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -833,6 +833,7 @@ extern char *devnum2devname(int num);
extern int devname2devnum(char *name);
extern int stat2devnum(struct stat *st);
extern int fd2devnum(int fd);
+extern void run_kpartx(char mode, char *dev);
static inline int dev2major(int d)
{
diff --git a/super-intel.c b/super-intel.c
index a2b9bd2..5f06f30 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -636,7 +636,7 @@ static void brief_examine_super_imsm(struct supertype *st)
getinfo_super_imsm(st, &info);
fname_from_uuid(st, &info, nbuf1,'-');
printf("ARRAY /dev/md/%.16s container=%s\n"
- " member=%d auto=mdp UUID=%s\n",
+ " member=%d auto=md UUID=%s\n",
dev->volume, nbuf + 5, i, nbuf1 + 5);
}
}
diff --git a/util.c b/util.c
index 8845a0f..f21d2bb 100644
--- a/util.c
+++ b/util.c
@@ -1327,6 +1327,31 @@ void append_metadata_update(struct supertype *st, void *buf, int len)
}
#endif /* MDASSEMBLE */
+void run_kpartx(char mode, char *dev)
+{
+ char buf[1024];
+ char *cp;
+
+ sprintf(buf, "/sbin/kpartx > /dev/null 2>&1 -%c '", mode);
+
+ cp = buf + strlen(buf);
+ while (cp < buf+sizeof(buf)-10 &&
+ *dev) {
+ if (*dev == '\'') {
+ *cp++ = '\'';
+ *cp++ = '\\';
+ *cp++ = '\'';
+ /* *cp++ = '\''; */
+ }
+ *cp ++ = *dev++;
+ }
+ *cp++ = '\'';
+ *cp++ = 0;
+ system(buf);
+}
+
+
+
#ifdef __TINYC__
/* tinyc doesn't optimize this check in ioctl.h out ... */
unsigned int __invalid_size_argument_for_IOC = 0;
--
1.5.6.5