Skip to contentSkip to conversation

md: assorted bugfixes - one serious.

PATCH New NeilBrown 1 participant 5 messages Oct 23, 2006 MD RAID

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 md: assorted bugfixes - one serious.

I rang my regression test suite on md for the first time in a while (obviously too long :-().
Found two bugs resulting in patches 1 and 3.
Others are fixes for more subtle issues.

All patches are suitable for 2.6.19, patch 1 is quite serious and should go in 2.6.18.2.

Thanks,
NeilBrown

[PATCH 001 of 4] md: Fix bug where spares don't always get rebuilt properly when they become live. [PATCH 002 of 4] md: Simplify checking of available size when resizing an array [PATCH 003 of 4] md: Fix up maintenance of ->degraded in multipath.
[PATCH 004 of 4] md: Fix printk format warnings, seen on powerpc64:

author
#1 lore raw

PATCH 1/1 md: Fix bug where spares don't always get rebuilt properly when they become live.

If save_raid_disk is >= 0, then the device could be a device that is already in sync that is being re-added. So we need to default this value to -1.

### Diffstat output

 ./drivers/md/md.c |    1 +
 1 file changed, 1 insertion(+)
drivers/md/md.c +1 -0
diff .prev/drivers/md/md.c ./drivers/md/md.c
@@ -2003,6 +2003,7 @@ static mdk_rdev_t *md_import_device(dev_
 	kobject_init(&rdev->kobj);
 
 	rdev->desc_nr = -1;
+	rdev->saved_raid_disk = -1;
 	rdev->flags = 0;
 	rdev->data_offset = 0;
 	rdev->sb_events = 0;
author
#2 lore raw

PATCH 1/1 md: Simplify checking of available size when resizing an array

In reply to NeilBrown

When "mdadm --grow --size=xxx" is used to resize an array (use more or less of each device), we check the new siza against the available space in each device.

The already have that number recorded in rdev->size, so calculating it is pointless (and wrong in one obscure case).

### Diffstat output

 ./drivers/md/md.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/md/md.c +2 -5
diff .prev/drivers/md/md.c ./drivers/md/md.c
@@ -4047,11 +4047,8 @@ static int update_size(mddev_t *mddev, u
 		return -EBUSY;
 	ITERATE_RDEV(mddev,rdev,tmp) {
 		sector_t avail;
-		if (rdev->sb_offset > rdev->data_offset)
-			avail = (rdev->sb_offset*2) - rdev->data_offset;
-		else
-			avail = get_capacity(rdev->bdev->bd_disk)
-				- rdev->data_offset;
+		avail = rdev->size * 2;
+
 		if (fit && (size == 0 || size > avail/2))
 			size = avail/2;
 		if (avail < ((sector_t)size << 1))
author
#3 lore raw

PATCH 1/1 md: Fix up maintenance of ->degraded in multipath.

In reply to NeilBrown

A recent fix which made sure ->degraded was initialised properly exposed a second bug - ->degraded wasn't been updated when drives failed or were hot-added.

### Diffstat output

 ./drivers/md/multipath.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/md/multipath.c +2 -0
diff .prev/drivers/md/multipath.c ./drivers/md/multipath.c
@@ -277,6 +277,7 @@ static void multipath_error (mddev_t *md
 			set_bit(Faulty, &rdev->flags);
 			set_bit(MD_CHANGE_DEVS, &mddev->flags);
 			conf->working_disks--;
+			mddev->degraded++;
 			printk(KERN_ALERT "multipath: IO failure on %s,"
 				" disabling IO path. \n	Operation continuing"
 				" on %d IO paths.\n",
@@ -336,6 +337,7 @@ static int multipath_add_disk(mddev_t *m
 				blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
 
 			conf->working_disks++;
+			mddev->degraded--;
 			rdev->raid_disk = path;
 			set_bit(In_sync, &rdev->flags);
 			rcu_assign_pointer(p->rdev, rdev);
author
#4 lore raw

PATCH 1/1 md: Fix printk format warnings, seen on powerpc64:

In reply to NeilBrown

From: Randy Dunlap <[email protected]>

drivers/md/raid1.c:1479: warning: long long unsigned int format, long unsigned int arg (arg 4) drivers/md/raid10.c:1475: warning: long long unsigned int format, long unsigned int arg (arg 4)

### Diffstat output

 ./drivers/md/raid1.c  |    4 ++--
 ./drivers/md/raid10.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/raid1.c +2 -2
diff .prev/drivers/md/raid1.c ./drivers/md/raid1.c
@@ -1474,8 +1474,8 @@ static void fix_read_error(conf_t *conf,
 					       "raid1:%s: read error corrected "
 					       "(%d sectors at %llu on %s)\n",
 					       mdname(mddev), s,
-					       (unsigned long long)sect +
-					           rdev->data_offset,
+					       (unsigned long long)(sect +
+					           rdev->data_offset),
 					       bdevname(rdev->bdev, b));
 				}
 			}
drivers/md/raid10.c +2 -2
diff .prev/drivers/md/raid10.c ./drivers/md/raid10.c
@@ -1470,8 +1470,8 @@ static void fix_read_error(conf_t *conf,
 					       "raid10:%s: read error corrected"
 					       " (%d sectors at %llu on %s)\n",
 					       mdname(mddev), s,
-					       (unsigned long long)sect+
-					            rdev->data_offset,
+					       (unsigned long long)(sect+
+					            rdev->data_offset),
 					       bdevname(rdev->bdev, b));
 
 				rdev_dec_pending(rdev, mddev);