From patchwork Tue Nov 14 06:48:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 13454896 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83DF98F5F for ; Tue, 14 Nov 2023 06:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JCFVlgJm" Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2176D43; Mon, 13 Nov 2023 22:49:04 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40891d38e3fso38862855e9.1; Mon, 13 Nov 2023 22:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699944543; x=1700549343; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bw0h9gFXlZYYMDHGobY26F6HHIbyTIfb69sBhweoBmw=; b=JCFVlgJmMHYsbRwngAoN4N6B3ds0+cOUq8RVqavwvigtno+yYJkba4PYllb3XBZ01E kpUd49+vyedB4g8fDWdykAAhmQZIm6zxxzYOdfz01rov3Z3D9PVHPnesongG8JHMWAmd W12l8wbrQ6bMwIBTZrOEkDyM9t+hoXhXfZzI/jXVFL0y/q6aPfprKhb70pHX54hG/3pt p7X3OBGWBKl0C6LnU7wGvz00Ca6VSs2huTjvPsS8EaHqRrORY4J9++ypMikiHtl+nau5 kwXffftnlmU3wD4czUOrNVKXws8wkZ7hjG/bZZPd5gzvCQB+kqyo0QI7QsIoU71DwVfh 4uKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699944543; x=1700549343; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bw0h9gFXlZYYMDHGobY26F6HHIbyTIfb69sBhweoBmw=; b=i4Z6mCKfV7FbZZbqGxnDa6E5EgVWQc9U/HVYlb75XmNlmUdotui7P/70Hn3noqbb1K vQBaUg442gl4AqOJoQwQslGwkq0X+DO6b/R+n3MJNUxvwuJJ04fzxbg5TXPgidOJmwZw vvU8s1sRY52jMJaM02eG6nptCzBF6m3b2tzUNSzhHgshvyMAMrv7orAD0EBrKWIrzGGe LpXe9lqLYYp5jIG+dfzwP+IQ4p+3fzboqxZZqQX2wlY1JjsEP37F8/b3pvQ7e5MlDJ0O svQygAfEyrtyZLpks37wmUO2rf4GBi8t1rmf4eQGrQhcYrEunnvvh2KqdsEJJNOd0rxr kPHA== X-Gm-Message-State: AOJu0Ywy9lrv98WBq938LnIQe+0adxVWffNe5ddugwk8eAfHa4IyoKV9 SKJpHbnHELzbXv7KAdSKETU= X-Google-Smtp-Source: AGHT+IENpBhZ9V0b1CXRsl+YBWoS+SiQyksRgsBF8/9Kxiqiu7fVx1JLCFhFFASiyd4pYlByH7ACVQ== X-Received: by 2002:a05:600c:3b91:b0:405:3455:e1a3 with SMTP id n17-20020a05600c3b9100b004053455e1a3mr6977846wms.17.1699944542568; Mon, 13 Nov 2023 22:49:02 -0800 (PST) Received: from amir-ThinkPad-T480.lan ([5.29.249.86]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c469100b004064e3b94afsm16338917wmo.4.2023.11.13.22.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 22:49:02 -0800 (PST) From: Amir Goldstein To: Zorro Lang Cc: Alexander Larsson , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/4] overlay: Add tests for nesting private xattrs Date: Tue, 14 Nov 2023 08:48:54 +0200 Message-Id: <20231114064857.1666718-2-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114064857.1666718-1-amir73il@gmail.com> References: <20231114064857.1666718-1-amir73il@gmail.com> Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alexander Larsson If overlayfs xattr escaping is supported, ensure: * We can create "overlay.*" xattrs on a file in the overlayfs * We can create an xwhiteout file in the overlayfs We check for nesting support by trying to getattr an "overlay.*" xattr in an overlayfs mount, which will return ENOSUPP in older kernels. Signed-off-by: Alexander Larsson Signed-off-by: Amir Goldstein --- common/overlay | 12 +++ tests/overlay/084 | 169 ++++++++++++++++++++++++++++++++++++++++++ tests/overlay/084.out | 61 +++++++++++++++ 3 files changed, 242 insertions(+) create mode 100755 tests/overlay/084 create mode 100644 tests/overlay/084.out diff --git a/common/overlay b/common/overlay index 7004187f..f6017e4e 100644 --- a/common/overlay +++ b/common/overlay @@ -201,6 +201,18 @@ _require_scratch_overlay_features() _scratch_unmount } +_require_scratch_overlay_xattr_escapes() +{ + _scratch_mkfs > /dev/null 2>&1 + _overlay_scratch_mount_dirs $OVL_BASE_SCRATCH_MNT/$OVL_LOWER $OVL_BASE_SCRATCH_MNT/$OVL_UPPER $OVL_BASE_SCRATCH_MNT/$OVL_WORK -o rw + + touch $SCRATCH_MNT/file + (getfattr -n trusted.overlay.foo $SCRATCH_MNT/file 2>&1 | grep -q "not supported") && \ + _notrun "xattr escaping is not supported by overlay" + + _scratch_unmount +} + _require_scratch_overlay_verity() { local lowerdirs="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER:$OVL_BASE_SCRATCH_MNT/$OVL_LOWER" diff --git a/tests/overlay/084 b/tests/overlay/084 new file mode 100755 index 00000000..ff451f38 --- /dev/null +++ b/tests/overlay/084 @@ -0,0 +1,169 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 Red Hat, Inc. All Rights Reserved. +# Copyright (C) 2023 CTERA Networks. All Rights Reserved. +# +# FS QA Test No. 084 +# +# Test advanded nesting functionallity +# +. ./common/preamble +_begin_fstest auto quick nested + +# Override the default cleanup function. +_cleanup() +{ + cd / + # Unmount nested mounts if things fail + $UMOUNT_PROG $OVL_BASE_SCRATCH_MNT/nested 2>/dev/null + rm -rf $tmp +} + +# Import common functions. +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs overlay +# We use non-default scratch underlying overlay dirs, we need to check +# them explicity after test. +_require_scratch_nocheck +_require_scratch_overlay_xattr_escapes + +# remove all files from previous tests +_scratch_mkfs + +lowerdir=$OVL_BASE_SCRATCH_MNT/lower +middir=$OVL_BASE_SCRATCH_MNT/mid +upperdir=$OVL_BASE_SCRATCH_MNT/upper +workdir=$OVL_BASE_SCRATCH_MNT/workdir +nesteddir=$OVL_BASE_SCRATCH_MNT/nested + +umount_overlay() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +test_escape() +{ + local prefix=$1 + + echo -e "\n== Check xattr escape $prefix ==" + + local extra_options="" + if [ "$prefix" == "user" ]; then + extra_options="-o userxattr" + fi + + _scratch_mkfs + mkdir -p $lowerdir $middir $upperdir $workdir $nesteddir + + _overlay_scratch_mount_dirs $lowerdir $middir $workdir $extra_options + + mkdir -p $SCRATCH_MNT/layer1/dir/ $SCRATCH_MNT/layer2/dir + + touch $SCRATCH_MNT/layer1/dir/file + + # Make layer2/dir an opaque file + # Only one of these will be escaped, but both should succeed + setfattr -n user.overlay.opaque -v "y" $SCRATCH_MNT/layer2/dir + setfattr -n trusted.overlay.opaque -v "y" $SCRATCH_MNT/layer2/dir + + getfattr -m "overlay\\." --absolute-names -d $SCRATCH_MNT/layer2/dir | _filter_scratch + + umount_overlay + + getfattr -m "overlay\\." --absolute-names -d $middir/layer2/dir | _filter_scratch + + # Remount as lower and try again + _overlay_scratch_mount_dirs $middir:$lowerdir $upperdir $workdir $extra_options + + getfattr -m "overlay\\." --absolute-names -d $SCRATCH_MNT/layer2/dir | _filter_scratch + + # Recursively mount and ensure the opaque dir is working with both trusted and user xattrs + echo "nested xattr mount with trusted.overlay" + _overlay_mount_dirs $SCRATCH_MNT/layer2:$SCRATCH_MNT/layer1 - - overlayfs $nesteddir + stat $nesteddir/dir/file 2>&1 | _filter_scratch + $UMOUNT_PROG $nesteddir + + echo "nested xattr mount with user.overlay" + _overlay_mount_dirs $SCRATCH_MNT/layer2:$SCRATCH_MNT/layer1 - - -o userxattr overlayfs $nesteddir + stat $nesteddir/dir/file 2>&1 | _filter_scratch + $UMOUNT_PROG $nesteddir + + # Also ensure propagate the escaped xattr when we copy-up layer2/dir + echo "copy-up of escaped xattrs" + touch $SCRATCH_MNT/layer2/dir/other_file + getfattr -m "$prefix.overlay\\.overlay" --absolute-names -d $upperdir/layer2/dir | _filter_scratch + + umount_overlay +} + +test_escape trusted +test_escape user + +do_test_xwhiteout() +{ + local prefix=$1 + local basedir=$2 + + local extra_options="" + if [ "$prefix" == "user" ]; then + extra_options="-o userxattr" + fi + + mkdir -p $basedir/lower $basedir/upper $basedir/work + touch $basedir/lower/regular $basedir/lower/hidden $basedir/upper/hidden + setfattr -n $prefix.overlay.whiteouts -v "y" $basedir/upper + setfattr -n $prefix.overlay.whiteout -v "y" $basedir/upper/hidden + + # Test the hidden is invisible + _overlay_scratch_mount_dirs $basedir/upper:$basedir/lower - - $extra_options + ls $SCRATCH_MNT + stat $SCRATCH_MNT/hidden 2>&1 | _filter_scratch + umount_overlay +} + +# Validate that xwhiteouts work like whiteouts +test_xwhiteout() +{ + local prefix=$1 + + echo -e "\n== Check xwhiteout $prefix ==" + + _scratch_mkfs + + do_test_xwhiteout $prefix $OVL_BASE_SCRATCH_MNT +} + +test_xwhiteout trusted +test_xwhiteout user + +# Validate that (escaped) xwhiteouts work inside a nested overlayfs mount +test_escaped_xwhiteout() +{ + local prefix=$1 + + echo -e "\n== Check escaped xwhiteout $prefix ==" + + local extra_options="" + if [ "$prefix" == "user" ]; then + extra_options="-o userxattr" + fi + + _scratch_mkfs + mkdir -p $lowerdir $upperdir $workdir $nesteddir + + _overlay_mount_dirs $lowerdir $upperdir $workdir $extra_options overlayfs $nesteddir + + do_test_xwhiteout $prefix $nesteddir + + $UMOUNT_PROG $nesteddir +} + +test_escaped_xwhiteout trusted +test_escaped_xwhiteout user + +# success, all done +status=0 +exit diff --git a/tests/overlay/084.out b/tests/overlay/084.out new file mode 100644 index 00000000..54b890de --- /dev/null +++ b/tests/overlay/084.out @@ -0,0 +1,61 @@ +QA output created by 084 + +== Check xattr escape trusted == +# file: SCRATCH_MNT/layer2/dir +trusted.overlay.opaque="y" +user.overlay.opaque="y" + +# file: SCRATCH_DEV/mid/layer2/dir +trusted.overlay.overlay.opaque="y" +user.overlay.opaque="y" + +# file: SCRATCH_MNT/layer2/dir +trusted.overlay.opaque="y" +user.overlay.opaque="y" + +nested xattr mount with trusted.overlay +stat: cannot statx 'SCRATCH_DEV/nested/dir/file': No such file or directory +nested xattr mount with user.overlay +stat: cannot statx 'SCRATCH_DEV/nested/dir/file': No such file or directory +copy-up of escaped xattrs +# file: SCRATCH_DEV/upper/layer2/dir +trusted.overlay.overlay.opaque="y" + + +== Check xattr escape user == +# file: SCRATCH_MNT/layer2/dir +trusted.overlay.opaque="y" +user.overlay.opaque="y" + +# file: SCRATCH_DEV/mid/layer2/dir +trusted.overlay.opaque="y" +user.overlay.overlay.opaque="y" + +# file: SCRATCH_MNT/layer2/dir +trusted.overlay.opaque="y" +user.overlay.opaque="y" + +nested xattr mount with trusted.overlay +stat: cannot statx 'SCRATCH_DEV/nested/dir/file': No such file or directory +nested xattr mount with user.overlay +stat: cannot statx 'SCRATCH_DEV/nested/dir/file': No such file or directory +copy-up of escaped xattrs +# file: SCRATCH_DEV/upper/layer2/dir +user.overlay.overlay.opaque="y" + + +== Check xwhiteout trusted == +regular +stat: cannot statx 'SCRATCH_MNT/hidden': No such file or directory + +== Check xwhiteout user == +regular +stat: cannot statx 'SCRATCH_MNT/hidden': No such file or directory + +== Check escaped xwhiteout trusted == +regular +stat: cannot statx 'SCRATCH_MNT/hidden': No such file or directory + +== Check escaped xwhiteout user == +regular +stat: cannot statx 'SCRATCH_MNT/hidden': No such file or directory From patchwork Tue Nov 14 06:48:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 13454897 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 538BD8F7D for ; Tue, 14 Nov 2023 06:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JOzitWkC" Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1397D45; Mon, 13 Nov 2023 22:49:05 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40806e4106dso30391835e9.1; Mon, 13 Nov 2023 22:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699944544; x=1700549344; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zZVf9DL80qWypckzs4NLQwWSEKE0rR0qyUo3ts621uw=; b=JOzitWkCIssFtQT3mj7X4bnYuwBEDT0jDpLYFmJUZFO8eJx4kXMjlduJfxajNJC4xe UypwKyP/V28FzOKb3q9rv1Pa8Kk+yxqyrqQHGrT8zZRTtwZq/XLqsUqD4Mj/O5jrIpLj LIiKq508y0X4aaElVRBNlvnCcV+P0R8sJPpS9dMdec0H/6AgwRrxPNxkVdDgXYRiVCGd XSWRxF6Vt53SF/ghgO3q6/DXlOYduSXSoU69L7yFoVi4Tn9X8oT2jgRz8HJ2lYvRxyVn 7d+PedQo2KoGUWyXABDkgWG+U2c8f6CVnCSDau1efJAHIiUS4sZwLaptfrZnOpSRxxPt CFxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699944544; x=1700549344; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zZVf9DL80qWypckzs4NLQwWSEKE0rR0qyUo3ts621uw=; b=AOCZWl8cHaB6B8w0K28d2htq1m4JuMXR5/K2F1GupgxQQgcG+i/5jNJDhPh1Jh5wtf UjKil5qM1X7ObUA4UxisGb8g8Rx5lNqUxi5icra4YnFOrTgOkpu/frsRRskgyEwL0s3w B3R/+5pa6O85obQc5aZX+vDxcPRN1JABYs/9Ty0YfqkenPxXWAMG68jFyn+ZZv7g04yN j41KbofLTUFmHGB3wEZaAyn0Cm7W3HER4p4RjrRyaRCGm8sCTCdiHf6L+AtcuSjokF/N WyU9OAnDGNuS6rdkQAMUjPHe098qXLZmUiYPGrlWzPQx75u8kHbIgUISXF/auGZ30pvK Af5g== X-Gm-Message-State: AOJu0YzimDYrnGQA7SDoz/J+gRx2f10hKGVoFzui7mjqNUU3h4jcnHQR Ef+UOzdtv6YMoW95J2okLuY= X-Google-Smtp-Source: AGHT+IFFUa9cl6KjETzEdj4z5z/fDAwA8G5TNwtsksKeaBA5Zol86thIKCOgCoPRvhOtAMKKVRsoYQ== X-Received: by 2002:a05:600c:5390:b0:407:73fc:6818 with SMTP id hg16-20020a05600c539000b0040773fc6818mr1244712wmb.2.1699944543996; Mon, 13 Nov 2023 22:49:03 -0800 (PST) Received: from amir-ThinkPad-T480.lan ([5.29.249.86]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c469100b004064e3b94afsm16338917wmo.4.2023.11.13.22.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 22:49:03 -0800 (PST) From: Amir Goldstein To: Zorro Lang Cc: Alexander Larsson , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 2/4] overlay: prepare for new lowerdir+,datadir+ tests Date: Tue, 14 Nov 2023 08:48:55 +0200 Message-Id: <20231114064857.1666718-3-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114064857.1666718-1-amir73il@gmail.com> References: <20231114064857.1666718-1-amir73il@gmail.com> Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation to forking tests for new lowerdir+,datadir+ mount options, prepare a helper to test kernel support and pass datadirs into mount helpers in overlay/079 test. Signed-off-by: Amir Goldstein --- common/overlay | 15 +++++++++++++++ tests/overlay/079 | 36 +++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/common/overlay b/common/overlay index f6017e4e..028019ce 100644 --- a/common/overlay +++ b/common/overlay @@ -240,6 +240,21 @@ _require_scratch_overlay_lowerdata_layers() _scratch_unmount } +# Check kernel support for lowerdir+=,datadir+= format +_require_scratch_overlay_lowerdir_add_layers() +{ + local lowerdir="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER" + local datadir="$OVL_BASE_SCRATCH_MNT/$OVL_LOWER" + + _scratch_mkfs > /dev/null 2>&1 + $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o"lowerdir+=$lowerdir,datadir+=$datadir" \ + -o"redirect_dir=follow,metacopy=on" > /dev/null 2>&1 || \ + _notrun "overlay lowerdir+,datadir+ not supported on ${SCRATCH_DEV}" + + _scratch_unmount +} + # Helper function to check underlying dirs of overlay filesystem _overlay_fsck_dirs() { diff --git a/tests/overlay/079 b/tests/overlay/079 index 77f94598..078ee816 100755 --- a/tests/overlay/079 +++ b/tests/overlay/079 @@ -139,16 +139,21 @@ check_file_size_contents() mount_overlay() { - local _lowerdir=$1 + local _lowerdir=$1 _datadir2=$2 _datadir=$3 - _overlay_scratch_mount_dirs "$_lowerdir" $upperdir $workdir -o redirect_dir=on,index=on,metacopy=on + $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o"lowerdir=$_lowerdir::$_datadir2::$_datadir" \ + -o"upperdir=$upperdir,workdir=$workdir" \ + -o redirect_dir=on,metacopy=on } mount_ro_overlay() { - local _lowerdir=$1 + local _lowerdir=$1 _datadir2=$2 _datadir=$3 - _overlay_scratch_mount_dirs "$_lowerdir" "-" "-" -o ro,redirect_dir=follow,metacopy=on + $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o"lowerdir=$_lowerdir::$_datadir2::$_datadir" \ + -o redirect_dir=follow,metacopy=on } umount_overlay() @@ -160,14 +165,14 @@ test_no_access() { local _target=$1 - mount_ro_overlay "$lowerdir::$datadir2::$datadir" + mount_ro_overlay "$lowerdir" "$datadir2" "$datadir" stat $SCRATCH_MNT/$_target >> $seqres.full 2>&1 || \ echo "No access to lowerdata layer $_target" echo "Unmount and Mount rw" umount_overlay - mount_overlay "$lowerdir::$datadir2::$datadir" + mount_overlay "$lowerdir" "$datadir2" "$datadir" stat $SCRATCH_MNT/$_target >> $seqres.full 2>&1 || \ echo "No access to lowerdata layer $_target" umount_overlay @@ -175,11 +180,12 @@ test_no_access() test_common() { - local _lowerdirs=$1 _target=$2 _size=$3 _blocks=$4 _data="$5" - local _redirect=$6 + local _lowerdir=$1 _datadir2=$2 _datadir=$3 + local _target=$4 _size=$5 _blocks=$6 _data="$7" + local _redirect=$8 echo "Mount ro" - mount_ro_overlay $_lowerdirs + mount_ro_overlay $_lowerdir $_datadir2 $_datadir # Check redirect xattr to lowerdata [ -n "$_redirect" ] && check_redirect $lowerdir/$_target "$_redirect" @@ -191,7 +197,7 @@ test_common() # Do a mount cycle and check size and contents again. echo "Unmount and Mount rw" umount_overlay - mount_overlay $_lowerdirs + mount_overlay $_lowerdir $_datadir2 $_datadir echo "check properties of metadata copied up file $_target" check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" check_file_blocks $SCRATCH_MNT/$_target $_blocks @@ -203,7 +209,7 @@ test_common() check_file_size_contents $upperdir/$_target $_size "" # Trigger data copy up and check absence of metacopy xattr. - mount_overlay $_lowerdirs + mount_overlay $_lowerdir $_datadir2 $_datadir $XFS_IO_PROG -c "falloc 0 1" $SCRATCH_MNT/$_target >> $seqres.full echo "check properties of data copied up file $_target" check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" @@ -216,7 +222,7 @@ test_lazy() { local _target=$1 - mount_overlay "$lowerdir::$datadir2::$datadir" + mount_overlay "$lowerdir" "$datadir2" "$datadir" # Metadata should be valid check_file_size $SCRATCH_MNT/$_target $datasize @@ -305,12 +311,12 @@ test_no_access "$sharedname" echo -e "\n== Check follow to lowerdata layer with absolute redirect ==" prepare_midlayer "/subdir/$dataname" -test_common "$lowerdir::$datadir2::$datadir" "$dataname" $datasize $datablocks \ +test_common "$lowerdir" "$datadir2" "$datadir" "$dataname" $datasize $datablocks \ "$datacontent" "/subdir/$dataname" -test_common "$lowerdir::$datadir2::$datadir" "$dataname2" $datasize $datablocks \ +test_common "$lowerdir" "$datadir2" "$datadir" "$dataname2" $datasize $datablocks \ "$datacontent2" "/subdir/$dataname.2" # Shared file should be picked from upper datadir -test_common "$lowerdir::$datadir2::$datadir" "$sharedname" $datasize $datablocks \ +test_common "$lowerdir" "$datadir2" "$datadir" "$sharedname" $datasize $datablocks \ "$datacontent2" "/subdir/$dataname.shared" echo -e "\n== Check lazy follow to lowerdata layer ==" From patchwork Tue Nov 14 06:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 13454898 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DCE8BE4D for ; Tue, 14 Nov 2023 06:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a9OGFM/a" Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BE6D44; Mon, 13 Nov 2023 22:49:07 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c788f5bf53so56912291fa.2; Mon, 13 Nov 2023 22:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699944545; x=1700549345; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5UfDXBa14ns5s9JcVo9HU0xMCh1R5d4DPkqc4xRiVgY=; b=a9OGFM/aePGbKPeFlJlh9xltSivYbc8Ue38wKfKtaU7enkJC+SLApKZ/ROfFylW8M+ 2m0APSqIfPW7/2UfTik3QMrZeYyGnuv3zULoAxJ21qoW7BiW+Q3Hp313YOFXwmyQgu8r V4ZF+Jov6zpX3uHaeqtnccd1G/sRsktzWvv/ueetKjFR8BRmdzBXXBr4QGbRWDlEQf1x 6ynG4XfTLGcdyOC+U5CJpFKg8KikxNOSuy/mT5M0UoEbMcApOuoj+bHyeJEZPsTeXSkq zdG8XYGCGfgc4ZCWbuddvr+NbIySjzn3x06LCyQpigskoJqUv1VVc/8Pr9uKaX7Zj7FG 5fQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699944545; x=1700549345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5UfDXBa14ns5s9JcVo9HU0xMCh1R5d4DPkqc4xRiVgY=; b=YcIke5095I49dFAUxukVF/wLjGec1miRdsKUTRTzdZ2NBzM4yNEcCJORihTMN9S9rn 3S6fiR8JvfyKPC3ov4o7rXiQ0p8SgNi1raOIS1Erh9j1LlOPvVxvYJq0j43BzG/8jL11 M1x5SEFtWXZkQNizAY2iSwn2n8LURuMRluFcWaHTb3UP8ykPIVeE4HnBuye9xaYp/ajY gzbmGfjcnT7anFSfC3YoEIypGHNL4fzB6twdpxo7OnjQpPgxKN4GoGOcIec0wdVJZVnI 4eFO9EkiCJCAwdZNmEMqsfBR1wGSHdtoSfulVR53s2D8IdtWfLAtzZ15kybaC/WkkhI7 8mCA== X-Gm-Message-State: AOJu0YzvqULJICIMsAhQchudgUpnfSdGaAndaGlNmVpT/rdaGbhQvwYG LuBlT0rx2ukB1BVlnJlGZu2rnsFHyV8= X-Google-Smtp-Source: AGHT+IG1Qgl2rxQj3BTLgKKZ8o+tUUk2rKmNJNGOXNC4YoyeiK78kMDViMF1AvcB+MrYbDop6jVgBQ== X-Received: by 2002:a05:651c:332:b0:2b6:fa3f:9230 with SMTP id b18-20020a05651c033200b002b6fa3f9230mr854767ljp.46.1699944545282; Mon, 13 Nov 2023 22:49:05 -0800 (PST) Received: from amir-ThinkPad-T480.lan ([5.29.249.86]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c469100b004064e3b94afsm16338917wmo.4.2023.11.13.22.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 22:49:04 -0800 (PST) From: Amir Goldstein To: Zorro Lang Cc: Alexander Larsson , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 3/4] overlay: test data-only lowerdirs with datadir+ mount option Date: Tue, 14 Nov 2023 08:48:56 +0200 Message-Id: <20231114064857.1666718-4-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114064857.1666718-1-amir73il@gmail.com> References: <20231114064857.1666718-1-amir73il@gmail.com> Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fork test overlay/079 to use the new lowerdir+,datadir+ mount options. Signed-off-by: Amir Goldstein --- tests/overlay/085 | 332 ++++++++++++++++++++++++++++++++++++++++++ tests/overlay/085.out | 42 ++++++ 2 files changed, 374 insertions(+) create mode 100755 tests/overlay/085 create mode 100644 tests/overlay/085.out diff --git a/tests/overlay/085 b/tests/overlay/085 new file mode 100755 index 00000000..07a32c24 --- /dev/null +++ b/tests/overlay/085 @@ -0,0 +1,332 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2018 Red Hat, Inc. All Rights Reserved. +# Copyright (C) 2023 CTERA Networks. All Rights Reserved. +# +# FS QA Test No. 085 +# +# Test data-only layers functionality. +# This is a variant of test overlay/079 with lowerdir+,datadir+ mount options +# +. ./common/preamble +_begin_fstest auto quick metacopy redirect prealloc + +# Import common functions. +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs overlay +# We use non-default scratch underlying overlay dirs, we need to check +# them explicity after test. +_require_scratch_nocheck +_require_scratch_overlay_features redirect_dir metacopy +_require_scratch_overlay_lowerdir_add_layers +_require_xfs_io_command "falloc" + +# remove all files from previous tests +_scratch_mkfs + +# File size on lower +dataname="datafile" +sharedname="shared" +datacontent="data" +dataname2="datafile2" +datacontent2="data2" +datasize="4096" + +# Number of blocks allocated by filesystem on lower. Will be queried later. +datarblocks="" +datarblocksize="" +estimated_datablocks="" + +udirname="pureupper" +ufile="upperfile" + +# Check metacopy xattr +check_metacopy() +{ + local target=$1 exist=$2 + local out_f target_f + local msg + + out_f=$(_getfattr --absolute-names --only-values -n \ + $OVL_XATTR_METACOPY $target 2>&1 | _filter_scratch) + + if [ "$exist" == "y" ];then + [ "$out_f" == "" ] && return + echo "Metacopy xattr does not exist on ${target}. stdout=$out_f" + return + fi + + if [ "$out_f" == "" ];then + echo "Metacopy xattr exists on ${target} unexpectedly." + return + fi + + target_f=`echo $target | _filter_scratch` + msg="$target_f: trusted.overlay.metacopy: No such attribute" + + [ "$out_f" == "$msg" ] && return + + echo "Error while checking xattr on ${target}. stdout=$out" +} + +# Check redirect xattr +check_redirect() +{ + local target=$1 + local expect=$2 + + value=$(_getfattr --absolute-names --only-values -n \ + $OVL_XATTR_REDIRECT $target) + + [[ "$value" == "$expect" ]] || echo "Redirect xattr incorrect. Expected=\"$expect\", actual=\"$value\"" +} + +# Check size +check_file_size() +{ + local target=$1 expected_size=$2 actual_size + + actual_size=$(_get_filesize $target) + + [ "$actual_size" == "$expected_size" ] || echo "Expected file size $expected_size but actual size is $actual_size" +} + +check_file_blocks() +{ + local target=$1 expected_blocks=$2 nr_blocks + + nr_blocks=$(stat -c "%b" $target) + + [ "$nr_blocks" == "$expected_blocks" ] || echo "Expected $expected_blocks blocks but actual number of blocks is ${nr_blocks}." +} + +check_file_contents() +{ + local target=$1 expected=$2 + local actual target_f + + target_f=`echo $target | _filter_scratch` + + read actual<$target + + [ "$actual" == "$expected" ] || echo "Expected file $target_f contents to be \"$expected\" but actual contents are \"$actual\"" +} + +check_no_file_contents() +{ + local target=$1 + local actual target_f out_f + + target_f=`echo $target | _filter_scratch` + out_f=`cat $target 2>&1 | _filter_scratch` + msg="cat: $target_f: No such file or directory" + + [ "$out_f" == "$msg" ] && return + + echo "$target_f unexpectedly has content" +} + + +check_file_size_contents() +{ + local target=$1 expected_size=$2 expected_content=$3 + + check_file_size $target $expected_size + check_file_contents $target $expected_content +} + +mount_overlay() +{ + local _lowerdir=$1 _datadir2=$2 _datadir=$3 + + $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o"lowerdir+=$_lowerdir,datadir+=$_datadir2,datadir+=$_datadir" \ + -o"upperdir=$upperdir,workdir=$workdir" \ + -o redirect_dir=on,metacopy=on +} + +mount_ro_overlay() +{ + local _lowerdir=$1 _datadir2=$2 _datadir=$3 + + $MOUNT_PROG -t overlay $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT \ + -o"lowerdir+=$_lowerdir,datadir+=$_datadir2,datadir+=$_datadir" \ + -o redirect_dir=follow,metacopy=on +} + +umount_overlay() +{ + $UMOUNT_PROG $SCRATCH_MNT +} + +test_no_access() +{ + local _target=$1 + + mount_ro_overlay "$lowerdir" "$datadir2" "$datadir" + + stat $SCRATCH_MNT/$_target >> $seqres.full 2>&1 || \ + echo "No access to lowerdata layer $_target" + + echo "Unmount and Mount rw" + umount_overlay + mount_overlay "$lowerdir" "$datadir2" "$datadir" + stat $SCRATCH_MNT/$_target >> $seqres.full 2>&1 || \ + echo "No access to lowerdata layer $_target" + umount_overlay +} + +test_common() +{ + local _lowerdir=$1 _datadir2=$2 _datadir=$3 + local _target=$4 _size=$5 _blocks=$6 _data="$7" + local _redirect=$8 + + echo "Mount ro" + mount_ro_overlay $_lowerdir $_datadir2 $_datadir + + # Check redirect xattr to lowerdata + [ -n "$_redirect" ] && check_redirect $lowerdir/$_target "$_redirect" + + echo "check properties of metadata copied up file $_target" + check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" + check_file_blocks $SCRATCH_MNT/$_target $_blocks + + # Do a mount cycle and check size and contents again. + echo "Unmount and Mount rw" + umount_overlay + mount_overlay $_lowerdir $_datadir2 $_datadir + echo "check properties of metadata copied up file $_target" + check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" + check_file_blocks $SCRATCH_MNT/$_target $_blocks + + # Trigger metadata copy up and check existence of metacopy xattr. + chmod 400 $SCRATCH_MNT/$_target + umount_overlay + check_metacopy $upperdir/$_target "y" + check_file_size_contents $upperdir/$_target $_size "" + + # Trigger data copy up and check absence of metacopy xattr. + mount_overlay $_lowerdir $_datadir2 $_datadir + $XFS_IO_PROG -c "falloc 0 1" $SCRATCH_MNT/$_target >> $seqres.full + echo "check properties of data copied up file $_target" + check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" + umount_overlay + check_metacopy $upperdir/$_target "n" + check_file_size_contents $upperdir/$_target $_size "$_data" +} + +test_lazy() +{ + local _target=$1 + + mount_overlay "$lowerdir" "$datadir2" "$datadir" + + # Metadata should be valid + check_file_size $SCRATCH_MNT/$_target $datasize + check_file_blocks $SCRATCH_MNT/$_target $estimated_datablocks + + # But have no content + check_no_file_contents $SCRATCH_MNT/$_target + + umount_overlay +} + +create_basic_files() +{ + _scratch_mkfs + mkdir -p $datadir/subdir $datadir2/subdir $lowerdir $lowerdir2 $upperdir $workdir $workdir2 + mkdir -p $upperdir/$udirname + echo "$datacontent" > $datadir/$dataname + chmod 600 $datadir/$dataname + echo "$datacontent2" > $datadir2/$dataname2 + chmod 600 $datadir2/$dataname2 + + echo "$datacontent" > $datadir/$sharedname + echo "$datacontent2" > $datadir2/$sharedname + chmod 600 $datadir/$sharedname $datadir2/$sharedname + + # Create files of size datasize. + for f in $datadir/$dataname $datadir2/$dataname2 $datadir/$sharedname $datadir2/$sharedname; do + $XFS_IO_PROG -c "falloc 0 $datasize" $f + $XFS_IO_PROG -c "fsync" $f + done + + # Query number of block + datablocks=$(stat -c "%b" $datadir/$dataname) + + # For lazy lookup file the block count is estimated based on size and block size + datablocksize=$(stat -c "%B" $datadir/$dataname) + estimated_datablocks=$(( ($datasize + $datablocksize - 1)/$datablocksize )) +} + +prepare_midlayer() +{ + local _redirect=$1 + + _scratch_mkfs + create_basic_files + if [ -n "$_redirect" ]; then + mv "$datadir/$dataname" "$datadir/$_redirect" + mv "$datadir2/$dataname2" "$datadir2/$_redirect.2" + mv "$datadir/$sharedname" "$datadir/$_redirect.shared" + mv "$datadir2/$sharedname" "$datadir2/$_redirect.shared" + fi + # Create midlayer + _overlay_scratch_mount_dirs $datadir2:$datadir $lowerdir $workdir2 -o redirect_dir=on,index=on,metacopy=on + # Trigger a metacopy with or without redirect + if [ -n "$_redirect" ]; then + mv "$SCRATCH_MNT/$_redirect" "$SCRATCH_MNT/$dataname" + mv "$SCRATCH_MNT/$_redirect.2" "$SCRATCH_MNT/$dataname2" + mv "$SCRATCH_MNT/$_redirect.shared" "$SCRATCH_MNT/$sharedname" + else + chmod 400 $SCRATCH_MNT/$dataname + chmod 400 $SCRATCH_MNT/$dataname2 + chmod 400 $SCRATCH_MNT/$sharedname + fi + umount_overlay +} + +# Create test directories +datadir=$OVL_BASE_SCRATCH_MNT/data +datadir2=$OVL_BASE_SCRATCH_MNT/data2 +lowerdir=$OVL_BASE_SCRATCH_MNT/lower +upperdir=$OVL_BASE_SCRATCH_MNT/upper +workdir=$OVL_BASE_SCRATCH_MNT/workdir +workdir2=$OVL_BASE_SCRATCH_MNT/workdir2 + +echo -e "\n== Check no follow to lowerdata layer without redirect ==" +prepare_midlayer +test_no_access "$dataname" +test_no_access "$dataname2" +test_no_access "$sharedname" + +echo -e "\n== Check no follow to lowerdata layer with relative redirect ==" +prepare_midlayer "$dataname.renamed" +test_no_access "$dataname" +test_no_access "$dataname2" +test_no_access "$sharedname" + +echo -e "\n== Check follow to lowerdata layer with absolute redirect ==" +prepare_midlayer "/subdir/$dataname" +test_common "$lowerdir" "$datadir2" "$datadir" "$dataname" $datasize $datablocks \ + "$datacontent" "/subdir/$dataname" +test_common "$lowerdir" "$datadir2" "$datadir" "$dataname2" $datasize $datablocks \ + "$datacontent2" "/subdir/$dataname.2" +# Shared file should be picked from upper datadir +test_common "$lowerdir" "$datadir2" "$datadir" "$sharedname" $datasize $datablocks \ + "$datacontent2" "/subdir/$dataname.shared" + +echo -e "\n== Check lazy follow to lowerdata layer ==" + +prepare_midlayer "/subdir/$dataname" +rm $datadir/subdir/$dataname +test_lazy $dataname + + +# success, all done +status=0 +exit diff --git a/tests/overlay/085.out b/tests/overlay/085.out new file mode 100644 index 00000000..4b9b2d7c --- /dev/null +++ b/tests/overlay/085.out @@ -0,0 +1,42 @@ +QA output created by 085 + +== Check no follow to lowerdata layer without redirect == +No access to lowerdata layer datafile +Unmount and Mount rw +No access to lowerdata layer datafile +No access to lowerdata layer datafile2 +Unmount and Mount rw +No access to lowerdata layer datafile2 +No access to lowerdata layer shared +Unmount and Mount rw +No access to lowerdata layer shared + +== Check no follow to lowerdata layer with relative redirect == +No access to lowerdata layer datafile +Unmount and Mount rw +No access to lowerdata layer datafile +No access to lowerdata layer datafile2 +Unmount and Mount rw +No access to lowerdata layer datafile2 +No access to lowerdata layer shared +Unmount and Mount rw +No access to lowerdata layer shared + +== Check follow to lowerdata layer with absolute redirect == +Mount ro +check properties of metadata copied up file datafile +Unmount and Mount rw +check properties of metadata copied up file datafile +check properties of data copied up file datafile +Mount ro +check properties of metadata copied up file datafile2 +Unmount and Mount rw +check properties of metadata copied up file datafile2 +check properties of data copied up file datafile2 +Mount ro +check properties of metadata copied up file shared +Unmount and Mount rw +check properties of metadata copied up file shared +check properties of data copied up file shared + +== Check lazy follow to lowerdata layer == From patchwork Tue Nov 14 06:48:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 13454899 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3061BE66 for ; Tue, 14 Nov 2023 06:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UUG1I55J" Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36589D48; Mon, 13 Nov 2023 22:49:08 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40839807e82so30440065e9.0; Mon, 13 Nov 2023 22:49:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699944546; x=1700549346; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=95nE7bWkcx0d4JSLcoybDbaWzT7WMYnwMt3WPJsD1uM=; b=UUG1I55JdQxFS7mrt/gtvt/Yub5T2ytjMEZzfPqu/C8cCmnR6ZZ5p13Y0YdwsBnint q1iNc0px+y1eKlQya/xXHU1RHfBUlqLO9E9MKp4qtM3H9B5+93pFFQ5wLm27mIG8TfWx 8xhikawYmuMIxcS/tKgzpVGBGV5M/prxcrFgrMxcqMJaXvOianw1qXQbZgz+bB5UbKKm R87HLc03xwcTp3mQ+4Q57MSKldq9XcrYRS9KsWhSIvDyqNzgde3oMN2Bg54Z96eLDjtA XLf31tJYGOcFXP8W+uojDYrzZ/LIE7oOEbrXViGjt6QDX3Xlx4cqb14cfOw8K/ewK0VW pj7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699944546; x=1700549346; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=95nE7bWkcx0d4JSLcoybDbaWzT7WMYnwMt3WPJsD1uM=; b=izl2H+iS4k3+u1AEXYnaYrrAsQylD6afo3RnB7hGAf+Ib9plYaX8ESoY05EZLDG3eR CqMp8H0CJrsZozx5p9l5kOc0EWqD1TxvicGvR106u32KPeYKMDSMX81LwfXYZnxb9UUv fJuxmRzJ6StavGgG34GEX5Ah24kyRgAFCh82z5qDLejFzeqo62shPptCJIIOYMoCtKzQ 8wPGW3G6fyuoAfz14lTwW7+atRoYZWkhOOZgq+MqRryQclUfyqtYEWIdgHxA3ARU3PsF C93NvQzeEYk2uy7Lq1qV+ZOws+h3Qf8R1VeCKFCifZzimaZQfMmrWm1IH6JsbvK7082g jdaQ== X-Gm-Message-State: AOJu0Ywy3f5nsctzaMvkAWiHCvomeCxbyc8/iiBkbr1kmKgqfQw2TQDd z79ylghKSztKaBQjbv1vI6xoaObhJyA= X-Google-Smtp-Source: AGHT+IH53CFYDggJu1XNd+9A2KSlmatUnwJOwLprt9QmK8LQPk5WTqAOfNUKAVhk3G0bNH9bOUu4AA== X-Received: by 2002:a05:600c:1f88:b0:406:51a0:17ea with SMTP id je8-20020a05600c1f8800b0040651a017eamr1362610wmb.10.1699944546373; Mon, 13 Nov 2023 22:49:06 -0800 (PST) Received: from amir-ThinkPad-T480.lan ([5.29.249.86]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c469100b004064e3b94afsm16338917wmo.4.2023.11.13.22.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 22:49:06 -0800 (PST) From: Amir Goldstein To: Zorro Lang Cc: Alexander Larsson , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 4/4] overlay: test parsing of lowerdir+,datadir+ mount options Date: Tue, 14 Nov 2023 08:48:57 +0200 Message-Id: <20231114064857.1666718-5-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231114064857.1666718-1-amir73il@gmail.com> References: <20231114064857.1666718-1-amir73il@gmail.com> Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fork test overlay/083 to test parsing of lowerdir+,datadir+ mount options. Signed-off-by: Amir Goldstein --- tests/overlay/086 | 81 +++++++++++++++++++++++++++++++++++++++++++ tests/overlay/086.out | 2 ++ 2 files changed, 83 insertions(+) create mode 100755 tests/overlay/086 create mode 100644 tests/overlay/086.out diff --git a/tests/overlay/086 b/tests/overlay/086 new file mode 100755 index 00000000..b5960517 --- /dev/null +++ b/tests/overlay/086 @@ -0,0 +1,81 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 CTERA Networks. All Rights Reserved. +# +# FS QA Test 086 +# +# Test lowerdir+,datadir+ mount option restrictions. +# + +. ./common/preamble +_begin_fstest auto quick mount + +# Import common functions. +. ./common/filter + +# real QA test starts here +_supported_fs overlay + +# _overlay_check_* helpers do not handle special chars well +_require_scratch_nocheck +_require_scratch_overlay_lowerdir_add_layers + +# Remove all files from previous tests +_scratch_mkfs + +# Create lowerdirs with special characters +lowerdir_spaces="$OVL_BASE_SCRATCH_MNT/lower1 with spaces" +lowerdir_colons="$OVL_BASE_SCRATCH_MNT/lower2:with::colons" +lowerdir_colons_esc="$OVL_BASE_SCRATCH_MNT/lower2\:with\:\:colons" +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK +mkdir -p "$lowerdir_spaces" "$lowerdir_colons" + +# _overlay_mount_* helpers do not handle lowerdir+,datadir+, so execute mount directly. + +# check illegal combinations and order of lowerdir,lowerdir+,datadir+ +$MOUNT_PROG -t overlay none $SCRATCH_MNT \ + -o"lowerdir=$lowerdir,lowerdir+=$lowerdir_colons" \ + 2>> $seqres.full && \ + echo "ERROR: invalid combination of lowerdir and lowerdir+ mount options" + +$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null + +$MOUNT_PROG -t overlay none $SCRATCH_MNT \ + -o"lowerdir=$lowerdir,datadir+=$lowerdir_colons" \ + -o redirect_dir=follow,metacopy=on 2>> $seqres.full && \ + echo "ERROR: invalid combination of lowerdir and datadir+ mount options" + +$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null + +$MOUNT_PROG -t overlay none $SCRATCH_MNT \ + -o"datadir+=$lowerdir,lowerdir+=$lowerdir_colons" \ + -o redirect_dir=follow,metacopy=on 2>> $seqres.full && \ + echo "ERROR: invalid order of lowerdir+ and datadir+ mount options" + +$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null + +# mount is expected to fail with escaped colons. +$MOUNT_PROG -t overlay none $SCRATCH_MNT \ + -o"lowerdir+=$lowerdir_colons_esc" \ + 2>> $seqres.full && \ + echo "ERROR: incorrect parsing of escaped colons in lowerdir+ mount option" + +$UMOUNT_PROG $SCRATCH_MNT 2>/dev/null + +# mount is expected to succeed without escaped colons. +$MOUNT_PROG -t overlay ovl_esc_test $SCRATCH_MNT \ + -o"lowerdir+=$lowerdir_colons,datadir+=$lowerdir_spaces" \ + -o redirect_dir=follow,metacopy=on \ + 2>&1 | tee -a $seqres.full + +# if spaces are not escaped when showing mount options, +# mount command will not show the word 'spaces' after the spaces +$MOUNT_PROG -t overlay | grep ovl_esc_test | tee -a $seqres.full | \ + grep -q 'datadir+'.*spaces || \ + echo "ERROR: escaped spaces truncated from datadir+ mount option" + +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/086.out b/tests/overlay/086.out new file mode 100644 index 00000000..b34758fd --- /dev/null +++ b/tests/overlay/086.out @@ -0,0 +1,2 @@ +QA output created by 086 +Silence is golden