Add ioctl to get resync speed, userspace tool
is dmsetup status:
        dmsetup status $device
e.g.
        dmsetup status /dev/dm-2

Signed-off-by: Guangliang Zhao <gz...@suse.com>
---
 drivers/md/dm-raid1.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 3cdad37..62acfa3 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1427,6 +1427,20 @@ static char device_status_char(struct mirror *m)
                (test_bit(DM_RAID1_READ_ERROR, &(m->error_type))) ? 'R' : 'U';
 }
 
+/*
+ * get speed from ratelimit_state
+ */
+static unsigned int rlimit_to_speed(struct mirror_set *ms,
+                                   struct ratelimit_state *rl)
+{
+       sector_t region_size = dm_rh_get_region_size(ms->rh);
+       unsigned int time, burst;
+
+       time = rl->interval / HZ;
+       burst = (rl->burst * region_size) >> 1;
+
+       return burst / time;
+}
 
 static int mirror_status(struct dm_target *ti, status_type_t type,
                         char *result, unsigned int maxlen)
@@ -1451,6 +1465,8 @@ static int mirror_status(struct dm_target *ti, 
status_type_t type,
 
                sz += log->type->status(log, type, result+sz, maxlen-sz);
 
+               DMEMIT(" %u", rlimit_to_speed(ms, &ms->ms_rlimit));
+
                break;
 
        case STATUSTYPE_TABLE:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to