-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This addition will enable us to sync an open TXG to the main pool on demand. The functionality is similar to 'sync(2)' but 'zpool sync' will return when data has hit the main storage instead of potentially just the ZIL as is the case with the 'sync(2)' cmd. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Signed-off-by: Alek Pinchuk <[email protected]>
- Loading branch information
Showing
19 changed files
with
681 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
* Copyright (c) 2012 by Cyril Plisko. All rights reserved. | ||
* Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved. | ||
* Copyright 2016 Nexenta Systems, Inc. | ||
* Copyright 2016 Igor Kozhukhov <[email protected]>. | ||
* Copyright (c) 2017 Datto Inc. | ||
*/ | ||
|
||
|
@@ -111,6 +112,8 @@ static int zpool_do_events(int, char **); | |
static int zpool_do_get(int, char **); | ||
static int zpool_do_set(int, char **); | ||
|
||
static int zpool_do_sync(int, char **); | ||
|
||
/* | ||
* These libumem hooks provide a reasonable set of defaults for the allocator's | ||
* debugging facilities. | ||
|
@@ -156,6 +159,7 @@ typedef enum { | |
HELP_GET, | ||
HELP_SET, | ||
HELP_SPLIT, | ||
HELP_SYNC, | ||
HELP_REGUID, | ||
HELP_REOPEN | ||
} zpool_help_t; | ||
|
@@ -288,6 +292,7 @@ static zpool_command_t command_table[] = { | |
{ NULL }, | ||
{ "get", zpool_do_get, HELP_GET }, | ||
{ "set", zpool_do_set, HELP_SET }, | ||
{ "sync", zpool_do_sync, HELP_SYNC }, | ||
}; | ||
|
||
#define NCOMMAND (ARRAY_SIZE(command_table)) | ||
|
@@ -378,6 +383,8 @@ get_usage(zpool_help_t idx) { | |
"[<device> ...]\n")); | ||
case HELP_REGUID: | ||
return (gettext("\treguid <pool>\n")); | ||
case HELP_SYNC: | ||
return (gettext("\tsync [pool] ...\n")); | ||
} | ||
|
||
abort(); | ||
|
@@ -2966,6 +2973,45 @@ zpool_do_import(int argc, char **argv) | |
return (err ? 1 : 0); | ||
} | ||
|
||
/* | ||
* zpool sync [-f] [pool] ... | ||
* | ||
* -f (undocumented) force uberblock (and config including zpool cache file) | ||
* update. | ||
* | ||
* Sync the specified pool(s). | ||
* Without arguments "zpool sync" will sync all pools. | ||
* This command initiates TXG sync(s) and will return after the TXG(s) commit. | ||
* | ||
*/ | ||
static int | ||
zpool_do_sync(int argc, char **argv) | ||
{ | ||
int ret; | ||
boolean_t force = B_FALSE; | ||
|
||
/* check options */ | ||
while ((ret = getopt(argc, argv, "f")) != -1) { | ||
switch (ret) { | ||
case 'f': | ||
force = B_TRUE; | ||
break; | ||
case '?': | ||
(void) fprintf(stderr, gettext("invalid option '%c'\n"), | ||
optopt); | ||
usage(B_FALSE); | ||
} | ||
} | ||
|
||
argc -= optind; | ||
argv += optind; | ||
|
||
/* if argc == 0 we will execute zpool_sync_one on all pools */ | ||
ret = for_each_pool(argc, argv, B_FALSE, NULL, zpool_sync_one, &force); | ||
|
||
return (ret); | ||
} | ||
|
||
typedef struct iostat_cbdata { | ||
uint64_t cb_flags; | ||
int cb_name_flags; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ | |
* Copyright (c) 2014 Integros [integros.com] | ||
* Copyright 2016 Toomas Soome <[email protected]> | ||
* Copyright 2017 RackTop Systems. | ||
* Copyright (c) 2017 Datto Inc. | ||
* Copyright (c) 2016 Actifio, Inc. All rights reserved. | ||
* Copyright (c) 2017, loli10K <[email protected]>. All rights reserved. | ||
*/ | ||
|
||
#define __APPLE_API_PRIVATE | ||
|
@@ -5315,6 +5316,7 @@ zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist) | |
static int | ||
zfs_ioc_get_holds(const char *snapname, nvlist_t *args, nvlist_t *outnvl) | ||
{ | ||
ASSERT3P(args, ==, NULL); | ||
return (dsl_dataset_get_holds(snapname, outnvl)); | ||
} | ||
|
||
|
@@ -5843,6 +5845,43 @@ zfs_ioc_osx_proxy_dataset(zfs_cmd_t *zc) | |
return (error); | ||
} | ||
|
||
/* | ||
* Sync the currently open TXG to disk for the specified pool. | ||
* This is somewhat similar to 'zfs_sync()'. | ||
* For cases that do not result in error this ioctl will wait for | ||
* the currently open TXG to commit before returning back to the caller. | ||
* | ||
* innvl: { | ||
* "force" -> when true, force uberblock update even if there is no dirty data. | ||
* In addition this will cause the vdev configuration to be written | ||
* out including updating the zpool cache file. (boolean_t) | ||
* } | ||
* | ||
* onvl is unused | ||
*/ | ||
/* ARGSUSED */ | ||
static int | ||
zfs_ioc_pool_sync(const char *pool, nvlist_t *innvl, nvlist_t *onvl) | ||
{ | ||
int err; | ||
boolean_t force; | ||
spa_t *spa; | ||
|
||
if ((err = spa_open(pool, &spa, FTAG)) != 0) | ||
return (err); | ||
|
||
force = fnvlist_lookup_boolean_value(innvl, "force"); | ||
if (force) { | ||
spa_config_enter(spa, SCL_CONFIG, FTAG, RW_WRITER); | ||
vdev_config_dirty(spa->spa_root_vdev); | ||
spa_config_exit(spa, SCL_CONFIG, FTAG); | ||
} | ||
txg_wait_synced(spa_get_dsl(spa), 0); | ||
|
||
spa_close(spa, FTAG); | ||
|
||
return (err); | ||
} | ||
|
||
static zfs_ioc_vec_t zfs_ioc_vec[ZFS_IOC_LAST - ZFS_IOC_FIRST]; | ||
|
||
|
@@ -6045,6 +6084,10 @@ zfs_ioctl_init(void) | |
POOL_NAME, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, | ||
B_TRUE); | ||
|
||
zfs_ioctl_register("sync", ZFS_IOC_POOL_SYNC, | ||
zfs_ioc_pool_sync, zfs_secpolicy_none, POOL_NAME, | ||
POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_FALSE); | ||
|
||
/* IOCTLS that use the legacy function signature */ | ||
|
||
zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.