diff options
author | Brian Behlendorf <[email protected]> | 2019-01-15 15:46:58 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2019-01-15 15:46:58 -0800 |
commit | 6e91a72fe3ff8bb282490773bd687632f3e8c79d (patch) | |
tree | 3eeada19664d8b2b4449c55fdb90c76fed5e17dc /cmd/zfs/zfs_main.c | |
parent | 5e7f3ace5807f950f3529361e03970101e61aa44 (diff) |
Disable 'zfs remap' command
The implementation of 'zfs remap' has proven to be problematic since
it modifies the objset (but not its logical contents) by dirtying
metadata without owning it. The consequence of which is that
dmu_objset_remap_indirects() is vulnerable to certain races.
For example, if we are in the middle of receiving into the filesystem
while it is being remapped. Then it is possible we could evict the
objset when the receive completes (see dsl_dataset_clone_swap_sync_impl,
or dmu_recv_end_sync), but dmu_objset_remap_indirects() may be still
using the objset. The result of which would be a panic.
Extended runs of ztest(8) have exposed other possible races which
can occur when using 'zfs remap'. Several of these have been fixed
but there may be others which have not yet been encountered and
diagnosed.
Furthermore, the ability to manually remap a filesystem is no longer
particularly useful now that the removal code can map large chunks.
Coupled with the fact that explaining what this command does and why
it may be useful requires a detailed understanding of the internals
of device removal. These are details users should not be bothered
with.
Therefore, the 'zfs remap' command is being disabled but not entirely
removed. It may be removed in the future or potentially reworked
to address the issues described above. Since 'zfs remap' has never
been part of a tagged release its removal is expected to have
minimal impact.
The ZTS tests have been updated to continue to exercise the command
to prevent atrophy, but it has been removed entirely from ztest(8).
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: Tom Caputi <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #8238
Diffstat (limited to 'cmd/zfs/zfs_main.c')
-rw-r--r-- | cmd/zfs/zfs_main.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 6b08bb115..b8258a9cf 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -7084,6 +7084,21 @@ zfs_do_unshare(int argc, char **argv) } static int +disable_command_idx(char *command) +{ + for (int i = 0; i < NCOMMAND; i++) { + if (command_table[i].name == NULL) + continue; + + if (strcmp(command, command_table[i].name) == 0) { + command_table[i].name = NULL; + return (0); + } + } + return (1); +} + +static int find_command_idx(char *command, int *idx) { int i; @@ -7180,7 +7195,22 @@ zfs_do_diff(int argc, char **argv) /* * zfs remap <filesystem | volume> * - * Remap the indirect blocks in the given fileystem or volume. + * N.B. The remap command has been disabled and may be removed in the future. + * + * Remap the indirect blocks in the given filesystem or volume so that they no + * longer reference blocks on previously removed vdevs and we can eventually + * shrink the size of the indirect mapping objects for the previously removed + * vdevs. Note that remapping all blocks might not be possible and that + * references from snapshots will still exist and cannot be remapped. + * + * This functionality is no longer particularly useful now that the removal + * code can map large chunks. Furthermore, explaining what this command + * does and why it may be useful requires a detailed understanding of the + * internals of device removal. These are details users should not be + * bothered with. If required, the remap command can be re-enabled by + * setting the ZFS_REMAP_ENABLED environment variable. + * + * > ZFS_REMAP_ENABLED=yes zfs remap <filesystem | volume> */ static int zfs_do_remap(int argc, char **argv) @@ -8007,6 +8037,13 @@ main(int argc, char **argv) cmdname = "snapshot"; /* + * The 'remap' command has been disabled and may be removed in the + * future. See the comment above zfs_do_remap() for details. + */ + if (!libzfs_envvar_is_set("ZFS_REMAP_ENABLED")) + disable_command_idx("remap"); + + /* * Special case '-?' */ if ((strcmp(cmdname, "-?") == 0) || |