staticvoid seq_printf_with_thousands_grouping(struct seq_file *seq, long v)
{ /* v is in kB/sec. We don't expect TiByte/sec yet. */ if (unlikely(v >= 1000000)) { /* cool: > GiByte/s */
seq_printf(seq, "%ld,", v / 1000000);
v %= 1000000;
seq_printf(seq, "%03ld,%03ld", v/1000, v % 1000);
} elseif (likely(v >= 1000))
seq_printf(seq, "%ld,%03ld", v/1000, v % 1000); else
seq_printf(seq, "%ld", v);
}
staticvoid drbd_get_syncer_progress(struct drbd_device *device, union drbd_dev_state state, unsignedlong *rs_total, unsignedlong *bits_left, unsignedint *per_mil_done)
{ /* this is to break it at compile time when we change that, in case we
* want to support more than (1<<32) bits on a 32bit arch. */
typecheck(unsignedlong, device->rs_total);
*rs_total = device->rs_total;
/* note: both rs_total and rs_left are in bits, i.e. in *unitsofBM_BLOCK_SIZE.
* for the percentage, we don't care. */
if (state.conn == C_VERIFY_S || state.conn == C_VERIFY_T)
*bits_left = device->ov_left; else
*bits_left = drbd_bm_total_weight(device) - device->rs_failed; /* >> 10 to prevent overflow,
* +1 to prevent division by zero */ if (*bits_left > *rs_total) { /* D'oh. Maybe a logic bug somewhere. More likely just a race *betweenstatechangeandresetofrs_total.
*/
*bits_left = *rs_total;
*per_mil_done = *rs_total ? 0 : 1000;
} else { /* Make sure the division happens in long context. *Weallowuptoonepetabytestoragerightnow, *atagranularityof4kperbitthatis2**38bits. *Aftershiftrightandmultiplicationby1000, *thisshouldstillfiteasilyintoa32bitlong, *sowedon'tneeda64bitdivisionon32bitarch. *Note:currentlywedon'tsupportsuchlargebitmapson32bit *archanyways,butnoharmdonetobepreparedforithere.
*/ unsignedint shift = *rs_total > UINT_MAX ? 16 : 10; unsignedlong left = *bits_left >> shift; unsignedlong total = 1UL + (*rs_total >> shift); unsignedlong tmp = 1000UL - left * 1000UL/total;
*per_mil_done = tmp;
}
}
/*lge *progressbarsshamelesslyadaptedfromdriver/md/md.c *outputlookslike *[=====>..............]33.5%(23456/123456) *finish:2:20:20speed:6,345(6,456)K/sec
*/ staticvoid drbd_syncer_progress(struct drbd_device *device, struct seq_file *seq, union drbd_dev_state state)
{ unsignedlong db, dt, dbdt, rt, rs_total, rs_left; unsignedint res; int i, x, y; int stalled = 0;
x = res/50;
y = 20-x;
seq_puts(seq, "\t["); for (i = 1; i < x; i++)
seq_putc(seq, '=');
seq_putc(seq, '>'); for (i = 0; i < y; i++)
seq_putc(seq, '.');
seq_puts(seq, "] ");
if (state.conn == C_VERIFY_S || state.conn == C_VERIFY_T)
seq_puts(seq, "verified:"); else
seq_puts(seq, "sync'ed:");
seq_printf(seq, "%3u.%u%% ", res / 10, res % 10);
/* if more than a few GB, display in MB */ if (rs_total > (4UL << (30 - BM_BLOCK_SHIFT)))
seq_printf(seq, "(%lu/%lu)M",
(unsignedlong) Bit2KB(rs_left >> 10),
(unsignedlong) Bit2KB(rs_total >> 10)); else
seq_printf(seq, "(%lu/%lu)K",
(unsignedlong) Bit2KB(rs_left),
(unsignedlong) Bit2KB(rs_total));
seq_puts(seq, "\n\t");
/* see drivers/md/md.c *Wedonotwanttooverflow,sotheorderofoperandsand *the*100/100trickareimportant.Wedoa+1tobe *safeagainstdivisionbyzero.Weonlyestimateanyway. * *dt:timefrommarkuntilnow *db:blockswrittenfrommarkuntilnow *rt:remainingtime
*/ /* Rolling marks. last_mark+1 may just now be modified. last_mark+2 is *atleast(DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEPold,andhasat
* least DRBD_SYNC_MARK_STEP time before it will be modified. */ /* ------------------------ ~18s average ------------------------ */
i = (device->rs_last_mark + 2) % DRBD_SYNC_MARKS;
dt = (jiffies - device->rs_mark_time[i]) / HZ; if (dt > 180)
stalled = 1;
if (!dt)
dt++;
db = device->rs_mark_left[i] - rs_left;
rt = (dt * (rs_left / (db/100+1)))/100; /* seconds */
dbdt = Bit2KB(db/dt);
seq_puts(seq, " speed: ");
seq_printf_with_thousands_grouping(seq, dbdt);
seq_puts(seq, " ("); /* ------------------------- ~3s average ------------------------ */ if (drbd_proc_details >= 1) { /* this is what drbd_rs_should_slow_down() uses */
i = (device->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS;
dt = (jiffies - device->rs_mark_time[i]) / HZ; if (!dt)
dt++;
db = device->rs_mark_left[i] - rs_left;
dbdt = Bit2KB(db/dt);
seq_printf_with_thousands_grouping(seq, dbdt);
seq_puts(seq, " -- ");
}
/* --------------------- long term average ---------------------- */ /* mean speed since syncer started
* we do account for PausedSync periods */
dt = (jiffies - device->rs_start - device->rs_paused) / HZ; if (dt == 0)
dt = 1;
db = rs_total - rs_left;
dbdt = Bit2KB(db/dt);
seq_printf_with_thousands_grouping(seq, dbdt);
seq_putc(seq, ')');
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.