1#!/bin/ksh -p 2# SPDX-License-Identifier: CDDL-1.0 3# 4# CDDL HEADER START 5# 6# The contents of this file are subject to the terms of the 7# Common Development and Distribution License (the "License"). 8# You may not use this file except in compliance with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or https://opensource.org/licenses/CDDL-1.0. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23 24# 25# Copyright (c) 2024 by Lawrence Livermore National Security, LLC. 26# Use is subject to license terms. 27# 28 29# DESCRIPTION: 30# Verify ZFS works on a LUKS-backed pool 31# 32# STRATEGY: 33# 1. Create a LUKS device 34# 2. Make a pool with it 35# 3. Write files to the pool 36# 4. Verify no errors 37 38. $STF_SUITE/include/libtest.shlib 39 40verify_runnable "both" 41 42VDEV=$(mktemp --suffix=luks_sanity) 43TESTPOOL=testpool 44 45function cleanup 46{ 47 log_must zpool destroy $TESTPOOL 48 49 log_must cryptsetup luksClose /dev/mapper/luksdev 50 log_must rm -f $VDEV 51} 52 53log_assert "Verify ZFS on LUKS works" 54log_onexit cleanup 55 56PASS="fdsjfosdijfsdkjsldfjdlk" 57 58# Make a small LUKS device since LUKS formatting takes time and we want to 59# make this test run as quickly as possible. 60truncate -s 100M $VDEV 61 62log_must cryptsetup luksFormat --type luks2 $VDEV <<< $PASS 63log_must cryptsetup luksOpen $VDEV luksdev <<< $PASS 64 65log_must zpool create $TESTPOOL /dev/mapper/luksdev 66 67CPUS=$(get_num_cpus) 68 69# Use these specific size and offset ranges as they often cause errors with 70# https://github.com/openzfs/zfs/issues/16631 71# and we want to try to test for that. 72for SIZE in {70..100} ; do 73 for OFF in {70..100} ; do 74 for i in {1..$CPUS} ; do 75 dd if=/dev/urandom of=/$TESTPOOL/file$i-bs$SIZE-off$OFF \ 76 seek=$OFF bs=$SIZE count=1 &>/dev/null & 77 done 78 wait 79 done 80 sync_pool $TESTPOOL 81 rm -f /$TESTPOOL/file* 82done 83 84# Verify no read/write/checksum errors. Don't use JSON here so that we could 85# could potentially backport this test case to the 2.2.x branch. 86if zpool status -e | grep -q "luksdev" ; then 87 log_note "$(zpool status -v)" 88 log_fail "Saw errors writing to LUKS device" 89fi 90 91log_pass "Verified ZFS on LUKS works" 92