}
static int update_super_imsm(struct supertype *st, struct mdinfo *info,
- char *update, char *devname, int verbose,
- int uuid_set, char *homehost)
+ enum update_opt update, char *devname,
+ int verbose, int uuid_set, char *homehost)
{
/* For 'assemble' and 'force' we need to return non-zero if any
* change was made. For others, the return value is ignored.
mpb = super->anchor;
- if (strcmp(update, "uuid") == 0) {
+ switch (update) {
+ case UOPT_UUID:
/* We take this to mean that the family_num should be updated.
* However that is much smaller than the uuid so we cannot really
* allow an explicit uuid to be given. And it is hard to reliably
}
if (rv == 0)
mpb->orig_family_num = info->uuid[0];
- } else if (strcmp(update, "assemble") == 0)
+ break;
+ case UOPT_SPEC_ASSEMBLE:
rv = 0;
- else
+ break;
+ default:
rv = -1;
+ break;
+ }
/* successful update? recompute checksum */
if (rv == 0)
if (mdmon_running(st->container_devnm))
st->update_tail = &st->updates;
- if (st->ss->update_subarray(st, subarray, "ppl", NULL)) {
+ if (st->ss->update_subarray(st, subarray, UOPT_PPL, NULL)) {
pr_err("Failed to update subarray %s\n",
subarray);
} else {
return 0;
}
-static int get_rwh_policy_from_update(char *update)
+/**
+ * get_rwh_policy_from_update() - Get the rwh policy for update option.
+ * @update: Update option.
+ */
+static int get_rwh_policy_from_update(enum update_opt update)
{
- if (strcmp(update, "ppl") == 0)
+ switch (update) {
+ case UOPT_PPL:
return RWH_MULTIPLE_DISTRIBUTED;
- else if (strcmp(update, "no-ppl") == 0)
+ case UOPT_NO_PPL:
return RWH_MULTIPLE_OFF;
- else if (strcmp(update, "bitmap") == 0)
+ case UOPT_BITMAP:
return RWH_BITMAP;
- else if (strcmp(update, "no-bitmap") == 0)
+ case UOPT_NO_BITMAP:
return RWH_OFF;
- return -1;
+ default:
+ break;
+ }
+ return UOPT_UNDEFINED;
}
static int update_subarray_imsm(struct supertype *st, char *subarray,
- char *update, struct mddev_ident *ident)
+ enum update_opt update, struct mddev_ident *ident)
{
/* update the subarray currently referenced by ->current_vol */
struct intel_super *super = st->sb;
struct imsm_super *mpb = super->anchor;
- if (strcmp(update, "name") == 0) {
+ if (update == UOPT_NAME) {
char *name = ident->name;
char *ep;
int vol;
- if (is_subarray_active(subarray, st->devnm)) {
- pr_err("Unable to update name of active subarray\n");
- return 2;
- }
-
if (!check_name(super, name, 0))
return 2;
}
super->updates_pending++;
}
- } else if (get_rwh_policy_from_update(update) != -1) {
+ } else if (get_rwh_policy_from_update(update) != UOPT_UNDEFINED) {
int new_policy;
char *ep;
int vol = strtoul(subarray, &ep, 10);