Skip to content

Commit c55e05c

Browse files
ahrensChristopher Siden
authored andcommitted
3618 ::zio dcmd does not show timestamp data
Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: George Wilson <gwilson@zfsmail.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Dan McDonald <danmcd@nexenta.com>
1 parent 702941c commit c55e05c

File tree

5 files changed

+53
-35
lines changed

5 files changed

+53
-35
lines changed

usr/src/cmd/mdb/common/modules/zfs/zfs.c

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
#ifdef _KERNEL
4848
#define ZFS_OBJ_NAME "zfs"
49+
extern int64_t mdb_gethrtime(void);
4950
#else
5051
#define ZFS_OBJ_NAME "libzpool.so.1"
5152
#endif
@@ -1712,13 +1713,13 @@ spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
17121713
* the main summary. More detailed information can always be found by doing a
17131714
* '::print zio' on the underlying zio_t. The columns we display are:
17141715
*
1715-
* ADDRESS TYPE STAGE WAITER
1716+
* ADDRESS TYPE STAGE WAITER TIME_ELAPSED
17161717
*
17171718
* The 'address' column is indented by one space for each depth level as we
17181719
* descend down the tree.
17191720
*/
17201721

1721-
#define ZIO_MAXINDENT 24
1722+
#define ZIO_MAXINDENT 7
17221723
#define ZIO_MAXWIDTH (sizeof (uintptr_t) * 2 + ZIO_MAXINDENT)
17231724
#define ZIO_WALK_SELF 0
17241725
#define ZIO_WALK_CHILD 1
@@ -1736,7 +1737,6 @@ typedef struct mdb_zio {
17361737
enum zio_type io_type;
17371738
enum zio_stage io_stage;
17381739
void *io_waiter;
1739-
uint64_t io_timestamp;
17401740
void *io_spa;
17411741
struct {
17421742
struct {
@@ -1746,15 +1746,26 @@ typedef struct mdb_zio {
17461746
int io_error;
17471747
} mdb_zio_t;
17481748

1749+
typedef struct mdb_zio_timestamp {
1750+
hrtime_t io_timestamp;
1751+
} mdb_zio_timestamp_t;
1752+
17491753
static int zio_child_cb(uintptr_t addr, const void *unknown, void *arg);
17501754

17511755
static int
1752-
zio_print_cb(uintptr_t addr, const mdb_zio_t *zio, zio_print_args_t *zpa)
1756+
zio_print_cb(uintptr_t addr, zio_print_args_t *zpa)
17531757
{
17541758
mdb_ctf_id_t type_enum, stage_enum;
17551759
int indent = zpa->zpa_current_depth;
17561760
const char *type, *stage;
17571761
uintptr_t laddr;
1762+
mdb_zio_t zio;
1763+
mdb_zio_timestamp_t zio_timestamp = { 0 };
1764+
1765+
if (mdb_ctf_vread(&zio, ZFS_STRUCT "zio", "mdb_zio_t", addr, 0) == -1)
1766+
return (WALK_ERR);
1767+
(void) mdb_ctf_vread(&zio_timestamp, ZFS_STRUCT "zio",
1768+
"mdb_zio_timestamp_t", addr, MDB_CTF_VREAD_QUIET);
17581769

17591770
if (indent > ZIO_MAXINDENT)
17601771
indent = ZIO_MAXINDENT;
@@ -1765,13 +1776,13 @@ zio_print_cb(uintptr_t addr, const mdb_zio_t *zio, zio_print_args_t *zpa)
17651776
return (WALK_ERR);
17661777
}
17671778

1768-
if ((type = mdb_ctf_enum_name(type_enum, zio->io_type)) != NULL)
1779+
if ((type = mdb_ctf_enum_name(type_enum, zio.io_type)) != NULL)
17691780
type += sizeof ("ZIO_TYPE_") - 1;
17701781
else
17711782
type = "?";
17721783

1773-
if (zio->io_error == 0) {
1774-
stage = mdb_ctf_enum_name(stage_enum, zio->io_stage);
1784+
if (zio.io_error == 0) {
1785+
stage = mdb_ctf_enum_name(stage_enum, zio.io_stage);
17751786
if (stage != NULL)
17761787
stage += sizeof ("ZIO_STAGE_") - 1;
17771788
else
@@ -1786,10 +1797,22 @@ zio_print_cb(uintptr_t addr, const mdb_zio_t *zio, zio_print_args_t *zpa)
17861797
} else {
17871798
mdb_printf("%*s%-*p %-5s %-16s ", indent, "",
17881799
ZIO_MAXWIDTH - indent, addr, type, stage);
1789-
if (zio->io_waiter)
1790-
mdb_printf("%?p\n", zio->io_waiter);
1800+
if (zio.io_waiter)
1801+
mdb_printf("%-16p ", zio.io_waiter);
17911802
else
1792-
mdb_printf("-\n");
1803+
mdb_printf("%-16s ", "-");
1804+
#ifdef _KERNEL
1805+
if (zio_timestamp.io_timestamp != 0) {
1806+
mdb_printf("%llums", (mdb_gethrtime() -
1807+
zio_timestamp.io_timestamp) /
1808+
1000000);
1809+
} else {
1810+
mdb_printf("%-12s ", "-");
1811+
}
1812+
#else
1813+
mdb_printf("%-12s ", "-");
1814+
#endif
1815+
mdb_printf("\n");
17931816
}
17941817
}
17951818

@@ -1818,7 +1841,6 @@ static int
18181841
zio_child_cb(uintptr_t addr, const void *unknown, void *arg)
18191842
{
18201843
zio_link_t zl;
1821-
mdb_zio_t zio;
18221844
uintptr_t ziop;
18231845
zio_print_args_t *zpa = arg;
18241846

@@ -1832,17 +1854,13 @@ zio_child_cb(uintptr_t addr, const void *unknown, void *arg)
18321854
else
18331855
ziop = (uintptr_t)zl.zl_child;
18341856

1835-
if (mdb_ctf_vread(&zio, ZFS_STRUCT "zio", "mdb_zio_t", ziop, 0) == -1)
1836-
return (WALK_ERR);
1837-
1838-
return (zio_print_cb(ziop, &zio, arg));
1857+
return (zio_print_cb(ziop, arg));
18391858
}
18401859

18411860
/* ARGSUSED */
18421861
static int
18431862
zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
18441863
{
1845-
mdb_zio_t zio;
18461864
zio_print_args_t zpa = { 0 };
18471865

18481866
if (!(flags & DCMD_ADDRSPEC))
@@ -1864,14 +1882,13 @@ zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
18641882
zpa.zpa_max_depth = 1;
18651883
}
18661884

1867-
if (mdb_ctf_vread(&zio, ZFS_STRUCT "zio", "mdb_zio_t", addr, 0) == -1)
1868-
return (DCMD_ERR);
1869-
1870-
if (!(flags & DCMD_PIPE_OUT) && DCMD_HDRSPEC(flags))
1871-
mdb_printf("%<u>%-*s %-5s %-16s %-?s%</u>\n", ZIO_MAXWIDTH,
1872-
"ADDRESS", "TYPE", "STAGE", "WAITER");
1885+
if (!(flags & DCMD_PIPE_OUT) && DCMD_HDRSPEC(flags)) {
1886+
mdb_printf("%<u>%-*s %-5s %-16s %-16s %-12s%</u>\n",
1887+
ZIO_MAXWIDTH, "ADDRESS", "TYPE", "STAGE", "WAITER",
1888+
"TIME_ELAPSED");
1889+
}
18731890

1874-
if (zio_print_cb(addr, &zio, &zpa) != WALK_NEXT)
1891+
if (zio_print_cb(addr, &zpa) != WALK_NEXT)
18751892
return (DCMD_ERR);
18761893

18771894
return (DCMD_OK);

usr/src/uts/common/fs/zfs/sys/vdev_impl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ struct vdev_queue {
104104
avl_tree_t vq_read_tree;
105105
avl_tree_t vq_write_tree;
106106
avl_tree_t vq_pending_tree;
107-
uint64_t vq_io_complete_ts;
108-
uint64_t vq_io_delta_ts;
107+
hrtime_t vq_io_complete_ts;
109108
kmutex_t vq_lock;
110109
};
111110

usr/src/uts/common/fs/zfs/sys/zio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ struct zio {
408408

409409
uint64_t io_offset;
410410
uint64_t io_deadline;
411-
uint64_t io_timestamp;
411+
hrtime_t io_timestamp;
412412
avl_node_t io_offset_node;
413413
avl_node_t io_deadline_node;
414414
avl_tree_t *io_vdev_tree;

usr/src/uts/common/fs/zfs/vdev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,10 +3180,10 @@ vdev_deadman(vdev_t *vd)
31803180
* the spa_deadman_synctime we panic the system.
31813181
*/
31823182
fio = avl_first(&vq->vq_pending_tree);
3183-
delta = ddi_get_lbolt64() - fio->io_timestamp;
3184-
if (delta > NSEC_TO_TICK(spa_deadman_synctime(spa))) {
3185-
zfs_dbgmsg("SLOW IO: zio timestamp %llu, "
3186-
"delta %llu, last io %llu",
3183+
delta = gethrtime() - fio->io_timestamp;
3184+
if (delta > spa_deadman_synctime(spa)) {
3185+
zfs_dbgmsg("SLOW IO: zio timestamp %lluns, "
3186+
"delta %lluns, last io %lluns",
31873187
fio->io_timestamp, delta,
31883188
vq->vq_io_complete_ts);
31893189
fm_panic("I/O to pool '%s' appears to be "

usr/src/uts/common/fs/zfs/vdev_queue.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
int zfs_vdev_max_pending = 10;
4646
int zfs_vdev_min_pending = 4;
4747

48-
/* deadline = pri + ddi_get_lbolt64() >> time_shift) */
49-
int zfs_vdev_time_shift = 6;
48+
/*
49+
* The deadlines are grouped into buckets based on zfs_vdev_time_shift:
50+
* deadline = pri + gethrtime() >> time_shift)
51+
*/
52+
int zfs_vdev_time_shift = 29; /* each bucket is 0.537 seconds */
5053

5154
/* exponential I/O issue ramp-up rate */
5255
int zfs_vdev_ramp_rate = 2;
@@ -412,7 +415,7 @@ vdev_queue_io(zio_t *zio)
412415

413416
mutex_enter(&vq->vq_lock);
414417

415-
zio->io_timestamp = ddi_get_lbolt64();
418+
zio->io_timestamp = gethrtime();
416419
zio->io_deadline = (zio->io_timestamp >> zfs_vdev_time_shift) +
417420
zio->io_priority;
418421

@@ -445,8 +448,7 @@ vdev_queue_io_done(zio_t *zio)
445448

446449
vdev_queue_pending_remove(vq, zio);
447450

448-
vq->vq_io_complete_ts = ddi_get_lbolt64();
449-
vq->vq_io_delta_ts = vq->vq_io_complete_ts - zio->io_timestamp;
451+
vq->vq_io_complete_ts = gethrtime();
450452

451453
for (int i = 0; i < zfs_vdev_ramp_rate; i++) {
452454
zio_t *nio = vdev_queue_io_to_issue(vq, zfs_vdev_max_pending);

0 commit comments

Comments
 (0)