From: Guangliang Zhao <gzhao@suse.com>
To: linux-kernel@vger.kernel.org, dm-devel@redhat.com
Subject: [PATCH 2/3] dm raid1: add interface to set resync speed
Date: Thu, 22 Nov 2012 14:27:52 +0800 [thread overview]
Message-ID: <1353565673-4233-3-git-send-email-gzhao@suse.com> (raw)
In-Reply-To: <1353565673-4233-1-git-send-email-gzhao@suse.com>
Add ioctl to control resync speed, userspace tool
is dmsetup message, message format is:
dmsetup message $device 0 "set $speed"
e.g.
dmsetup message /dev/dm-2 "set 12345"
Signed-off-by: Guangliang Zhao <gzhao@suse.com>
---
drivers/md/dm-raid1.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index fb87779..1da25eb 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1361,6 +1361,49 @@ static void mirror_resume(struct dm_target *ti)
}
/*
+ * convert speed into members of ratelimit_state
+ */
+static void speed_to_rlimit(struct mirror_set *ms, struct ratelimit_state *rl,
+ unsigned int speed)
+{
+ sector_t region_size = dm_rh_get_region_size(ms->rh);
+
+ rl->interval = RESYNC_JIFFIES;
+ rl->burst = (speed * (RESYNC_JIFFIES / HZ)) << 1;
+ rl->burst = DIV_ROUND_UP(rl->burst, region_size);
+}
+
+/*
+ * Message interface
+ * set speed(KB/s)
+ */
+static int mirror_message(struct dm_target *ti, unsigned argc, char **argv)
+{
+ struct mirror_set *ms = ti->private;
+ unsigned int speed;
+ int ret = 0;
+
+ if (!strcasecmp(argv[0], "set")) {
+ if (sscanf(argv[1], "%u", &speed) != 1) {
+ DMWARN("invalid speed parameter %s", argv[1]);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ speed_to_rlimit(ms, &ms->ms_rlimit, speed);
+ goto out;
+ } else {
+ ret = -EINVAL;
+ goto error;
+ }
+
+error:
+ DMWARN("unrecognised message received.");
+out:
+ return ret;
+}
+
+/*
* device_status_char
* @m: mirror device/leg we want the status of
*
@@ -1450,6 +1493,7 @@ static struct target_type mirror_target = {
.presuspend = mirror_presuspend,
.postsuspend = mirror_postsuspend,
.resume = mirror_resume,
+ .message = mirror_message,
.status = mirror_status,
.iterate_devices = mirror_iterate_devices,
};
--
1.7.10.4
next prev parent reply other threads:[~2012-11-22 6:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-22 6:27 [PATCH 0/3] add resync speed control for dm-raid1 Guangliang Zhao
2012-11-22 6:27 ` [PATCH 1/3] dm raid1: " Guangliang Zhao
2012-11-22 6:27 ` Guangliang Zhao [this message]
2012-11-30 11:39 ` [dm-devel] [PATCH 2/3] dm raid1: add interface to set resync speed Lars Marowsky-Bree
2012-12-03 9:12 ` Guangliang Zhao
2012-11-22 6:27 ` [PATCH 3/3] dm raid1: add interface to get " Guangliang Zhao
2012-12-10 2:21 ` [dm-devel] [PATCH 0/3] add resync speed control for dm-raid1 NeilBrown
2012-12-10 12:27 ` Guangliang Zhao
2012-12-11 8:56 ` Lars Marowsky-Bree
2012-12-11 8:56 ` [dm-devel] " Lars Marowsky-Bree
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=1353565673-4233-3-git-send-email-gzhao@suse.com \
--to=gzhao@suse.com \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.