Remove code for zfs remap

The "zfs remap" command was disabled by
6e91a72fe3, 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 <tcaputi@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8944
This commit is contained in:
Matthew Ahrens
2019-06-24 16:44:01 -07:00
committed by Brian Behlendorf
parent 53864800f6
commit 59ec30a329
40 changed files with 29 additions and 947 deletions
+2 -6
View File
@@ -210,10 +210,6 @@ tests = ['zfs_receive_001_pos', 'zfs_receive_002_pos', 'zfs_receive_003_pos',
'zfs_receive_raw_incremental', 'zfs_receive_-e']
tags = ['functional', 'cli_root', 'zfs_receive']
[tests/functional/cli_root/zfs_remap]
tests = ['zfs_remap_cliargs', 'zfs_remap_obsolete_counts']
tags = ['functional', 'cli_root', 'zfs_remap']
[tests/functional/cli_root/zfs_rename]
tests = ['zfs_rename_001_pos', 'zfs_rename_002_pos', 'zfs_rename_003_pos',
'zfs_rename_004_neg', 'zfs_rename_005_neg', 'zfs_rename_006_pos',
@@ -767,11 +763,11 @@ tags = ['functional', 'refreserv']
pre =
tests = ['removal_all_vdev', 'removal_check_space',
'removal_condense_export', 'removal_multiple_indirection',
'removal_remap', 'removal_remap_deadlists',
'removal_remap_deadlists',
'removal_resume_export', 'removal_sanity', 'removal_with_add',
'removal_with_create_fs', 'removal_with_dedup',
'removal_with_errors', 'removal_with_export',
'removal_with_ganging', 'removal_with_faulted', 'removal_with_remap',
'removal_with_ganging', 'removal_with_faulted',
'removal_with_remove', 'removal_with_scrub', 'removal_with_send',
'removal_with_send_recv', 'removal_with_snapshot',
'removal_with_write', 'removal_with_zdb', 'remove_expanded',
-1
View File
@@ -186,7 +186,6 @@ known = {
'inuse/inuse_007_pos': ['SKIP', na_reason],
'privilege/setup': ['SKIP', na_reason],
'refreserv/refreserv_004_pos': ['FAIL', known_reason],
'removal/removal_condense_export': ['SKIP', known_reason],
'removal/removal_with_zdb': ['SKIP', known_reason],
'rootpool/setup': ['SKIP', na_reason],
'rsend/rsend_008_pos': ['SKIP', '6066'],
@@ -93,14 +93,7 @@ for i in 1 2 3 4; do
log_must file_in_special_vdev $dataset $inum
done
#
# remove a special allocation vdev and force a remapping
# N.B. The 'zfs remap' command has been disabled and may be removed.
#
export ZFS_REMAP_ENABLED=YES
log_must zpool remove $TESTPOOL $CLASS_DISK0
log_must zfs remap $TESTPOOL/$TESTFS
sleep 5
log_must sync_pool $TESTPOOL
@@ -20,7 +20,6 @@ SUBDIRS = \
zfs_promote \
zfs_property \
zfs_receive \
zfs_remap \
zfs_rename \
zfs_reservation \
zfs_rollback \
@@ -1,7 +0,0 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_remap
dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
zfs_remap_cliargs.ksh \
zfs_remap_obsolete_counts.ksh
@@ -1,19 +0,0 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
default_cleanup
@@ -1,17 +0,0 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -1,81 +0,0 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
#
# DESCRIPTION:
# 'zfs remap' should only work with supported parameters.
#
# STRATEGY:
# 1. Prepare a pool where a top-level VDEV has been removed
# 2. Verify every supported parameter to 'zfs remap' is accepted
# 3. Verify other unsupported parameters raise an error
#
# The 'zfs remap' command has been disabled and may be removed.
export ZFS_REMAP_ENABLED=YES
verify_runnable "both"
function cleanup
{
destroy_pool $TESTPOOL
rm -f $DISK1 $DISK2
}
log_assert "'zfs remap' should only work with supported parameters"
log_onexit cleanup
f="$TESTPOOL/fs"
v="$TESTPOOL/vol"
s="$TESTPOOL/fs@snap"
b="$TESTPOOL/fs#bmark"
c="$TESTPOOL/clone"
typeset goodparams=("$f" "$v" "$c")
typeset badparams=("-H" "-p" "-?" "$s" "$b" "$f $f" "$f $v" "$f $s")
DISK1="$TEST_BASE_DIR/zfs_remap-1"
DISK2="$TEST_BASE_DIR/zfs_remap-2"
# 1. Prepare a pool where a top-level VDEV has been removed
log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK1
log_must zpool create $TESTPOOL $DISK1
log_must zfs create $f
log_must zfs create -V 1M -s $v
log_must zfs snap $s
log_must zfs bookmark $s $b
log_must zfs clone $s $c
log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK2
log_must zpool add $TESTPOOL $DISK2
log_must zpool remove $TESTPOOL $DISK1
log_must wait_for_removal $TESTPOOL
# 2. Verify every supported parameter to 'zfs remap' is accepted
for param in "${goodparams[@]}"
do
log_must zfs remap $param
done
# 3. Verify other unsupported parameters raise an error
for param in "${badparams[@]}"
do
log_mustnot zfs remap $param
done
log_pass "'zfs remap' only works with supported parameters"
@@ -1,79 +0,0 @@
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
#
# DESCRIPTION:
# 'zfs remap' depends on 'feature@obsolete_counts' being active
#
# STRATEGY:
# 1. Prepare a pool where a top-level VDEV has been removed and with
# feature@obsolete_counts disabled
# 2. Verify any 'zfs remap' command cannot be executed
# 3. Verify the same commands complete successfully when
# feature@obsolete_counts is enabled
#
# N.B. The 'zfs remap' command has been disabled and may be removed.
export ZFS_REMAP_ENABLED=YES
verify_runnable "both"
function cleanup
{
destroy_pool $TESTPOOL
rm -f $DISK1 $DISK2
}
log_assert "'zfs remap' depends on feature@obsolete_counts being active"
log_onexit cleanup
f="$TESTPOOL/fs"
v="$TESTPOOL/vol"
s="$TESTPOOL/fs@snap"
c="$TESTPOOL/clone"
DISK1="$TEST_BASE_DIR/zfs_remap-1"
DISK2="$TEST_BASE_DIR/zfs_remap-2"
# 1. Prepare a pool where a top-level VDEV has been removed with
# feature@obsolete_counts disabled
log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK1
log_must zpool create -o feature@obsolete_counts=disabled $TESTPOOL $DISK1
log_must zfs create $f
log_must zfs create -V 1M -s $v
log_must zfs snap $s
log_must zfs clone $s $c
log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK2
log_must zpool add $TESTPOOL $DISK2
log_must zpool remove $TESTPOOL $DISK1
log_must wait_for_removal $TESTPOOL
# 2. Verify any 'zfs remap' command cannot be executed
log_mustnot zfs remap $f
log_mustnot zfs remap $v
log_mustnot zfs remap $c
# 3. Verify the same commands complete successfully when
# feature@obsolete_counts is enabled
log_must zpool set feature@obsolete_counts=enabled $TESTPOOL
log_must zfs remap $f
log_must zfs remap $v
log_must zfs remap $c
log_pass "'zfs remap' correctly depends on feature@obsolete_counts being active"
@@ -18,12 +18,12 @@ pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/removal
dist_pkgdata_SCRIPTS = \
cleanup.ksh removal_all_vdev.ksh removal_check_space.ksh \
removal_condense_export.ksh removal_multiple_indirection.ksh \
removal_remap_deadlists.ksh removal_remap.ksh \
removal_remap_deadlists.ksh \
removal_reservation.ksh removal_resume_export.ksh \
removal_sanity.ksh removal_with_add.ksh removal_with_create_fs.ksh \
removal_with_dedup.ksh removal_with_errors.ksh \
removal_with_export.ksh removal_with_faulted.ksh \
removal_with_ganging.ksh removal_with_remap.ksh \
removal_with_ganging.ksh \
removal_with_remove.ksh removal_with_scrub.ksh \
removal_with_send.ksh removal_with_send_recv.ksh \
removal_with_snapshot.ksh removal_with_write.ksh \
@@ -21,10 +21,6 @@
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
if is_linux; then
log_unsupported "ZDB fails during concurrent pool activity."
fi
function reset
{
log_must set_tunable64 zfs_condense_indirect_commit_entry_delay_ms 0
@@ -77,7 +73,14 @@ log_must zpool remove $TESTPOOL $REMOVEDISK
log_must wait_for_removal $TESTPOOL
log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK
log_must zfs remap $TESTPOOL/$TESTFS
#
# Touch one block under each L1 indirect block, so that the other data blocks
# will be remapped to their concrete locations. These parameters assume
# recordsize=512, indirect block size of 128K (1024 block pointers per
# indirect block), and file size of less than 20*1024 blocks (10MB).
#
log_must stride_dd -i /dev/urandom -o $TESTDIR/file -b 512 -c 20 -s 1024
sync_pool $TESTPOOL
sleep 5
sync_pool $TESTPOOL
@@ -1,126 +0,0 @@
#! /bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#
#
# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
# N.B. The 'zfs remap' command has been disabled and may be removed.
export ZFS_REMAP_ENABLED=YES
default_setup_noexit "$DISKS"
function cleanup
{
set_tunable64 zfs_condense_min_mapping_bytes 131072
default_cleanup_noexit
}
log_onexit cleanup
log_must set_tunable64 zfs_condense_min_mapping_bytes 1
log_must zfs set recordsize=512 $TESTPOOL/$TESTFS
#
# Create a large file so that we know some of the blocks will be on the
# removed device, and hence eligible for remapping.
#
log_must dd if=/dev/urandom of=$TESTDIR/file bs=$((2**12)) count=$((2**9))
#
# Randomly rewrite some of blocks in the file so that there will be holes and
# we will not be able to remap the entire file in a few huge chunks.
#
for i in $(seq $((2**12))); do
#
# We have to sync periodically so that all the writes don't end up in
# the same txg. If they were all in the same txg, only the last write
# would go through and we would not have as many allocations to
# fragment the file.
#
((i % 100 > 0 )) || sync_pool || log_fail "Could not sync."
random_write $TESTDIR/file $((2**9)) || \
log_fail "Could not random write."
done
#
# Remap should quietly succeed as a noop before a removal.
#
log_must zfs remap $TESTPOOL/$TESTFS
remaptxg_before=$(zfs get -H -o value remaptxg $TESTPOOL/$TESTFS)
(( $? == 0 )) || log_fail "Could not get remaptxg."
[[ $remaptxg_before == "-" ]] || \
log_fail "remaptxg ($remaptxg_before) had value before a removal"
log_must zpool remove $TESTPOOL $REMOVEDISK
log_must wait_for_removal $TESTPOOL
log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK
#
# remaptxg should not be set if we haven't done a remap.
#
remaptxg_before=$(zfs get -H -o value remaptxg $TESTPOOL/$TESTFS)
(( $? == 0 )) || log_fail "Could not get remaptxg."
[[ $remaptxg_before == "-" ]] || \
log_fail "remaptxg ($remaptxg_before) had value before a removal"
mapping_size_before=$(indirect_vdev_mapping_size $TESTPOOL)
log_must zfs remap $TESTPOOL/$TESTFS
# Try to wait for a condense to finish.
for i in {1..5}; do
sleep 5
sync_pool
done
mapping_size_after=$(indirect_vdev_mapping_size $TESTPOOL)
#
# After the remap, there should not be very many blocks referenced. The reason
# why our threshold is as high as 512 is because our ratio of metadata to
# user data is relatively high, with only 64M of user data on the file system.
#
(( mapping_size_after < mapping_size_before )) || \
log_fail "Mapping size did not decrease after remap: " \
"$mapping_size_before before to $mapping_size_after after."
(( mapping_size_after < 512 )) || \
log_fail "Mapping size not small enough after remap: " \
"$mapping_size_before before to $mapping_size_after after."
#
# After a remap, the remaptxg should be set to a non-zero value.
#
remaptxg_after=$(zfs get -H -o value remaptxg $TESTPOOL/$TESTFS)
(( $? == 0 )) || log_fail "Could not get remaptxg."
log_note "remap txg after remap is $remaptxg_after"
(( remaptxg_after > 0 )) || log_fail "remaptxg not increased"
#
# Remap should quietly succeed as a noop if there have been no removals since
# the last remap.
#
log_must zfs remap $TESTPOOL/$TESTFS
remaptxg_again=$(zfs get -H -o value remaptxg $TESTPOOL/$TESTFS)
(( $? == 0 )) || log_fail "Could not get remaptxg."
log_note "remap txg after second remap is $remaptxg_again"
(( remaptxg_again == remaptxg_after )) || \
log_fail "remap not noop if there has been no removal"
log_pass "Remapping a fs caused mapping size to decrease."
@@ -21,9 +21,6 @@
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
# N.B. The 'zfs remap' command has been disabled and may be removed.
export ZFS_REMAP_ENABLED=YES
default_setup_noexit "$DISKS"
log_onexit default_cleanup_noexit
@@ -45,7 +42,14 @@ fi
log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK
log_must zdb -cd $TESTPOOL
log_must zfs remap $TESTPOOL/$TESTFS
#
# Touch one block under each L1 indirect block, so that the other data blocks
# will be remapped to their concrete locations. These parameters assume
# recordsize=128K, indirect block size of 128K (1024 block pointers per
# indirect block), and file size of less than 3*1024 blocks (384MB).
#
log_must stride_dd -i /dev/urandom -o $TESTDIR/file -b 131072 -c 3 -s 1024
log_must zdb -cd $TESTPOOL
log_must zfs snapshot $TESTPOOL/$TESTFS@snap-post3
@@ -1,32 +0,0 @@
#! /bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#
#
# Copyright (c) 2015, 2017 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
# N.B. The 'zfs remap' command has been disabled and may be removed.
export ZFS_REMAP_ENABLED=YES
default_setup_noexit "$DISKS"
log_onexit default_cleanup_noexit
test_removal_with_operation zfs remap $TESTPOOL/$TESTFS
log_pass "Can remap a filesystem during removal"