From 59ec30a3290d865b98e3805df6c82b6b4f88aab0 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Mon, 24 Jun 2019 16:44:01 -0700 Subject: Remove code for zfs remap The "zfs remap" command was disabled by 6e91a72fe3ff8bb282490773bd687632f3e8c79d, because it has little utility and introduced some tricky bugs. This commit removes the code for it, the associated ZFS_IOC_REMAP ioctl, and tests. Note that the ioctl and property will remain, but have no functionality. This allows older software to fail gracefully if it attempts to use these, and avoids a backwards incompatibility that would be introduced if we renumbered the later ioctls/props. Reviewed-by: Tom Caputi Reviewed-by: Brian Behlendorf Signed-off-by: Matthew Ahrens Closes #8944 --- cmd/zfs/zfs_main.c | 78 ------------------------------------------------------ 1 file changed, 78 deletions(-) (limited to 'cmd/zfs') diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 634303f80..30942e1f0 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -114,7 +114,6 @@ static int zfs_do_release(int argc, char **argv); static int zfs_do_diff(int argc, char **argv); static int zfs_do_bookmark(int argc, char **argv); static int zfs_do_channel_program(int argc, char **argv); -static int zfs_do_remap(int argc, char **argv); static int zfs_do_load_key(int argc, char **argv); static int zfs_do_unload_key(int argc, char **argv); static int zfs_do_change_key(int argc, char **argv); @@ -169,7 +168,6 @@ typedef enum { HELP_HOLDS, HELP_RELEASE, HELP_DIFF, - HELP_REMAP, HELP_BOOKMARK, HELP_CHANNEL_PROGRAM, HELP_LOAD_KEY, @@ -237,7 +235,6 @@ static zfs_command_t command_table[] = { { "holds", zfs_do_holds, HELP_HOLDS }, { "release", zfs_do_release, HELP_RELEASE }, { "diff", zfs_do_diff, HELP_DIFF }, - { "remap", zfs_do_remap, HELP_REMAP }, { "load-key", zfs_do_load_key, HELP_LOAD_KEY }, { "unload-key", zfs_do_unload_key, HELP_UNLOAD_KEY }, { "change-key", zfs_do_change_key, HELP_CHANGE_KEY }, @@ -371,8 +368,6 @@ get_usage(zfs_help_t idx) case HELP_DIFF: return (gettext("\tdiff [-FHt] " "[snapshot|filesystem]\n")); - case HELP_REMAP: - return (gettext("\tremap \n")); case HELP_BOOKMARK: return (gettext("\tbookmark \n")); case HELP_CHANNEL_PROGRAM: @@ -4587,7 +4582,6 @@ zfs_do_receive(int argc, char **argv) #define ZFS_DELEG_PERM_RELEASE "release" #define ZFS_DELEG_PERM_DIFF "diff" #define ZFS_DELEG_PERM_BOOKMARK "bookmark" -#define ZFS_DELEG_PERM_REMAP "remap" #define ZFS_DELEG_PERM_LOAD_KEY "load-key" #define ZFS_DELEG_PERM_CHANGE_KEY "change-key" @@ -4615,7 +4609,6 @@ static zfs_deleg_perm_tab_t zfs_deleg_perm_tbl[] = { { ZFS_DELEG_PERM_SHARE, ZFS_DELEG_NOTE_SHARE }, { ZFS_DELEG_PERM_SNAPSHOT, ZFS_DELEG_NOTE_SNAPSHOT }, { ZFS_DELEG_PERM_BOOKMARK, ZFS_DELEG_NOTE_BOOKMARK }, - { ZFS_DELEG_PERM_REMAP, ZFS_DELEG_NOTE_REMAP }, { ZFS_DELEG_PERM_LOAD_KEY, ZFS_DELEG_NOTE_LOAD_KEY }, { ZFS_DELEG_PERM_CHANGE_KEY, ZFS_DELEG_NOTE_CHANGE_KEY }, @@ -7311,21 +7304,6 @@ zfs_do_unshare(int argc, char **argv) return (unshare_unmount(OP_SHARE, argc, 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) { @@ -7429,55 +7407,6 @@ out: return (err != 0); } - -/* - * zfs remap - * - * 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 - */ -static int -zfs_do_remap(int argc, char **argv) -{ - const char *fsname; - int err = 0; - int c; - - /* check options */ - while ((c = getopt(argc, argv, "")) != -1) { - switch (c) { - case '?': - (void) fprintf(stderr, - gettext("invalid option '%c'\n"), optopt); - usage(B_FALSE); - } - } - - if (argc != 2) { - (void) fprintf(stderr, gettext("wrong number of arguments\n")); - usage(B_FALSE); - } - - fsname = argv[1]; - err = zfs_remap_indirects(g_zfs, fsname); - - return (err); -} - /* * zfs bookmark * @@ -8286,13 +8215,6 @@ main(int argc, char **argv) if (strcmp(cmdname, "snap") == 0) 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 '-?' */ -- cgit v1.2.3