replace nreserved with ndirty in txgs kstat

The nreserved column in the txgs kstat file always contains 0
following the write throttle restructuring of commit
e8b96c6007.

Prior to that commit, the nreserved column showed the number of bytes
temporarily reserved in the pool by a transaction group at sync time.
The new write throttle did away with temporary reservations and uses
the amount of dirty data instead.  To approximate the old output of
the txgs kstat, the number of dirty bytes per-txg was passed in as
the nreserved value to spa_txg_history_set_io().  This approach did
not work as intended, because the per-txg dirty value is decremented
as data is written out to disk, so it is zero by the time we call
spa_txg_history_set_io().  To fix this, save the number of dirty
bytes before calling spa_sync(), and pass this value in to
spa_txg_history_set_io().

Also, since the name "nreserved" is now a misnomer, the column
heading is now labeled "ndirty".

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1696
This commit is contained in:
Ned Bass 2014-02-27 16:32:36 -08:00 committed by Brian Behlendorf
parent 3d920a1567
commit 3ccab25205
3 changed files with 9 additions and 7 deletions

View File

@ -570,7 +570,7 @@ extern void spa_txg_history_add(spa_t *spa, uint64_t txg, hrtime_t birth_time);
extern int spa_txg_history_set(spa_t *spa, uint64_t txg, extern int spa_txg_history_set(spa_t *spa, uint64_t txg,
txg_state_t completed_state, hrtime_t completed_time); txg_state_t completed_state, hrtime_t completed_time);
extern int spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread, extern int spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread,
uint64_t nwritten, uint64_t reads, uint64_t writes, uint64_t nreserved); uint64_t nwritten, uint64_t reads, uint64_t writes, uint64_t ndirty);
extern void spa_tx_assign_add_nsecs(spa_t *spa, uint64_t nsecs); extern void spa_tx_assign_add_nsecs(spa_t *spa, uint64_t nsecs);
/* Pool configuration locks */ /* Pool configuration locks */

View File

@ -248,7 +248,7 @@ typedef struct spa_txg_history {
uint64_t nwritten; /* number of bytes written */ uint64_t nwritten; /* number of bytes written */
uint64_t reads; /* number of read operations */ uint64_t reads; /* number of read operations */
uint64_t writes; /* number of write operations */ uint64_t writes; /* number of write operations */
uint64_t nreserved; /* number of bytes reserved */ uint64_t ndirty; /* number of dirty bytes */
hrtime_t times[TXG_STATE_COMMITTED]; /* completion times */ hrtime_t times[TXG_STATE_COMMITTED]; /* completion times */
list_node_t sth_link; list_node_t sth_link;
} spa_txg_history_t; } spa_txg_history_t;
@ -258,7 +258,7 @@ spa_txg_history_headers(char *buf, size_t size)
{ {
size = snprintf(buf, size - 1, "%-8s %-16s %-5s %-12s %-12s %-12s " size = snprintf(buf, size - 1, "%-8s %-16s %-5s %-12s %-12s %-12s "
"%-8s %-8s %-12s %-12s %-12s %-12s\n", "txg", "birth", "state", "%-8s %-8s %-12s %-12s %-12s %-12s\n", "txg", "birth", "state",
"nreserved", "nread", "nwritten", "reads", "writes", "ndirty", "nread", "nwritten", "reads", "writes",
"otime", "qtime", "wtime", "stime"); "otime", "qtime", "wtime", "stime");
buf[size] = '\0'; buf[size] = '\0';
@ -301,7 +301,7 @@ spa_txg_history_data(char *buf, size_t size, void *data)
size = snprintf(buf, size - 1, "%-8llu %-16llu %-5c %-12llu " size = snprintf(buf, size - 1, "%-8llu %-16llu %-5c %-12llu "
"%-12llu %-12llu %-8llu %-8llu %-12llu %-12llu %-12llu %-12llu\n", "%-12llu %-12llu %-8llu %-8llu %-12llu %-12llu %-12llu %-12llu\n",
(longlong_t)sth->txg, sth->times[TXG_STATE_BIRTH], state, (longlong_t)sth->txg, sth->times[TXG_STATE_BIRTH], state,
(u_longlong_t)sth->nreserved, (u_longlong_t)sth->ndirty,
(u_longlong_t)sth->nread, (u_longlong_t)sth->nwritten, (u_longlong_t)sth->nread, (u_longlong_t)sth->nwritten,
(u_longlong_t)sth->reads, (u_longlong_t)sth->writes, (u_longlong_t)sth->reads, (u_longlong_t)sth->writes,
(u_longlong_t)open, (u_longlong_t)quiesce, (u_longlong_t)wait, (u_longlong_t)open, (u_longlong_t)quiesce, (u_longlong_t)wait,
@ -482,7 +482,7 @@ spa_txg_history_set(spa_t *spa, uint64_t txg, txg_state_t completed_state,
*/ */
int int
spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread, spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread,
uint64_t nwritten, uint64_t reads, uint64_t writes, uint64_t nreserved) uint64_t nwritten, uint64_t reads, uint64_t writes, uint64_t ndirty)
{ {
spa_stats_history_t *ssh = &spa->spa_stats.txg_history; spa_stats_history_t *ssh = &spa->spa_stats.txg_history;
spa_txg_history_t *sth; spa_txg_history_t *sth;
@ -499,7 +499,7 @@ spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread,
sth->nwritten = nwritten; sth->nwritten = nwritten;
sth->reads = reads; sth->reads = reads;
sth->writes = writes; sth->writes = writes;
sth->nreserved = nreserved; sth->ndirty = ndirty;
error = 0; error = 0;
break; break;
} }

View File

@ -500,6 +500,7 @@ txg_sync_thread(dsl_pool_t *dp)
for (;;) { for (;;) {
uint64_t timer, timeout; uint64_t timer, timeout;
uint64_t txg; uint64_t txg;
uint64_t ndirty;
timeout = zfs_txg_timeout * hz; timeout = zfs_txg_timeout * hz;
@ -557,6 +558,7 @@ txg_sync_thread(dsl_pool_t *dp)
spa_txg_history_set(spa, txg, TXG_STATE_WAIT_FOR_SYNC, spa_txg_history_set(spa, txg, TXG_STATE_WAIT_FOR_SYNC,
gethrtime()); gethrtime());
ndirty = dp->dp_dirty_pertxg[txg & TXG_MASK];
start = ddi_get_lbolt(); start = ddi_get_lbolt();
spa_sync(spa, txg); spa_sync(spa, txg);
@ -579,7 +581,7 @@ txg_sync_thread(dsl_pool_t *dp)
vs2->vs_bytes[ZIO_TYPE_WRITE]-vs1->vs_bytes[ZIO_TYPE_WRITE], vs2->vs_bytes[ZIO_TYPE_WRITE]-vs1->vs_bytes[ZIO_TYPE_WRITE],
vs2->vs_ops[ZIO_TYPE_READ]-vs1->vs_ops[ZIO_TYPE_READ], vs2->vs_ops[ZIO_TYPE_READ]-vs1->vs_ops[ZIO_TYPE_READ],
vs2->vs_ops[ZIO_TYPE_WRITE]-vs1->vs_ops[ZIO_TYPE_WRITE], vs2->vs_ops[ZIO_TYPE_WRITE]-vs1->vs_ops[ZIO_TYPE_WRITE],
dp->dp_dirty_pertxg[txg & TXG_MASK]); ndirty);
spa_txg_history_set(spa, txg, TXG_STATE_SYNCED, gethrtime()); spa_txg_history_set(spa, txg, TXG_STATE_SYNCED, gethrtime());
} }
} }