From: NeilBrown <neilb@suse.de>
To: linux-raid@vger.kernel.org
Subject: [md PATCH 12/13] md: allow suspend_lo and suspend_hi to decrease as well as increase.
Date: Wed, 12 Jan 2011 09:12:47 +1100 [thread overview]
Message-ID: <20110111221247.12732.75960.stgit@notabene.brown> (raw)
In-Reply-To: <20110111221050.12732.31647.stgit@notabene.brown>
The sysfs attributes 'suspend_lo' and 'suspend_hi' describe a region
to which read/writes are suspended so that the under lying data can be
manipulated without user-space noticing.
Currently the window they describe can only move forwards along the
device. However this is an unnecessary restriction which will cause
problems with planned developments.
So relax this restriction and allow these endpoint to move
arbitrarily.
Signed-off-by: NeilBrown <neilb@suse.de>
---
drivers/md/md.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 42b1d9e..c0cba8d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4016,19 +4016,24 @@ suspend_lo_store(mddev_t *mddev, const char *buf, size_t len)
{
char *e;
unsigned long long new = simple_strtoull(buf, &e, 10);
+ unsigned long long old = mddev->suspend_lo;
if (mddev->pers == NULL ||
mddev->pers->quiesce == NULL)
return -EINVAL;
if (buf == e || (*e && *e != '\n'))
return -EINVAL;
- if (new >= mddev->suspend_hi ||
- (new > mddev->suspend_lo && new < mddev->suspend_hi)) {
- mddev->suspend_lo = new;
+
+ mddev->suspend_lo = new;
+ if (new >= old)
+ /* Shrinking suspended region */
mddev->pers->quiesce(mddev, 2);
- return len;
- } else
- return -EINVAL;
+ else {
+ /* Expanding suspended region - need to wait */
+ mddev->pers->quiesce(mddev, 1);
+ mddev->pers->quiesce(mddev, 0);
+ }
+ return len;
}
static struct md_sysfs_entry md_suspend_lo =
__ATTR(suspend_lo, S_IRUGO|S_IWUSR, suspend_lo_show, suspend_lo_store);
@@ -4045,20 +4050,23 @@ suspend_hi_store(mddev_t *mddev, const char *buf, size_t len)
{
char *e;
unsigned long long new = simple_strtoull(buf, &e, 10);
+ unsigned long long old = mddev->suspend_hi;
if (mddev->pers == NULL ||
mddev->pers->quiesce == NULL)
return -EINVAL;
if (buf == e || (*e && *e != '\n'))
return -EINVAL;
- if ((new <= mddev->suspend_lo && mddev->suspend_lo >= mddev->suspend_hi) ||
- (new > mddev->suspend_lo && new > mddev->suspend_hi)) {
- mddev->suspend_hi = new;
+
+ if (new <= old)
+ /* Shrinking suspended region */
+ mddev->pers->quiesce(mddev, 2);
+ else {
+ /* Expanding suspended region - need to wait */
mddev->pers->quiesce(mddev, 1);
mddev->pers->quiesce(mddev, 0);
- return len;
- } else
- return -EINVAL;
+ }
+ return len;
}
static struct md_sysfs_entry md_suspend_hi =
__ATTR(suspend_hi, S_IRUGO|S_IWUSR, suspend_hi_show, suspend_hi_store);
next prev parent reply other threads:[~2011-01-11 22:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-11 22:12 [md PATCH 00/13] md patches for the current merge window NeilBrown
2011-01-11 22:12 ` [md PATCH 05/13] md/raid5: use sysfs_notify_dirent_safe to avoid NULL pointer NeilBrown
2011-01-11 22:12 ` [md PATCH 07/13] md: Be more careful about clearing flags bit in ->recovery NeilBrown
2011-01-11 22:12 ` [md PATCH 01/13] md: fix regression with re-adding devices to arrays with no metadata NeilBrown
2011-01-11 22:12 ` [md PATCH 04/13] md: Ensure no IO request to get md device before it is properly initialised NeilBrown
2011-01-11 22:12 ` [md PATCH 06/13] md: md_stop_writes requires mddev_lock NeilBrown
2011-01-11 22:12 ` [md PATCH 02/13] md: fix regression resulting in delays in clearing bits in a bitmap NeilBrown
2011-01-11 22:12 ` [md PATCH 03/13] md: Fix single printks with multiple KERN_<level>s NeilBrown
2011-01-11 22:12 ` [md PATCH 13/13] md: fix sync_completed reporting for very large drives (>2TB) NeilBrown
2011-01-11 22:12 ` NeilBrown [this message]
2011-01-11 22:12 ` [md PATCH 09/13] md-new-param-to_sync_page_io NeilBrown
2011-01-11 22:12 ` [md PATCH 11/13] md: Don't let implementation detail of curr_resync leak out through sysfs NeilBrown
2011-01-11 22:12 ` [md PATCH 10/13] md: separate meta and data devs NeilBrown
2011-01-11 22:12 ` [md PATCH 08/13] md-new-param-to-calc_dev_sboffset NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110111221247.12732.75960.stgit@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).