summaryrefslogtreecommitdiffstats
path: root/Assemble.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-09-18 16:01:55 +1000
committerNeilBrown <neilb@suse.de>2008-09-18 16:01:55 +1000
commitf35f25259279573c6274e2783536c0b0a399bdd4 (patch)
treefc464d06069d7cf50b642dce3bc01ec6d5f08677 /Assemble.c
parent7801ac209240ca5d5159d2ab990dd8d5573e2195 (diff)
downloadmdadm-f35f25259279573c6274e2783536c0b0a399bdd4.tar.gz
mdadm-f35f25259279573c6274e2783536c0b0a399bdd4.tar.xz
mdadm-f35f25259279573c6274e2783536c0b0a399bdd4.zip
Move calls to SET_ARRAY_INFO to common helper.
When we assemble an array, there are three different approaches depending on whether metadata is internal or external, and on kernel version. Move all this to a common helper instead of duplicating in 3 places. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c36
1 files changed, 8 insertions, 28 deletions
diff --git a/Assemble.c b/Assemble.c
index 1f41369..65a679b 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -140,6 +140,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
char *avail;
int nextspare = 0;
+ memset(&info, 0, sizeof(info));
+
if (get_linux_version() < 2004000)
old_linux = 1;
@@ -736,6 +738,9 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
return 1;
}
st->ss->getinfo_super(st, &info);
+#ifndef MDASSEMBLE
+ sysfs_init(&info, mdfd, 0);
+#endif
for (i=0; i<bestcnt; i++) {
int j = best[i];
unsigned int desired_state;
@@ -844,36 +849,11 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
/* Almost ready to actually *do* something */
if (!old_linux) {
- struct mdinfo *sra = NULL;
int rv;
-#ifndef MDASSEMBLE
- if (st->ss->external) {
- char ver[100];
- strcat(strcpy(ver, "external:"), info.text_version);
- sra = sysfs_read(mdfd, 0, 0);
- if ((vers % 100) < 2 ||
- sra == NULL ||
- sysfs_set_str(sra, NULL, "metadata_version",
- ver) < 0) {
- fprintf(stderr, Name ": This kernel does not "
- "support external metadata.\n");
- return 1;
- }
- rv = sysfs_set_array(sra, &info);
- } else
-#endif
- if ((vers % 100) >= 1) { /* can use different versions */
- mdu_array_info_t inf;
- memset(&inf, 0, sizeof(inf));
- inf.major_version = info.array.major_version;
- inf.minor_version = info.array.minor_version;
- rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
- } else
- rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
-
+ rv = set_array_info(mdfd, st, &info);
if (rv) {
- fprintf(stderr, Name ": SET_ARRAY_INFO failed for %s: %s\n",
+ fprintf(stderr, Name ": failed to set array info for %s: %s\n",
mddev, strerror(errno));
if (must_close) close(mdfd);
return 1;
@@ -913,7 +893,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
j = chosen_drive;
if (j >= 0 /* && devices[j].uptodate */) {
- rv = add_disk(mdfd, st, sra, &devices[j].i);
+ rv = add_disk(mdfd, st, &info, &devices[j].i);
if (rv) {
fprintf(stderr, Name ": failed to add "