Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b03e0ccb authored by NeilBrown's avatar NeilBrown Committed by Shaohua Li
Browse files

md: remove special meaning of ->quiesce(.., 2)



The '2' argument means "wake up anything that is waiting".
This is an inelegant part of the design and was added
to help support management of suspend_lo/suspend_hi setting.
Now that suspend_lo/hi is managed in mddev_suspend/resume,
that need is gone.
These is still a couple of places where we call 'quiesce'
with an argument of '2', but they can safely be changed to
call ->quiesce(.., 1); ->quiesce(.., 0) which
achieve the same result at the small cost of pausing IO
briefly.

This removes a small "optimization" from suspend_{hi,lo}_store,
but it isn't clear that optimization served a useful purpose.
The code now is a lot clearer.

Suggested-by: default avatarShaohua Li <shli@kernel.org>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent 35bfc521
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -442,10 +442,11 @@ static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot)
static void remove_suspend_info(struct mddev *mddev, int slot)
{
	struct md_cluster_info *cinfo = mddev->cluster_info;
	mddev->pers->quiesce(mddev, 1);
	spin_lock_irq(&cinfo->suspend_lock);
	__remove_suspend_info(cinfo, slot);
	spin_unlock_irq(&cinfo->suspend_lock);
	mddev->pers->quiesce(mddev, 2);
	mddev->pers->quiesce(mddev, 0);
}


@@ -492,13 +493,12 @@ static void process_suspend_info(struct mddev *mddev,
	s->lo = lo;
	s->hi = hi;
	mddev->pers->quiesce(mddev, 1);
	mddev->pers->quiesce(mddev, 0);
	spin_lock_irq(&cinfo->suspend_lock);
	/* Remove existing entry (if exists) before adding */
	__remove_suspend_info(cinfo, slot);
	list_add(&s->list, &cinfo->suspend_list);
	spin_unlock_irq(&cinfo->suspend_lock);
	mddev->pers->quiesce(mddev, 2);
	mddev->pers->quiesce(mddev, 0);
}

static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
+10 −24
Original line number Diff line number Diff line
@@ -4846,7 +4846,7 @@ suspend_lo_show(struct mddev *mddev, char *page)
static ssize_t
suspend_lo_store(struct mddev *mddev, const char *buf, size_t len)
{
	unsigned long long old, new;
	unsigned long long new;
	int err;

	err = kstrtoull(buf, 10, &new);
@@ -4862,17 +4862,10 @@ suspend_lo_store(struct mddev *mddev, const char *buf, size_t len)
	if (mddev->pers == NULL ||
	    mddev->pers->quiesce == NULL)
		goto unlock;
	old = mddev->suspend_lo;
	mddev->suspend_lo = new;
	if (new >= old) {
		/* Shrinking suspended region */
		wake_up(&mddev->sb_wait);
		mddev->pers->quiesce(mddev, 2);
	} else {
		/* Expanding suspended region - need to wait */
	mddev_suspend(mddev);
	mddev->suspend_lo = new;
	mddev_resume(mddev);
	}

	err = 0;
unlock:
	mddev_unlock(mddev);
@@ -4890,7 +4883,7 @@ suspend_hi_show(struct mddev *mddev, char *page)
static ssize_t
suspend_hi_store(struct mddev *mddev, const char *buf, size_t len)
{
	unsigned long long old, new;
	unsigned long long new;
	int err;

	err = kstrtoull(buf, 10, &new);
@@ -4903,20 +4896,13 @@ suspend_hi_store(struct mddev *mddev, const char *buf, size_t len)
	if (err)
		return err;
	err = -EINVAL;
	if (mddev->pers == NULL ||
	    mddev->pers->quiesce == NULL)
	if (mddev->pers == NULL)
		goto unlock;
	old = mddev->suspend_hi;
	mddev->suspend_hi = new;
	if (new <= old) {
		/* Shrinking suspended region */
		wake_up(&mddev->sb_wait);
		mddev->pers->quiesce(mddev, 2);
	} else {
		/* Expanding suspended region - need to wait */

	mddev_suspend(mddev);
	mddev->suspend_hi = new;
	mddev_resume(mddev);
	}

	err = 0;
unlock:
	mddev_unlock(mddev);
+4 −5
Original line number Diff line number Diff line
@@ -544,12 +544,11 @@ struct md_personality
	int (*check_reshape) (struct mddev *mddev);
	int (*start_reshape) (struct mddev *mddev);
	void (*finish_reshape) (struct mddev *mddev);
	/* quiesce moves between quiescence states
	 * 0 - fully active
	 * 1 - no new requests allowed
	 * others - reserved
	/* quiesce suspends or resumes internal processing.
	 * 1 - stop new actions and wait for action io to complete
	 * 0 - return to normal behaviour
	 */
	void (*quiesce) (struct mddev *mddev, int state);
	void (*quiesce) (struct mddev *mddev, int quiesce);
	/* takeover is used to transition an array from one
	 * personality to another.  The new personality must be able
	 * to handle the data in the current layout.
+1 −1
Original line number Diff line number Diff line
@@ -768,7 +768,7 @@ static void *raid0_takeover(struct mddev *mddev)
	return ERR_PTR(-EINVAL);
}

static void raid0_quiesce(struct mddev *mddev, int state)
static void raid0_quiesce(struct mddev *mddev, int quiesce)
{
}

+3 −10
Original line number Diff line number Diff line
@@ -3273,21 +3273,14 @@ static int raid1_reshape(struct mddev *mddev)
	return 0;
}

static void raid1_quiesce(struct mddev *mddev, int state)
static void raid1_quiesce(struct mddev *mddev, int quiesce)
{
	struct r1conf *conf = mddev->private;

	switch(state) {
	case 2: /* wake for suspend */
		wake_up(&conf->wait_barrier);
		break;
	case 1:
	if (quiesce)
		freeze_array(conf, 0);
		break;
	case 0:
	else
		unfreeze_array(conf);
		break;
	}
}

static void *raid1_takeover(struct mddev *mddev)
Loading