[PATCH] imsm: FIX: do not load migration record from spare disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Load migration record from first 2 disks only, not from spare disks.
Check for negative values is missing.

This problem can be observed when slots are managed by md.
When they are set by mdadm problem is not visible, but still exists.

Signed-off-by: Adam Kwolek <adam.kwolek@xxxxxxxxx>
---

 super-intel.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 4758951..2070869 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1602,14 +1602,15 @@ static int load_imsm_migr_rec(struct intel_super *super, struct mdinfo *info)
 {
 	unsigned long long dsize;
 	struct mdinfo *sd;
-	struct dl *dl;
+	struct dl *dl = NULL;
 	char nm[30];
 	int retval = -1;
 	int fd = -1;
 
 	for (sd = info->devs ; sd ; sd = sd->next) {
 		/* read only from one of the first two slots */
-		if (sd->disk.raid_disk > 1)
+		if ((sd->disk.raid_disk > 1) ||
+		    (sd->disk.raid_disk < 0))
 			continue;
 		sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
 		fd = dev_open(nm, O_RDONLY);
@@ -1643,7 +1644,7 @@ static int load_imsm_migr_rec(struct intel_super *super, struct mdinfo *info)
 		goto out;
 	}
 	retval = 0;
- out:
+out:
 	if (fd >= 0)
 		close(fd);
 	return retval;
@@ -1662,7 +1663,7 @@ static int write_imsm_migr_rec(struct intel_super *super, struct mdinfo *info)
 
 	for (sd = info->devs ; sd ; sd = sd->next) {
 		/* write only to the first two slots */
-		if (sd->disk.raid_disk > 1)
+		if ((sd->disk.raid_disk > 1) || (sd->disk.raid_disk < 0))
 			continue;
 		sprintf(nm, "%d:%d", sd->disk.major, sd->disk.minor);
 		fd = dev_open(nm, O_RDWR);

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux