zpool_main.c (cbcb6089) | zpool_main.c (088e9d47) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 323 unchanged lines hidden (view full) --- 332 poolname = argv[0]; 333 334 argc--; 335 argv++; 336 337 if ((zhp = zpool_open(poolname)) == NULL) 338 return (1); 339 | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 323 unchanged lines hidden (view full) --- 332 poolname = argv[0]; 333 334 argc--; 335 argv++; 336 337 if ((zhp = zpool_open(poolname)) == NULL) 338 return (1); 339 |
340 if ((config = zpool_get_config(zhp)) == NULL) { | 340 if ((config = zpool_get_config(zhp, NULL)) == NULL) { |
341 (void) fprintf(stderr, gettext("pool '%s' is unavailable\n"), 342 poolname); 343 zpool_close(zhp); 344 return (1); 345 } 346 347 /* pass off to get_vdev_spec for processing */ 348 nvroot = make_root_vdev(config, force, !force, argc, argv); --- 900 unchanged lines hidden (view full) --- 1249 &oldchild, &c) != 0) 1250 return; 1251 1252 for (c = 0; c < children; c++) 1253 print_vdev_stats(vdev_get_name(newchild[c]), 1254 oldnv ? oldchild[c] : NULL, newchild[c], cb, depth + 2); 1255} 1256 | 341 (void) fprintf(stderr, gettext("pool '%s' is unavailable\n"), 342 poolname); 343 zpool_close(zhp); 344 return (1); 345 } 346 347 /* pass off to get_vdev_spec for processing */ 348 nvroot = make_root_vdev(config, force, !force, argc, argv); --- 900 unchanged lines hidden (view full) --- 1249 &oldchild, &c) != 0) 1250 return; 1251 1252 for (c = 0; c < children; c++) 1253 print_vdev_stats(vdev_get_name(newchild[c]), 1254 oldnv ? oldchild[c] : NULL, newchild[c], cb, depth + 2); 1255} 1256 |
1257static int 1258refresh_iostat(zpool_handle_t *zhp, void *data) 1259{ 1260 iostat_cbdata_t *cb = data; 1261 1262 /* 1263 * If the pool has disappeared, remove it from the list and continue. 1264 */ 1265 if (zpool_refresh_stats(zhp) != 0) 1266 pool_list_remove(cb->cb_list, zhp); 1267 1268 return (0); 1269} 1270 |
|
1257/* 1258 * Callback to print out the iostats for the given pool. 1259 */ 1260int 1261print_iostat(zpool_handle_t *zhp, void *data) 1262{ 1263 iostat_cbdata_t *cb = data; 1264 nvlist_t *oldconfig, *newconfig; 1265 nvlist_t *oldnvroot, *newnvroot; | 1271/* 1272 * Callback to print out the iostats for the given pool. 1273 */ 1274int 1275print_iostat(zpool_handle_t *zhp, void *data) 1276{ 1277 iostat_cbdata_t *cb = data; 1278 nvlist_t *oldconfig, *newconfig; 1279 nvlist_t *oldnvroot, *newnvroot; |
1266 uint64_t oldtxg, newtxg; | |
1267 | 1280 |
1268 if (zpool_refresh_stats(zhp, &oldconfig, &newconfig) != 0) { 1269 /* 1270 * This pool has disappeared, so remove it 1271 * from the list and continue. 1272 */ 1273 pool_list_remove(cb->cb_list, zhp); 1274 return (0); 1275 } | 1281 newconfig = zpool_get_config(zhp, &oldconfig); |
1276 | 1282 |
1277 if (cb->cb_iteration == 1) { 1278 if (oldconfig != NULL) 1279 nvlist_free(oldconfig); | 1283 if (cb->cb_iteration == 1) |
1280 oldconfig = NULL; | 1284 oldconfig = NULL; |
1281 } | |
1282 | 1285 |
1283 verify(nvlist_lookup_uint64(newconfig, ZPOOL_CONFIG_POOL_TXG, 1284 &newtxg) == 0); | |
1285 verify(nvlist_lookup_nvlist(newconfig, ZPOOL_CONFIG_VDEV_TREE, 1286 &newnvroot) == 0); 1287 | 1286 verify(nvlist_lookup_nvlist(newconfig, ZPOOL_CONFIG_VDEV_TREE, 1287 &newnvroot) == 0); 1288 |
1288 if (oldconfig == NULL || 1289 nvlist_lookup_uint64(oldconfig, ZPOOL_CONFIG_POOL_TXG, &oldtxg) || 1290 oldtxg != newtxg || 1291 nvlist_lookup_nvlist(oldconfig, ZPOOL_CONFIG_VDEV_TREE, &oldnvroot)) | 1289 if (oldconfig == NULL) |
1292 oldnvroot = NULL; | 1290 oldnvroot = NULL; |
1291 else 1292 verify(nvlist_lookup_nvlist(oldconfig, ZPOOL_CONFIG_VDEV_TREE, 1293 &oldnvroot) == 0); |
|
1293 1294 /* 1295 * Print out the statistics for the pool. 1296 */ 1297 print_vdev_stats(zpool_get_name(zhp), oldnvroot, newnvroot, cb, 0); 1298 1299 if (cb->cb_verbose) 1300 print_iostat_separator(cb); 1301 | 1294 1295 /* 1296 * Print out the statistics for the pool. 1297 */ 1298 print_vdev_stats(zpool_get_name(zhp), oldnvroot, newnvroot, cb, 0); 1299 1300 if (cb->cb_verbose) 1301 print_iostat_separator(cb); 1302 |
1302 if (oldconfig != NULL) 1303 nvlist_free(oldconfig); 1304 | |
1305 return (0); 1306} 1307 1308int 1309get_namewidth(zpool_handle_t *zhp, void *data) 1310{ 1311 iostat_cbdata_t *cb = data; 1312 nvlist_t *config, *nvroot; 1313 | 1303 return (0); 1304} 1305 1306int 1307get_namewidth(zpool_handle_t *zhp, void *data) 1308{ 1309 iostat_cbdata_t *cb = data; 1310 nvlist_t *config, *nvroot; 1311 |
1314 if ((config = zpool_get_config(zhp)) != NULL) { | 1312 if ((config = zpool_get_config(zhp, NULL)) != NULL) { |
1315 verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, 1316 &nvroot) == 0); 1317 if (!cb->cb_verbose) 1318 cb->cb_namewidth = strlen(zpool_get_name(zhp)); 1319 else 1320 cb->cb_namewidth = max_width(nvroot, 0, 0); 1321 } 1322 --- 129 unchanged lines hidden (view full) --- 1452 1453 for (;;) { 1454 pool_list_update(list); 1455 1456 if ((npools = pool_list_count(list)) == 0) 1457 break; 1458 1459 /* | 1313 verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, 1314 &nvroot) == 0); 1315 if (!cb->cb_verbose) 1316 cb->cb_namewidth = strlen(zpool_get_name(zhp)); 1317 else 1318 cb->cb_namewidth = max_width(nvroot, 0, 0); 1319 } 1320 --- 129 unchanged lines hidden (view full) --- 1450 1451 for (;;) { 1452 pool_list_update(list); 1453 1454 if ((npools = pool_list_count(list)) == 0) 1455 break; 1456 1457 /* |
1458 * Refresh all statistics. This is done as an explicit step 1459 * before calculating the maximum name width, so that any 1460 * configuration changes are properly accounted for. 1461 */ 1462 (void) pool_list_iter(list, FALSE, refresh_iostat, &cb); 1463 1464 /* |
|
1460 * Iterate over all pools to determine the maximum width 1461 * for the pool / device name column across all pools. 1462 */ 1463 cb.cb_namewidth = 0; 1464 (void) pool_list_iter(list, FALSE, get_namewidth, &cb); 1465 1466 /* 1467 * If it's the first time, or verbose mode, print the header. --- 76 unchanged lines hidden (view full) --- 1544 if (!cbp->cb_scripted) 1545 print_header(cbp->cb_fields, cbp->cb_fieldcount); 1546 cbp->cb_first = FALSE; 1547 } 1548 1549 if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) { 1550 config = NULL; 1551 } else { | 1465 * Iterate over all pools to determine the maximum width 1466 * for the pool / device name column across all pools. 1467 */ 1468 cb.cb_namewidth = 0; 1469 (void) pool_list_iter(list, FALSE, get_namewidth, &cb); 1470 1471 /* 1472 * If it's the first time, or verbose mode, print the header. --- 76 unchanged lines hidden (view full) --- 1549 if (!cbp->cb_scripted) 1550 print_header(cbp->cb_fields, cbp->cb_fieldcount); 1551 cbp->cb_first = FALSE; 1552 } 1553 1554 if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) { 1555 config = NULL; 1556 } else { |
1552 config = zpool_get_config(zhp); | 1557 config = zpool_get_config(zhp, NULL); |
1553 total = zpool_get_space_total(zhp); 1554 used = zpool_get_space_used(zhp); 1555 } 1556 1557 for (i = 0; i < cbp->cb_fieldcount; i++) { 1558 if (i != 0) { 1559 if (cbp->cb_scripted) 1560 (void) printf("\t"); --- 247 unchanged lines hidden (view full) --- 1808 if (argc > 1) { 1809 (void) fprintf(stderr, gettext("too many arguments\n")); 1810 usage(FALSE); 1811 } 1812 1813 if ((zhp = zpool_open(poolname)) == NULL) 1814 return (1); 1815 | 1558 total = zpool_get_space_total(zhp); 1559 used = zpool_get_space_used(zhp); 1560 } 1561 1562 for (i = 0; i < cbp->cb_fieldcount; i++) { 1563 if (i != 0) { 1564 if (cbp->cb_scripted) 1565 (void) printf("\t"); --- 247 unchanged lines hidden (view full) --- 1813 if (argc > 1) { 1814 (void) fprintf(stderr, gettext("too many arguments\n")); 1815 usage(FALSE); 1816 } 1817 1818 if ((zhp = zpool_open(poolname)) == NULL) 1819 return (1); 1820 |
1816 if ((config = zpool_get_config(zhp)) == NULL) { | 1821 if ((config = zpool_get_config(zhp, NULL)) == NULL) { |
1817 (void) fprintf(stderr, gettext("pool '%s' is unavailable\n"), 1818 poolname); 1819 zpool_close(zhp); 1820 return (1); 1821 } 1822 1823 nvroot = make_root_vdev(config, force, B_FALSE, argc, argv); 1824 if (nvroot == NULL) { --- 393 unchanged lines hidden (view full) --- 2218status_callback(zpool_handle_t *zhp, void *data) 2219{ 2220 status_cbdata_t *cbp = data; 2221 nvlist_t *config, *nvroot; 2222 char *msgid; 2223 int reason; 2224 char *health; 2225 | 1822 (void) fprintf(stderr, gettext("pool '%s' is unavailable\n"), 1823 poolname); 1824 zpool_close(zhp); 1825 return (1); 1826 } 1827 1828 nvroot = make_root_vdev(config, force, B_FALSE, argc, argv); 1829 if (nvroot == NULL) { --- 393 unchanged lines hidden (view full) --- 2223status_callback(zpool_handle_t *zhp, void *data) 2224{ 2225 status_cbdata_t *cbp = data; 2226 nvlist_t *config, *nvroot; 2227 char *msgid; 2228 int reason; 2229 char *health; 2230 |
2226 config = zpool_get_config(zhp); | 2231 config = zpool_get_config(zhp, NULL); |
2227 reason = zpool_get_status(zhp, &msgid); 2228 2229 cbp->cb_count++; 2230 2231 /* 2232 * If we were given 'zpool status -x', only report those pools with 2233 * problems. 2234 */ --- 237 unchanged lines hidden --- | 2232 reason = zpool_get_status(zhp, &msgid); 2233 2234 cbp->cb_count++; 2235 2236 /* 2237 * If we were given 'zpool status -x', only report those pools with 2238 * problems. 2239 */ --- 237 unchanged lines hidden --- |