Linux-FSCrypt Archive mirror
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@kernel.org>
To: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Cc: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	kernel-team@meta.com, ebiggers@google.com, anand.jain@oracle.com,
	linux-fscrypt@vger.kernel.org, fsverity@lists.linux.dev,
	zlang@kernel.org
Subject: Re: [RFC PATCH 8/8] btrfs: add simple test of reflink of encrypted data
Date: Mon, 3 Jul 2023 18:12:48 +0100	[thread overview]
Message-ID: <CAL3q7H6TM-0a6aaJz6SNdU5Ke28Fk-TMeS1zS47H=KSNGfxkXQ@mail.gmail.com> (raw)
In-Reply-To: <dbf938dfa6828b9307759c89a48237b16dbcb5a3.1688076612.git.sweettea-kernel@dorminy.me>

On Thu, Jun 29, 2023 at 11:26 PM Sweet Tea Dorminy
<sweettea-kernel@dorminy.me> wrote:
>
> 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.
> ---
>  tests/btrfs/613     | 62 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/613.out | 13 ++++++++++
>  2 files changed, 75 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..93c209c4
> --- /dev/null
> +++ b/tests/btrfs/613
> @@ -0,0 +1,62 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2023 YOUR NAME HERE.  All Rights Reserved.

Don't forget to fill this...

> +#
> +# 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
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +
> +_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 33k" $dir/test > /dev/null

Why the -t (truncate)? We are creating the file on a brand new fs.

> +sync

What's this sync for? The reflink code flushes delalloc (for both
source and destination inodes, always).
Is this really necessary? If so please add a comment explaining why
it's needed, otherwise remove it.

> +cp --reflink=always $dir/test $dir/test2
> +sync

Same here. What is this sync for?
Please add a comment explaining why it's needed, otherwise remove it.

Thanks.

> +
> +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"
> +echo 2 > /proc/sys/vm/drop_caches
> +_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.40.1
>

      reply	other threads:[~2023-07-03 17:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 22:17 [RFC PATCH 0/8] fstests: add btrfs encryption testing Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 1/8] common/encrypt: separate data and inode nonces Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 2/8] common/encrypt: add btrfs to get_encryption_*nonce Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 3/8] common/encrypt: add btrfs to get_ciphertext_filename Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 4/8] common/encrypt: enable making a encrypted btrfs filesystem Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 5/8] generic/613: write some actual data for btrfs Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 6/8] tests: adjust encryption tests for extent encryption Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 7/8] common/verity: explicitly don't allow btrfs encryption Sweet Tea Dorminy
2023-06-29 22:17 ` [RFC PATCH 8/8] btrfs: add simple test of reflink of encrypted data Sweet Tea Dorminy
2023-07-03 17:12   ` Filipe Manana [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL3q7H6TM-0a6aaJz6SNdU5Ke28Fk-TMeS1zS47H=KSNGfxkXQ@mail.gmail.com' \
    --to=fdmanana@kernel.org \
    --cc=anand.jain@oracle.com \
    --cc=ebiggers@google.com \
    --cc=fstests@vger.kernel.org \
    --cc=fsverity@lists.linux.dev \
    --cc=kernel-team@meta.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=sweettea-kernel@dorminy.me \
    --cc=zlang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).