Deleted Added
full compact
zhack.c (236884) zhack.c (248571)
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

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

41#include <sys/dsl_synctask.h>
42#include <sys/vdev.h>
43#include <sys/fs/zfs.h>
44#include <sys/dmu_objset.h>
45#include <sys/dsl_pool.h>
46#include <sys/zio_checksum.h>
47#include <sys/zio_compress.h>
48#include <sys/zfeature.h>
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

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

41#include <sys/dsl_synctask.h>
42#include <sys/vdev.h>
43#include <sys/fs/zfs.h>
44#include <sys/dmu_objset.h>
45#include <sys/dsl_pool.h>
46#include <sys/zio_checksum.h>
47#include <sys/zio_compress.h>
48#include <sys/zfeature.h>
49#include <sys/dmu_tx.h>
49#undef ZFS_MAXNAMELEN
50#undef verify
51#include <libzfs.h>
52
53extern boolean_t zfeature_checks_disable;
54
55const char cmdname[] = "zhack";
56libzfs_handle_t *g_zfs;

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

268 dump_obj(os, spa->spa_feat_for_write_obj, "for_write");
269 dump_obj(os, spa->spa_feat_desc_obj, "descriptions");
270 dump_mos(spa);
271
272 spa_close(spa, FTAG);
273}
274
275static void
50#undef ZFS_MAXNAMELEN
51#undef verify
52#include <libzfs.h>
53
54extern boolean_t zfeature_checks_disable;
55
56const char cmdname[] = "zhack";
57libzfs_handle_t *g_zfs;

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

269 dump_obj(os, spa->spa_feat_for_write_obj, "for_write");
270 dump_obj(os, spa->spa_feat_desc_obj, "descriptions");
271 dump_mos(spa);
272
273 spa_close(spa, FTAG);
274}
275
276static void
276feature_enable_sync(void *arg1, void *arg2, dmu_tx_t *tx)
277feature_enable_sync(void *arg, dmu_tx_t *tx)
277{
278{
278 spa_t *spa = arg1;
279 zfeature_info_t *feature = arg2;
279 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
280 zfeature_info_t *feature = arg;
280
281 spa_feature_enable(spa, feature, tx);
281
282 spa_feature_enable(spa, feature, tx);
283 spa_history_log_internal(spa, "zhack enable feature", tx,
284 "name=%s can_readonly=%u",
285 feature->fi_guid, feature->fi_can_readonly);
282}
283
284static void
285zhack_do_feature_enable(int argc, char **argv)
286{
287 char c;
288 char *desc, *target;
289 spa_t *spa;

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

336 zhack_spa_open(target, B_FALSE, FTAG, &spa);
337 mos = spa->spa_meta_objset;
338
339 if (0 == zfeature_lookup_guid(feature.fi_guid, NULL))
340 fatal("'%s' is a real feature, will not enable");
341 if (0 == zap_contains(mos, spa->spa_feat_desc_obj, feature.fi_guid))
342 fatal("feature already enabled: %s", feature.fi_guid);
343
286}
287
288static void
289zhack_do_feature_enable(int argc, char **argv)
290{
291 char c;
292 char *desc, *target;
293 spa_t *spa;

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

340 zhack_spa_open(target, B_FALSE, FTAG, &spa);
341 mos = spa->spa_meta_objset;
342
343 if (0 == zfeature_lookup_guid(feature.fi_guid, NULL))
344 fatal("'%s' is a real feature, will not enable");
345 if (0 == zap_contains(mos, spa->spa_feat_desc_obj, feature.fi_guid))
346 fatal("feature already enabled: %s", feature.fi_guid);
347
344 VERIFY3U(0, ==, dsl_sync_task_do(spa->spa_dsl_pool, NULL,
345 feature_enable_sync, spa, &feature, 5));
348 VERIFY0(dsl_sync_task(spa_name(spa), NULL,
349 feature_enable_sync, &feature, 5));
346
347 spa_close(spa, FTAG);
348
349 free(desc);
350}
351
352static void
350
351 spa_close(spa, FTAG);
352
353 free(desc);
354}
355
356static void
353feature_incr_sync(void *arg1, void *arg2, dmu_tx_t *tx)
357feature_incr_sync(void *arg, dmu_tx_t *tx)
354{
358{
355 spa_t *spa = arg1;
356 zfeature_info_t *feature = arg2;
359 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
360 zfeature_info_t *feature = arg;
357
358 spa_feature_incr(spa, feature, tx);
361
362 spa_feature_incr(spa, feature, tx);
363 spa_history_log_internal(spa, "zhack feature incr", tx,
364 "name=%s", feature->fi_guid);
359}
360
361static void
365}
366
367static void
362feature_decr_sync(void *arg1, void *arg2, dmu_tx_t *tx)
368feature_decr_sync(void *arg, dmu_tx_t *tx)
363{
369{
364 spa_t *spa = arg1;
365 zfeature_info_t *feature = arg2;
370 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
371 zfeature_info_t *feature = arg;
366
367 spa_feature_decr(spa, feature, tx);
372
373 spa_feature_decr(spa, feature, tx);
374 spa_history_log_internal(spa, "zhack feature decr", tx,
375 "name=%s", feature->fi_guid);
368}
369
370static void
371zhack_do_feature_ref(int argc, char **argv)
372{
373 char c;
374 char *target;
375 boolean_t decr = B_FALSE;

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

430 feature.fi_can_readonly = B_TRUE;
431 } else {
432 fatal("feature is not enabled: %s", feature.fi_guid);
433 }
434
435 if (decr && !spa_feature_is_active(spa, &feature))
436 fatal("feature refcount already 0: %s", feature.fi_guid);
437
376}
377
378static void
379zhack_do_feature_ref(int argc, char **argv)
380{
381 char c;
382 char *target;
383 boolean_t decr = B_FALSE;

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

438 feature.fi_can_readonly = B_TRUE;
439 } else {
440 fatal("feature is not enabled: %s", feature.fi_guid);
441 }
442
443 if (decr && !spa_feature_is_active(spa, &feature))
444 fatal("feature refcount already 0: %s", feature.fi_guid);
445
438 VERIFY3U(0, ==, dsl_sync_task_do(spa->spa_dsl_pool, NULL,
439 decr ? feature_decr_sync : feature_incr_sync, spa, &feature, 5));
446 VERIFY0(dsl_sync_task(spa_name(spa), NULL,
447 decr ? feature_decr_sync : feature_incr_sync, &feature, 5));
440
441 spa_close(spa, FTAG);
442}
443
444static int
445zhack_do_feature(int argc, char **argv)
446{
447 char *subcommand;

--- 86 unchanged lines hidden ---
448
449 spa_close(spa, FTAG);
450}
451
452static int
453zhack_do_feature(int argc, char **argv)
454{
455 char *subcommand;

--- 86 unchanged lines hidden ---