aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_proc.c
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2010-11-05 04:52:46 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-03-10 05:18:58 -0500
commit439d595379f87ec95249da21122eb085866f8ba9 (patch)
treebcf189586472ec7b64a37a3494b704bedb7c5906 /drivers/block/drbd/drbd_proc.c
parentea5442aff68c559c951373739201721185191748 (diff)
drbd: show progress bar and ETA for online-verify
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_proc.c')
-rw-r--r--drivers/block/drbd/drbd_proc.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index 0b20aa837022..0ec6f4b6a4a8 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -45,6 +45,19 @@ const struct file_operations drbd_proc_fops = {
45 .release = single_release, 45 .release = single_release,
46}; 46};
47 47
48void seq_printf_with_thousands_grouping(struct seq_file *seq, long v)
49{
50 /* v is in kB/sec. We don't expect TiByte/sec yet. */
51 if (unlikely(v >= 1000000)) {
52 /* cool: > GiByte/s */
53 seq_printf(seq, "%ld,", v / 1000000);
54 v /= 1000000;
55 seq_printf(seq, "%03ld,%03ld", v/1000, v % 1000);
56 } else if (likely(v >= 1000))
57 seq_printf(seq, "%ld,%03ld", v/1000, v % 1000);
58 else
59 seq_printf(seq, "%ld", v);
60}
48 61
49/*lge 62/*lge
50 * progress bars shamelessly adapted from driver/md/md.c 63 * progress bars shamelessly adapted from driver/md/md.c
@@ -94,6 +107,7 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq)
94 /* Rolling marks. last_mark+1 may just now be modified. last_mark+2 is 107 /* Rolling marks. last_mark+1 may just now be modified. last_mark+2 is
95 * at least (DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEP old, and has at 108 * at least (DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEP old, and has at
96 * least DRBD_SYNC_MARK_STEP time before it will be modified. */ 109 * least DRBD_SYNC_MARK_STEP time before it will be modified. */
110 /* ------------------------ ~18s average ------------------------ */
97 i = (mdev->rs_last_mark + 2) % DRBD_SYNC_MARKS; 111 i = (mdev->rs_last_mark + 2) % DRBD_SYNC_MARKS;
98 dt = (jiffies - mdev->rs_mark_time[i]) / HZ; 112 dt = (jiffies - mdev->rs_mark_time[i]) / HZ;
99 if (dt > (DRBD_SYNC_MARK_STEP * DRBD_SYNC_MARKS)) 113 if (dt > (DRBD_SYNC_MARK_STEP * DRBD_SYNC_MARKS))
@@ -107,14 +121,29 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq)
107 seq_printf(seq, "finish: %lu:%02lu:%02lu", 121 seq_printf(seq, "finish: %lu:%02lu:%02lu",
108 rt / 3600, (rt % 3600) / 60, rt % 60); 122 rt / 3600, (rt % 3600) / 60, rt % 60);
109 123
110 /* current speed average over (SYNC_MARKS * SYNC_MARK_STEP) jiffies */
111 dbdt = Bit2KB(db/dt); 124 dbdt = Bit2KB(db/dt);
112 if (dbdt > 1000) 125 seq_printf(seq, " speed: ");
113 seq_printf(seq, " speed: %ld,%03ld", 126 seq_printf_with_thousands_grouping(seq, dbdt);
114 dbdt/1000, dbdt % 1000); 127 seq_printf(seq, " (");
115 else 128 /* ------------------------- ~3s average ------------------------ */
116 seq_printf(seq, " speed: %ld", dbdt); 129 if (proc_details >= 1) {
130 /* this is what drbd_rs_should_slow_down() uses */
131 i = (mdev->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS;
132 dt = (jiffies - mdev->rs_mark_time[i]) / HZ;
133 if (dt > (DRBD_SYNC_MARK_STEP * DRBD_SYNC_MARKS))
134 stalled = 1;
135
136 if (!dt)
137 dt++;
138 db = mdev->rs_mark_left[i] - rs_left;
139 rt = (dt * (rs_left / (db/100+1)))/100; /* seconds */
140
141 dbdt = Bit2KB(db/dt);
142 seq_printf_with_thousands_grouping(seq, dbdt);
143 seq_printf(seq, " -- ");
144 }
117 145
146 /* --------------------- long term average ---------------------- */
118 /* mean speed since syncer started 147 /* mean speed since syncer started
119 * we do account for PausedSync periods */ 148 * we do account for PausedSync periods */
120 dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ; 149 dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ;
@@ -122,11 +151,8 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq)
122 dt = 1; 151 dt = 1;
123 db = mdev->rs_total - rs_left; 152 db = mdev->rs_total - rs_left;
124 dbdt = Bit2KB(db/dt); 153 dbdt = Bit2KB(db/dt);
125 if (dbdt > 1000) 154 seq_printf_with_thousands_grouping(seq, dbdt);
126 seq_printf(seq, " (%ld,%03ld)", 155 seq_printf(seq, ")");
127 dbdt/1000, dbdt % 1000);
128 else
129 seq_printf(seq, " (%ld)", dbdt);
130 156
131 if (mdev->state.conn == C_SYNC_TARGET) { 157 if (mdev->state.conn == C_SYNC_TARGET) {
132 if (mdev->c_sync_rate > 1000) 158 if (mdev->c_sync_rate > 1000)
@@ -236,7 +262,9 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
236 Bit2KB(drbd_bm_total_weight(mdev))); 262 Bit2KB(drbd_bm_total_weight(mdev)));
237 } 263 }
238 if (mdev->state.conn == C_SYNC_SOURCE || 264 if (mdev->state.conn == C_SYNC_SOURCE ||
239 mdev->state.conn == C_SYNC_TARGET) 265 mdev->state.conn == C_SYNC_TARGET ||
266 mdev->state.conn == C_VERIFY_S ||
267 mdev->state.conn == C_VERIFY_T)
240 drbd_syncer_progress(mdev, seq); 268 drbd_syncer_progress(mdev, seq);
241 269
242 if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T) { 270 if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T) {