From: Josef Bacik <josef@toxicpanda.com>
To: Lee Trager <lee@trager.us>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH v2] fstests: Vertify dir permissions when creating a stub subvolume
Date: Mon, 14 Aug 2023 15:16:37 -0400 [thread overview]
Message-ID: <20230814191637.GA2832769@perftesting> (raw)
In-Reply-To: <20230814051342.3245942-1-lee@trager.us>
On Sun, Aug 13, 2023 at 10:13:42PM -0700, Lee Trager wrote:
> btrfs supports creating nesting subvolumes however snapshots are not
> recurive. When a snapshot is taken of a volume which contains a subvolume
> the subvolume is replaced with a stub subvolume which has the same name and
> uses inode number 2. This test validates that the stub volume copies
> permissions of the original volume.
> Signed-off-by: Lee Trager <lee@trager.us>
> ---
> v2:
> - Migrated _require_unshare from overlay/020 into common_rc. Updated the error
> message as most Linux systems should have unshare from util-linux.
> - Added note about why the test must be done in one subshell process.
> - chown command now uses $qa_user:$qa_group instead of hard coded values.
> common/rc | 6 ++++++
> tests/btrfs/300 | 46 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/300.out | 18 ++++++++++++++++++
> tests/overlay/020 | 7 +------
> 4 files changed, 71 insertions(+), 6 deletions(-)
> create mode 100755 tests/btrfs/300
> create mode 100644 tests/btrfs/300.out
>
> diff --git a/common/rc b/common/rc
> index 5c4429ed..ca7c5c14 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -5224,6 +5224,12 @@ _soak_loop_running() {
> return 0
> }
>
> +
> +_require_unshare() {
> + unshare -f -r -m -p -U true &>/dev/null || \
> + _notrun "unshare $@: not found, should be in util-linux"
> +}
> +
> init_rc
>
> ################################################################################
> diff --git a/tests/btrfs/300 b/tests/btrfs/300
> new file mode 100755
> index 00000000..c86ed268
> --- /dev/null
> +++ b/tests/btrfs/300
> @@ -0,0 +1,46 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Meta Platforms, Inc. All Rights Reserved.
> +#
> +# FS QA Test 300
> +#
> +# Validate that snapshots taken while in a remapped namespace preserve
> +# the permissions of the user.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick subvol snapshot
> +
> +_supported_fs btrfs
> +
> +_require_test
> +_require_user
> +_require_group
> +_require_unix_perm_checking
> +_require_unshare
> +_register_cleanup "cleanup"
> +
> +test_dir="${TEST_DIR}/$(basename $0)"
> +cleanup() {
> + [ -d "$test_dir" ] && rm -rf $test_dir
> +}
> +
> +mkdir $test_dir
> +chown $qa_user:$qa_group $test_dir
> +
> +# _user_do executes each command as $qa_user in its own subshell. unshare
> +# sets the namespace for the running shell. The test must run in one user
> +# subshell to preserve the namespace over multiple commands.
> +_user_do "
> +cd ${test_dir};
> +unshare --user --keep-caps --map-auto --map-root-user;
> +$BTRFS_UTIL_PROG subvolume create subvol;
> +touch subvol/{1,2,3};
> +$BTRFS_UTIL_PROG subvolume create subvol/subsubvol;
> +touch subvol/subsubvol/{4,5,6};
> +$BTRFS_UTIL_PROG subvolume snapshot subvol snapshot;
> +"
> +
> +find $test_dir -printf "%M %u %g %P\n"
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/300.out b/tests/btrfs/300.out
> new file mode 100644
> index 00000000..33b5fb44
> --- /dev/null
> +++ b/tests/btrfs/300.out
> @@ -0,0 +1,18 @@
> +QA output created by 300
> +Create subvolume './subvol'
> +Create subvolume 'subvol/subsubvol'
> +Create a snapshot of 'subvol' in './snapshot'
> +drwxr-xr-x fsgqa fsgqa
There's an extra whitespace here, did it come from the output or is it
extraneous? Either way it should probably be removed. Thanks,
Josef
prev parent reply other threads:[~2023-08-14 19:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 5:13 [PATCH v2] fstests: Vertify dir permissions when creating a stub subvolume Lee Trager
2023-08-14 19:16 ` Josef Bacik [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=20230814191637.GA2832769@perftesting \
--to=josef@toxicpanda.com \
--cc=fstests@vger.kernel.org \
--cc=lee@trager.us \
/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