Message ID | 669007608d711c1c4f6b8f835affc2660084f76c.1688634271.git.alexl@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | overlayfs: Test data-only upperdirs and fs-verity | expand |
On Thu, Jul 6, 2023 at 11:50 AM <alexl@redhat.com> wrote: > > From: Amir Goldstein <amir73il@gmail.com> > > Add test coverage for following metacopy from lower layer to > lower data with absolute, relative and no redirect. > > Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Alexander Larsson <alexl@redhat.com> > --- > tests/overlay/060 | 43 ++++++++++++++++++++++++++++++++++++++----- > tests/overlay/060.out | 18 ++++++++++++++++++ > 2 files changed, 56 insertions(+), 5 deletions(-) > > diff --git a/tests/overlay/060 b/tests/overlay/060 > index 363207ba..f37755da 100755 > --- a/tests/overlay/060 > +++ b/tests/overlay/060 > @@ -7,7 +7,7 @@ > # Test metadata only copy up functionality. > # > . ./common/preamble > -_begin_fstest auto quick metacopy prealloc > +_begin_fstest auto quick metacopy redirect prealloc > > # Import common functions. > . ./common/filter > @@ -123,6 +123,13 @@ mount_overlay() > _overlay_scratch_mount_dirs "$_lowerdir" $upperdir $workdir -o redirect_dir=on,index=on,metacopy=on > } > > +mount_ro_overlay() > +{ > + local _lowerdir=$1 > + > + _overlay_scratch_mount_dirs "$_lowerdir" "-" "-" -o ro,redirect_dir=follow,metacopy=on > +} > + > umount_overlay() > { > $UMOUNT_PROG $SCRATCH_MNT > @@ -146,7 +153,8 @@ test_common() > check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" > check_file_blocks $SCRATCH_MNT/$_target $_blocks > > - # Make sure copied up file is a metacopy file. > + # 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 "" > @@ -165,7 +173,7 @@ test_common() > create_basic_files() > { > _scratch_mkfs > - mkdir -p $lowerdir $lowerdir2 $upperdir $workdir $workdir2 > + mkdir -p $lowerdir/subdir $lowerdir2 $upperdir $workdir $workdir2 > mkdir -p $upperdir/$udirname > echo "$lowerdata" > $lowerdir/$lowername > chmod 600 $lowerdir/$lowername > @@ -184,12 +192,19 @@ create_lower_link() > > prepare_midlayer() > { > + local _redirect=$1 > + > _scratch_mkfs > create_basic_files > + [ -n "$_redirect" ] && mv "$lowerdir/$lowername" "$lowerdir/$_redirect" > # Create midlayer > _overlay_scratch_mount_dirs $lowerdir $lowerdir2 $workdir2 -o redirect_dir=on,index=on,metacopy=on > - # Trigger a metacopy > - chmod 400 $SCRATCH_MNT/$lowername > + # Trigger a metacopy with or without redirect > + if [ -n "$_redirect" ]; then > + mv "$SCRATCH_MNT/$_redirect" "$SCRATCH_MNT/$lowername" > + else > + chmod 400 $SCRATCH_MNT/$lowername > + fi > umount_overlay > } > > @@ -254,6 +269,24 @@ mount_overlay $lowerdir > mv $SCRATCH_MNT/$lowerlink $SCRATCH_MNT/$ufile > test_common $lowerdir $ufile $lowersize $lowerblocks "$lowerdata" "/$lowerlink" > > +echo -e "\n== Check follow to lowerdata without redirect ==" > +prepare_midlayer > +mount_ro_overlay "$lowerdir2:$lowerdir" > +test_common "$lowerdir2:$lowerdir" $lowername $lowersize $lowerblocks \ > + "$lowerdata" > + > +echo -e "\n== Check follow to lowerdata with relative redirect ==" > +prepare_midlayer "$lowername.renamed" > +mount_ro_overlay "$lowerdir2:$lowerdir" > +test_common "$lowerdir2:$lowerdir" "$lowername" $lowersize $lowerblocks \ > + "$lowerdata" > + > +echo -e "\n== Check follow to lowerdata with absolute redirect ==" > +prepare_midlayer "/subdir/$lowername" > +mount_ro_overlay "$lowerdir2:$lowerdir" > +test_common "$lowerdir2:$lowerdir" "$lowername" $lowersize $lowerblocks \ > + "$lowerdata" > + > # success, all done > status=0 > exit > diff --git a/tests/overlay/060.out b/tests/overlay/060.out > index a4790d31..f4ce0244 100644 > --- a/tests/overlay/060.out > +++ b/tests/overlay/060.out > @@ -40,3 +40,21 @@ check properties of metadata copied up file > Unmount and Mount again > check properties of metadata copied up file > check properties of data copied up file > + > +== Check follow to lowerdata without redirect == > +check properties of metadata copied up file > +Unmount and Mount again > +check properties of metadata copied up file > +check properties of data copied up file > + > +== Check follow to lowerdata with relative redirect == > +check properties of metadata copied up file > +Unmount and Mount again > +check properties of metadata copied up file > +check properties of data copied up file > + > +== Check follow to lowerdata with absolute redirect == > +check properties of metadata copied up file > +Unmount and Mount again > +check properties of metadata copied up file > +check properties of data copied up file > -- > 2.40.1 >
diff --git a/tests/overlay/060 b/tests/overlay/060 index 363207ba..f37755da 100755 --- a/tests/overlay/060 +++ b/tests/overlay/060 @@ -7,7 +7,7 @@ # Test metadata only copy up functionality. # . ./common/preamble -_begin_fstest auto quick metacopy prealloc +_begin_fstest auto quick metacopy redirect prealloc # Import common functions. . ./common/filter @@ -123,6 +123,13 @@ mount_overlay() _overlay_scratch_mount_dirs "$_lowerdir" $upperdir $workdir -o redirect_dir=on,index=on,metacopy=on } +mount_ro_overlay() +{ + local _lowerdir=$1 + + _overlay_scratch_mount_dirs "$_lowerdir" "-" "-" -o ro,redirect_dir=follow,metacopy=on +} + umount_overlay() { $UMOUNT_PROG $SCRATCH_MNT @@ -146,7 +153,8 @@ test_common() check_file_size_contents $SCRATCH_MNT/$_target $_size "$_data" check_file_blocks $SCRATCH_MNT/$_target $_blocks - # Make sure copied up file is a metacopy file. + # 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 "" @@ -165,7 +173,7 @@ test_common() create_basic_files() { _scratch_mkfs - mkdir -p $lowerdir $lowerdir2 $upperdir $workdir $workdir2 + mkdir -p $lowerdir/subdir $lowerdir2 $upperdir $workdir $workdir2 mkdir -p $upperdir/$udirname echo "$lowerdata" > $lowerdir/$lowername chmod 600 $lowerdir/$lowername @@ -184,12 +192,19 @@ create_lower_link() prepare_midlayer() { + local _redirect=$1 + _scratch_mkfs create_basic_files + [ -n "$_redirect" ] && mv "$lowerdir/$lowername" "$lowerdir/$_redirect" # Create midlayer _overlay_scratch_mount_dirs $lowerdir $lowerdir2 $workdir2 -o redirect_dir=on,index=on,metacopy=on - # Trigger a metacopy - chmod 400 $SCRATCH_MNT/$lowername + # Trigger a metacopy with or without redirect + if [ -n "$_redirect" ]; then + mv "$SCRATCH_MNT/$_redirect" "$SCRATCH_MNT/$lowername" + else + chmod 400 $SCRATCH_MNT/$lowername + fi umount_overlay } @@ -254,6 +269,24 @@ mount_overlay $lowerdir mv $SCRATCH_MNT/$lowerlink $SCRATCH_MNT/$ufile test_common $lowerdir $ufile $lowersize $lowerblocks "$lowerdata" "/$lowerlink" +echo -e "\n== Check follow to lowerdata without redirect ==" +prepare_midlayer +mount_ro_overlay "$lowerdir2:$lowerdir" +test_common "$lowerdir2:$lowerdir" $lowername $lowersize $lowerblocks \ + "$lowerdata" + +echo -e "\n== Check follow to lowerdata with relative redirect ==" +prepare_midlayer "$lowername.renamed" +mount_ro_overlay "$lowerdir2:$lowerdir" +test_common "$lowerdir2:$lowerdir" "$lowername" $lowersize $lowerblocks \ + "$lowerdata" + +echo -e "\n== Check follow to lowerdata with absolute redirect ==" +prepare_midlayer "/subdir/$lowername" +mount_ro_overlay "$lowerdir2:$lowerdir" +test_common "$lowerdir2:$lowerdir" "$lowername" $lowersize $lowerblocks \ + "$lowerdata" + # success, all done status=0 exit diff --git a/tests/overlay/060.out b/tests/overlay/060.out index a4790d31..f4ce0244 100644 --- a/tests/overlay/060.out +++ b/tests/overlay/060.out @@ -40,3 +40,21 @@ check properties of metadata copied up file Unmount and Mount again check properties of metadata copied up file check properties of data copied up file + +== Check follow to lowerdata without redirect == +check properties of metadata copied up file +Unmount and Mount again +check properties of metadata copied up file +check properties of data copied up file + +== Check follow to lowerdata with relative redirect == +check properties of metadata copied up file +Unmount and Mount again +check properties of metadata copied up file +check properties of data copied up file + +== Check follow to lowerdata with absolute redirect == +check properties of metadata copied up file +Unmount and Mount again +check properties of metadata copied up file +check properties of data copied up file