From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
To: shli@fb.com
Cc: linux-raid@vger.kernel.org,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: [PATCH v5 7/7] raid5-ppl: runtime PPL enabling or disabling
Date: Thu, 9 Mar 2017 10:00:03 +0100 [thread overview]
Message-ID: <20170309090003.13298-8-artur.paszkiewicz@intel.com> (raw)
In-Reply-To: <20170309090003.13298-1-artur.paszkiewicz@intel.com>
Allow writing to 'consistency_policy' attribute when the array is
active. Add a new function 'change_consistency_policy' to the
md_personality operations structure to handle the change in the
personality code. Values "ppl" and "resync" are accepted and
turn PPL on and off respectively.
When enabling PPL its location and size should first be set using
'ppl_sector' and 'ppl_size' attributes and a valid PPL header should be
written at this location on each member device.
Enabling or disabling PPL is performed under a suspended array. The
raid5_reset_stripe_cache function frees the stripe cache and allocates
it again in order to allocate or free the ppl_pages for the stripes in
the stripe cache.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
drivers/md/md.c | 12 +++++++++---
drivers/md/md.h | 2 ++
drivers/md/raid5-ppl.c | 4 ++++
drivers/md/raid5.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1df48f365b3c..8ef2100e2788 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4995,14 +4995,20 @@ consistency_policy_show(struct mddev *mddev, char *page)
static ssize_t
consistency_policy_store(struct mddev *mddev, const char *buf, size_t len)
{
+ int err = 0;
+
if (mddev->pers) {
- return -EBUSY;
+ if (mddev->pers->change_consistency_policy)
+ err = mddev->pers->change_consistency_policy(mddev, buf);
+ else
+ err = -EBUSY;
} else if (mddev->external && strncmp(buf, "ppl", 3) == 0) {
set_bit(MD_HAS_PPL, &mddev->flags);
- return len;
} else {
- return -EINVAL;
+ err = -EINVAL;
}
+
+ return err ? err : len;
}
static struct md_sysfs_entry md_consistency_policy =
diff --git a/drivers/md/md.h b/drivers/md/md.h
index a7b2f16452c4..e0940064c3ec 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -545,6 +545,8 @@ struct md_personality
/* congested implements bdi.congested_fn().
* Will not be called while array is 'suspended' */
int (*congested)(struct mddev *mddev, int bits);
+ /* Changes the consistency policy of an active array. */
+ int (*change_consistency_policy)(struct mddev *mddev, const char *buf);
};
struct md_sysfs_entry {
diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c
index b5fcf55edee9..ca1ef644351a 100644
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@ -1195,6 +1195,10 @@ int ppl_init_log(struct r5conf *conf)
*/
mddev->recovery_cp = MaxSector;
set_bit(MD_SB_CHANGE_CLEAN, &mddev->sb_flags);
+ } else if (mddev->pers && ppl_conf->mismatch_count > 0) {
+ /* no mismatch allowed when enabling PPL for a running array */
+ ret = -EINVAL;
+ goto err;
}
conf->log_private = ppl_conf;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8b8f172d6807..7a6a6184e2a7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8213,6 +8213,58 @@ static void *raid6_takeover(struct mddev *mddev)
return setup_conf(mddev);
}
+static void raid5_reset_stripe_cache(struct mddev *mddev)
+{
+ struct r5conf *conf = mddev->private;
+
+ mutex_lock(&conf->cache_size_mutex);
+ while (conf->max_nr_stripes &&
+ drop_one_stripe(conf))
+ ;
+ while (conf->min_nr_stripes > conf->max_nr_stripes &&
+ grow_one_stripe(conf, GFP_KERNEL))
+ ;
+ mutex_unlock(&conf->cache_size_mutex);
+}
+
+static int raid5_change_consistency_policy(struct mddev *mddev, const char *buf)
+{
+ struct r5conf *conf;
+ int err;
+
+ err = mddev_lock(mddev);
+ if (err)
+ return err;
+ conf = mddev->private;
+ if (!conf) {
+ mddev_unlock(mddev);
+ return -ENODEV;
+ }
+
+ if (strncmp(buf, "ppl", 3) == 0 && !raid5_has_ppl(conf)) {
+ mddev_suspend(mddev);
+ set_bit(MD_HAS_PPL, &mddev->flags);
+ err = log_init(conf, NULL);
+ if (!err)
+ raid5_reset_stripe_cache(mddev);
+ mddev_resume(mddev);
+ } else if (strncmp(buf, "resync", 6) == 0 && raid5_has_ppl(conf)) {
+ mddev_suspend(mddev);
+ log_exit(conf);
+ raid5_reset_stripe_cache(mddev);
+ mddev_resume(mddev);
+ } else {
+ err = -EINVAL;
+ }
+
+ if (!err)
+ md_update_sb(mddev, 1);
+
+ mddev_unlock(mddev);
+
+ return err;
+}
+
static struct md_personality raid6_personality =
{
.name = "raid6",
@@ -8258,6 +8310,7 @@ static struct md_personality raid5_personality =
.quiesce = raid5_quiesce,
.takeover = raid5_takeover,
.congested = raid5_congested,
+ .change_consistency_policy = raid5_change_consistency_policy,
};
static struct md_personality raid4_personality =
--
2.11.0
next prev parent reply other threads:[~2017-03-09 9:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 8:59 [PATCH v5 0/7] Partial Parity Log for MD RAID 5 Artur Paszkiewicz
2017-03-09 8:59 ` [PATCH v5 1/7] md: superblock changes for PPL Artur Paszkiewicz
2017-03-09 8:59 ` [PATCH v5 2/7] raid5: separate header for log functions Artur Paszkiewicz
2017-03-09 8:59 ` [PATCH v5 3/7] raid5-ppl: Partial Parity Log write logging implementation Artur Paszkiewicz
2017-03-09 23:24 ` Shaohua Li
2017-03-10 15:16 ` Artur Paszkiewicz
2017-03-10 18:15 ` Shaohua Li
2017-03-10 18:42 ` Dan Williams
2017-03-21 22:00 ` NeilBrown
2017-03-24 16:46 ` Shaohua Li
2017-03-28 14:12 ` Artur Paszkiewicz
2017-03-28 16:16 ` Shaohua Li
2017-04-16 22:58 ` Greg Thelen
2017-04-19 8:48 ` [PATCH] uapi: fix linux/raid/md_p.h userspace compilation error Artur Paszkiewicz
2017-04-19 16:59 ` Greg Thelen
2017-04-20 16:41 ` Shaohua Li
2017-03-09 9:00 ` [PATCH v5 4/7] md: add sysfs entries for PPL Artur Paszkiewicz
2017-03-09 9:00 ` [PATCH v5 5/7] raid5-ppl: load and recover the log Artur Paszkiewicz
2017-03-09 23:30 ` Shaohua Li
2017-03-10 15:23 ` Artur Paszkiewicz
2017-03-09 9:00 ` [PATCH v5 6/7] raid5-ppl: support disk hot add/remove with PPL Artur Paszkiewicz
2017-03-09 9:00 ` Artur Paszkiewicz [this message]
2017-03-09 23:32 ` [PATCH v5 0/7] Partial Parity Log for MD RAID 5 Shaohua Li
2017-03-10 15:40 ` [PATCH] raid5-ppl: two minor improvements Artur Paszkiewicz
2017-03-10 18:16 ` Shaohua Li
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=20170309090003.13298-8-artur.paszkiewicz@intel.com \
--to=artur.paszkiewicz@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=shli@fb.com \
/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).