mdadm/0073-super-intel-refactor-the-code-for-enum.patch
Coly Li 058b24e58a Accepting request 1137473 from home:colyli:branches:Base:System
- Update mdadm to latest upstream state upto commit
  582945c2d3bb. (jsc#PED-7542)
  1) The testing changes are not included here.
  2) Code clean up, and more helper routines added for Manage.c,
     Monitor.c, mdadm.c, ReadMe.c, super-intel.c, super0.c, super1.c,
     Create.c, Incremental.c and so on.
  3) Man page update for mdadm.8.in.
  4) Several memory leak and double free fixes.
  5) Check /etc/initrd-release for whether systemd running on an initrd.
  - Manage: Block unsafe member failing
    0062-Manage-Block-unsafe-member-failing.patch
  - Mdmonitor: Split alert() into separate functions
    0063-Mdmonitor-Split-alert-into-separate-functions.patch
  - Monitor: block if monitor modes are combined.
    0064-Monitor-block-if-monitor-modes-are-combined.patch
  - Update mdadm Monitor manual.
    0065-Update-mdadm-Monitor-manual.patch
  - mdadm: create ident_init()
    0066-mdadm-create-ident_init.patch
  - mdadm: Add option validation for --update-subarray
    0067-mdadm-Add-option-validation-for-update-subarray.patch
  - Fix --update-subarray on active volume
    0068-Fix-update-subarray-on-active-volume.patch
  - Add code specific update options to enum.
    0069-Add-code-specific-update-options-to-enum.patch
  - super-ddf: Remove update_super_ddf.
    0070-super-ddf-Remove-update_super_ddf.patch
  - super0: refactor the code for enum
    0071-super0-refactor-the-code-for-enum.patch
  - super1: refactor the code for enum

OBS-URL: https://build.opensuse.org/request/show/1137473
OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=231
2024-01-11 00:49:23 +00:00

107 lines
3.3 KiB
Diff

From 4345e135c4c7dd04bb15bad140dfc4747f677738 Mon Sep 17 00:00:00 2001
From: Mateusz Kusiak <mateusz.kusiak@intel.com>
Date: Mon, 2 Jan 2023 09:35:21 +0100
Subject: [PATCH] super-intel: refactor the code for enum
It prepares super-intel for change context->update to enum.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
---
super-intel.c | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/super-intel.c b/super-intel.c
index 5f93f3d..85fb7f1 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -3930,7 +3930,8 @@ static int update_super_imsm(struct supertype *st, struct mdinfo *info,
mpb = super->anchor;
- if (strcmp(update, "uuid") == 0) {
+ switch (map_name(update_options, 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
@@ -3954,10 +3955,14 @@ static int update_super_imsm(struct supertype *st, struct mdinfo *info,
}
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)
@@ -7889,17 +7894,25 @@ static int kill_subarray_imsm(struct supertype *st, char *subarray_id)
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,
@@ -7909,7 +7922,7 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
struct intel_super *super = st->sb;
struct imsm_super *mpb = super->anchor;
- if (strcmp(update, "name") == 0) {
+ if (map_name(update_options, update) == UOPT_NAME) {
char *name = ident->name;
char *ep;
int vol;
@@ -7943,7 +7956,7 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
}
super->updates_pending++;
}
- } else if (get_rwh_policy_from_update(update) != -1) {
+ } else if (get_rwh_policy_from_update(map_name(update_options, update)) != UOPT_UNDEFINED) {
int new_policy;
char *ep;
int vol = strtoul(subarray, &ep, 10);
@@ -7951,7 +7964,7 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
if (*ep != '\0' || vol >= super->anchor->num_raid_devs)
return 2;
- new_policy = get_rwh_policy_from_update(update);
+ new_policy = get_rwh_policy_from_update(map_name(update_options, update));
if (st->update_tail) {
struct imsm_update_rwh_policy *u = xmalloc(sizeof(*u));
--
2.35.3