Deleted Added
full compact
zhack.c (259813) zhack.c (260150)
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 263 unchanged lines hidden (view full) ---

272 target = argv[0];
273
274 zhack_spa_open(target, B_TRUE, FTAG, &spa);
275 os = spa->spa_meta_objset;
276
277 dump_obj(os, spa->spa_feat_for_read_obj, "for_read");
278 dump_obj(os, spa->spa_feat_for_write_obj, "for_write");
279 dump_obj(os, spa->spa_feat_desc_obj, "descriptions");
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 263 unchanged lines hidden (view full) ---

272 target = argv[0];
273
274 zhack_spa_open(target, B_TRUE, FTAG, &spa);
275 os = spa->spa_meta_objset;
276
277 dump_obj(os, spa->spa_feat_for_read_obj, "for_read");
278 dump_obj(os, spa->spa_feat_for_write_obj, "for_write");
279 dump_obj(os, spa->spa_feat_desc_obj, "descriptions");
280 if (spa_feature_is_active(spa, SPA_FEATURE_ENABLED_TXG)) {
281 dump_obj(os, spa->spa_feat_enabled_txg_obj, "enabled_txg");
282 }
280 dump_mos(spa);
281
282 spa_close(spa, FTAG);
283}
284
285static void
286zhack_feature_enable_sync(void *arg, dmu_tx_t *tx)
287{

--- 20 unchanged lines hidden (view full) ---

308 /*
309 * Features are not added to the pool's label until their refcounts
310 * are incremented, so fi_mos can just be left as false for now.
311 */
312 desc = NULL;
313 feature.fi_uname = "zhack";
314 feature.fi_mos = B_FALSE;
315 feature.fi_can_readonly = B_FALSE;
283 dump_mos(spa);
284
285 spa_close(spa, FTAG);
286}
287
288static void
289zhack_feature_enable_sync(void *arg, dmu_tx_t *tx)
290{

--- 20 unchanged lines hidden (view full) ---

311 /*
312 * Features are not added to the pool's label until their refcounts
313 * are incremented, so fi_mos can just be left as false for now.
314 */
315 desc = NULL;
316 feature.fi_uname = "zhack";
317 feature.fi_mos = B_FALSE;
318 feature.fi_can_readonly = B_FALSE;
319 feature.fi_activate_on_enable = B_FALSE;
316 feature.fi_depends = nodeps;
320 feature.fi_depends = nodeps;
321 feature.fi_feature = SPA_FEATURE_NONE;
317
318 optind = 1;
319 while ((c = getopt(argc, argv, "rmd:")) != -1) {
320 switch (c) {
321 case 'r':
322 feature.fi_can_readonly = B_TRUE;
323 break;
324 case 'd':

--- 41 unchanged lines hidden (view full) ---

366
367static void
368feature_incr_sync(void *arg, dmu_tx_t *tx)
369{
370 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
371 zfeature_info_t *feature = arg;
372 uint64_t refcount;
373
322
323 optind = 1;
324 while ((c = getopt(argc, argv, "rmd:")) != -1) {
325 switch (c) {
326 case 'r':
327 feature.fi_can_readonly = B_TRUE;
328 break;
329 case 'd':

--- 41 unchanged lines hidden (view full) ---

371
372static void
373feature_incr_sync(void *arg, dmu_tx_t *tx)
374{
375 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
376 zfeature_info_t *feature = arg;
377 uint64_t refcount;
378
374 VERIFY0(feature_get_refcount(spa, feature, &refcount));
379 VERIFY0(feature_get_refcount_from_disk(spa, feature, &refcount));
375 feature_sync(spa, feature, refcount + 1, tx);
376 spa_history_log_internal(spa, "zhack feature incr", tx,
377 "name=%s", feature->fi_guid);
378}
379
380static void
381feature_decr_sync(void *arg, dmu_tx_t *tx)
382{
383 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
384 zfeature_info_t *feature = arg;
385 uint64_t refcount;
386
380 feature_sync(spa, feature, refcount + 1, tx);
381 spa_history_log_internal(spa, "zhack feature incr", tx,
382 "name=%s", feature->fi_guid);
383}
384
385static void
386feature_decr_sync(void *arg, dmu_tx_t *tx)
387{
388 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
389 zfeature_info_t *feature = arg;
390 uint64_t refcount;
391
387 VERIFY0(feature_get_refcount(spa, feature, &refcount));
392 VERIFY0(feature_get_refcount_from_disk(spa, feature, &refcount));
388 feature_sync(spa, feature, refcount - 1, tx);
389 spa_history_log_internal(spa, "zhack feature decr", tx,
390 "name=%s", feature->fi_guid);
391}
392
393static void
394zhack_do_feature_ref(int argc, char **argv)
395{

--- 10 unchanged lines hidden (view full) ---

406 * when the feature was enabled, but we need to properly set the
407 * feature for read or write based on the information we read off
408 * disk later.
409 */
410 feature.fi_uname = "zhack";
411 feature.fi_mos = B_FALSE;
412 feature.fi_desc = NULL;
413 feature.fi_depends = nodeps;
393 feature_sync(spa, feature, refcount - 1, tx);
394 spa_history_log_internal(spa, "zhack feature decr", tx,
395 "name=%s", feature->fi_guid);
396}
397
398static void
399zhack_do_feature_ref(int argc, char **argv)
400{

--- 10 unchanged lines hidden (view full) ---

411 * when the feature was enabled, but we need to properly set the
412 * feature for read or write based on the information we read off
413 * disk later.
414 */
415 feature.fi_uname = "zhack";
416 feature.fi_mos = B_FALSE;
417 feature.fi_desc = NULL;
418 feature.fi_depends = nodeps;
419 feature.fi_feature = SPA_FEATURE_NONE;
414
415 optind = 1;
416 while ((c = getopt(argc, argv, "md")) != -1) {
417 switch (c) {
418 case 'm':
419 feature.fi_mos = B_TRUE;
420 break;
421 case 'd':

--- 32 unchanged lines hidden (view full) ---

454 feature.fi_guid)) {
455 feature.fi_can_readonly = B_TRUE;
456 } else {
457 fatal(spa, FTAG, "feature is not enabled: %s", feature.fi_guid);
458 }
459
460 if (decr) {
461 uint64_t count;
420
421 optind = 1;
422 while ((c = getopt(argc, argv, "md")) != -1) {
423 switch (c) {
424 case 'm':
425 feature.fi_mos = B_TRUE;
426 break;
427 case 'd':

--- 32 unchanged lines hidden (view full) ---

460 feature.fi_guid)) {
461 feature.fi_can_readonly = B_TRUE;
462 } else {
463 fatal(spa, FTAG, "feature is not enabled: %s", feature.fi_guid);
464 }
465
466 if (decr) {
467 uint64_t count;
462 if (feature_get_refcount(spa, &feature, &count) == 0 &&
463 count != 0) {
468 if (feature_get_refcount_from_disk(spa, &feature,
469 &count) == 0 && count != 0) {
464 fatal(spa, FTAG, "feature refcount already 0: %s",
465 feature.fi_guid);
466 }
467 }
468
469 VERIFY0(dsl_sync_task(spa_name(spa), NULL,
470 decr ? feature_decr_sync : feature_incr_sync, &feature, 5));
471

--- 93 unchanged lines hidden ---
470 fatal(spa, FTAG, "feature refcount already 0: %s",
471 feature.fi_guid);
472 }
473 }
474
475 VERIFY0(dsl_sync_task(spa_name(spa), NULL,
476 decr ? feature_decr_sync : feature_incr_sync, &feature, 5));
477

--- 93 unchanged lines hidden ---