Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vdev prop allocating #3

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cmd/zhack/zhack.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,36 @@ zhack_do_feature(int argc, char **argv)
return (0);
}

static int
zhack_do_zap(int argc, char **argv)
{
spa_t *spa;
uint64_t obj;
char *target;

argc--;
argv++;

if (argc < 1) {
(void) fprintf(stderr, "error: missing pool name\n");
usage();
}
if (argc < 2) {
(void) fprintf(stderr, "error: missing object id\n");
usage();
}
target = argv[0];
obj = strtoull(argv[1], NULL, 0);

zhack_spa_open(target, B_TRUE, FTAG, &spa);

dump_obj(spa->spa_meta_objset, obj, argv[1]);

spa_close(spa, FTAG);

return (0);
}

#define MAX_NUM_PATHS 1024

int
Expand Down Expand Up @@ -516,6 +546,8 @@ main(int argc, char **argv)

if (strcmp(subcommand, "feature") == 0) {
rv = zhack_do_feature(argc, argv);
} else if (strcmp(subcommand, "zap") == 0) {
rv = zhack_do_zap(argc, argv);
} else {
(void) fprintf(stderr, "error: unknown subcommand: %s\n",
subcommand);
Expand Down
22 changes: 13 additions & 9 deletions cmd/zpool/zpool_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct zpool_list {
uu_avl_t *zl_avl;
uu_avl_pool_t *zl_pool;
zprop_list_t **zl_proplist;
zfs_type_t zl_type;
};

/* ARGSUSED */
Expand Down Expand Up @@ -90,8 +91,7 @@ add_pool(zpool_handle_t *zhp, void *data)
if (uu_avl_find(zlp->zl_avl, node, NULL, &idx) == NULL) {
if (zlp->zl_proplist &&
zpool_expand_proplist(zhp, zlp->zl_proplist,
zlp->zl_literal)
!= 0) {
zlp->zl_type, zlp->zl_literal) != 0) {
zpool_close(zhp);
free(node);
return (-1);
Expand All @@ -113,7 +113,7 @@ add_pool(zpool_handle_t *zhp, void *data)
* line.
*/
zpool_list_t *
pool_list_get(int argc, char **argv, zprop_list_t **proplist,
pool_list_get(int argc, char **argv, zprop_list_t **proplist, zfs_type_t type,
boolean_t literal, int *err)
{
zpool_list_t *zlp;
Expand All @@ -131,6 +131,7 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist,
zpool_no_memory();

zlp->zl_proplist = proplist;
zlp->zl_type = type;

zlp->zl_literal = literal;

Expand Down Expand Up @@ -248,12 +249,14 @@ pool_list_count(zpool_list_t *zlp)
*/
int
for_each_pool(int argc, char **argv, boolean_t unavail,
zprop_list_t **proplist, boolean_t literal, zpool_iter_f func, void *data)
zprop_list_t **proplist, zfs_type_t type, boolean_t literal,
zpool_iter_f func, void *data)
{
zpool_list_t *list;
int ret = 0;

if ((list = pool_list_get(argc, argv, proplist, literal, &ret)) == NULL)
if ((list = pool_list_get(argc, argv, proplist, type, literal,
&ret)) == NULL)
return (1);

if (pool_list_iter(list, unavail, func, data) != 0)
Expand Down Expand Up @@ -301,8 +304,9 @@ for_each_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, pool_vdev_iter_f func,
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0)
return (ret);

/* Don't run our function on root vdevs */
if (strcmp(type, VDEV_TYPE_ROOT) != 0) {
/* Don't run our function on root or indirect vdevs */
if ((strcmp(type, VDEV_TYPE_ROOT) != 0) &&
(strcmp(type, VDEV_TYPE_INDIRECT) != 0)) {
ret |= func(zhp, nv, data);
}

Expand Down Expand Up @@ -717,8 +721,8 @@ all_pools_for_each_vdev_run(int argc, char **argv, char *cmd,
vcdl->g_zfs = g_zfs;

/* Gather our list of all vdevs in all pools */
for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
all_pools_for_each_vdev_gather_cb, vcdl);
for_each_pool(argc, argv, B_TRUE, NULL, ZFS_TYPE_POOL,
B_FALSE, all_pools_for_each_vdev_gather_cb, vcdl);

/* Run command on all vdevs in all pools */
all_pools_for_each_vdev_run_vcdl(vcdl);
Expand Down
Loading