Skip to contentSkip to conversation

Remove container_enough logic

PATCH Applied Pawel Piatkowski 2 participants 4 messages Oct 19, 2023 – Oct 26, 2023 MD RAID

lore
Share & tools
lore
#0 lore raw

cover Remove container_enough logic

Pawel Piatkowski (2):
mdadm: remove container_enough logic
Fix assembling RAID volume by using incremental

 Assemble.c    | 10 ++++------
 Incremental.c | 11 -----------
 mdadm.h       |  3 ---
 super-ddf.c   |  1 -
 super-intel.c | 32 +-------------------------------
 5 files changed, 5 insertions(+), 52 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/2 mdadm: remove container_enough logic

Arrays without enough disk count will be assembled but not started.
Now RAIDs will be assembled always (even if they are failed). RAID devices in all states will be assembled and exposed to mdstat.
This change affects only IMSM (for ddf it wasn't used, container_enough was set to true always).
Removed this logic from incremental_container as well with runstop checking because runstop condition is being verified in assemble_container_content function.

---
 Incremental.c | 11 -----------
 mdadm.h       |  3 ---
 super-ddf.c   |  1 -
 super-intel.c | 32 +-------------------------------
 4 files changed, 1 insertion(+), 46 deletions(-)
Incremental.c +0 -11
index f13ce027..332fb846 100644
@@ -1467,17 +1467,6 @@ static int Incremental_container(struct supertype *st, char *devname,
 
 	st->ss->getinfo_super(st, &info, NULL);
 
-	if ((c->runstop > 0 && info.container_enough >= 0) ||
-	    info.container_enough > 0)
-		/* pass */;
-	else {
-		if (c->export) {
-			printf("MD_STARTED=no\n");
-		} else if (c->verbose)
-			pr_err("not enough devices to start the container\n");
-		return 0;
-	}
-
 	match = conf_match(st, &info, devname, c->verbose, &rv);
 	if (match == NULL && rv == 2)
 		return rv;
mdadm.h +0 -3
index 83f2cf7f..fb4c6fa1 100644
@@ -372,9 +372,6 @@ struct mdinfo {
 	int container_member; /* for assembling external-metatdata arrays
 			       * This is to be used internally by metadata
 			       * handler only */
-	int container_enough; /* flag external handlers can set to
-			       * indicate that subarrays have not enough (-1),
-			       * enough to start (0), or all expected disks (1) */
 	char		sys_name[32];
 	struct mdinfo *devs;
 	struct mdinfo *next;
super-ddf.c +0 -1
index 7213284e..d06bd781 100644
@@ -1975,7 +1975,6 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
 	info->array.ctime	  = DECADE + __be32_to_cpu(*cptr);
 
 	info->array.chunk_size	  = 0;
-	info->container_enough	  = 1;
 
 	info->disk.major	  = 0;
 	info->disk.minor	  = 0;
super-intel.c +1 -31
index ae0f4a8c..56dda5a6 100644
@@ -3778,7 +3778,6 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
 	struct intel_super *super = st->sb;
 	struct imsm_disk *disk;
 	int map_disks = info->array.raid_disks;
-	int max_enough = -1;
 	int i;
 	struct imsm_super *mpb;
 
@@ -3820,12 +3819,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
 
 	for (i = 0; i < mpb->num_raid_devs; i++) {
 		struct imsm_dev *dev = get_imsm_dev(super, i);
-		int failed, enough, j, missing = 0;
+		int j = 0;
 		struct imsm_map *map;
-		__u8 state;
 
-		failed = imsm_count_failed(super, dev, MAP_0);
-		state = imsm_check_degraded(super, dev, failed, MAP_0);
 		map = get_imsm_map(dev, MAP_0);
 
 		/* any newly missing disks?
@@ -3840,36 +3836,10 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
 
 			if (!(ord & IMSM_ORD_REBUILD) &&
 			    get_imsm_missing(super, idx)) {
-				missing = 1;
 				break;
 			}
 		}
-
-		if (state == IMSM_T_STATE_FAILED)
-			enough = -1;
-		else if (state == IMSM_T_STATE_DEGRADED &&
-			 (state != map->map_state || missing))
-			enough = 0;
-		else /* we're normal, or already degraded */
-			enough = 1;
-		if (is_gen_migration(dev) && missing) {
-			/* during general migration we need all disks
-			 * that process is running on.
-			 * No new missing disk is allowed.
-			 */
-			max_enough = -1;
-			enough = -1;
-			/* no more checks necessary
-			 */
-			break;
-		}
-		/* in the missing/failed disk case check to see
-		 * if at least one array is runnable
-		 */
-		max_enough = max(max_enough, enough);
 	}
-	dprintf("enough: %d\n", max_enough);
-	info->container_enough = max_enough;
 
 	if (super->disks) {
 		__u32 reserved = imsm_reserved_sectors(super, super->disks);
Signature · 1 line
2.39.1
#2 lore raw

PATCH 2/2 Fix assembling RAID volume by using incremental

In reply to Pawel Piatkowski

After change "mdadm: remove container_enough logic" IMSM volumes are started immediately. If volume is during reshape, then it will be blocked by block_subarray() during first mdadm -I <devname>. Assemble_container_content() for next disk will see the change because metadata version from sysfs and metadata doesn't match and will execute sysfs_set_array again. Then it fails to set same component_size, it is prohibited by kernel.

If array is frozen then first sign from metadata version is different ("/" vs "-"), so exclude it from comparison. All we want is to double check that base properties are set and we don't need to call sysfs_set_array again.

---
 Assemble.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Assemble.c +4 -6
index 49804941..add002f8 100644
@@ -1982,12 +1982,10 @@ int assemble_container_content(struct supertype *st, int mdfd,
 		return 1;
 	}
 
-	if (strcmp(sra->text_version, content->text_version) != 0) {
-		if (content->array.major_version == -1 &&
-		    content->array.minor_version == -2 &&
-		    c->readonly &&
-		    content->text_version[0] == '/')
-			content->text_version[0] = '-';
+	/* Fill sysfs properties only if they are not set. Determine it by checking text_version
+	 * and ignoring special character on the first place.
+	 */
+	if (strcmp(sra->text_version + 1, content->text_version + 1) != 0) {
 		if (sysfs_set_array(content, 9003) != 0) {
 			sysfs_free(sra);
 			return 1;
Signature · 1 line
2.39.1
Applied
#3 lore raw
In reply to Pawel Piatkowski
Quoted 11 lines · Pawel Piatkowski

Pawel Piatkowski (2):
mdadm: remove container_enough logic
Fix assembling RAID volume by using incremental

 Assemble.c    | 10 ++++------
 Incremental.c | 11 -----------
 mdadm.h       |  3 ---
 super-ddf.c   |  1 -
 super-intel.c | 32 +-------------------------------
 5 files changed, 5 insertions(+), 52 deletions(-)

Looks reasonable to me. If it breaks, we know where to find Intel :)

Applied

Thanks,
Jes