Skip to content

Commit

Permalink
[PATCH] md: Assorted little md fixes
Browse files Browse the repository at this point in the history
- 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>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Feb 3, 2006
1 parent 284ae7c commit 29fc7e3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
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);
Expand Down Expand Up @@ -1162,7 +1162,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/raid0.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static int raid0_run (mddev_t *mddev)
kfree(conf);
mddev->private = NULL;
out:
return 1;
return -ENOMEM;
}

static int raid0_stop (mddev_t *mddev)
Expand Down
2 changes: 2 additions & 0 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)

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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ static void shrink_stripes(raid5_conf_t *conf)
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;
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/md/raid6main.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ static void shrink_stripes(raid6_conf_t *conf)
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;
}

Expand Down

0 comments on commit 29fc7e3

Please sign in to comment.