mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Illumos #1748: desire support for reguid in zfs
Reviewed by: George Wilson <gwilson@zfsmail.com> Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com> Reviewed by: Alexander Stetsenko <ams@nexenta.com> Approved by: Richard Lowe <richlowe@richlowe.net> References: https://www.illumos.org/issues/1748 This commit modifies the user to kernel space ioctl ABI. Extra care should be taken when updating to ensure both the kernel modules and utilities are updated. If only the user space component is updated both the 'zpool events' command and the 'zpool reguid' command will not work until the kernel modules are updated. Ported by: Martin Matuska <martin@matuska.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #665
This commit is contained in:
committed by
Brian Behlendorf
parent
ba9b5428fd
commit
3541dc6d02
+53
-1
@@ -69,6 +69,8 @@ static int zpool_do_online(int, char **);
|
||||
static int zpool_do_offline(int, char **);
|
||||
static int zpool_do_clear(int, char **);
|
||||
|
||||
static int zpool_do_reguid(int, char **);
|
||||
|
||||
static int zpool_do_attach(int, char **);
|
||||
static int zpool_do_detach(int, char **);
|
||||
static int zpool_do_replace(int, char **);
|
||||
@@ -128,7 +130,8 @@ typedef enum {
|
||||
HELP_EVENTS,
|
||||
HELP_GET,
|
||||
HELP_SET,
|
||||
HELP_SPLIT
|
||||
HELP_SPLIT,
|
||||
HELP_REGUID
|
||||
} zpool_help_t;
|
||||
|
||||
|
||||
@@ -172,6 +175,7 @@ static zpool_command_t command_table[] = {
|
||||
{ "import", zpool_do_import, HELP_IMPORT },
|
||||
{ "export", zpool_do_export, HELP_EXPORT },
|
||||
{ "upgrade", zpool_do_upgrade, HELP_UPGRADE },
|
||||
{ "reguid", zpool_do_reguid, HELP_REGUID },
|
||||
{ NULL },
|
||||
{ "history", zpool_do_history, HELP_HISTORY },
|
||||
{ "events", zpool_do_events, HELP_EVENTS },
|
||||
@@ -254,6 +258,8 @@ get_usage(zpool_help_t idx) {
|
||||
return (gettext("\tsplit [-n] [-R altroot] [-o mntopts]\n"
|
||||
"\t [-o property=value] <pool> <newpool> "
|
||||
"[<device> ...]\n"));
|
||||
case HELP_REGUID:
|
||||
return (gettext("\treguid <pool>\n"));
|
||||
}
|
||||
|
||||
abort();
|
||||
@@ -3206,6 +3212,52 @@ zpool_do_clear(int argc, char **argv)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* zpool reguid <pool>
|
||||
*/
|
||||
int
|
||||
zpool_do_reguid(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char *poolname;
|
||||
zpool_handle_t *zhp;
|
||||
int ret = 0;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, "")) != -1) {
|
||||
switch (c) {
|
||||
case '?':
|
||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||
optopt);
|
||||
usage(B_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
/* get pool name and check number of arguments */
|
||||
if (argc < 1) {
|
||||
(void) fprintf(stderr, gettext("missing pool name\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
(void) fprintf(stderr, gettext("too many arguments\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
poolname = argv[0];
|
||||
if ((zhp = zpool_open(g_zfs, poolname)) == NULL)
|
||||
return (1);
|
||||
|
||||
ret = zpool_reguid(zhp);
|
||||
|
||||
zpool_close(zhp);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
typedef struct scrub_cbdata {
|
||||
int cb_type;
|
||||
int cb_argc;
|
||||
|
||||
+35
-1
@@ -21,6 +21,7 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011 by Delphix. All rights reserved.
|
||||
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -260,6 +261,7 @@ ztest_func_t ztest_vdev_LUN_growth;
|
||||
ztest_func_t ztest_vdev_add_remove;
|
||||
ztest_func_t ztest_vdev_aux_add_remove;
|
||||
ztest_func_t ztest_split_pool;
|
||||
ztest_func_t ztest_reguid;
|
||||
|
||||
uint64_t zopt_always = 0ULL * NANOSEC; /* all the time */
|
||||
uint64_t zopt_incessant = 1ULL * NANOSEC / 10; /* every 1/10 second */
|
||||
@@ -290,6 +292,7 @@ ztest_info_t ztest_info[] = {
|
||||
{ ztest_fault_inject, 1, &zopt_sometimes },
|
||||
{ ztest_ddt_repair, 1, &zopt_sometimes },
|
||||
{ ztest_dmu_snapshot_hold, 1, &zopt_sometimes },
|
||||
{ ztest_reguid, 1, &zopt_sometimes },
|
||||
{ ztest_spa_rename, 1, &zopt_rarely },
|
||||
{ ztest_scrub, 1, &zopt_rarely },
|
||||
{ ztest_dsl_dataset_promote_busy, 1, &zopt_rarely },
|
||||
@@ -326,6 +329,7 @@ typedef struct ztest_shared {
|
||||
uint64_t zs_vdev_aux;
|
||||
uint64_t zs_alloc;
|
||||
uint64_t zs_space;
|
||||
uint64_t zs_guid;
|
||||
kmutex_t zs_vdev_lock;
|
||||
krwlock_t zs_name_lock;
|
||||
ztest_info_t zs_info[ZTEST_FUNCS];
|
||||
@@ -4804,7 +4808,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
|
||||
|
||||
object = od[0].od_object;
|
||||
blocksize = od[0].od_blocksize;
|
||||
pattern = spa_guid(spa) ^ dmu_objset_fsid_guid(os);
|
||||
pattern = zs->zs_guid ^ dmu_objset_fsid_guid(os);
|
||||
|
||||
ASSERT(object != 0);
|
||||
|
||||
@@ -4876,6 +4880,31 @@ ztest_scrub(ztest_ds_t *zd, uint64_t id)
|
||||
(void) spa_scan(spa, POOL_SCAN_SCRUB);
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the guid for the pool.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
void
|
||||
ztest_reguid(ztest_ds_t *zd, uint64_t id)
|
||||
{
|
||||
ztest_shared_t *zs = ztest_shared;
|
||||
spa_t *spa = zs->zs_spa;
|
||||
uint64_t orig, load;
|
||||
|
||||
orig = spa_guid(spa);
|
||||
load = spa_load_guid(spa);
|
||||
if (spa_change_guid(spa) != 0)
|
||||
return;
|
||||
|
||||
if (zopt_verbose >= 3) {
|
||||
(void) printf("Changed guid old %llu -> %llu\n",
|
||||
(u_longlong_t)orig, (u_longlong_t)spa_guid(spa));
|
||||
}
|
||||
|
||||
VERIFY3U(orig, !=, spa_guid(spa));
|
||||
VERIFY3U(load, ==, spa_load_guid(spa));
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename the pool to a different name and then rename it back.
|
||||
*/
|
||||
@@ -5307,6 +5336,7 @@ ztest_run(ztest_shared_t *zs)
|
||||
{
|
||||
kt_did_t *tid;
|
||||
spa_t *spa;
|
||||
objset_t *os;
|
||||
kthread_t *resume_thread;
|
||||
uint64_t object;
|
||||
int error;
|
||||
@@ -5340,6 +5370,10 @@ ztest_run(ztest_shared_t *zs)
|
||||
spa->spa_debug = B_TRUE;
|
||||
zs->zs_spa = spa;
|
||||
|
||||
VERIFY3U(0, ==, dmu_objset_hold(zs->zs_pool, FTAG, &os));
|
||||
zs->zs_guid = dmu_objset_fsid_guid(os);
|
||||
dmu_objset_rele(os, FTAG);
|
||||
|
||||
spa->spa_dedup_ditto = 2 * ZIO_DEDUPDITTO_MIN;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user