From: Dan Williams Date: Fri, 2 Jul 2010 00:36:05 +0000 (-0700) Subject: Merge branch 'subarray' into for-neil X-Git-Tag: mdadm-3.1.3~28^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cfc801c72f079618b39d04c2e0fe32adbc2474e;p=thirdparty%2Fmdadm.git Merge branch 'subarray' into for-neil Conflicts: mdadm.h super-intel.c --- 8cfc801c72f079618b39d04c2e0fe32adbc2474e diff --cc mdadm.h index 142868ad,68d61a3a..798713cb --- a/mdadm.h +++ b/mdadm.h @@@ -609,8 -612,10 +612,12 @@@ extern struct superswitch struct mdinfo *(*container_content)(struct supertype *st); /* Allow a metadata handler to override mdadm's default layouts */ int (*default_layout)(int level); /* optional */ + /* query the supertype for default chunk size */ + int (*default_chunk)(struct supertype *st); /* optional */ + /* Permit subarray's to be deleted from inactive containers */ + int (*kill_subarray)(struct supertype *st); /* optional */ + /* Permit subarray's to be modified */ + int (*update_subarray)(struct supertype *st, char *update, mddev_ident_t ident); /* optional */ /* for mdmon */ int (*open_new)(struct supertype *c, struct active_array *a, diff --cc super-intel.c index 3bd041ad,f0377b81..159ae4a8 --- a/super-intel.c +++ b/super-intel.c @@@ -4010,16 -4055,129 +4061,139 @@@ static int validate_geometry_imsm(struc return 0; } +static int default_chunk_imsm(struct supertype *st) +{ + struct intel_super *super = st->sb; + + if (!super->orom) + return 0; + + return imsm_orom_default_chunk(super->orom); +} + + static void handle_missing(struct intel_super *super, struct imsm_dev *dev); + + static int kill_subarray_imsm(struct supertype *st) + { + /* remove the subarray currently referenced by ->current_vol */ + __u8 i; + struct intel_dev **dp; + struct intel_super *super = st->sb; + __u8 current_vol = super->current_vol; + struct imsm_super *mpb = super->anchor; + + if (super->current_vol < 0) + return 2; + super->current_vol = -1; /* invalidate subarray cursor */ + + /* block deletions that would change the uuid of active subarrays + * + * FIXME when immutable ids are available, but note that we'll + * also need to fixup the invalidated/active subarray indexes in + * mdstat + */ + for (i = 0; i < mpb->num_raid_devs; i++) { + char subarray[4]; + + if (i < current_vol) + continue; + sprintf(subarray, "%u", i); + if (is_subarray_active(subarray, st->devname)) { + fprintf(stderr, + Name ": deleting subarray-%d would change the UUID of active subarray-%d, aborting\n", + current_vol, i); + + return 2; + } + } + + if (st->update_tail) { + struct imsm_update_kill_array *u = malloc(sizeof(*u)); + + if (!u) + return 2; + u->type = update_kill_array; + u->dev_idx = current_vol; + append_metadata_update(st, u, sizeof(*u)); + + return 0; + } + + for (dp = &super->devlist; *dp;) + if ((*dp)->index == current_vol) { + *dp = (*dp)->next; + } else { + handle_missing(super, (*dp)->dev); + if ((*dp)->index > current_vol) + (*dp)->index--; + dp = &(*dp)->next; + } + + /* no more raid devices, all active components are now spares, + * but of course failed are still failed + */ + if (--mpb->num_raid_devs == 0) { + struct dl *d; + + for (d = super->disks; d; d = d->next) + if (d->index > -2) { + d->index = -1; + d->disk.status = SPARE_DISK; + } + } + + super->updates_pending++; + + return 0; + } + + static int update_subarray_imsm(struct supertype *st, char *update, mddev_ident_t ident) + { + /* update the subarray currently referenced by ->current_vol */ + struct intel_super *super = st->sb; + struct imsm_super *mpb = super->anchor; + + if (super->current_vol < 0) + return 2; + + if (strcmp(update, "name") == 0) { + char *name = ident->name; + + if (is_subarray_active(st->subarray, st->devname)) { + fprintf(stderr, + Name ": Unable to update name of active subarray\n"); + return 2; + } + + if (!check_name(super, name, 0)) + return 2; + + if (st->update_tail) { + struct imsm_update_rename_array *u = malloc(sizeof(*u)); + + if (!u) + return 2; + u->type = update_rename_array; + u->dev_idx = super->current_vol; + snprintf((char *) u->name, MAX_RAID_SERIAL_LEN, "%s", name); + append_metadata_update(st, u, sizeof(*u)); + } else { + struct imsm_dev *dev; + int i; + + dev = get_imsm_dev(super, super->current_vol); + snprintf((char *) dev->volume, MAX_RAID_SERIAL_LEN, "%s", name); + for (i = 0; i < mpb->num_raid_devs; i++) { + dev = get_imsm_dev(super, i); + handle_missing(super, dev); + } + super->updates_pending++; + } + } else + return 2; + + return 0; + } #endif /* MDASSEMBLE */ static int is_rebuilding(struct imsm_dev *dev) @@@ -5254,9 -5486,10 +5503,11 @@@ struct superswitch super_imsm = .brief_detail_super = brief_detail_super_imsm, .write_init_super = write_init_super_imsm, .validate_geometry = validate_geometry_imsm, + .default_chunk = default_chunk_imsm, .add_to_super = add_to_super_imsm, .detail_platform = detail_platform_imsm, + .kill_subarray = kill_subarray_imsm, + .update_subarray = update_subarray_imsm, #endif .match_home = match_home_imsm, .uuid_from_super= uuid_from_super_imsm,