1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2019 by Tim Chase. All rights reserved. 19# Copyright (c) 2019 Lawrence Livermore National Security, LLC. 20# Copyright 2019 Joyent, Inc. 21# 22 23. $STF_SUITE/include/libtest.shlib 24. $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib 25 26# 27# DESCRIPTION: 28# Trimming does not cause file corruption. 29# 30# STRATEGY: 31# 1. Create a one-disk pool. 32# 2. Write data to the pool. 33# 3. Start trimming and verify that trimming is active. 34# 4. Write more data to the pool. 35# 5. Export the pool and use zdb to validate checksums. 36# 37 38function cleanup 39{ 40 if poolexists $TESTPOOL; then 41 destroy_pool $TESTPOOL 42 fi 43 44 if [[ -d "$TESTDIR" ]]; then 45 rm -rf "$TESTDIR" 46 fi 47} 48log_onexit cleanup 49 50LARGESIZE=$((MINVDEVSIZE * 4)) 51LARGEFILE="$TESTDIR/largefile" 52 53log_must mkdir "$TESTDIR" 54log_must truncate -s $LARGESIZE "$LARGEFILE" 55log_must zpool create $TESTPOOL "$LARGEFILE" 56 57log_must dd if=/dev/urandom of=/$TESTPOOL/file1 bs=1048576 count=64 58sync_all_pools 59log_must zpool trim $TESTPOOL 60 61[[ -z "$(trim_progress $TESTPOOL $LARGEFILE)" ]] && \ 62 log_fail "Trimming did not start" 63 64log_must dd if=/dev/urandom of=/$TESTPOOL/file2 bs=1048576 count=64 65sync_all_pools 66 67log_must zpool export $TESTPOOL 68log_must zdb -e -p "$TESTDIR" -cc $TESTPOOL 69 70log_pass "Trimming does not corrupt existing or new data" 71