Skip to content

Commit 0c696bb

Browse files
committed
Merge tag 'md-next-20231020' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.7/block
Pull MD changes from Song: "1. Handle timeout in md-cluster, by Denis Plotnikov; 2. Cleanup pers->prepare_suspend, by Yu Kuai." * tag 'md-next-20231020' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md: md: cleanup pers->prepare_suspend() md-cluster: check for timeout while a new disk adding
2 parents 4119575 + 78b7b13 commit 0c696bb

4 files changed

Lines changed: 28 additions & 66 deletions

File tree

drivers/md/md-cluster.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,15 @@ static void process_suspend_info(struct mddev *mddev,
501501
mddev->pers->quiesce(mddev, 0);
502502
}
503503

504-
static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
504+
static int process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
505505
{
506506
char disk_uuid[64];
507507
struct md_cluster_info *cinfo = mddev->cluster_info;
508508
char event_name[] = "EVENT=ADD_DEVICE";
509509
char raid_slot[16];
510510
char *envp[] = {event_name, disk_uuid, raid_slot, NULL};
511511
int len;
512+
int res = 0;
512513

513514
len = snprintf(disk_uuid, 64, "DEVICE_UUID=");
514515
sprintf(disk_uuid + len, "%pU", cmsg->uuid);
@@ -517,9 +518,14 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
517518
init_completion(&cinfo->newdisk_completion);
518519
set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
519520
kobject_uevent_env(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE, envp);
520-
wait_for_completion_timeout(&cinfo->newdisk_completion,
521-
NEW_DEV_TIMEOUT);
521+
if (!wait_for_completion_timeout(&cinfo->newdisk_completion,
522+
NEW_DEV_TIMEOUT)) {
523+
pr_err("md-cluster(%s:%d): timeout on a new disk adding\n",
524+
__func__, __LINE__);
525+
res = -1;
526+
}
522527
clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
528+
return res;
523529
}
524530

525531

@@ -594,7 +600,8 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
594600
le64_to_cpu(msg->high));
595601
break;
596602
case NEWDISK:
597-
process_add_new_disk(mddev, msg);
603+
if (process_add_new_disk(mddev, msg))
604+
ret = -1;
598605
break;
599606
case REMOVE:
600607
process_remove_disk(mddev, msg);

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)