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
This commit is contained in:
commit
0c696bb38f
4 changed files with 28 additions and 66 deletions
|
@ -501,7 +501,7 @@ static void process_suspend_info(struct mddev *mddev,
|
|||
mddev->pers->quiesce(mddev, 0);
|
||||
}
|
||||
|
||||
static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
|
||||
static int process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
|
||||
{
|
||||
char disk_uuid[64];
|
||||
struct md_cluster_info *cinfo = mddev->cluster_info;
|
||||
|
@ -509,6 +509,7 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
|
|||
char raid_slot[16];
|
||||
char *envp[] = {event_name, disk_uuid, raid_slot, NULL};
|
||||
int len;
|
||||
int res = 0;
|
||||
|
||||
len = snprintf(disk_uuid, 64, "DEVICE_UUID=");
|
||||
sprintf(disk_uuid + len, "%pU", cmsg->uuid);
|
||||
|
@ -517,9 +518,14 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
|
|||
init_completion(&cinfo->newdisk_completion);
|
||||
set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
|
||||
kobject_uevent_env(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE, envp);
|
||||
wait_for_completion_timeout(&cinfo->newdisk_completion,
|
||||
NEW_DEV_TIMEOUT);
|
||||
if (!wait_for_completion_timeout(&cinfo->newdisk_completion,
|
||||
NEW_DEV_TIMEOUT)) {
|
||||
pr_err("md-cluster(%s:%d): timeout on a new disk adding\n",
|
||||
__func__, __LINE__);
|
||||
res = -1;
|
||||
}
|
||||
clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -594,7 +600,8 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
|
|||
le64_to_cpu(msg->high));
|
||||
break;
|
||||
case NEWDISK:
|
||||
process_add_new_disk(mddev, msg);
|
||||
if (process_add_new_disk(mddev, msg))
|
||||
ret = -1;
|
||||
break;
|
||||
case REMOVE:
|
||||
process_remove_disk(mddev, msg);
|
||||
|
|
|
@ -91,6 +91,18 @@ static void mddev_detach(struct mddev *mddev);
|
|||
static void export_rdev(struct md_rdev *rdev, struct mddev *mddev);
|
||||
static void md_wakeup_thread_directly(struct md_thread __rcu *thread);
|
||||
|
||||
enum md_ro_state {
|
||||
MD_RDWR,
|
||||
MD_RDONLY,
|
||||
MD_AUTO_READ,
|
||||
MD_MAX_STATE
|
||||
};
|
||||
|
||||
static bool md_is_rdwr(struct mddev *mddev)
|
||||
{
|
||||
return (mddev->ro == MD_RDWR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default number of read corrections we'll attempt on an rdev
|
||||
* before ejecting it from the array. We divide the read error
|
||||
|
@ -333,6 +345,10 @@ EXPORT_SYMBOL_GPL(md_new_event);
|
|||
static LIST_HEAD(all_mddevs);
|
||||
static DEFINE_SPINLOCK(all_mddevs_lock);
|
||||
|
||||
static bool is_md_suspended(struct mddev *mddev)
|
||||
{
|
||||
return percpu_ref_is_dying(&mddev->active_io);
|
||||
}
|
||||
/* Rather than calling directly into the personality make_request function,
|
||||
* IO requests come here first so that we can check if the device is
|
||||
* being suspended pending a reconfiguration.
|
||||
|
@ -9144,7 +9160,6 @@ void md_do_sync(struct md_thread *thread)
|
|||
spin_unlock(&mddev->lock);
|
||||
|
||||
wake_up(&resync_wait);
|
||||
wake_up(&mddev->sb_wait);
|
||||
md_wakeup_thread(mddev->thread);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -565,23 +565,6 @@ enum recovery_flags {
|
|||
MD_RESYNCING_REMOTE, /* remote node is running resync thread */
|
||||
};
|
||||
|
||||
enum md_ro_state {
|
||||
MD_RDWR,
|
||||
MD_RDONLY,
|
||||
MD_AUTO_READ,
|
||||
MD_MAX_STATE
|
||||
};
|
||||
|
||||
static inline bool md_is_rdwr(struct mddev *mddev)
|
||||
{
|
||||
return (mddev->ro == MD_RDWR);
|
||||
}
|
||||
|
||||
static inline bool is_md_suspended(struct mddev *mddev)
|
||||
{
|
||||
return percpu_ref_is_dying(&mddev->active_io);
|
||||
}
|
||||
|
||||
static inline int __must_check mddev_lock(struct mddev *mddev)
|
||||
{
|
||||
return mutex_lock_interruptible(&mddev->reconfig_mutex);
|
||||
|
@ -641,7 +624,6 @@ struct md_personality
|
|||
int (*start_reshape) (struct mddev *mddev);
|
||||
void (*finish_reshape) (struct mddev *mddev);
|
||||
void (*update_reshape_pos) (struct mddev *mddev);
|
||||
void (*prepare_suspend) (struct mddev *mddev);
|
||||
/* quiesce suspends or resumes internal processing.
|
||||
* 1 - stop new actions and wait for action io to complete
|
||||
* 0 - return to normal behaviour
|
||||
|
|
|
@ -5953,19 +5953,6 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool reshape_inprogress(struct mddev *mddev)
|
||||
{
|
||||
return test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
|
||||
test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&
|
||||
!test_bit(MD_RECOVERY_DONE, &mddev->recovery) &&
|
||||
!test_bit(MD_RECOVERY_INTR, &mddev->recovery);
|
||||
}
|
||||
|
||||
static bool reshape_disabled(struct mddev *mddev)
|
||||
{
|
||||
return is_md_suspended(mddev) || !md_is_rdwr(mddev);
|
||||
}
|
||||
|
||||
static enum stripe_result make_stripe_request(struct mddev *mddev,
|
||||
struct r5conf *conf, struct stripe_request_ctx *ctx,
|
||||
sector_t logical_sector, struct bio *bi)
|
||||
|
@ -5997,8 +5984,7 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
|
|||
if (ahead_of_reshape(mddev, logical_sector,
|
||||
conf->reshape_safe)) {
|
||||
spin_unlock_irq(&conf->device_lock);
|
||||
ret = STRIPE_SCHEDULE_AND_RETRY;
|
||||
goto out;
|
||||
return STRIPE_SCHEDULE_AND_RETRY;
|
||||
}
|
||||
}
|
||||
spin_unlock_irq(&conf->device_lock);
|
||||
|
@ -6077,15 +6063,6 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
|
|||
|
||||
out_release:
|
||||
raid5_release_stripe(sh);
|
||||
out:
|
||||
if (ret == STRIPE_SCHEDULE_AND_RETRY && !reshape_inprogress(mddev) &&
|
||||
reshape_disabled(mddev)) {
|
||||
bi->bi_status = BLK_STS_IOERR;
|
||||
ret = STRIPE_FAIL;
|
||||
pr_err("md/raid456:%s: io failed across reshape position while reshape can't make progress.\n",
|
||||
mdname(mddev));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -9027,22 +9004,6 @@ static int raid5_start(struct mddev *mddev)
|
|||
return r5l_start(conf->log);
|
||||
}
|
||||
|
||||
static void raid5_prepare_suspend(struct mddev *mddev)
|
||||
{
|
||||
struct r5conf *conf = mddev->private;
|
||||
|
||||
wait_event(mddev->sb_wait, !reshape_inprogress(mddev) ||
|
||||
percpu_ref_is_zero(&mddev->active_io));
|
||||
if (percpu_ref_is_zero(&mddev->active_io))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Reshape is not in progress, and array is suspended, io that is
|
||||
* waiting for reshpape can never be done.
|
||||
*/
|
||||
wake_up(&conf->wait_for_overlap);
|
||||
}
|
||||
|
||||
static struct md_personality raid6_personality =
|
||||
{
|
||||
.name = "raid6",
|
||||
|
@ -9063,7 +9024,6 @@ static struct md_personality raid6_personality =
|
|||
.check_reshape = raid6_check_reshape,
|
||||
.start_reshape = raid5_start_reshape,
|
||||
.finish_reshape = raid5_finish_reshape,
|
||||
.prepare_suspend = raid5_prepare_suspend,
|
||||
.quiesce = raid5_quiesce,
|
||||
.takeover = raid6_takeover,
|
||||
.change_consistency_policy = raid5_change_consistency_policy,
|
||||
|
@ -9088,7 +9048,6 @@ static struct md_personality raid5_personality =
|
|||
.check_reshape = raid5_check_reshape,
|
||||
.start_reshape = raid5_start_reshape,
|
||||
.finish_reshape = raid5_finish_reshape,
|
||||
.prepare_suspend = raid5_prepare_suspend,
|
||||
.quiesce = raid5_quiesce,
|
||||
.takeover = raid5_takeover,
|
||||
.change_consistency_policy = raid5_change_consistency_policy,
|
||||
|
@ -9114,7 +9073,6 @@ static struct md_personality raid4_personality =
|
|||
.check_reshape = raid5_check_reshape,
|
||||
.start_reshape = raid5_start_reshape,
|
||||
.finish_reshape = raid5_finish_reshape,
|
||||
.prepare_suspend = raid5_prepare_suspend,
|
||||
.quiesce = raid5_quiesce,
|
||||
.takeover = raid4_takeover,
|
||||
.change_consistency_policy = raid5_change_consistency_policy,
|
||||
|
|
Loading…
Add table
Reference in a new issue