From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A2034334A6 for ; Fri, 24 Jul 2026 13:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900040; cv=none; b=d9eFbarcYrW64+vwBDi9dlXk4S+PwFuG8A924EaMSdgEbXNURXyVW3Dfsh9EKK7+xiCfudIDzlgO89DD8YTX2RAtCdNQfVCrYRRcPImvS3CyuoA3mkvcKZa9F7JhA7KXqh5OAnlebj3zjiHOrdCo87dd4ZXFdKliCkVMtMV46KE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900040; c=relaxed/simple; bh=laEx4axiic4Dxy17rHnzvYHy92dzBYUX+3ZvP7qtll8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KGKbiVvxHwIEO//C665PuJKThlZIyum7sOYJ5vKzaJOCAxJUrwcA/mLX/Q/ohgWW7DOgAFsebRXmO41SD87GD5JHd13hJ+5JW9cKAR2a5IbHckN/+LRbK236H6rkynyus4t4EbdDeZf+MiLNV5io9uWGkjgZVgyUfsAj0dD0NuE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=dvrScDRF; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=dvrScDRF; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="dvrScDRF"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="dvrScDRF" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 426FF3F58; Fri, 24 Jul 2026 13:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784900027; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dDkj4/XaZCB/3RGw6WFW1ZhjB+XY1FzxG2VHfm9q1zw=; b=dvrScDRFg7hbmYFkkSATulRQNReIBu8GNs0Pu/CuOutAsHzIIjm0hoCU5C3Jy7kgxa4UdC 2luPawCAxuWOkeFbf72NW4lu+yH/6zQvsGN2xW8VJ8y3lEIkTAKJW3essZISgWp6pzWaPf aHpxBN/s5kCz0oY7VFa3Bvjj12CSQ/k= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784900027; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dDkj4/XaZCB/3RGw6WFW1ZhjB+XY1FzxG2VHfm9q1zw=; b=dvrScDRFg7hbmYFkkSATulRQNReIBu8GNs0Pu/CuOutAsHzIIjm0hoCU5C3Jy7kgxa4UdC 2luPawCAxuWOkeFbf72NW4lu+yH/6zQvsGN2xW8VJ8y3lEIkTAKJW3essZISgWp6pzWaPf aHpxBN/s5kCz0oY7VFa3Bvjj12CSQ/k= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B3A18779BA; Fri, 24 Jul 2026 13:33:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 6FkaHLppY2pIJgAAD6G6ig (envelope-from ); Fri, 24 Jul 2026 13:33:46 +0000 From: Daniel Vacek To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, zlang@redhat.com, hch@infradead.org, djwong@kernel.org, David Sterba , Daniel Vacek , linux-fscrypt@vger.kernel.org, Sweet Tea Dorminy Subject: [PATCH 06/12] btrfs: add simple test of reflink of encrypted data Date: Fri, 24 Jul 2026 15:33:22 +0200 Message-ID: <20260724133328.1837318-7-neelx@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260724133328.1837318-1-neelx@suse.com> References: <20260724133328.1837318-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_TWELVE(0.00)[12]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:helo] From: Sweet Tea Dorminy Make sure that we succeed at reflinking encrypted data. Test deliberately numbered with a high number so it won't conflict with tests between now and merge. v1: An array overflow bug in btrfs_check_encrypted_read_bio() was hidden during fscrypt v6 32/43 patch development until the file size was extended to more than 144k (16k + 64k + >64k a.k.a. BTRFS_MAX_BLOCKSIZE - it was 33k before). We simply needed more pages in the game to run out of the array. Even-though the bug was fixed in v7, it may be useful to keep this test checking, just to be sure nothing similar happens in the future. Signed-off-by: Daniel Vacek --- tests/btrfs/613 | 54 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/613.out | 13 +++++++++++ 2 files changed, 67 insertions(+) create mode 100755 tests/btrfs/613 create mode 100644 tests/btrfs/613.out diff --git a/tests/btrfs/613 b/tests/btrfs/613 new file mode 100755 index 00000000..fddb9243 --- /dev/null +++ b/tests/btrfs/613 @@ -0,0 +1,54 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 613 +# +# Check if reflinking one encrypted file on btrfs succeeds. +# +. ./common/preamble +_begin_fstest auto encrypt + +# Import common functions. +. ./common/encrypt +. ./common/filter +. ./common/reflink + +_require_test +_require_scratch +_require_cp_reflink +_require_scratch_encryption -v 2 +_require_command "$KEYCTL_PROG" keyctl + +_scratch_mkfs_encrypted &>> $seqres.full +_scratch_mount + +dir=$SCRATCH_MNT/dir +mkdir $dir +_set_encpolicy $dir $TEST_KEY_IDENTIFIER +_add_enckey $SCRATCH_MNT "$TEST_RAW_KEY" +echo "Creating and reflinking a file" +$XFS_IO_PROG -t -f -c "pwrite 0 145k" $dir/test > /dev/null +cp --reflink=always $dir/test $dir/test2 + +echo "Can't reflink encrypted and unencrypted" +cp --reflink=always $dir/test $SCRATCH_MNT/fail |& _filter_scratch + +echo "Diffing the file and its copy" +diff $dir/test $dir/test2 + +echo "Verifying the files are reflinked" +_verify_reflink $dir/test $dir/test2 + +echo "Diffing the files after remount" +_scratch_cycle_mount +_add_enckey $SCRATCH_MNT "$TEST_RAW_KEY" +diff $dir/test $dir/test2 + +echo "Diffing the files after key remove" +_rm_enckey $SCRATCH_MNT $TEST_KEY_IDENTIFIER +diff $dir/test $dir/test2 |& _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/btrfs/613.out b/tests/btrfs/613.out new file mode 100644 index 00000000..4895d6dd --- /dev/null +++ b/tests/btrfs/613.out @@ -0,0 +1,13 @@ +QA output created by 613 +Added encryption key with identifier 69b2f6edeee720cce0577937eb8a6751 +Creating and reflinking a file +Can't reflink encrypted and unencrypted +cp: failed to clone 'SCRATCH_MNT/fail' from 'SCRATCH_MNT/dir/test': Invalid argument +Diffing the file and its copy +Verifying the files are reflinked +Diffing the files after remount +Added encryption key with identifier 69b2f6edeee720cce0577937eb8a6751 +Diffing the files after key remove +Removed encryption key with identifier 69b2f6edeee720cce0577937eb8a6751 +diff: SCRATCH_MNT/dir/test: No such file or directory +diff: SCRATCH_MNT/dir/test2: No such file or directory -- 2.53.0