Skip to content

Commit 78b7b13

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: cleanup pers->prepare_suspend()
pers->prepare_suspend() is not used anymore and can be removed. Reverts following three commit: - commit 431e612 ("md: export md_is_rdwr() and is_md_suspended()") - commit 3e00777 ("md: add a new api prepare_suspend() in md_personality") - commit 868bba5 ("md/raid5: fix a deadlock in the case that reshape is interrupted") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231016100240.540474-1-yukuai1@huaweicloud.com
1 parent 1bbe254 commit 78b7b13

3 files changed

Lines changed: 17 additions & 62 deletions

File tree

drivers/md/md.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ static void mddev_detach(struct mddev *mddev);
9191
static void export_rdev(struct md_rdev *rdev, struct mddev *mddev);
9292
static void md_wakeup_thread_directly(struct md_thread __rcu *thread);
9393

94+
enum md_ro_state {
95+
MD_RDWR,
96+
MD_RDONLY,
97+
MD_AUTO_READ,
98+
MD_MAX_STATE
99+
};
100+
101+
static bool md_is_rdwr(struct mddev *mddev)
102+
{
103+
return (mddev->ro == MD_RDWR);
104+
}
105+
94106
/*
95107
* Default number of read corrections we'll attempt on an rdev
96108
* before ejecting it from the array. We divide the read error
@@ -333,6 +345,10 @@ EXPORT_SYMBOL_GPL(md_new_event);
333345
static LIST_HEAD(all_mddevs);
334346
static DEFINE_SPINLOCK(all_mddevs_lock);
335347

348+
static bool is_md_suspended(struct mddev *mddev)
349+
{
350+
return percpu_ref_is_dying(&mddev->active_io);
351+
}
336352
/* Rather than calling directly into the personality make_request function,
337353
* IO requests come here first so that we can check if the device is
338354
* being suspended pending a reconfiguration.
@@ -9144,7 +9160,6 @@ void md_do_sync(struct md_thread *thread)
91449160
spin_unlock(&mddev->lock);
91459161

91469162
wake_up(&resync_wait);
9147-
wake_up(&mddev->sb_wait);
91489163
md_wakeup_thread(mddev->thread);
91499164
return;
91509165
}

drivers/md/md.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -565,23 +565,6 @@ enum recovery_flags {
565565
MD_RESYNCING_REMOTE, /* remote node is running resync thread */
566566
};
567567

568-
enum md_ro_state {
569-
MD_RDWR,
570-
MD_RDONLY,
571-
MD_AUTO_READ,
572-
MD_MAX_STATE
573-
};
574-
575-
static inline bool md_is_rdwr(struct mddev *mddev)
576-
{
577-
return (mddev->ro == MD_RDWR);
578-
}
579-
580-
static inline bool is_md_suspended(struct mddev *mddev)
581-
{
582-
return percpu_ref_is_dying(&mddev->active_io);
583-
}
584-
585568
static inline int __must_check mddev_lock(struct mddev *mddev)
586569
{
587570
return mutex_lock_interruptible(&mddev->reconfig_mutex);
@@ -641,7 +624,6 @@ struct md_personality
641624
int (*start_reshape) (struct mddev *mddev);
642625
void (*finish_reshape) (struct mddev *mddev);
643626
void (*update_reshape_pos) (struct mddev *mddev);
644-
void (*prepare_suspend) (struct mddev *mddev);
645627
/* quiesce suspends or resumes internal processing.
646628
* 1 - stop new actions and wait for action io to complete
647629
* 0 - return to normal behaviour

drivers/md/raid5.c

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5953,19 +5953,6 @@ static int add_all_stripe_bios(struct r5conf *conf,
59535953
return ret;
59545954
}
59555955

5956-
static bool reshape_inprogress(struct mddev *mddev)
5957-
{
5958-
return test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
5959-
test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&
5960-
!test_bit(MD_RECOVERY_DONE, &mddev->recovery) &&
5961-
!test_bit(MD_RECOVERY_INTR, &mddev->recovery);
5962-
}
5963-
5964-
static bool reshape_disabled(struct mddev *mddev)
5965-
{
5966-
return is_md_suspended(mddev) || !md_is_rdwr(mddev);
5967-
}
5968-
59695956
static enum stripe_result make_stripe_request(struct mddev *mddev,
59705957
struct r5conf *conf, struct stripe_request_ctx *ctx,
59715958
sector_t logical_sector, struct bio *bi)
@@ -5997,8 +5984,7 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
59975984
if (ahead_of_reshape(mddev, logical_sector,
59985985
conf->reshape_safe)) {
59995986
spin_unlock_irq(&conf->device_lock);
6000-
ret = STRIPE_SCHEDULE_AND_RETRY;
6001-
goto out;
5987+
return STRIPE_SCHEDULE_AND_RETRY;
60025988
}
60035989
}
60045990
spin_unlock_irq(&conf->device_lock);
@@ -6077,15 +6063,6 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
60776063

60786064
out_release:
60796065
raid5_release_stripe(sh);
6080-
out:
6081-
if (ret == STRIPE_SCHEDULE_AND_RETRY && !reshape_inprogress(mddev) &&
6082-
reshape_disabled(mddev)) {
6083-
bi->bi_status = BLK_STS_IOERR;
6084-
ret = STRIPE_FAIL;
6085-
pr_err("md/raid456:%s: io failed across reshape position while reshape can't make progress.\n",
6086-
mdname(mddev));
6087-
}
6088-
60896066
return ret;
60906067
}
60916068

@@ -9027,22 +9004,6 @@ static int raid5_start(struct mddev *mddev)
90279004
return r5l_start(conf->log);
90289005
}
90299006

9030-
static void raid5_prepare_suspend(struct mddev *mddev)
9031-
{
9032-
struct r5conf *conf = mddev->private;
9033-
9034-
wait_event(mddev->sb_wait, !reshape_inprogress(mddev) ||
9035-
percpu_ref_is_zero(&mddev->active_io));
9036-
if (percpu_ref_is_zero(&mddev->active_io))
9037-
return;
9038-
9039-
/*
9040-
* Reshape is not in progress, and array is suspended, io that is
9041-
* waiting for reshpape can never be done.
9042-
*/
9043-
wake_up(&conf->wait_for_overlap);
9044-
}
9045-
90469007
static struct md_personality raid6_personality =
90479008
{
90489009
.name = "raid6",
@@ -9063,7 +9024,6 @@ static struct md_personality raid6_personality =
90639024
.check_reshape = raid6_check_reshape,
90649025
.start_reshape = raid5_start_reshape,
90659026
.finish_reshape = raid5_finish_reshape,
9066-
.prepare_suspend = raid5_prepare_suspend,
90679027
.quiesce = raid5_quiesce,
90689028
.takeover = raid6_takeover,
90699029
.change_consistency_policy = raid5_change_consistency_policy,
@@ -9088,7 +9048,6 @@ static struct md_personality raid5_personality =
90889048
.check_reshape = raid5_check_reshape,
90899049
.start_reshape = raid5_start_reshape,
90909050
.finish_reshape = raid5_finish_reshape,
9091-
.prepare_suspend = raid5_prepare_suspend,
90929051
.quiesce = raid5_quiesce,
90939052
.takeover = raid5_takeover,
90949053
.change_consistency_policy = raid5_change_consistency_policy,
@@ -9114,7 +9073,6 @@ static struct md_personality raid4_personality =
91149073
.check_reshape = raid5_check_reshape,
91159074
.start_reshape = raid5_start_reshape,
91169075
.finish_reshape = raid5_finish_reshape,
9117-
.prepare_suspend = raid5_prepare_suspend,
91189076
.quiesce = raid5_quiesce,
91199077
.takeover = raid4_takeover,
91209078
.change_consistency_policy = raid5_change_consistency_policy,

0 commit comments

Comments
 (0)