]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_secure.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_trim / zpool_trim_secure.ksh
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 #
21
22 . $STF_SUITE/include/libtest.shlib
23 . $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib
24
25 #
26 # DESCRIPTION:
27 #       Verify 'zpool trim -d' secure trim.
28 #
29 # STRATEGY:
30 #       1. Create a pool on a single file vdev.
31 #       2. Run 'zpool trim -d' to securely TRIM allocated space maps.
32 #       3. Verify it fails when using a file vdev.
33 #
34 # NOTE: Currently secure discard cannot be verified using file vdevs,
35 # loopback, or scsi_debug devices.  None of which support the feature.
36 # It can only be tested using real SSDs which provide support.
37 #
38
39 function cleanup
40 {
41         if poolexists $TESTPOOL; then
42                 destroy_pool $TESTPOOL
43         fi
44
45         if [[ -d "$TESTDIR" ]]; then
46                 rm -rf "$TESTDIR"
47         fi
48 }
49 log_onexit cleanup
50
51 LARGESIZE=$((MINVDEVSIZE * 4))
52 LARGEFILE="$TESTDIR/largefile"
53
54 log_must mkdir "$TESTDIR"
55 log_must truncate -s $LARGESIZE "$LARGEFILE"
56 log_must zpool create $TESTPOOL "$LARGEFILE"
57 log_mustnot zpool trim -d $TESTPOOL
58
59 log_pass "Manual 'zpool trim -d' failed as expected for file vdevs"