637 return (WALK_ERR); |
637 return (WALK_ERR); |
638 } |
638 } |
639 |
639 |
640 if ((data->objset == DBUFS_UNSET || data->objset == objset) && |
640 if ((data->objset == DBUFS_UNSET || data->objset == objset) && |
641 (data->osname == NULL || (objset_name(objset, osname) == 0 && |
641 (data->osname == NULL || (objset_name(objset, osname) == 0 && |
642 strcmp(data->osname, osname) == 0)) && |
642 strcmp(data->osname, osname) == 0)) && |
643 (data->object == DBUFS_UNSET || data->object == db.db_object) && |
643 (data->object == DBUFS_UNSET || data->object == db.db_object) && |
644 (data->level == DBUFS_UNSET || data->level == level) && |
644 (data->level == DBUFS_UNSET || data->level == level) && |
645 (data->blkid == DBUFS_UNSET || data->blkid == blkid)) { |
645 (data->blkid == DBUFS_UNSET || data->blkid == blkid)) { |
646 mdb_printf("%#lr\n", addr); |
646 mdb_printf("%#lr\n", addr); |
647 } |
647 } |
1101 |
1101 |
1102 mdb_printf("%0?p ", addr); |
1102 mdb_printf("%0?p ", addr); |
1103 |
1103 |
1104 switch (vdev.vdev_state) { |
1104 switch (vdev.vdev_state) { |
1105 case VDEV_STATE_CLOSED: |
1105 case VDEV_STATE_CLOSED: |
1106 state = "CLOSED"; |
1106 state = "CLOSED"; |
1107 break; |
1107 break; |
1108 case VDEV_STATE_OFFLINE: |
1108 case VDEV_STATE_OFFLINE: |
1109 state = "OFFLINE"; |
1109 state = "OFFLINE"; |
1110 break; |
1110 break; |
1111 case VDEV_STATE_CANT_OPEN: |
1111 case VDEV_STATE_CANT_OPEN: |
1112 state = "CANT_OPEN"; |
1112 state = "CANT_OPEN"; |
1113 break; |
1113 break; |
1114 case VDEV_STATE_DEGRADED: |
1114 case VDEV_STATE_DEGRADED: |
1115 state = "DEGRADED"; |
1115 state = "DEGRADED"; |
1116 break; |
1116 break; |
1117 case VDEV_STATE_HEALTHY: |
1117 case VDEV_STATE_HEALTHY: |
1118 state = "HEALTHY"; |
1118 state = "HEALTHY"; |
1119 break; |
1119 break; |
1120 default: |
1120 default: |
1121 state = "UNKNOWN"; |
1121 state = "UNKNOWN"; |
1122 break; |
1122 break; |
1123 } |
1123 } |
1124 |
1124 |
1125 switch (vdev.vdev_stat.vs_aux) { |
1125 switch (vdev.vdev_stat.vs_aux) { |
1126 case VDEV_AUX_NONE: |
1126 case VDEV_AUX_NONE: |
1127 aux = "-"; |
1127 aux = "-"; |
1550 |
1550 |
1551 return (mdb_call_dcmd("vdev", (uintptr_t)spa.spa_root_vdev, |
1551 return (mdb_call_dcmd("vdev", (uintptr_t)spa.spa_root_vdev, |
1552 flags, 1, &v)); |
1552 flags, 1, &v)); |
1553 } |
1553 } |
1554 |
1554 |
|
1555 /* |
|
1556 * ::zio |
|
1557 * |
|
1558 * Print a summary of zio_t and all its children. This is intended to display a |
|
1559 * zio tree, and hence we only pick the most important pieces of information for |
|
1560 * the main summary. More detailed information can always be found by doing a |
|
1561 * '::print zio' on the underlying zio_t. The columns we display are: |
|
1562 * |
|
1563 * ADDRESS TYPE STAGE WAITER |
|
1564 * |
|
1565 * The 'address' column is indented by one space for each depth level as we |
|
1566 * descend down the tree. |
|
1567 */ |
|
1568 static int |
|
1569 zio_print_cb(uintptr_t addr, const void *data, void *priv) |
|
1570 { |
|
1571 const zio_t *zio = data; |
|
1572 uintptr_t depth = (uintptr_t)priv; |
|
1573 mdb_ctf_id_t type_enum, stage_enum; |
|
1574 const char *type, *stage; |
|
1575 int maxdepth; |
|
1576 |
|
1577 /* |
|
1578 * Allow enough space for a pointer and up to a 16-deep tree. |
|
1579 */ |
|
1580 maxdepth = sizeof (uintptr_t) * 2 + 16; |
|
1581 if (depth > 16) |
|
1582 depth = 16; |
|
1583 |
|
1584 if (depth == 0) |
|
1585 mdb_printf("%<u>%-*s %-5s %-22s %-?s%</u>\n", maxdepth, |
|
1586 "ADDRESS", "TYPE", "STAGE", "WAITER"); |
|
1587 |
|
1588 if (mdb_ctf_lookup_by_name("enum zio_type", &type_enum) == -1 || |
|
1589 mdb_ctf_lookup_by_name("enum zio_stage", &stage_enum) == -1) { |
|
1590 mdb_warn("failed to lookup zio enums"); |
|
1591 return (WALK_ERR); |
|
1592 } |
|
1593 |
|
1594 if ((type = mdb_ctf_enum_name(type_enum, zio->io_type)) != NULL) |
|
1595 type += sizeof ("ZIO_TYPE_") - 1; |
|
1596 else |
|
1597 type = "?"; |
|
1598 |
|
1599 if ((stage = mdb_ctf_enum_name(stage_enum, zio->io_stage)) != NULL) |
|
1600 stage += sizeof ("ZIO_STAGE_") - 1; |
|
1601 else |
|
1602 stage = "?"; |
|
1603 |
|
1604 |
|
1605 mdb_printf("%*s%-*p %-5s %-22s ", |
|
1606 depth, "", maxdepth - depth, addr, type, stage); |
|
1607 if (zio->io_waiter) |
|
1608 mdb_printf("%?p\n", zio->io_waiter); |
|
1609 else |
|
1610 mdb_printf("-\n"); |
|
1611 |
|
1612 if (mdb_pwalk("zio_child", zio_print_cb, (void *)(depth + 1), |
|
1613 addr) != 0) { |
|
1614 mdb_warn("failed to walk zio_t children at %p\n", addr); |
|
1615 return (WALK_ERR); |
|
1616 } |
|
1617 |
|
1618 return (WALK_NEXT); |
|
1619 } |
|
1620 |
|
1621 /*ARGSUSED*/ |
|
1622 static int |
|
1623 zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) |
|
1624 { |
|
1625 zio_t zio; |
|
1626 |
|
1627 if (!(flags & DCMD_ADDRSPEC)) |
|
1628 return (DCMD_USAGE); |
|
1629 |
|
1630 if (mdb_vread(&zio, sizeof (zio_t), addr) == -1) { |
|
1631 mdb_warn("failed to read zio_t at %p", addr); |
|
1632 return (DCMD_ERR); |
|
1633 } |
|
1634 |
|
1635 if (zio_print_cb(addr, &zio, NULL) != WALK_NEXT) |
|
1636 return (DCMD_ERR); |
|
1637 |
|
1638 return (DCMD_OK); |
|
1639 } |
|
1640 |
|
1641 /* |
|
1642 * [addr]::zio_state |
|
1643 * |
|
1644 * Print a summary of all zio_t structures on the system, or for a particular |
|
1645 * pool. This is equivalent to '::walk zio_root | ::zio'. |
|
1646 */ |
|
1647 /*ARGSUSED*/ |
|
1648 static int |
|
1649 zio_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) |
|
1650 { |
|
1651 /* |
|
1652 * MDB will remember the last address of the pipeline, so if we don't |
|
1653 * zero this we'll end up trying to walk zio structures for a |
|
1654 * non-existent spa_t. |
|
1655 */ |
|
1656 if (!(flags & DCMD_ADDRSPEC)) |
|
1657 addr = 0; |
|
1658 |
|
1659 return (mdb_pwalk_dcmd("zio_root", "zio", argc, argv, addr)); |
|
1660 } |
|
1661 |
1555 typedef struct txg_list_walk_data { |
1662 typedef struct txg_list_walk_data { |
1556 uintptr_t lw_head[TXG_SIZE]; |
1663 uintptr_t lw_head[TXG_SIZE]; |
1557 int lw_txgoff; |
1664 int lw_txgoff; |
1558 int lw_maxoff; |
1665 int lw_maxoff; |
1559 size_t lw_offset; |
1666 size_t lw_offset; |
1688 mdb_warn("failed to read spa_t at %p", wsp->walk_addr); |
1795 mdb_warn("failed to read spa_t at %p", wsp->walk_addr); |
1689 return (WALK_ERR); |
1796 return (WALK_ERR); |
1690 } |
1797 } |
1691 |
1798 |
1692 return (wsp->walk_callback(wsp->walk_addr, &spa, wsp->walk_cbdata)); |
1799 return (wsp->walk_callback(wsp->walk_addr, &spa, wsp->walk_cbdata)); |
|
1800 } |
|
1801 |
|
1802 /* |
|
1803 * [addr]::walk zio |
|
1804 * |
|
1805 * Walk all active zio_t structures on the system. This is simply a layered |
|
1806 * walk on top of ::walk zio_cache, with the optional ability to limit the |
|
1807 * structures to a particular pool. |
|
1808 */ |
|
1809 static int |
|
1810 zio_walk_init(mdb_walk_state_t *wsp) |
|
1811 { |
|
1812 wsp->walk_data = (void *)wsp->walk_addr; |
|
1813 |
|
1814 if (mdb_layered_walk("zio_cache", wsp) == -1) { |
|
1815 mdb_warn("failed to walk 'zio_cache'\n"); |
|
1816 return (WALK_ERR); |
|
1817 } |
|
1818 |
|
1819 return (WALK_NEXT); |
|
1820 } |
|
1821 |
|
1822 static int |
|
1823 zio_walk_step(mdb_walk_state_t *wsp) |
|
1824 { |
|
1825 zio_t zio; |
|
1826 |
|
1827 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { |
|
1828 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); |
|
1829 return (WALK_ERR); |
|
1830 } |
|
1831 |
|
1832 if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa) |
|
1833 return (WALK_NEXT); |
|
1834 |
|
1835 return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata)); |
|
1836 } |
|
1837 |
|
1838 /* |
|
1839 * ::walk zio_child |
|
1840 * |
|
1841 * Walk the children of a zio_t structure. |
|
1842 */ |
|
1843 static int |
|
1844 zio_child_walk_init(mdb_walk_state_t *wsp) |
|
1845 { |
|
1846 zio_t zio; |
|
1847 |
|
1848 if (wsp->walk_addr == 0) { |
|
1849 mdb_warn("::walk zio_child doesn't support global walks\n"); |
|
1850 return (WALK_ERR); |
|
1851 } |
|
1852 |
|
1853 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { |
|
1854 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); |
|
1855 return (WALK_ERR); |
|
1856 } |
|
1857 |
|
1858 wsp->walk_addr = (uintptr_t)zio.io_child; |
|
1859 return (WALK_NEXT); |
|
1860 } |
|
1861 |
|
1862 static int |
|
1863 zio_sibling_walk_step(mdb_walk_state_t *wsp) |
|
1864 { |
|
1865 zio_t zio; |
|
1866 int status; |
|
1867 |
|
1868 if (wsp->walk_addr == NULL) |
|
1869 return (WALK_DONE); |
|
1870 |
|
1871 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { |
|
1872 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); |
|
1873 return (WALK_ERR); |
|
1874 } |
|
1875 |
|
1876 status = wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata); |
|
1877 |
|
1878 wsp->walk_addr = (uintptr_t)zio.io_sibling_next; |
|
1879 return (status); |
|
1880 } |
|
1881 |
|
1882 /* |
|
1883 * [addr]::walk zio_root |
|
1884 * |
|
1885 * Walk only root zio_t structures, optionally for a particular spa_t. |
|
1886 */ |
|
1887 static int |
|
1888 zio_walk_root_step(mdb_walk_state_t *wsp) |
|
1889 { |
|
1890 zio_t zio; |
|
1891 |
|
1892 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { |
|
1893 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); |
|
1894 return (WALK_ERR); |
|
1895 } |
|
1896 |
|
1897 if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa) |
|
1898 return (WALK_NEXT); |
|
1899 |
|
1900 if ((uintptr_t)zio.io_root != wsp->walk_addr) |
|
1901 return (WALK_NEXT); |
|
1902 |
|
1903 return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata)); |
1693 } |
1904 } |
1694 |
1905 |
1695 /* |
1906 /* |
1696 * MDB module linkage information: |
1907 * MDB module linkage information: |
1697 * |
1908 * |
1715 { "spa_config", ":", "print spa_t configuration", spa_print_config }, |
1926 { "spa_config", ":", "print spa_t configuration", spa_print_config }, |
1716 { "spa_verify", ":", "verify spa_t consistency", spa_verify }, |
1927 { "spa_verify", ":", "verify spa_t consistency", spa_verify }, |
1717 { "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space }, |
1928 { "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space }, |
1718 { "spa_vdevs", ":", "given a spa_t, print vdev summary", spa_vdevs }, |
1929 { "spa_vdevs", ":", "given a spa_t, print vdev summary", spa_vdevs }, |
1719 { "vdev", ":[-re]", "vdev_t summary", vdev_print }, |
1930 { "vdev", ":[-re]", "vdev_t summary", vdev_print }, |
|
1931 { "zio", ":", "zio_t summary", zio_print }, |
|
1932 { "zio_state", "?", "print out all zio_t structures on system or " |
|
1933 "for a particular pool", zio_state }, |
1720 { "zio_pipeline", ":", "decode a zio pipeline", zio_pipeline }, |
1934 { "zio_pipeline", ":", "decode a zio pipeline", zio_pipeline }, |
1721 { "zfs_params", "", "print zfs tunable parameters", zfs_params }, |
1935 { "zfs_params", "", "print zfs tunable parameters", zfs_params }, |
1722 { NULL } |
1936 { NULL } |
1723 }; |
1937 }; |
1724 |
1938 |
1741 txg_list1_walk_init, txg_list_walk_step, NULL }, |
1955 txg_list1_walk_init, txg_list_walk_step, NULL }, |
1742 { "txg_list2", "given any txg_list_t *, walk all entries in txg 2", |
1956 { "txg_list2", "given any txg_list_t *, walk all entries in txg 2", |
1743 txg_list2_walk_init, txg_list_walk_step, NULL }, |
1957 txg_list2_walk_init, txg_list_walk_step, NULL }, |
1744 { "txg_list3", "given any txg_list_t *, walk all entries in txg 3", |
1958 { "txg_list3", "given any txg_list_t *, walk all entries in txg 3", |
1745 txg_list3_walk_init, txg_list_walk_step, NULL }, |
1959 txg_list3_walk_init, txg_list_walk_step, NULL }, |
|
1960 { "zio", "walk all zio structures, optionally for a particular spa_t", |
|
1961 zio_walk_init, zio_walk_step, NULL }, |
|
1962 { "zio_child", "walk children of a zio_t structure", |
|
1963 zio_child_walk_init, zio_sibling_walk_step, NULL }, |
|
1964 { "zio_root", "walk all root zio_t structures, optionally for a " |
|
1965 "particular spa_t", |
|
1966 zio_walk_init, zio_walk_root_step, NULL }, |
1746 { "spa", "walk all spa_t entries in the namespace", |
1967 { "spa", "walk all spa_t entries in the namespace", |
1747 spa_walk_init, spa_walk_step, NULL }, |
1968 spa_walk_init, spa_walk_step, NULL }, |
1748 { "metaslab", "given a spa_t *, walk all metaslab_t structures", |
1969 { "metaslab", "given a spa_t *, walk all metaslab_t structures", |
1749 metaslab_walk_init, metaslab_walk_step, NULL }, |
1970 metaslab_walk_init, metaslab_walk_step, NULL }, |
1750 { NULL } |
1971 { NULL } |