Skip to content

Commit 4717c02

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: remove old apis to suspend the array
Now that mddev_suspend() and mddev_resume() is not used anywhere, remove them, and remove 'MD_ALLOW_SB_UPDATE' and 'MD_UPDATING_SB' as well. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231010151958.145896-19-yukuai1@huaweicloud.com
1 parent bc08041 commit 4717c02

2 files changed

Lines changed: 3 additions & 87 deletions

File tree

drivers/md/md.c

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -418,74 +418,10 @@ static void md_submit_bio(struct bio *bio)
418418
md_handle_request(mddev, bio);
419419
}
420420

421-
/* mddev_suspend makes sure no new requests are submitted
422-
* to the device, and that any requests that have been submitted
423-
* are completely handled.
424-
* Once mddev_detach() is called and completes, the module will be
425-
* completely unused.
421+
/*
422+
* Make sure no new requests are submitted to the device, and any requests that
423+
* have been submitted are completely handled.
426424
*/
427-
void mddev_suspend(struct mddev *mddev)
428-
{
429-
struct md_thread *thread = rcu_dereference_protected(mddev->thread,
430-
lockdep_is_held(&mddev->reconfig_mutex));
431-
432-
WARN_ON_ONCE(thread && current == thread->tsk);
433-
434-
/* can't concurrent with __mddev_suspend() and __mddev_resume() */
435-
mutex_lock(&mddev->suspend_mutex);
436-
if (mddev->suspended++) {
437-
mutex_unlock(&mddev->suspend_mutex);
438-
return;
439-
}
440-
441-
wake_up(&mddev->sb_wait);
442-
set_bit(MD_ALLOW_SB_UPDATE, &mddev->flags);
443-
percpu_ref_kill(&mddev->active_io);
444-
445-
/*
446-
* TODO: cleanup 'pers->prepare_suspend after all callers are replaced
447-
* by __mddev_suspend().
448-
*/
449-
if (mddev->pers && mddev->pers->prepare_suspend)
450-
mddev->pers->prepare_suspend(mddev);
451-
452-
wait_event(mddev->sb_wait, percpu_ref_is_zero(&mddev->active_io));
453-
clear_bit_unlock(MD_ALLOW_SB_UPDATE, &mddev->flags);
454-
wait_event(mddev->sb_wait, !test_bit(MD_UPDATING_SB, &mddev->flags));
455-
456-
del_timer_sync(&mddev->safemode_timer);
457-
/* restrict memory reclaim I/O during raid array is suspend */
458-
mddev->noio_flag = memalloc_noio_save();
459-
460-
mutex_unlock(&mddev->suspend_mutex);
461-
}
462-
EXPORT_SYMBOL_GPL(mddev_suspend);
463-
464-
void mddev_resume(struct mddev *mddev)
465-
{
466-
lockdep_assert_held(&mddev->reconfig_mutex);
467-
468-
/* can't concurrent with __mddev_suspend() and __mddev_resume() */
469-
mutex_lock(&mddev->suspend_mutex);
470-
if (--mddev->suspended) {
471-
mutex_unlock(&mddev->suspend_mutex);
472-
return;
473-
}
474-
475-
/* entred the memalloc scope from mddev_suspend() */
476-
memalloc_noio_restore(mddev->noio_flag);
477-
478-
percpu_ref_resurrect(&mddev->active_io);
479-
wake_up(&mddev->sb_wait);
480-
481-
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
482-
md_wakeup_thread(mddev->thread);
483-
md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
484-
485-
mutex_unlock(&mddev->suspend_mutex);
486-
}
487-
EXPORT_SYMBOL_GPL(mddev_resume);
488-
489425
int __mddev_suspend(struct mddev *mddev, bool interruptible)
490426
{
491427
int err = 0;
@@ -9503,18 +9439,6 @@ static void md_start_sync(struct work_struct *ws)
95039439
*/
95049440
void md_check_recovery(struct mddev *mddev)
95059441
{
9506-
if (test_bit(MD_ALLOW_SB_UPDATE, &mddev->flags) && mddev->sb_flags) {
9507-
/* Write superblock - thread that called mddev_suspend()
9508-
* holds reconfig_mutex for us.
9509-
*/
9510-
set_bit(MD_UPDATING_SB, &mddev->flags);
9511-
smp_mb__after_atomic();
9512-
if (test_bit(MD_ALLOW_SB_UPDATE, &mddev->flags))
9513-
md_update_sb(mddev, 0);
9514-
clear_bit_unlock(MD_UPDATING_SB, &mddev->flags);
9515-
wake_up(&mddev->sb_wait);
9516-
}
9517-
95189442
if (READ_ONCE(mddev->suspended))
95199443
return;
95209444

drivers/md/md.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,6 @@ struct md_cluster_info;
248248
* become failed.
249249
* @MD_HAS_PPL: The raid array has PPL feature set.
250250
* @MD_HAS_MULTIPLE_PPLS: The raid array has multiple PPLs feature set.
251-
* @MD_ALLOW_SB_UPDATE: md_check_recovery is allowed to update the metadata
252-
* without taking reconfig_mutex.
253-
* @MD_UPDATING_SB: md_check_recovery is updating the metadata without
254-
* explicitly holding reconfig_mutex.
255251
* @MD_NOT_READY: do_md_run() is active, so 'array_state', ust not report that
256252
* array is ready yet.
257253
* @MD_BROKEN: This is used to stop writes and mark array as failed.
@@ -268,8 +264,6 @@ enum mddev_flags {
268264
MD_FAILFAST_SUPPORTED,
269265
MD_HAS_PPL,
270266
MD_HAS_MULTIPLE_PPLS,
271-
MD_ALLOW_SB_UPDATE,
272-
MD_UPDATING_SB,
273267
MD_NOT_READY,
274268
MD_BROKEN,
275269
MD_DELETED,
@@ -810,8 +804,6 @@ extern int md_rdev_init(struct md_rdev *rdev);
810804
extern void md_rdev_clear(struct md_rdev *rdev);
811805

812806
extern void md_handle_request(struct mddev *mddev, struct bio *bio);
813-
extern void mddev_suspend(struct mddev *mddev);
814-
extern void mddev_resume(struct mddev *mddev);
815807
extern int __mddev_suspend(struct mddev *mddev, bool interruptible);
816808
extern void __mddev_resume(struct mddev *mddev);
817809

0 commit comments

Comments
 (0)