diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2018-10-18 04:37:48 -0400 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2018-10-18 12:41:25 -0400 |
commit | ea89238c0a7b346bc90552e0244e87edf3311920 (patch) | |
tree | 870f449b56b956e7d1eeff06842affb1c26d16b0 /drivers/md | |
parent | cb9ee154317b084a96a7c2b771d1688f39fc714c (diff) |
md-cluster: remove suspend_info
Previously, we allow multiple nodes can resync device, but we
had changed it to only support one node can do resync at one
time, but suspend_info is still used.
Now, let's remove the structure and use suspend_lo/hi to record
the range.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md-cluster.c | 103 |
1 files changed, 32 insertions, 71 deletions
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index f1b870766deb..8dff19d5502e 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c | |||
@@ -33,13 +33,6 @@ struct dlm_lock_resource { | |||
33 | int mode; | 33 | int mode; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | struct suspend_info { | ||
37 | int slot; | ||
38 | sector_t lo; | ||
39 | sector_t hi; | ||
40 | struct list_head list; | ||
41 | }; | ||
42 | |||
43 | struct resync_info { | 36 | struct resync_info { |
44 | __le64 lo; | 37 | __le64 lo; |
45 | __le64 hi; | 38 | __le64 hi; |
@@ -80,7 +73,13 @@ struct md_cluster_info { | |||
80 | struct dlm_lock_resource **other_bitmap_lockres; | 73 | struct dlm_lock_resource **other_bitmap_lockres; |
81 | struct dlm_lock_resource *resync_lockres; | 74 | struct dlm_lock_resource *resync_lockres; |
82 | struct list_head suspend_list; | 75 | struct list_head suspend_list; |
76 | |||
83 | spinlock_t suspend_lock; | 77 | spinlock_t suspend_lock; |
78 | /* record the region which write should be suspended */ | ||
79 | sector_t suspend_lo; | ||
80 | sector_t suspend_hi; | ||
81 | int suspend_from; /* the slot which broadcast suspend_lo/hi */ | ||
82 | |||
84 | struct md_thread *recovery_thread; | 83 | struct md_thread *recovery_thread; |
85 | unsigned long recovery_map; | 84 | unsigned long recovery_map; |
86 | /* communication loc resources */ | 85 | /* communication loc resources */ |
@@ -271,25 +270,22 @@ static void add_resync_info(struct dlm_lock_resource *lockres, | |||
271 | ri->hi = cpu_to_le64(hi); | 270 | ri->hi = cpu_to_le64(hi); |
272 | } | 271 | } |
273 | 272 | ||
274 | static struct suspend_info *read_resync_info(struct mddev *mddev, struct dlm_lock_resource *lockres) | 273 | static int read_resync_info(struct mddev *mddev, |
274 | struct dlm_lock_resource *lockres) | ||
275 | { | 275 | { |
276 | struct resync_info ri; | 276 | struct resync_info ri; |
277 | struct suspend_info *s = NULL; | 277 | struct md_cluster_info *cinfo = mddev->cluster_info; |
278 | sector_t hi = 0; | 278 | int ret = 0; |
279 | 279 | ||
280 | dlm_lock_sync(lockres, DLM_LOCK_CR); | 280 | dlm_lock_sync(lockres, DLM_LOCK_CR); |
281 | memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info)); | 281 | memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info)); |
282 | hi = le64_to_cpu(ri.hi); | 282 | if (le64_to_cpu(ri.hi) > 0) { |
283 | if (hi > 0) { | 283 | cinfo->suspend_hi = le64_to_cpu(ri.hi); |
284 | s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL); | 284 | cinfo->suspend_lo = le64_to_cpu(ri.lo); |
285 | if (!s) | 285 | ret = 1; |
286 | goto out; | ||
287 | s->hi = hi; | ||
288 | s->lo = le64_to_cpu(ri.lo); | ||
289 | } | 286 | } |
290 | dlm_unlock_sync(lockres); | 287 | dlm_unlock_sync(lockres); |
291 | out: | 288 | return ret; |
292 | return s; | ||
293 | } | 289 | } |
294 | 290 | ||
295 | static void recover_bitmaps(struct md_thread *thread) | 291 | static void recover_bitmaps(struct md_thread *thread) |
@@ -299,7 +295,6 @@ static void recover_bitmaps(struct md_thread *thread) | |||
299 | struct dlm_lock_resource *bm_lockres; | 295 | struct dlm_lock_resource *bm_lockres; |
300 | char str[64]; | 296 | char str[64]; |
301 | int slot, ret; | 297 | int slot, ret; |
302 | struct suspend_info *s, *tmp; | ||
303 | sector_t lo, hi; | 298 | sector_t lo, hi; |
304 | 299 | ||
305 | while (cinfo->recovery_map) { | 300 | while (cinfo->recovery_map) { |
@@ -326,11 +321,9 @@ static void recover_bitmaps(struct md_thread *thread) | |||
326 | 321 | ||
327 | /* Clear suspend_area associated with the bitmap */ | 322 | /* Clear suspend_area associated with the bitmap */ |
328 | spin_lock_irq(&cinfo->suspend_lock); | 323 | spin_lock_irq(&cinfo->suspend_lock); |
329 | list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list) | 324 | cinfo->suspend_hi = 0; |
330 | if (slot == s->slot) { | 325 | cinfo->suspend_lo = 0; |
331 | list_del(&s->list); | 326 | cinfo->suspend_from = -1; |
332 | kfree(s); | ||
333 | } | ||
334 | spin_unlock_irq(&cinfo->suspend_lock); | 327 | spin_unlock_irq(&cinfo->suspend_lock); |
335 | 328 | ||
336 | /* Kick off a reshape if needed */ | 329 | /* Kick off a reshape if needed */ |
@@ -441,24 +434,13 @@ static void ack_bast(void *arg, int mode) | |||
441 | } | 434 | } |
442 | } | 435 | } |
443 | 436 | ||
444 | static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot) | ||
445 | { | ||
446 | struct suspend_info *s, *tmp; | ||
447 | |||
448 | list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list) | ||
449 | if (slot == s->slot) { | ||
450 | list_del(&s->list); | ||
451 | kfree(s); | ||
452 | break; | ||
453 | } | ||
454 | } | ||
455 | |||
456 | static void remove_suspend_info(struct mddev *mddev, int slot) | 437 | static void remove_suspend_info(struct mddev *mddev, int slot) |
457 | { | 438 | { |
458 | struct md_cluster_info *cinfo = mddev->cluster_info; | 439 | struct md_cluster_info *cinfo = mddev->cluster_info; |
459 | mddev->pers->quiesce(mddev, 1); | 440 | mddev->pers->quiesce(mddev, 1); |
460 | spin_lock_irq(&cinfo->suspend_lock); | 441 | spin_lock_irq(&cinfo->suspend_lock); |
461 | __remove_suspend_info(cinfo, slot); | 442 | cinfo->suspend_hi = 0; |
443 | cinfo->suspend_lo = 0; | ||
462 | spin_unlock_irq(&cinfo->suspend_lock); | 444 | spin_unlock_irq(&cinfo->suspend_lock); |
463 | mddev->pers->quiesce(mddev, 0); | 445 | mddev->pers->quiesce(mddev, 0); |
464 | } | 446 | } |
@@ -467,7 +449,6 @@ static void process_suspend_info(struct mddev *mddev, | |||
467 | int slot, sector_t lo, sector_t hi) | 449 | int slot, sector_t lo, sector_t hi) |
468 | { | 450 | { |
469 | struct md_cluster_info *cinfo = mddev->cluster_info; | 451 | struct md_cluster_info *cinfo = mddev->cluster_info; |
470 | struct suspend_info *s; | ||
471 | struct mdp_superblock_1 *sb = NULL; | 452 | struct mdp_superblock_1 *sb = NULL; |
472 | struct md_rdev *rdev; | 453 | struct md_rdev *rdev; |
473 | 454 | ||
@@ -516,17 +497,11 @@ static void process_suspend_info(struct mddev *mddev, | |||
516 | cinfo->sync_low = lo; | 497 | cinfo->sync_low = lo; |
517 | cinfo->sync_hi = hi; | 498 | cinfo->sync_hi = hi; |
518 | 499 | ||
519 | s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL); | ||
520 | if (!s) | ||
521 | return; | ||
522 | s->slot = slot; | ||
523 | s->lo = lo; | ||
524 | s->hi = hi; | ||
525 | mddev->pers->quiesce(mddev, 1); | 500 | mddev->pers->quiesce(mddev, 1); |
526 | spin_lock_irq(&cinfo->suspend_lock); | 501 | spin_lock_irq(&cinfo->suspend_lock); |
527 | /* Remove existing entry (if exists) before adding */ | 502 | cinfo->suspend_from = slot; |
528 | __remove_suspend_info(cinfo, slot); | 503 | cinfo->suspend_lo = lo; |
529 | list_add(&s->list, &cinfo->suspend_list); | 504 | cinfo->suspend_hi = hi; |
530 | spin_unlock_irq(&cinfo->suspend_lock); | 505 | spin_unlock_irq(&cinfo->suspend_lock); |
531 | mddev->pers->quiesce(mddev, 0); | 506 | mddev->pers->quiesce(mddev, 0); |
532 | } | 507 | } |
@@ -825,7 +800,6 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots) | |||
825 | struct md_cluster_info *cinfo = mddev->cluster_info; | 800 | struct md_cluster_info *cinfo = mddev->cluster_info; |
826 | int i, ret = 0; | 801 | int i, ret = 0; |
827 | struct dlm_lock_resource *bm_lockres; | 802 | struct dlm_lock_resource *bm_lockres; |
828 | struct suspend_info *s; | ||
829 | char str[64]; | 803 | char str[64]; |
830 | sector_t lo, hi; | 804 | sector_t lo, hi; |
831 | 805 | ||
@@ -844,16 +818,13 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots) | |||
844 | bm_lockres->flags |= DLM_LKF_NOQUEUE; | 818 | bm_lockres->flags |= DLM_LKF_NOQUEUE; |
845 | ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); | 819 | ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); |
846 | if (ret == -EAGAIN) { | 820 | if (ret == -EAGAIN) { |
847 | s = read_resync_info(mddev, bm_lockres); | 821 | if (read_resync_info(mddev, bm_lockres)) { |
848 | if (s) { | ||
849 | pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n", | 822 | pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n", |
850 | __func__, __LINE__, | 823 | __func__, __LINE__, |
851 | (unsigned long long) s->lo, | 824 | (unsigned long long) cinfo->suspend_lo, |
852 | (unsigned long long) s->hi, i); | 825 | (unsigned long long) cinfo->suspend_hi, |
853 | spin_lock_irq(&cinfo->suspend_lock); | 826 | i); |
854 | s->slot = i; | 827 | cinfo->suspend_from = i; |
855 | list_add(&s->list, &cinfo->suspend_list); | ||
856 | spin_unlock_irq(&cinfo->suspend_lock); | ||
857 | } | 828 | } |
858 | ret = 0; | 829 | ret = 0; |
859 | lockres_free(bm_lockres); | 830 | lockres_free(bm_lockres); |
@@ -1352,13 +1323,10 @@ static int resync_start(struct mddev *mddev) | |||
1352 | static void resync_info_get(struct mddev *mddev, sector_t *lo, sector_t *hi) | 1323 | static void resync_info_get(struct mddev *mddev, sector_t *lo, sector_t *hi) |
1353 | { | 1324 | { |
1354 | struct md_cluster_info *cinfo = mddev->cluster_info; | 1325 | struct md_cluster_info *cinfo = mddev->cluster_info; |
1355 | struct suspend_info *s; | ||
1356 | 1326 | ||
1357 | spin_lock_irq(&cinfo->suspend_lock); | 1327 | spin_lock_irq(&cinfo->suspend_lock); |
1358 | list_for_each_entry(s, &cinfo->suspend_list, list) { | 1328 | *lo = cinfo->suspend_lo; |
1359 | *lo = s->lo; | 1329 | *hi = cinfo->suspend_hi; |
1360 | *hi = s->hi; | ||
1361 | } | ||
1362 | spin_unlock_irq(&cinfo->suspend_lock); | 1330 | spin_unlock_irq(&cinfo->suspend_lock); |
1363 | } | 1331 | } |
1364 | 1332 | ||
@@ -1414,21 +1382,14 @@ static int area_resyncing(struct mddev *mddev, int direction, | |||
1414 | { | 1382 | { |
1415 | struct md_cluster_info *cinfo = mddev->cluster_info; | 1383 | struct md_cluster_info *cinfo = mddev->cluster_info; |
1416 | int ret = 0; | 1384 | int ret = 0; |
1417 | struct suspend_info *s; | ||
1418 | 1385 | ||
1419 | if ((direction == READ) && | 1386 | if ((direction == READ) && |
1420 | test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state)) | 1387 | test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state)) |
1421 | return 1; | 1388 | return 1; |
1422 | 1389 | ||
1423 | spin_lock_irq(&cinfo->suspend_lock); | 1390 | spin_lock_irq(&cinfo->suspend_lock); |
1424 | if (list_empty(&cinfo->suspend_list)) | 1391 | if (hi > cinfo->suspend_lo && lo < cinfo->suspend_hi) |
1425 | goto out; | 1392 | ret = 1; |
1426 | list_for_each_entry(s, &cinfo->suspend_list, list) | ||
1427 | if (hi > s->lo && lo < s->hi) { | ||
1428 | ret = 1; | ||
1429 | break; | ||
1430 | } | ||
1431 | out: | ||
1432 | spin_unlock_irq(&cinfo->suspend_lock); | 1393 | spin_unlock_irq(&cinfo->suspend_lock); |
1433 | return ret; | 1394 | return ret; |
1434 | } | 1395 | } |