diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh index bdbf3db53336..9342cbe880ae 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh @@ -1,114 +1,114 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib # # DESCRIPTION: # Verify 'zpool trim' partial trim. # # STRATEGY: # 1. Create a pool on a single disk and mostly fill it. # 2. Expand the pool to create new unallocated metaslabs. # 3. Run 'zpool trim' to only TRIM allocated space maps. # 4. Verify the disk is least 90% of its original size. # 5. Run 'zpool trim' to perform a full TRIM. # 6. Verify the disk is less than 10% of its original size. function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi if [[ -d "$TESTDIR" ]]; then rm -rf "$TESTDIR" fi log_must set_tunable64 TRIM_METASLAB_SKIP 0 log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min log_must set_tunable64 VDEV_MIN_MS_COUNT $vdev_min_ms_count } log_onexit cleanup LARGESIZE=$((MINVDEVSIZE * 4)) LARGEFILE="$TESTDIR/largefile" # The minimum number of metaslabs is increased in order to simulate the # behavior of partial trimming on a more typically sized 1TB disk. typeset vdev_min_ms_count=$(get_tunable VDEV_MIN_MS_COUNT) log_must set_tunable64 VDEV_MIN_MS_COUNT 64 # Minimum trim size is decreased to verify all trim sizes. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 log_must mkdir "$TESTDIR" log_must truncate -s $LARGESIZE "$LARGEFILE" log_must zpool create -O compression=off $TESTPOOL "$LARGEFILE" log_must mkfile $(( floor(LARGESIZE * 0.80) )) /$TESTPOOL/file sync_all_pools new_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must test $new_size -le $LARGESIZE log_must test $new_size -gt $(( floor(LARGESIZE * 0.70) )) # Expand the pool to create new unallocated metaslabs. log_must zpool export $TESTPOOL log_must dd if=/dev/urandom of=$LARGEFILE conv=notrunc,nocreat \ seek=$((LARGESIZE / (1024 * 1024))) bs=$((1024 * 1024)) \ count=$((3 * LARGESIZE / (1024 * 1024))) log_must zpool import -d $TESTDIR $TESTPOOL log_must zpool online -e $TESTPOOL "$LARGEFILE" new_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must test $new_size -gt $((4 * floor(LARGESIZE * 0.70) )) # Perform a partial trim, we expect it to skip most of the new metaslabs # which have never been used and therefore do not need be trimmed. log_must set_tunable64 TRIM_METASLAB_SKIP 1 log_must zpool trim $TESTPOOL log_must set_tunable64 TRIM_METASLAB_SKIP 0 sync_all_pools while [[ "$(trim_progress $TESTPOOL $LARGEFILE)" -lt "100" ]]; do sleep 0.5 done new_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must test $new_size -gt $LARGESIZE # Perform a full trim, all metaslabs will be trimmed the pool vdev # size will be reduced but not down to its original size due to the # space usage of the new metaslabs. log_must zpool trim $TESTPOOL sync_all_pools while [[ "$(trim_progress $TESTPOOL $LARGEFILE)" -lt "100" ]]; do sleep 0.5 done new_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must test $new_size -le $(( 2 * LARGESIZE)) log_must test $new_size -gt $(( floor(LARGESIZE * 0.70) )) log_pass "Manual 'zpool trim' successfully partially trimmed pool" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_verify_trimmed.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_verify_trimmed.ksh index d5aaf49aebc5..41d1decd13ce 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_verify_trimmed.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_verify_trimmed.ksh @@ -1,81 +1,81 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib . $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib # # DESCRIPTION: # After trimming, the disk is actually trimmed. # # STRATEGY: # 1. Create a one-disk pool using a sparse file. # 2. Initialize the pool and verify the file vdev is no longer sparse. # 3. Trim the pool and verify the file vdev is again sparse. # function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi if [[ -d "$TESTDIR" ]]; then rm -rf "$TESTDIR" fi log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min } log_onexit cleanup LARGESIZE=$((MINVDEVSIZE * 4)) LARGEFILE="$TESTDIR/largefile" # Reduce trim size to allow for tighter tolerance below when checking. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 log_must mkdir "$TESTDIR" log_must truncate -s $LARGESIZE "$LARGEFILE" log_must zpool create $TESTPOOL "$LARGEFILE" original_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must zpool initialize $TESTPOOL while [[ "$(initialize_progress $TESTPOOL $LARGEFILE)" -lt "100" ]]; do sleep 0.5 done new_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must within_tolerance $new_size $LARGESIZE $((128 * 1024 * 1024)) log_must zpool trim $TESTPOOL while [[ "$(trim_progress $TESTPOOL $LARGEFILE)" -lt "100" ]]; do sleep 0.5 done new_size=$(du -B1 "$LARGEFILE" | cut -f1) log_must within_tolerance $new_size $original_size $((128 * 1024 * 1024)) log_pass "Trimmed appropriate amount of disk space" diff --git a/tests/zfs-tests/tests/functional/trim/autotrim_config.ksh b/tests/zfs-tests/tests/functional/trim/autotrim_config.ksh index c97772585737..4dba4616e947 100755 --- a/tests/zfs-tests/tests/functional/trim/autotrim_config.ksh +++ b/tests/zfs-tests/tests/functional/trim/autotrim_config.ksh @@ -1,110 +1,110 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/trim/trim.kshlib . $STF_SUITE/tests/functional/trim/trim.cfg # # DESCRIPTION: # Check various pool geometries stripe, mirror, raidz) # # STRATEGY: # 1. Create a pool on file vdevs to trim. # 2. Set 'autotrim=on' on pool. # 3. Fill the pool to a known percentage of capacity. # 4. Verify the vdevs contain 75% or more allocated blocks. # 5. Remove all files making it possible to trim the entire pool. # 6. Wait for auto trim to issue trim IOs for the free blocks. # 7. Verify the disks contain 30% or less allocated blocks. # 8. Repeat for test for striped, mirrored, and RAIDZ pools. verify_runnable "global" log_assert "Set 'autotrim=on' verify pool disks were trimmed" function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi log_must rm -f $TRIM_VDEVS log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch log_must set_tunable64 VDEV_MIN_MS_COUNT $vdev_min_ms_count } log_onexit cleanup # Minimum trim size is decreased to verify all trim sizes. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 # Reduced TRIM_TXG_BATCH to make trimming more frequent. typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) log_must set_tunable64 TRIM_TXG_BATCH 8 # Increased metaslabs to better simulate larger more realistic devices. typeset vdev_min_ms_count=$(get_tunable VDEV_MIN_MS_COUNT) log_must set_tunable64 VDEV_MIN_MS_COUNT 32 typeset VDEV_MAX_MB=$(( floor(4 * MINVDEVSIZE * 0.75 / 1024 / 1024) )) typeset VDEV_MIN_MB=$(( floor(4 * MINVDEVSIZE * 0.30 / 1024 / 1024) )) for type in "" "mirror" "raidz2" "draid"; do if [[ "$type" = "" ]]; then VDEVS="$TRIM_VDEV1" elif [[ "$type" = "mirror" ]]; then VDEVS="$TRIM_VDEV1 $TRIM_VDEV2" elif [[ "$type" = "raidz2" ]]; then VDEVS="$TRIM_VDEV1 $TRIM_VDEV2 $TRIM_VDEV3" elif [[ "$type" = "draid" ]]; then VDEVS="$TRIM_VDEV1 $TRIM_VDEV2 $TRIM_VDEV3 $TRIM_VDEV4" # The per-vdev utilization is lower due to the capacity # resilverd for the distributed spare. VDEV_MAX_MB=$(( floor(4 * MINVDEVSIZE * 0.50 / 1024 / 1024) )) fi log_must truncate -s $((4 * MINVDEVSIZE)) $VDEVS log_must zpool create -f $TESTPOOL $VDEVS log_must zpool set autotrim=on $TESTPOOL typeset availspace=$(get_prop available $TESTPOOL) typeset fill_mb=$(( floor(availspace * 0.90 / 1024 / 1024) )) # Fill the pool, verify the vdevs are no longer sparse. file_write -o create -f /$TESTPOOL/file -b 1048576 -c $fill_mb -d R sync_pool $TESTPOOL verify_vdevs "-ge" "$VDEV_MAX_MB" $VDEVS # Remove the file, wait for trim, verify the vdevs are now sparse. log_must rm /$TESTPOOL/file wait_trim_io $TESTPOOL "ind" 64 verify_vdevs "-le" "$VDEV_MIN_MB" $VDEVS log_must zpool destroy $TESTPOOL log_must rm -f $VDEVS done log_pass "Auto trim successfully shrunk vdevs" diff --git a/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh b/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh index e25390339b6c..e139809105df 100755 --- a/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh +++ b/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh @@ -1,87 +1,87 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/trim/trim.kshlib . $STF_SUITE/tests/functional/trim/trim.cfg # # DESCRIPTION: # Verify automatic trim pool data integrity. # # STRATEGY: # 1. Create a pool on sparse file vdevs to trim. # 2. Set autotrim=on to enable asynchronous pool trimming. # 3. Generate some interesting pool data which can be trimmed. # 4. Verify trim IOs of the expected type were issued for the pool. # 5. Verify data integrity of the pool after trim. # 6. Repeat test for striped, mirrored, and RAIDZ pools. verify_runnable "global" log_assert "Set 'autotrim=on' pool property verify pool data integrity" function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi log_must rm -f $TRIM_VDEVS log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch } log_onexit cleanup # Minimum trim size is decreased to verify all trim sizes. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 # Reduced TRIM_TXG_BATCH to make trimming more frequent. typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) log_must set_tunable64 TRIM_TXG_BATCH 8 for type in "" "mirror" "raidz" "draid"; do log_must truncate -s 1G $TRIM_VDEVS log_must zpool create -f $TESTPOOL $type $TRIM_VDEVS log_must zpool set autotrim=on $TESTPOOL # Add and remove data from the pool in a random fashion in order # to generate a variety of interesting ranges to be auto trimmed. for n in {0..10}; do dir="/$TESTPOOL/autotrim-$((RANDOM % 5))" filesize=$((4096 + ((RANDOM * 691) % 131072) )) log_must rm -rf $dir log_must fill_fs $dir 10 10 $filesize 1 R sync_all_pools done log_must du -hs /$TESTPOOL verify_trim_io $TESTPOOL "ind" 10 verify_pool $TESTPOOL log_must zpool destroy $TESTPOOL log_must rm -f $TRIM_VDEVS done log_pass "Automatic trim successfully validated" diff --git a/tests/zfs-tests/tests/functional/trim/autotrim_trim_integrity.ksh b/tests/zfs-tests/tests/functional/trim/autotrim_trim_integrity.ksh index ae7ad8d73dd8..53de485b1a8e 100755 --- a/tests/zfs-tests/tests/functional/trim/autotrim_trim_integrity.ksh +++ b/tests/zfs-tests/tests/functional/trim/autotrim_trim_integrity.ksh @@ -1,92 +1,92 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/trim/trim.kshlib . $STF_SUITE/tests/functional/trim/trim.cfg # # DESCRIPTION: # Verify automatic trim and manual trim coexist correctly. # # STRATEGY: # 1. Create a pool on sparse file vdevs to trim. # 2. Set autotrim=on to enable asynchronous pool trimming. # 3. Generate some interesting pool data which can be trimmed. # 4. While generating data issue manual trims. # 4. Verify trim IOs of the expected type were issued for the pool. # 5. Verify data integrity of the pool after trim. # 6. Repeat test for striped, mirrored, and RAIDZ pools. verify_runnable "global" log_assert "Set 'autotrim=on', run 'zpool trim' and verify pool data integrity" function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi log_must rm -f $TRIM_VDEVS log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch } log_onexit cleanup # Minimum trim size is decreased to verify all trim sizes. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 # Reduced TRIM_TXG_BATCH to make trimming more frequent. typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) log_must set_tunable64 TRIM_TXG_BATCH 8 for type in "" "mirror" "raidz" "raidz2" "draid" "draid2"; do log_must truncate -s 1G $TRIM_VDEVS log_must zpool create -f $TESTPOOL $type $TRIM_VDEVS log_must zpool set autotrim=on $TESTPOOL # Add and remove data from the pool in a random fashion in order # to generate a variety of interesting ranges to be auto trimmed. for n in {0..10}; do dir="/$TESTPOOL/autotrim-$((RANDOM % 5))" filesize=$((4096 + ((RANDOM * 691) % 131072) )) log_must rm -rf $dir log_must fill_fs $dir 10 10 $filesize 1 R sync_all_pools if [[ $((n % 4)) -eq 0 ]]; then log_must timeout 120 zpool trim -w $TESTPOOL fi done log_must du -hs /$TESTPOOL verify_trim_io $TESTPOOL "ind" 10 verify_pool $TESTPOOL log_must zpool destroy $TESTPOOL log_must rm -f $TRIM_VDEVS done log_pass "Automatic trim and manual trim coexistence successfully validated" diff --git a/tests/zfs-tests/tests/functional/trim/trim_config.ksh b/tests/zfs-tests/tests/functional/trim/trim_config.ksh index 6a187a05b579..c08b5edb5698 100755 --- a/tests/zfs-tests/tests/functional/trim/trim_config.ksh +++ b/tests/zfs-tests/tests/functional/trim/trim_config.ksh @@ -1,109 +1,109 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/trim/trim.kshlib . $STF_SUITE/tests/functional/trim/trim.cfg # # DESCRIPTION: # Check various pool geometries stripe, mirror, raidz # # STRATEGY: # 1. Create a pool on file vdevs to trim. # 2. Fill the pool to a known percentage of capacity. # 3. Verify the vdevs contain 75% or more allocated blocks. # 4. Remove all files making it possible to trim the entire pool. # 5. Manually trim the pool. # 6. Wait for trim to issue trim IOs for the free blocks. # 7. Verify the disks contain 30% or less allocated blocks. # 8. Repeat for test for striped, mirrored, and RAIDZ pools. verify_runnable "global" log_assert "Run 'zpool trim' verify pool disks were trimmed" function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi log_must rm -f $TRIM_VDEVS log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch log_must set_tunable64 VDEV_MIN_MS_COUNT $vdev_min_ms_count } log_onexit cleanup # Minimum trim size is decreased to verify all trim sizes. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 # Reduced TRIM_TXG_BATCH to make trimming more frequent. typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) log_must set_tunable64 TRIM_TXG_BATCH 8 # Increased metaslabs to better simulate larger more realistic devices. typeset vdev_min_ms_count=$(get_tunable VDEV_MIN_MS_COUNT) log_must set_tunable64 VDEV_MIN_MS_COUNT 32 typeset VDEV_MAX_MB=$(( floor(4 * MINVDEVSIZE * 0.75 / 1024 / 1024) )) typeset VDEV_MIN_MB=$(( floor(4 * MINVDEVSIZE * 0.30 / 1024 / 1024) )) for type in "" "mirror" "raidz2" "draid"; do if [[ "$type" = "" ]]; then VDEVS="$TRIM_VDEV1" elif [[ "$type" = "mirror" ]]; then VDEVS="$TRIM_VDEV1 $TRIM_VDEV2" elif [[ "$type" = "raidz2" ]]; then VDEVS="$TRIM_VDEV1 $TRIM_VDEV2 $TRIM_VDEV3" elif [[ "$type" = "draid" ]]; then VDEVS="$TRIM_VDEV1 $TRIM_VDEV2 $TRIM_VDEV3 $TRIM_VDEV4" # The per-vdev utilization is lower due to the capacity # resilverd for the distributed spare. VDEV_MAX_MB=$(( floor(4 * MINVDEVSIZE * 0.50 / 1024 / 1024) )) fi log_must truncate -s $((4 * MINVDEVSIZE)) $VDEVS log_must zpool create -f $TESTPOOL $type $VDEVS typeset availspace=$(get_prop available $TESTPOOL) typeset fill_mb=$(( floor(availspace * 0.90 / 1024 / 1024) )) # Fill the pool, verify the vdevs are no longer sparse. file_write -o create -f /$TESTPOOL/file -b 1048576 -c $fill_mb -d R sync_pool $TESTPOOL verify_vdevs "-ge" "$VDEV_MAX_MB" $VDEVS # Remove the file, issue trim, verify the vdevs are now sparse. log_must rm /$TESTPOOL/file log_must timeout 120 zpool trim -w $TESTPOOL verify_vdevs "-le" "$VDEV_MIN_MB" $VDEVS log_must zpool destroy $TESTPOOL log_must rm -f $VDEVS done log_pass "Manual trim successfully shrunk vdevs" diff --git a/tests/zfs-tests/tests/functional/trim/trim_integrity.ksh b/tests/zfs-tests/tests/functional/trim/trim_integrity.ksh index 2dff0924f7b1..c67697521ce8 100755 --- a/tests/zfs-tests/tests/functional/trim/trim_integrity.ksh +++ b/tests/zfs-tests/tests/functional/trim/trim_integrity.ksh @@ -1,88 +1,88 @@ #!/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) 2019 by Tim Chase. All rights reserved. # Copyright (c) 2019 Lawrence Livermore National Security, LLC. # . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/trim/trim.kshlib . $STF_SUITE/tests/functional/trim/trim.cfg # # DESCRIPTION: # Verify manual trim pool data integrity. # # STRATEGY: # 1. Create a pool on sparse file vdevs to trim. # 2. Generate some interesting pool data which can be trimmed. # 3. Manually trim the pool. # 4. Verify trim IOs of the expected type were issued for the pool. # 5. Verify data integrity of the pool after trim. # 6. Repeat test for striped, mirrored, and RAIDZ pools. verify_runnable "global" log_assert "Run 'zpool trim' and verify pool data integrity" function cleanup { if poolexists $TESTPOOL; then destroy_pool $TESTPOOL fi log_must rm -f $TRIM_VDEVS log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch } log_onexit cleanup # Minimum trim size is decreased to verify all trim sizes. typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) -log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 512 # Reduced TRIM_TXG_BATCH to make trimming more frequent. typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) log_must set_tunable64 TRIM_TXG_BATCH 8 for type in "" "mirror" "raidz" "draid"; do log_must truncate -s 1G $TRIM_VDEVS log_must zpool create -f $TESTPOOL $type $TRIM_VDEVS # Add and remove data from the pool in a random fashion in order # to generate a variety of interesting ranges to be manually trimmed. for n in {0..10}; do dir="/$TESTPOOL/trim-$((RANDOM % 5))" filesize=$((4096 + ((RANDOM * 691) % 131072) )) log_must rm -rf $dir log_must fill_fs $dir 10 10 $filesize 1 R sync_all_pools done log_must du -hs /$TESTPOOL log_must timeout 120 zpool trim -w $TESTPOOL verify_trim_io $TESTPOOL "ind" 10 verify_pool $TESTPOOL log_must zpool destroy $TESTPOOL log_must rm -f $TRIM_VDEVS done log_pass "Manual trim successfully validated"