public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 000 of 3] md: Introduction
@ 2006-02-02  6:02 NeilBrown
  2006-02-02  6:02 ` [PATCH 001 of 3] md: Handle overflow of mdu_array_info_t->size better NeilBrown
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: NeilBrown @ 2006-02-02  6:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


Three patches for 2.6.lastest. All should go in 2.6.16.
One won't apply against -rc1-git5 as it fixes a bug in a patch
in -mm that hasn't quite got to -linus yes.

They are mostly little fixes.  I've been doing some more testing,
particularly creating a raid1 over 2 6TB arrays.  This requires
version-1 superblocks, so they have had a bit more testing too.

(No, I didn't try to resync the 6TB raid1.  I created it 
--assume-clean and gave it a write-intent bitmap so a full resync
would never be needed.  If one side died, a recovery would take
ages!!!! but for me it was only an experiment, not a serious configuration).
(You will need mdadm-2.3 if you too want a 6TB raid1).


 [PATCH 001 of 3] md: Handle overflow of mdu_array_info_t->size better.
 [PATCH 002 of 3] md: Assorted little md fixes:
 [PATCH 003 of 3] md: Make sure rdev->size gets set for version-1 superblocks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 001 of 3] md: Handle overflow of mdu_array_info_t->size better.
  2006-02-02  6:02 [PATCH 000 of 3] md: Introduction NeilBrown
@ 2006-02-02  6:02 ` NeilBrown
  2006-02-02  6:02 ` [PATCH 002 of 3] md: Assorted little md fixes: NeilBrown
  2006-02-02  6:02 ` [PATCH 003 of 3] md: Make sure rdev->size gets set for version-1 superblocks NeilBrown
  2 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2006-02-02  6:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


mdu_array_info_t->size is 'int', which isn't big enough for the
size (in KB of each component in) some arrays.

So rather than a random overflow, set size to -1 when it cannot be set
correctly.

To update aspect on an array, userspace will sometimes:
  get_array_info
  change one field
  set_array_info

in this case, we don't want the '-1' in 'size' to change to size, or
look like a size change at all.  So test for that in update_array_info.



Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/md.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff ./drivers/md/md.c~current~ ./drivers/md/md.c
--- ./drivers/md/md.c~current~	2006-02-02 16:42:56.000000000 +1100
+++ ./drivers/md/md.c	2006-02-02 16:48:47.000000000 +1100
@@ -2943,6 +2943,8 @@ static int get_array_info(mddev_t * mdde
 	info.ctime         = mddev->ctime;
 	info.level         = mddev->level;
 	info.size          = mddev->size;
+	if (info.size != mddev->size) /* overflow */
+		info.size = -1;
 	info.nr_disks      = nr;
 	info.raid_disks    = mddev->raid_disks;
 	info.md_minor      = mddev->md_minor;
@@ -3524,7 +3526,7 @@ static int update_array_info(mddev_t *md
 		)
 		return -EINVAL;
 	/* Check there is only one change */
-	if (mddev->size != info->size) cnt++;
+	if (info->size >= 0 && mddev->size != info->size) cnt++;
 	if (mddev->raid_disks != info->raid_disks) cnt++;
 	if (mddev->layout != info->layout) cnt++;
 	if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++;
@@ -3541,7 +3543,7 @@ static int update_array_info(mddev_t *md
 		else
 			return mddev->pers->reconfig(mddev, info->layout, -1);
 	}
-	if (mddev->size != info->size)
+	if (info->size >= 0 && mddev->size != info->size)
 		rv = update_size(mddev, info->size);
 
 	if (mddev->raid_disks    != info->raid_disks)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 002 of 3] md: Assorted little md fixes:
  2006-02-02  6:02 [PATCH 000 of 3] md: Introduction NeilBrown
  2006-02-02  6:02 ` [PATCH 001 of 3] md: Handle overflow of mdu_array_info_t->size better NeilBrown
@ 2006-02-02  6:02 ` NeilBrown
  2006-02-02  6:02 ` [PATCH 003 of 3] md: Make sure rdev->size gets set for version-1 superblocks NeilBrown
  2 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2006-02-02  6:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


- version-1 superblock
  + The default_bitmap_offset is in sectors, not bytes.
  + the 'size' field in the superblock is in sectors, not KB
- raid0_run should return a negative number on error, not '1'
- raid10_read_balance should not return a valid 'disk' number if
     ->rdev turned out to be NULL
- kmem_cache_destroy doesn't like being passed a NULL.


Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/md.c        |    4 ++--
 ./drivers/md/raid0.c     |    2 +-
 ./drivers/md/raid10.c    |    2 ++
 ./drivers/md/raid5.c     |    3 ++-
 ./drivers/md/raid6main.c |    3 ++-
 5 files changed, 9 insertions(+), 5 deletions(-)

diff ./drivers/md/md.c~current~ ./drivers/md/md.c
--- ./drivers/md/md.c~current~	2006-02-02 16:48:47.000000000 +1100
+++ ./drivers/md/md.c	2006-02-02 16:51:46.000000000 +1100
@@ -1082,7 +1082,7 @@ static int super_1_validate(mddev_t *mdd
 		mddev->size = le64_to_cpu(sb->size)/2;
 		mddev->events = le64_to_cpu(sb->events);
 		mddev->bitmap_offset = 0;
-		mddev->default_bitmap_offset = 1024;
+		mddev->default_bitmap_offset = 1024 >> 9;
 		
 		mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
 		memcpy(mddev->uuid, sb->set_uuid, 16);
@@ -1163,7 +1163,7 @@ static void super_1_sync(mddev_t *mddev,
 	sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors);
 
 	sb->raid_disks = cpu_to_le32(mddev->raid_disks);
-	sb->size = cpu_to_le64(mddev->size);
+	sb->size = cpu_to_le64(mddev->size<<1);
 
 	if (mddev->bitmap && mddev->bitmap_file == NULL) {
 		sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);

diff ./drivers/md/raid0.c~current~ ./drivers/md/raid0.c
--- ./drivers/md/raid0.c~current~	2006-02-02 16:48:19.000000000 +1100
+++ ./drivers/md/raid0.c	2006-02-02 16:51:53.000000000 +1100
@@ -372,7 +372,7 @@ out_free_conf:
 	kfree(conf);
 	mddev->private = NULL;
 out:
-	return 1;
+	return -ENOMEM;
 }
 
 static int raid0_stop (mddev_t *mddev)

diff ./drivers/md/raid10.c~current~ ./drivers/md/raid10.c
--- ./drivers/md/raid10.c~current~	2006-02-02 16:48:19.000000000 +1100
+++ ./drivers/md/raid10.c	2006-02-02 16:51:53.000000000 +1100
@@ -565,6 +565,8 @@ rb_out:
 
 	if (disk >= 0 && (rdev=rcu_dereference(conf->mirrors[disk].rdev))!= NULL)
 		atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
+	else
+		disk = -1;
 	rcu_read_unlock();
 
 	return disk;

diff ./drivers/md/raid5.c~current~ ./drivers/md/raid5.c
--- ./drivers/md/raid5.c~current~	2006-02-02 16:48:19.000000000 +1100
+++ ./drivers/md/raid5.c	2006-02-02 16:51:53.000000000 +1100
@@ -350,7 +350,8 @@ static void shrink_stripes(raid5_conf_t 
 	while (drop_one_stripe(conf))
 		;
 
-	kmem_cache_destroy(conf->slab_cache);
+	if (conf->slab_cache)
+		kmem_cache_destroy(conf->slab_cache);
 	conf->slab_cache = NULL;
 }
 

diff ./drivers/md/raid6main.c~current~ ./drivers/md/raid6main.c
--- ./drivers/md/raid6main.c~current~	2006-02-02 16:48:19.000000000 +1100
+++ ./drivers/md/raid6main.c	2006-02-02 16:55:25.000000000 +1100
@@ -366,7 +366,8 @@ static void shrink_stripes(raid6_conf_t 
 	while (drop_one_stripe(conf))
 		;
 
-	kmem_cache_destroy(conf->slab_cache);
+	if (conf->slab_cache)
+		kmem_cache_destroy(conf->slab_cache);
 	conf->slab_cache = NULL;
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 003 of 3] md: Make sure rdev->size gets set for version-1 superblocks.
  2006-02-02  6:02 [PATCH 000 of 3] md: Introduction NeilBrown
  2006-02-02  6:02 ` [PATCH 001 of 3] md: Handle overflow of mdu_array_info_t->size better NeilBrown
  2006-02-02  6:02 ` [PATCH 002 of 3] md: Assorted little md fixes: NeilBrown
@ 2006-02-02  6:02 ` NeilBrown
  2 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2006-02-02  6:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


Sometimes it doesn't so make the code more like the version-0 code
which works.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/md.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff ./drivers/md/md.c~current~ ./drivers/md/md.c
--- ./drivers/md/md.c~current~	2006-02-02 16:51:46.000000000 +1100
+++ ./drivers/md/md.c	2006-02-02 16:56:12.000000000 +1100
@@ -1025,7 +1025,7 @@ static int super_1_load(mdk_rdev_t *rdev
 		rdev-> sb_size = (rdev->sb_size | bmask)+1;
 
 	if (refdev == 0)
-		return 1;
+		ret = 1;
 	else {
 		__u64 ev1, ev2;
 		struct mdp_superblock_1 *refsb = 
@@ -1045,7 +1045,9 @@ static int super_1_load(mdk_rdev_t *rdev
 		ev2 = le64_to_cpu(refsb->events);
 
 		if (ev1 > ev2)
-			return 1;
+			ret = 1;
+		else
+			ret = 0;
 	}
 	if (minor_version) 
 		rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2;
@@ -1059,7 +1061,7 @@ static int super_1_load(mdk_rdev_t *rdev
 
 	if (le32_to_cpu(sb->size) > rdev->size*2)
 		return -EINVAL;
-	return 0;
+	return ret;
 }
 
 static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-02-02  6:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-02  6:02 [PATCH 000 of 3] md: Introduction NeilBrown
2006-02-02  6:02 ` [PATCH 001 of 3] md: Handle overflow of mdu_array_info_t->size better NeilBrown
2006-02-02  6:02 ` [PATCH 002 of 3] md: Assorted little md fixes: NeilBrown
2006-02-02  6:02 ` [PATCH 003 of 3] md: Make sure rdev->size gets set for version-1 superblocks NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox