diff options
author | NeilBrown <neilb@suse.de> | 2009-06-17 18:47:55 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-06-17 18:47:55 -0400 |
commit | 50ac168a6e0a061bf5346d53aa9e7beb94c97527 (patch) | |
tree | 4f1eff67793bd8349a1995c921a63e9512be7818 /drivers/md | |
parent | 597a711b69cfff95c4b8f6069037e7ad3fc71f56 (diff) |
md: merge reconfig and check_reshape methods.
The difference between these two methods is artificial.
Both check that a pending reshape is valid, and perform any
aspect of it that can be done immediately.
'reconfig' handles chunk size and layout.
'check_reshape' handles raid_disks.
So make them just one method.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/faulty.c | 6 | ||||
-rw-r--r-- | drivers/md/md.c | 15 | ||||
-rw-r--r-- | drivers/md/md.h | 1 | ||||
-rw-r--r-- | drivers/md/raid5.c | 17 |
4 files changed, 19 insertions, 20 deletions
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c index 6513b7b3e379..6e83b38d931d 100644 --- a/drivers/md/faulty.c +++ b/drivers/md/faulty.c | |||
@@ -255,7 +255,7 @@ static void status(struct seq_file *seq, mddev_t *mddev) | |||
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | static int reconfig(mddev_t *mddev) | 258 | static int reshape(mddev_t *mddev) |
259 | { | 259 | { |
260 | int mode = mddev->new_layout & ModeMask; | 260 | int mode = mddev->new_layout & ModeMask; |
261 | int count = mddev->new_layout >> ModeShift; | 261 | int count = mddev->new_layout >> ModeShift; |
@@ -316,7 +316,7 @@ static int run(mddev_t *mddev) | |||
316 | md_set_array_sectors(mddev, faulty_size(mddev, 0, 0)); | 316 | md_set_array_sectors(mddev, faulty_size(mddev, 0, 0)); |
317 | mddev->private = conf; | 317 | mddev->private = conf; |
318 | 318 | ||
319 | reconfig(mddev); | 319 | reshape(mddev); |
320 | 320 | ||
321 | return 0; | 321 | return 0; |
322 | } | 322 | } |
@@ -339,7 +339,7 @@ static struct mdk_personality faulty_personality = | |||
339 | .run = run, | 339 | .run = run, |
340 | .stop = stop, | 340 | .stop = stop, |
341 | .status = status, | 341 | .status = status, |
342 | .reconfig = reconfig, | 342 | .check_reshape = reshape, |
343 | .size = faulty_size, | 343 | .size = faulty_size, |
344 | }; | 344 | }; |
345 | 345 | ||
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5caa421c2367..80f039ec3ac2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2807,10 +2807,10 @@ layout_store(mddev_t *mddev, const char *buf, size_t len) | |||
2807 | 2807 | ||
2808 | if (mddev->pers) { | 2808 | if (mddev->pers) { |
2809 | int err; | 2809 | int err; |
2810 | if (mddev->pers->reconfig == NULL) | 2810 | if (mddev->pers->check_reshape == NULL) |
2811 | return -EBUSY; | 2811 | return -EBUSY; |
2812 | mddev->new_layout = n; | 2812 | mddev->new_layout = n; |
2813 | err = mddev->pers->reconfig(mddev); | 2813 | err = mddev->pers->check_reshape(mddev); |
2814 | if (err) { | 2814 | if (err) { |
2815 | mddev->new_layout = mddev->layout; | 2815 | mddev->new_layout = mddev->layout; |
2816 | return err; | 2816 | return err; |
@@ -2885,10 +2885,10 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len) | |||
2885 | 2885 | ||
2886 | if (mddev->pers) { | 2886 | if (mddev->pers) { |
2887 | int err; | 2887 | int err; |
2888 | if (mddev->pers->reconfig == NULL) | 2888 | if (mddev->pers->check_reshape == NULL) |
2889 | return -EBUSY; | 2889 | return -EBUSY; |
2890 | mddev->new_chunk_sectors = n >> 9; | 2890 | mddev->new_chunk_sectors = n >> 9; |
2891 | err = mddev->pers->reconfig(mddev); | 2891 | err = mddev->pers->check_reshape(mddev); |
2892 | if (err) { | 2892 | if (err) { |
2893 | mddev->new_chunk_sectors = mddev->chunk_sectors; | 2893 | mddev->new_chunk_sectors = mddev->chunk_sectors; |
2894 | return err; | 2894 | return err; |
@@ -5224,11 +5224,11 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) | |||
5224 | * we don't need to do anything at the md level, the | 5224 | * we don't need to do anything at the md level, the |
5225 | * personality will take care of it all. | 5225 | * personality will take care of it all. |
5226 | */ | 5226 | */ |
5227 | if (mddev->pers->reconfig == NULL) | 5227 | if (mddev->pers->check_reshape == NULL) |
5228 | return -EINVAL; | 5228 | return -EINVAL; |
5229 | else { | 5229 | else { |
5230 | mddev->new_layout = info->layout; | 5230 | mddev->new_layout = info->layout; |
5231 | rv = mddev->pers->reconfig(mddev); | 5231 | rv = mddev->pers->check_reshape(mddev); |
5232 | if (rv) | 5232 | if (rv) |
5233 | mddev->new_layout = mddev->layout; | 5233 | mddev->new_layout = mddev->layout; |
5234 | return rv; | 5234 | return rv; |
@@ -6731,7 +6731,8 @@ void md_check_recovery(mddev_t *mddev) | |||
6731 | */ | 6731 | */ |
6732 | 6732 | ||
6733 | if (mddev->reshape_position != MaxSector) { | 6733 | if (mddev->reshape_position != MaxSector) { |
6734 | if (mddev->pers->check_reshape(mddev) != 0) | 6734 | if (mddev->pers->check_reshape == NULL || |
6735 | mddev->pers->check_reshape(mddev) != 0) | ||
6735 | /* Cannot proceed */ | 6736 | /* Cannot proceed */ |
6736 | goto unlock; | 6737 | goto unlock; |
6737 | set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); | 6738 | set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); |
diff --git a/drivers/md/md.h b/drivers/md/md.h index 815013f8da6c..bac7c2bf8616 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -326,7 +326,6 @@ struct mdk_personality | |||
326 | int (*check_reshape) (mddev_t *mddev); | 326 | int (*check_reshape) (mddev_t *mddev); |
327 | int (*start_reshape) (mddev_t *mddev); | 327 | int (*start_reshape) (mddev_t *mddev); |
328 | void (*finish_reshape) (mddev_t *mddev); | 328 | void (*finish_reshape) (mddev_t *mddev); |
329 | int (*reconfig) (mddev_t *mddev); | ||
330 | /* quiesce moves between quiescence states | 329 | /* quiesce moves between quiescence states |
331 | * 0 - fully active | 330 | * 0 - fully active |
332 | * 1 - no new requests allowed | 331 | * 1 - no new requests allowed |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 136051bc6725..5ea2bdece278 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -4868,14 +4868,14 @@ static int check_stripe_cache(mddev_t *mddev) | |||
4868 | return 1; | 4868 | return 1; |
4869 | } | 4869 | } |
4870 | 4870 | ||
4871 | static int raid5_check_reshape(mddev_t *mddev) | 4871 | static int check_reshape(mddev_t *mddev) |
4872 | { | 4872 | { |
4873 | raid5_conf_t *conf = mddev->private; | 4873 | raid5_conf_t *conf = mddev->private; |
4874 | 4874 | ||
4875 | if (mddev->delta_disks == 0 && | 4875 | if (mddev->delta_disks == 0 && |
4876 | mddev->new_layout == mddev->layout && | 4876 | mddev->new_layout == mddev->layout && |
4877 | mddev->new_chunk_sectors == mddev->chunk_sectors) | 4877 | mddev->new_chunk_sectors == mddev->chunk_sectors) |
4878 | return -EINVAL; /* nothing to do */ | 4878 | return 0; /* nothing to do */ |
4879 | if (mddev->bitmap) | 4879 | if (mddev->bitmap) |
4880 | /* Cannot grow a bitmap yet */ | 4880 | /* Cannot grow a bitmap yet */ |
4881 | return -EBUSY; | 4881 | return -EBUSY; |
@@ -5165,7 +5165,7 @@ static void *raid5_takeover_raid6(mddev_t *mddev) | |||
5165 | } | 5165 | } |
5166 | 5166 | ||
5167 | 5167 | ||
5168 | static int raid5_reconfig(mddev_t *mddev) | 5168 | static int raid5_check_reshape(mddev_t *mddev) |
5169 | { | 5169 | { |
5170 | /* For a 2-drive array, the layout and chunk size can be changed | 5170 | /* For a 2-drive array, the layout and chunk size can be changed |
5171 | * immediately as not restriping is needed. | 5171 | * immediately as not restriping is needed. |
@@ -5202,12 +5202,13 @@ static int raid5_reconfig(mddev_t *mddev) | |||
5202 | set_bit(MD_CHANGE_DEVS, &mddev->flags); | 5202 | set_bit(MD_CHANGE_DEVS, &mddev->flags); |
5203 | md_wakeup_thread(mddev->thread); | 5203 | md_wakeup_thread(mddev->thread); |
5204 | } | 5204 | } |
5205 | return 0; | 5205 | return check_reshape(mddev); |
5206 | } | 5206 | } |
5207 | 5207 | ||
5208 | static int raid6_reconfig(mddev_t *mddev) | 5208 | static int raid6_check_reshape(mddev_t *mddev) |
5209 | { | 5209 | { |
5210 | int new_chunk = mddev->new_chunk_sectors; | 5210 | int new_chunk = mddev->new_chunk_sectors; |
5211 | |||
5211 | if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout)) | 5212 | if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout)) |
5212 | return -EINVAL; | 5213 | return -EINVAL; |
5213 | if (new_chunk > 0) { | 5214 | if (new_chunk > 0) { |
@@ -5221,7 +5222,7 @@ static int raid6_reconfig(mddev_t *mddev) | |||
5221 | } | 5222 | } |
5222 | 5223 | ||
5223 | /* They look valid */ | 5224 | /* They look valid */ |
5224 | return 0; | 5225 | return check_reshape(mddev); |
5225 | } | 5226 | } |
5226 | 5227 | ||
5227 | static void *raid5_takeover(mddev_t *mddev) | 5228 | static void *raid5_takeover(mddev_t *mddev) |
@@ -5312,12 +5313,11 @@ static struct mdk_personality raid6_personality = | |||
5312 | .sync_request = sync_request, | 5313 | .sync_request = sync_request, |
5313 | .resize = raid5_resize, | 5314 | .resize = raid5_resize, |
5314 | .size = raid5_size, | 5315 | .size = raid5_size, |
5315 | .check_reshape = raid5_check_reshape, | 5316 | .check_reshape = raid6_check_reshape, |
5316 | .start_reshape = raid5_start_reshape, | 5317 | .start_reshape = raid5_start_reshape, |
5317 | .finish_reshape = raid5_finish_reshape, | 5318 | .finish_reshape = raid5_finish_reshape, |
5318 | .quiesce = raid5_quiesce, | 5319 | .quiesce = raid5_quiesce, |
5319 | .takeover = raid6_takeover, | 5320 | .takeover = raid6_takeover, |
5320 | .reconfig = raid6_reconfig, | ||
5321 | }; | 5321 | }; |
5322 | static struct mdk_personality raid5_personality = | 5322 | static struct mdk_personality raid5_personality = |
5323 | { | 5323 | { |
@@ -5340,7 +5340,6 @@ static struct mdk_personality raid5_personality = | |||
5340 | .finish_reshape = raid5_finish_reshape, | 5340 | .finish_reshape = raid5_finish_reshape, |
5341 | .quiesce = raid5_quiesce, | 5341 | .quiesce = raid5_quiesce, |
5342 | .takeover = raid5_takeover, | 5342 | .takeover = raid5_takeover, |
5343 | .reconfig = raid5_reconfig, | ||
5344 | }; | 5343 | }; |
5345 | 5344 | ||
5346 | static struct mdk_personality raid4_personality = | 5345 | static struct mdk_personality raid4_personality = |