Skip to contentSkip to conversation

md: Five minor md patch, some for 2.6.24.

PATCH New NeilBrown 1 participant 6 messages Oct 15, 2007 MD RAID

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 md: Five minor md patch, some for 2.6.24.

Following are 5 minor patches for md in current -mm.

The first 4 are suitable to flow into 2.6.24.

The last fixes a small bug in Dan Williams' patches currently in -mm, which are not scheduled for 2.6.24.

Thanks,
NeilBrown

[PATCH 001 of 5] md: Fix a bug in some never-used code.
[PATCH 002 of 5] md: 'sync_action' in sysfs returns wrong value for readonly arrays [PATCH 003 of 5] md: Expose the degraded status of an assembled array through sysfs [PATCH 004 of 5] md: Make sure read errors are auto-corrected during a 'check' resync in raid1 [PATCH 005 of 5] md: Fix type that is stopping raid5 grow from working.

author
#1 lore raw

PATCH 1/1 md: Fix a bug in some never-used code.

http://bugzilla.kernel.org/show_bug.cgi?id=3277

There is a seq_printf here that isn't being passed a 'seq'. Howeve as the code is inside #ifdef MD_DEBUG, nobody noticed.

Also remove some extra spaces.

### Diffstat output

 ./drivers/md/raid0.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/md/raid0.c +5 -5
diff .prev/drivers/md/raid0.c ./drivers/md/raid0.c
@@ -472,7 +472,7 @@ bad_map:
 	bio_io_error(bio);
 	return 0;
 }
-			   
+
 static void raid0_status (struct seq_file *seq, mddev_t *mddev)
 {
 #undef MD_DEBUG
@@ -480,18 +480,18 @@ static void raid0_status (struct seq_fil
 	int j, k, h;
 	char b[BDEVNAME_SIZE];
 	raid0_conf_t *conf = mddev_to_conf(mddev);
-  
+
 	h = 0;
 	for (j = 0; j < conf->nr_strip_zones; j++) {
 		seq_printf(seq, "      z%d", j);
 		if (conf->hash_table[h] == conf->strip_zone+j)
-			seq_printf("(h%d)", h++);
+			seq_printf(seq, "(h%d)", h++);
 		seq_printf(seq, "=[");
 		for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
-			seq_printf (seq, "%s/", bdevname(
+			seq_printf(seq, "%s/", bdevname(
 				conf->strip_zone[j].dev[k]->bdev,b));
 
-		seq_printf (seq, "] zo=%d do=%d s=%d\n",
+		seq_printf(seq, "] zo=%d do=%d s=%d\n",
 				conf->strip_zone[j].zone_offset,
 				conf->strip_zone[j].dev_offset,
 				conf->strip_zone[j].size);
author
#2 lore raw

PATCH 1/1 md: 'sync_action' in sysfs returns wrong value for readonly arrays

In reply to NeilBrown

When an array is started read-only, MD_RECOVERY_NEEDED can be set but no recovery will be running. This causes 'sync_action' to report the wrong value.

We could remove the test for MD_RECOVERY_NEEDED, but doing so would leave a small gap after requesting a sync action, where 'sync_action' would still report the old value.

So make sure that for a read-only array, 'sync_action' always returns 'idle'.

### Diffstat output

 ./drivers/md/md.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/md.c +1 -1
diff .prev/drivers/md/md.c ./drivers/md/md.c
@@ -2714,7 +2714,7 @@ action_show(mddev_t *mddev, char *page)
 {
 	char *type = "idle";
 	if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
-	    test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) {
+	    (!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))) {
 		if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
 			type = "reshape";
 		else if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
author
#3 lore raw

PATCH 1/1 md: Expose the degraded status of an assembled array through sysfs

In reply to NeilBrown

From: Iustin Pop <[email protected]>

The 'degraded' attribute is useful to quickly determine if the array is degraded, instead of parsing 'mdadm -D' output or relying on the other techniques (number of working devices against number of defined devices, etc.). The md code already keeps track of this attribute, so it's useful to export it.

### Diffstat output

 ./drivers/md/md.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/md/md.c +7 -0
diff .prev/drivers/md/md.c ./drivers/md/md.c
@@ -2833,6 +2833,12 @@ sync_max_store(mddev_t *mddev, const cha
 static struct md_sysfs_entry md_sync_max =
 __ATTR(sync_speed_max, S_IRUGO|S_IWUSR, sync_max_show, sync_max_store);
 
+static ssize_t
+degraded_show(mddev_t *mddev, char *page)
+{
+	return sprintf(page, "%d\n", mddev->degraded);
+}
+static struct md_sysfs_entry md_degraded = __ATTR_RO(degraded);
 
 static ssize_t
 sync_speed_show(mddev_t *mddev, char *page)
@@ -2976,6 +2982,7 @@ static struct attribute *md_redundancy_a
 	&md_suspend_lo.attr,
 	&md_suspend_hi.attr,
 	&md_bitmap.attr,
+	&md_degraded.attr,
 	NULL,
 };
 static struct attribute_group md_redundancy_group = {
author
#4 lore raw

PATCH 1/1 md: Make sure read errors are auto-corrected during a 'check' resync in raid1

In reply to NeilBrown

Whenever a read error is found, we should attempt to overwrite with correct data to 'fix' it.

However when do a 'check' pass (which compares data blocks that are successfully read, but doesn't normally overwrite) we don't do that. We should.

### Diffstat output

 ./drivers/md/raid1.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid1.c +2 -1
diff .prev/drivers/md/raid1.c ./drivers/md/raid1.c
@@ -1214,7 +1214,8 @@ static void sync_request_write(mddev_t *
 					j = 0;
 				if (j >= 0)
 					mddev->resync_mismatches += r1_bio->sectors;
-				if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) {
+				if (j < 0 || (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)
+					      && test_bit(BIO_UPTODATE, &sbio->bi_flags))) {
 					sbio->bi_end_io = NULL;
 					rdev_dec_pending(conf->mirrors[i].rdev, mddev);
 				} else {
author
#5 lore raw

PATCH 1/1 md: Fix type that is stopping raid5 grow from working.

In reply to NeilBrown

This kmem_cache_create is creating a cache that already exists. We could us the alternate name, just like we do a few lines up.

Cc "Dan Williams" <[email protected]>

### Diffstat output

 ./drivers/md/raid5.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
diff .prev/drivers/md/raid5.c ./drivers/md/raid5.c
@@ -1380,7 +1380,7 @@ static int resize_stripes(raid5_conf_t *
 	if (!sc)
 		return -ENOMEM;
 
-	sc_q = kmem_cache_create(conf->sq_cache_name[conf->active_name],
+	sc_q = kmem_cache_create(conf->sq_cache_name[1-conf->active_name],
 			       (sizeof(struct stripe_queue)+(newsize-1) *
 				sizeof(struct r5_queue_dev)) +
 				r5_io_weight_size(newsize) +