From 0f82a9298db4b3711863022dc0805c908db3bb98 Mon Sep 17 00:00:00 2001 From: Li Nan Date: Mon, 20 Mar 2023 16:53:08 +0800 Subject: [PATCH] echo idle Signed-off-by: Yu Kuai --- drivers/md/md.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index 546b1b81eb28..196810067f29 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4753,6 +4753,7 @@ action_show(struct mddev *mddev, char *page) return sprintf(page, "%s\n", type); } +static bool set_delay = false; static ssize_t action_store(struct mddev *mddev, const char *page, size_t len) { @@ -4775,6 +4776,11 @@ action_store(struct mddev *mddev, const char *page, size_t len) mddev_unlock(mddev); set_bit(MD_RECOVERY_INTR, &mddev->recovery); md_unregister_thread(&mddev->sync_thread); + if (set_delay) { + printk("%s unregister success! delay 10s\n", __func__); + mdelay(10000); + printk("%s delay done\n", __func__); + } mddev_lock_nointr(mddev); /* * set RECOVERY_INTR again and restore reshape @@ -8700,6 +8706,13 @@ void md_do_sync(struct md_thread *thread) struct blk_plug plug; int ret; + if (set_delay) { + printk("%s: before new wor, sleep 10s\n", __func__); + mdelay(1000); + printk("%s: delay done\n", __func__); + } + BUG_ON(!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)); + /* just incase thread restarts... */ if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) || test_bit(MD_RECOVERY_WAIT, &mddev->recovery)) @@ -8899,6 +8912,7 @@ void md_do_sync(struct md_thread *thread) skipped = 0; + BUG_ON(!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)); if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && ((mddev->curr_resync > mddev->curr_resync_completed && (mddev->curr_resync - mddev->curr_resync_completed) @@ -9067,6 +9081,7 @@ void md_do_sync(struct md_thread *thread) /* set CHANGE_PENDING here since maybe another update is needed, * so other nodes are informed. It should be harmless for normal * raid */ + BUG_ON(!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)); set_mask_bits(&mddev->sb_flags, 0, BIT(MD_SB_CHANGE_PENDING) | BIT(MD_SB_CHANGE_DEVS)); @@ -9361,6 +9376,7 @@ void md_check_recovery(struct mddev *mddev) mddev->curr_resync_completed = 0; spin_lock(&mddev->lock); set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); + printk("%s: running is set\n", __func__); spin_unlock(&mddev->lock); /* Clear some bits that don't mean anything, but * might be left set @@ -9405,6 +9421,9 @@ void md_check_recovery(struct mddev *mddev) */ md_bitmap_write_all(mddev->bitmap); } + + printk("%s: queue new sync thread\n", __func__); + BUG_ON(!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)); INIT_WORK(&mddev->del_work, md_start_sync); queue_work(md_misc_wq, &mddev->del_work); goto unlock; @@ -9463,6 +9482,7 @@ void md_reap_sync_thread(struct mddev *mddev) if (test_and_clear_bit(MD_CLUSTER_RESYNC_LOCKED, &mddev->flags)) md_cluster_ops->resync_finish(mddev); clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); + printk("%s: running is cleared!\n", __func__); clear_bit(MD_RECOVERY_DONE, &mddev->recovery); clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); @@ -9956,6 +9976,7 @@ module_param_call(start_ro, set_ro, get_ro, NULL, S_IRUSR|S_IWUSR); module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR); module_param_call(new_array, add_named_array, NULL, NULL, S_IWUSR); module_param(create_on_open, bool, S_IRUSR|S_IWUSR); +module_param(set_delay, bool, S_IRUSR|S_IWUSR); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("MD RAID framework"); -- 2.31.1