46
46
47
47
#ifdef _KERNEL
48
48
#define ZFS_OBJ_NAME "zfs"
49
+ extern int64_t mdb_gethrtime (void );
49
50
#else
50
51
#define ZFS_OBJ_NAME "libzpool.so.1"
51
52
#endif
@@ -1712,13 +1713,13 @@ spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1712
1713
* the main summary. More detailed information can always be found by doing a
1713
1714
* '::print zio' on the underlying zio_t. The columns we display are:
1714
1715
*
1715
- * ADDRESS TYPE STAGE WAITER
1716
+ * ADDRESS TYPE STAGE WAITER TIME_ELAPSED
1716
1717
*
1717
1718
* The 'address' column is indented by one space for each depth level as we
1718
1719
* descend down the tree.
1719
1720
*/
1720
1721
1721
- #define ZIO_MAXINDENT 24
1722
+ #define ZIO_MAXINDENT 7
1722
1723
#define ZIO_MAXWIDTH (sizeof (uintptr_t) * 2 + ZIO_MAXINDENT)
1723
1724
#define ZIO_WALK_SELF 0
1724
1725
#define ZIO_WALK_CHILD 1
@@ -1736,7 +1737,6 @@ typedef struct mdb_zio {
1736
1737
enum zio_type io_type ;
1737
1738
enum zio_stage io_stage ;
1738
1739
void * io_waiter ;
1739
- uint64_t io_timestamp ;
1740
1740
void * io_spa ;
1741
1741
struct {
1742
1742
struct {
@@ -1746,15 +1746,26 @@ typedef struct mdb_zio {
1746
1746
int io_error ;
1747
1747
} mdb_zio_t ;
1748
1748
1749
+ typedef struct mdb_zio_timestamp {
1750
+ hrtime_t io_timestamp ;
1751
+ } mdb_zio_timestamp_t ;
1752
+
1749
1753
static int zio_child_cb (uintptr_t addr , const void * unknown , void * arg );
1750
1754
1751
1755
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 )
1753
1757
{
1754
1758
mdb_ctf_id_t type_enum , stage_enum ;
1755
1759
int indent = zpa -> zpa_current_depth ;
1756
1760
const char * type , * stage ;
1757
1761
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 );
1758
1769
1759
1770
if (indent > ZIO_MAXINDENT )
1760
1771
indent = ZIO_MAXINDENT ;
@@ -1765,13 +1776,13 @@ zio_print_cb(uintptr_t addr, const mdb_zio_t *zio, zio_print_args_t *zpa)
1765
1776
return (WALK_ERR );
1766
1777
}
1767
1778
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 )
1769
1780
type += sizeof ("ZIO_TYPE_" ) - 1 ;
1770
1781
else
1771
1782
type = "?" ;
1772
1783
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 );
1775
1786
if (stage != NULL )
1776
1787
stage += sizeof ("ZIO_STAGE_" ) - 1 ;
1777
1788
else
@@ -1786,10 +1797,22 @@ zio_print_cb(uintptr_t addr, const mdb_zio_t *zio, zio_print_args_t *zpa)
1786
1797
} else {
1787
1798
mdb_printf ("%*s%-*p %-5s %-16s " , indent , "" ,
1788
1799
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 );
1791
1802
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" );
1793
1816
}
1794
1817
}
1795
1818
@@ -1818,7 +1841,6 @@ static int
1818
1841
zio_child_cb (uintptr_t addr , const void * unknown , void * arg )
1819
1842
{
1820
1843
zio_link_t zl ;
1821
- mdb_zio_t zio ;
1822
1844
uintptr_t ziop ;
1823
1845
zio_print_args_t * zpa = arg ;
1824
1846
@@ -1832,17 +1854,13 @@ zio_child_cb(uintptr_t addr, const void *unknown, void *arg)
1832
1854
else
1833
1855
ziop = (uintptr_t )zl .zl_child ;
1834
1856
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 ));
1839
1858
}
1840
1859
1841
1860
/* ARGSUSED */
1842
1861
static int
1843
1862
zio_print (uintptr_t addr , uint_t flags , int argc , const mdb_arg_t * argv )
1844
1863
{
1845
- mdb_zio_t zio ;
1846
1864
zio_print_args_t zpa = { 0 };
1847
1865
1848
1866
if (!(flags & DCMD_ADDRSPEC ))
@@ -1864,14 +1882,13 @@ zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1864
1882
zpa .zpa_max_depth = 1 ;
1865
1883
}
1866
1884
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
+ }
1873
1890
1874
- if (zio_print_cb (addr , & zio , & zpa ) != WALK_NEXT )
1891
+ if (zio_print_cb (addr , & zpa ) != WALK_NEXT )
1875
1892
return (DCMD_ERR );
1876
1893
1877
1894
return (DCMD_OK );
0 commit comments