diff mbox series

[v2,2/4] xfs: add parent pointer test

Message ID 20221012013812.82161-3-catherine.hoang@oracle.com (mailing list archive)
State New, archived
Headers show
Series xfstests: add parent pointer tests | expand

Commit Message

Catherine Hoang Oct. 12, 2022, 1:38 a.m. UTC
From: Allison Henderson <allison.henderson@oracle.com>

Add a test to verify basic parent pointers operations (create, move, link,
unlink, rename, overwrite).

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
---
 doc/group-names.txt |   1 +
 tests/xfs/554       | 125 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/554.out   |  59 +++++++++++++++++++++
 3 files changed, 185 insertions(+)
 create mode 100755 tests/xfs/554
 create mode 100644 tests/xfs/554.out

Comments

Zorro Lang Oct. 12, 2022, 3:02 a.m. UTC | #1
On Tue, Oct 11, 2022 at 06:38:10PM -0700, Catherine Hoang wrote:
> From: Allison Henderson <allison.henderson@oracle.com>
> 
> Add a test to verify basic parent pointers operations (create, move, link,
> unlink, rename, overwrite).
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> ---
>  doc/group-names.txt |   1 +
>  tests/xfs/554       | 125 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/554.out   |  59 +++++++++++++++++++++
>  3 files changed, 185 insertions(+)
>  create mode 100755 tests/xfs/554
>  create mode 100644 tests/xfs/554.out
> 
> diff --git a/doc/group-names.txt b/doc/group-names.txt
> index ef411b5e..8e35c699 100644
> --- a/doc/group-names.txt
> +++ b/doc/group-names.txt
> @@ -77,6 +77,7 @@ nfs4_acl		NFSv4 access control lists
>  nonsamefs		overlayfs layers on different filesystems
>  online_repair		online repair functionality tests
>  other			dumping ground, do not add more tests to this group
> +parent			Parent pointer tests
>  pattern			specific IO pattern tests
>  perms			access control and permission checking
>  pipe			pipe functionality
> diff --git a/tests/xfs/554 b/tests/xfs/554
> new file mode 100755
> index 00000000..26914e4c
> --- /dev/null
> +++ b/tests/xfs/554
> @@ -0,0 +1,125 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# FS QA Test 554
> +#
> +# simple parent pointer test
> +#
> +
> +. ./common/preamble
> +_begin_fstest auto quick parent
> +
> +cleanup()
> +{
> +	cd /
> +	rm -f $tmp.*
> +}

This's same with common cleanup function, you can remove this function.

> +
> +full()
> +{
> +    echo ""            >>$seqres.full
> +    echo "*** $* ***"  >>$seqres.full
> +    echo ""            >>$seqres.full
> +}

What's this function for? I didn't see this function is called in this case.
Am I missing something?

> +
> +# get standard environment, filters and checks
> +. ./common/filter
> +. ./common/reflink
> +. ./common/inject
> +. ./common/parent
> +
> +# Modify as appropriate
> +_supported_fs xfs
> +_require_scratch
> +_require_xfs_sysfs debug/larp
> +_require_xfs_io_error_injection "larp"
> +_require_xfs_parent
> +_require_xfs_io_command "parent"
> +
> +# real QA test starts here
> +
> +# Create a directory tree using a protofile and
> +# make sure all inodes created have parent pointers
> +
> +protofile=$tmp.proto
> +
> +cat >$protofile <<EOF
> +DUMMY1
> +0 0
> +: root directory
> +d--777 3 1
> +: a directory
> +testfolder1 d--755 3 1
> +file1 ---755 3 1 /dev/null
> +$
> +: back in the root
> +testfolder2 d--755 3 1
> +file2 ---755 3 1 /dev/null
> +: done
> +$
> +EOF
> +
> +if [ $? -ne 0 ]
> +then
> +    _fail "failed to create test protofile"
> +fi

It just writes a general file, right? Is there any special reason might cause
write fail?

I think we don't need to check each step's return value. And if we fail to write
a file, bash helps to output error message to break golden image too.

Thanks,
Zorro

> +
> +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \
> +	|| _fail "mkfs failed"
> +_check_scratch_fs
> +
> +_scratch_mount >>$seqres.full 2>&1 \
> +	|| _fail "mount failed"
> +
> +testfolder1="testfolder1"
> +testfolder2="testfolder2"
> +file1="file1"
> +file2="file2"
> +file3="file3"
> +file4="file4"
> +file5="file5"
> +file1_ln="file1_link"
> +
> +echo ""
> +# Create parent pointer test
> +_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1"
> +
> +echo ""
> +# Move parent pointer test
> +mv $SCRATCH_MNT/$testfolder1/$file1 $SCRATCH_MNT/$testfolder2/$file1
> +_verify_parent "$testfolder2" "$file1" "$testfolder2/$file1"
> +
> +echo ""
> +# Hard link parent pointer test
> +ln $SCRATCH_MNT/$testfolder2/$file1 $SCRATCH_MNT/$testfolder1/$file1_ln
> +_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
> +_verify_parent "$testfolder1" "$file1_ln" "$testfolder2/$file1"
> +_verify_parent "$testfolder2" "$file1"    "$testfolder1/$file1_ln"
> +_verify_parent "$testfolder2" "$file1"    "$testfolder2/$file1"
> +
> +echo ""
> +# Remove hard link parent pointer test
> +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file1)"
> +rm $SCRATCH_MNT/$testfolder2/$file1
> +_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
> +_verify_no_parent "$file1" "$ino" "$testfolder1/$file1_ln"
> +
> +echo ""
> +# Rename parent pointer test
> +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln)"
> +mv $SCRATCH_MNT/$testfolder1/$file1_ln $SCRATCH_MNT/$testfolder1/$file2
> +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> +_verify_no_parent "$file1_ln" "$ino" "$testfolder1/$file2"
> +
> +echo ""
> +# Over write parent pointer test
> +touch $SCRATCH_MNT/$testfolder2/$file3
> +_verify_parent "$testfolder2" "$file3" "$testfolder2/$file3"
> +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file3)"
> +mv -f $SCRATCH_MNT/$testfolder2/$file3 $SCRATCH_MNT/$testfolder1/$file2
> +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/554.out b/tests/xfs/554.out
> new file mode 100644
> index 00000000..67ea9f2b
> --- /dev/null
> +++ b/tests/xfs/554.out
> @@ -0,0 +1,59 @@
> +QA output created by 554
> +
> +*** testfolder1 OK
> +*** testfolder1/file1 OK
> +*** testfolder1/file1 OK
> +*** Verified parent pointer: name:file1, namelen:5
> +*** Parent pointer OK for child testfolder1/file1
> +
> +*** testfolder2 OK
> +*** testfolder2/file1 OK
> +*** testfolder2/file1 OK
> +*** Verified parent pointer: name:file1, namelen:5
> +*** Parent pointer OK for child testfolder2/file1
> +
> +*** testfolder1 OK
> +*** testfolder1/file1_link OK
> +*** testfolder1/file1_link OK
> +*** Verified parent pointer: name:file1_link, namelen:10
> +*** Parent pointer OK for child testfolder1/file1_link
> +*** testfolder1 OK
> +*** testfolder2/file1 OK
> +*** testfolder1/file1_link OK
> +*** Verified parent pointer: name:file1_link, namelen:10
> +*** Parent pointer OK for child testfolder2/file1
> +*** testfolder2 OK
> +*** testfolder1/file1_link OK
> +*** testfolder2/file1 OK
> +*** Verified parent pointer: name:file1, namelen:5
> +*** Parent pointer OK for child testfolder1/file1_link
> +*** testfolder2 OK
> +*** testfolder2/file1 OK
> +*** testfolder2/file1 OK
> +*** Verified parent pointer: name:file1, namelen:5
> +*** Parent pointer OK for child testfolder2/file1
> +
> +*** testfolder1 OK
> +*** testfolder1/file1_link OK
> +*** testfolder1/file1_link OK
> +*** Verified parent pointer: name:file1_link, namelen:10
> +*** Parent pointer OK for child testfolder1/file1_link
> +*** testfolder1/file1_link OK
> +
> +*** testfolder1 OK
> +*** testfolder1/file2 OK
> +*** testfolder1/file2 OK
> +*** Verified parent pointer: name:file2, namelen:5
> +*** Parent pointer OK for child testfolder1/file2
> +*** testfolder1/file2 OK
> +
> +*** testfolder2 OK
> +*** testfolder2/file3 OK
> +*** testfolder2/file3 OK
> +*** Verified parent pointer: name:file3, namelen:5
> +*** Parent pointer OK for child testfolder2/file3
> +*** testfolder1 OK
> +*** testfolder1/file2 OK
> +*** testfolder1/file2 OK
> +*** Verified parent pointer: name:file2, namelen:5
> +*** Parent pointer OK for child testfolder1/file2
> -- 
> 2.25.1
>
Zorro Lang Oct. 12, 2022, 3:10 a.m. UTC | #2
On Wed, Oct 12, 2022 at 11:02:20AM +0800, Zorro Lang wrote:
> On Tue, Oct 11, 2022 at 06:38:10PM -0700, Catherine Hoang wrote:
> > From: Allison Henderson <allison.henderson@oracle.com>
> > 
> > Add a test to verify basic parent pointers operations (create, move, link,
> > unlink, rename, overwrite).
> > 
> > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > ---
> >  doc/group-names.txt |   1 +
> >  tests/xfs/554       | 125 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/554.out   |  59 +++++++++++++++++++++
> >  3 files changed, 185 insertions(+)
> >  create mode 100755 tests/xfs/554
> >  create mode 100644 tests/xfs/554.out
> > 
> > diff --git a/doc/group-names.txt b/doc/group-names.txt
> > index ef411b5e..8e35c699 100644
> > --- a/doc/group-names.txt
> > +++ b/doc/group-names.txt
> > @@ -77,6 +77,7 @@ nfs4_acl		NFSv4 access control lists
> >  nonsamefs		overlayfs layers on different filesystems
> >  online_repair		online repair functionality tests
> >  other			dumping ground, do not add more tests to this group
> > +parent			Parent pointer tests
> >  pattern			specific IO pattern tests
> >  perms			access control and permission checking
> >  pipe			pipe functionality
> > diff --git a/tests/xfs/554 b/tests/xfs/554
> > new file mode 100755
> > index 00000000..26914e4c
> > --- /dev/null
> > +++ b/tests/xfs/554
> > @@ -0,0 +1,125 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
> > +#
> > +# FS QA Test 554
> > +#
> > +# simple parent pointer test
> > +#
> > +
> > +. ./common/preamble
> > +_begin_fstest auto quick parent
> > +
> > +cleanup()
> > +{
> > +	cd /
> > +	rm -f $tmp.*
> > +}
> 
> This's same with common cleanup function, you can remove this function.

Same for patch 3 and 4.

> 
> > +
> > +full()
> > +{
> > +    echo ""            >>$seqres.full
> > +    echo "*** $* ***"  >>$seqres.full
> > +    echo ""            >>$seqres.full
> > +}
> 
> What's this function for? I didn't see this function is called in this case.
> Am I missing something?

Same question for patch 3 and 4.

> 
> > +
> > +# get standard environment, filters and checks
> > +. ./common/filter
> > +. ./common/reflink
> > +. ./common/inject
> > +. ./common/parent
> > +
> > +# Modify as appropriate
> > +_supported_fs xfs
> > +_require_scratch
> > +_require_xfs_sysfs debug/larp
> > +_require_xfs_io_error_injection "larp"

And does this case really do error injection? I didn't find that. If not, please
remove this requirement and above common/inject. Same question for patch 4.

Thanks,
Zorro

> > +_require_xfs_parent
> > +_require_xfs_io_command "parent"
> > +
> > +# real QA test starts here
> > +
> > +# Create a directory tree using a protofile and
> > +# make sure all inodes created have parent pointers
> > +
> > +protofile=$tmp.proto
> > +
> > +cat >$protofile <<EOF
> > +DUMMY1
> > +0 0
> > +: root directory
> > +d--777 3 1
> > +: a directory
> > +testfolder1 d--755 3 1
> > +file1 ---755 3 1 /dev/null
> > +$
> > +: back in the root
> > +testfolder2 d--755 3 1
> > +file2 ---755 3 1 /dev/null
> > +: done
> > +$
> > +EOF
> > +
> > +if [ $? -ne 0 ]
> > +then
> > +    _fail "failed to create test protofile"
> > +fi
> 
> It just writes a general file, right? Is there any special reason might cause
> write fail?
> 
> I think we don't need to check each step's return value. And if we fail to write
> a file, bash helps to output error message to break golden image too.
> 
> Thanks,
> Zorro
> 
> > +
> > +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \
> > +	|| _fail "mkfs failed"
> > +_check_scratch_fs
> > +
> > +_scratch_mount >>$seqres.full 2>&1 \
> > +	|| _fail "mount failed"
> > +
> > +testfolder1="testfolder1"
> > +testfolder2="testfolder2"
> > +file1="file1"
> > +file2="file2"
> > +file3="file3"
> > +file4="file4"
> > +file5="file5"
> > +file1_ln="file1_link"
> > +
> > +echo ""
> > +# Create parent pointer test
> > +_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1"
> > +
> > +echo ""
> > +# Move parent pointer test
> > +mv $SCRATCH_MNT/$testfolder1/$file1 $SCRATCH_MNT/$testfolder2/$file1
> > +_verify_parent "$testfolder2" "$file1" "$testfolder2/$file1"
> > +
> > +echo ""
> > +# Hard link parent pointer test
> > +ln $SCRATCH_MNT/$testfolder2/$file1 $SCRATCH_MNT/$testfolder1/$file1_ln
> > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
> > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder2/$file1"
> > +_verify_parent "$testfolder2" "$file1"    "$testfolder1/$file1_ln"
> > +_verify_parent "$testfolder2" "$file1"    "$testfolder2/$file1"
> > +
> > +echo ""
> > +# Remove hard link parent pointer test
> > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file1)"
> > +rm $SCRATCH_MNT/$testfolder2/$file1
> > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
> > +_verify_no_parent "$file1" "$ino" "$testfolder1/$file1_ln"
> > +
> > +echo ""
> > +# Rename parent pointer test
> > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln)"
> > +mv $SCRATCH_MNT/$testfolder1/$file1_ln $SCRATCH_MNT/$testfolder1/$file2
> > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > +_verify_no_parent "$file1_ln" "$ino" "$testfolder1/$file2"
> > +
> > +echo ""
> > +# Over write parent pointer test
> > +touch $SCRATCH_MNT/$testfolder2/$file3
> > +_verify_parent "$testfolder2" "$file3" "$testfolder2/$file3"
> > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file3)"
> > +mv -f $SCRATCH_MNT/$testfolder2/$file3 $SCRATCH_MNT/$testfolder1/$file2
> > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/554.out b/tests/xfs/554.out
> > new file mode 100644
> > index 00000000..67ea9f2b
> > --- /dev/null
> > +++ b/tests/xfs/554.out
> > @@ -0,0 +1,59 @@
> > +QA output created by 554
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file1 OK
> > +*** testfolder1/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder1/file1
> > +
> > +*** testfolder2 OK
> > +*** testfolder2/file1 OK
> > +*** testfolder2/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder2/file1
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file1_link OK
> > +*** testfolder1/file1_link OK
> > +*** Verified parent pointer: name:file1_link, namelen:10
> > +*** Parent pointer OK for child testfolder1/file1_link
> > +*** testfolder1 OK
> > +*** testfolder2/file1 OK
> > +*** testfolder1/file1_link OK
> > +*** Verified parent pointer: name:file1_link, namelen:10
> > +*** Parent pointer OK for child testfolder2/file1
> > +*** testfolder2 OK
> > +*** testfolder1/file1_link OK
> > +*** testfolder2/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder1/file1_link
> > +*** testfolder2 OK
> > +*** testfolder2/file1 OK
> > +*** testfolder2/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder2/file1
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file1_link OK
> > +*** testfolder1/file1_link OK
> > +*** Verified parent pointer: name:file1_link, namelen:10
> > +*** Parent pointer OK for child testfolder1/file1_link
> > +*** testfolder1/file1_link OK
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file2 OK
> > +*** testfolder1/file2 OK
> > +*** Verified parent pointer: name:file2, namelen:5
> > +*** Parent pointer OK for child testfolder1/file2
> > +*** testfolder1/file2 OK
> > +
> > +*** testfolder2 OK
> > +*** testfolder2/file3 OK
> > +*** testfolder2/file3 OK
> > +*** Verified parent pointer: name:file3, namelen:5
> > +*** Parent pointer OK for child testfolder2/file3
> > +*** testfolder1 OK
> > +*** testfolder1/file2 OK
> > +*** testfolder1/file2 OK
> > +*** Verified parent pointer: name:file2, namelen:5
> > +*** Parent pointer OK for child testfolder1/file2
> > -- 
> > 2.25.1
> >
Allison Henderson Oct. 13, 2022, 7:07 p.m. UTC | #3
On Wed, 2022-10-12 at 11:02 +0800, Zorro Lang wrote:
> On Tue, Oct 11, 2022 at 06:38:10PM -0700, Catherine Hoang wrote:
> > From: Allison Henderson <allison.henderson@oracle.com>
> > 
> > Add a test to verify basic parent pointers operations (create,
> > move, link,
> > unlink, rename, overwrite).
> > 
> > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > ---
> >  doc/group-names.txt |   1 +
> >  tests/xfs/554       | 125
> > ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/554.out   |  59 +++++++++++++++++++++
> >  3 files changed, 185 insertions(+)
> >  create mode 100755 tests/xfs/554
> >  create mode 100644 tests/xfs/554.out
> > 
> > diff --git a/doc/group-names.txt b/doc/group-names.txt
> > index ef411b5e..8e35c699 100644
> > --- a/doc/group-names.txt
> > +++ b/doc/group-names.txt
> > @@ -77,6 +77,7 @@ nfs4_acl              NFSv4 access control lists
> >  nonsamefs              overlayfs layers on different filesystems
> >  online_repair          online repair functionality tests
> >  other                  dumping ground, do not add more tests to
> > this group
> > +parent                 Parent pointer tests
> >  pattern                        specific IO pattern tests
> >  perms                  access control and permission checking
> >  pipe                   pipe functionality
> > diff --git a/tests/xfs/554 b/tests/xfs/554
> > new file mode 100755
> > index 00000000..26914e4c
> > --- /dev/null
> > +++ b/tests/xfs/554
> > @@ -0,0 +1,125 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights
> > Reserved.
> > +#
> > +# FS QA Test 554
> > +#
> > +# simple parent pointer test
> > +#
> > +
> > +. ./common/preamble
> > +_begin_fstest auto quick parent
> > +
> > +cleanup()
> > +{
> > +       cd /
> > +       rm -f $tmp.*
> > +}
> 
> This's same with common cleanup function, you can remove this
> function.
Ok, these tests were initially written before these helpers were
hoisted into a common location, so it makes sense to clean them out
now.

> 
> > +
> > +full()
> > +{
> > +    echo ""            >>$seqres.full
> > +    echo "*** $* ***"  >>$seqres.full
> > +    echo ""            >>$seqres.full
> > +}
> 
> What's this function for? I didn't see this function is called in
> this case.
> Am I missing something?
I think it's another common helper that's over in common/log now.  I
suspect it was just reminiscent of the test case I modeled this after
at the time.  It should likely come out now too.

> 
> > +
> > +# get standard environment, filters and checks
> > +. ./common/filter
> > +. ./common/reflink
> > +. ./common/inject
> > +. ./common/parent
> > +
> > +# Modify as appropriate
> > +_supported_fs xfs
> > +_require_scratch
> > +_require_xfs_sysfs debug/larp
> > +_require_xfs_io_error_injection "larp"
> > +_require_xfs_parent
> > +_require_xfs_io_command "parent"
> > +
> > +# real QA test starts here
> > +
> > +# Create a directory tree using a protofile and
> > +# make sure all inodes created have parent pointers
> > +
> > +protofile=$tmp.proto
> > +
> > +cat >$protofile <<EOF
> > +DUMMY1
> > +0 0
> > +: root directory
> > +d--777 3 1
> > +: a directory
> > +testfolder1 d--755 3 1
> > +file1 ---755 3 1 /dev/null
> > +$
> > +: back in the root
> > +testfolder2 d--755 3 1
> > +file2 ---755 3 1 /dev/null
> > +: done
> > +$
> > +EOF
> > +
> > +if [ $? -ne 0 ]
> > +then
> > +    _fail "failed to create test protofile"
> > +fi
> 
> It just writes a general file, right? Is there any special reason
> might cause
> write fail?
> 
> I think we don't need to check each step's return value. And if we
> fail to write
> a file, bash helps to output error message to break golden image too.
> 
I think I had borrowed this from the protofile test case
(tests/xfs/019).  But yes, if the file creation were to fail, I think
the mkfs command will just error out.  It should be fine to take it out
if folks prefer.  Thanks for the reviews!

Allison

> Thanks,
> Zorro
> 
> > +
> > +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \
> > +       || _fail "mkfs failed"
> > +_check_scratch_fs
> > +
> > +_scratch_mount >>$seqres.full 2>&1 \
> > +       || _fail "mount failed"
> > +
> > +testfolder1="testfolder1"
> > +testfolder2="testfolder2"
> > +file1="file1"
> > +file2="file2"
> > +file3="file3"
> > +file4="file4"
> > +file5="file5"
> > +file1_ln="file1_link"
> > +
> > +echo ""
> > +# Create parent pointer test
> > +_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1"
> > +
> > +echo ""
> > +# Move parent pointer test
> > +mv $SCRATCH_MNT/$testfolder1/$file1
> > $SCRATCH_MNT/$testfolder2/$file1
> > +_verify_parent "$testfolder2" "$file1" "$testfolder2/$file1"
> > +
> > +echo ""
> > +# Hard link parent pointer test
> > +ln $SCRATCH_MNT/$testfolder2/$file1
> > $SCRATCH_MNT/$testfolder1/$file1_ln
> > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
> > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder2/$file1"
> > +_verify_parent "$testfolder2" "$file1"    "$testfolder1/$file1_ln"
> > +_verify_parent "$testfolder2" "$file1"    "$testfolder2/$file1"
> > +
> > +echo ""
> > +# Remove hard link parent pointer test
> > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file1)"
> > +rm $SCRATCH_MNT/$testfolder2/$file1
> > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
> > +_verify_no_parent "$file1" "$ino" "$testfolder1/$file1_ln"
> > +
> > +echo ""
> > +# Rename parent pointer test
> > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln)"
> > +mv $SCRATCH_MNT/$testfolder1/$file1_ln
> > $SCRATCH_MNT/$testfolder1/$file2
> > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > +_verify_no_parent "$file1_ln" "$ino" "$testfolder1/$file2"
> > +
> > +echo ""
> > +# Over write parent pointer test
> > +touch $SCRATCH_MNT/$testfolder2/$file3
> > +_verify_parent "$testfolder2" "$file3" "$testfolder2/$file3"
> > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file3)"
> > +mv -f $SCRATCH_MNT/$testfolder2/$file3
> > $SCRATCH_MNT/$testfolder1/$file2
> > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/554.out b/tests/xfs/554.out
> > new file mode 100644
> > index 00000000..67ea9f2b
> > --- /dev/null
> > +++ b/tests/xfs/554.out
> > @@ -0,0 +1,59 @@
> > +QA output created by 554
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file1 OK
> > +*** testfolder1/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder1/file1
> > +
> > +*** testfolder2 OK
> > +*** testfolder2/file1 OK
> > +*** testfolder2/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder2/file1
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file1_link OK
> > +*** testfolder1/file1_link OK
> > +*** Verified parent pointer: name:file1_link, namelen:10
> > +*** Parent pointer OK for child testfolder1/file1_link
> > +*** testfolder1 OK
> > +*** testfolder2/file1 OK
> > +*** testfolder1/file1_link OK
> > +*** Verified parent pointer: name:file1_link, namelen:10
> > +*** Parent pointer OK for child testfolder2/file1
> > +*** testfolder2 OK
> > +*** testfolder1/file1_link OK
> > +*** testfolder2/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder1/file1_link
> > +*** testfolder2 OK
> > +*** testfolder2/file1 OK
> > +*** testfolder2/file1 OK
> > +*** Verified parent pointer: name:file1, namelen:5
> > +*** Parent pointer OK for child testfolder2/file1
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file1_link OK
> > +*** testfolder1/file1_link OK
> > +*** Verified parent pointer: name:file1_link, namelen:10
> > +*** Parent pointer OK for child testfolder1/file1_link
> > +*** testfolder1/file1_link OK
> > +
> > +*** testfolder1 OK
> > +*** testfolder1/file2 OK
> > +*** testfolder1/file2 OK
> > +*** Verified parent pointer: name:file2, namelen:5
> > +*** Parent pointer OK for child testfolder1/file2
> > +*** testfolder1/file2 OK
> > +
> > +*** testfolder2 OK
> > +*** testfolder2/file3 OK
> > +*** testfolder2/file3 OK
> > +*** Verified parent pointer: name:file3, namelen:5
> > +*** Parent pointer OK for child testfolder2/file3
> > +*** testfolder1 OK
> > +*** testfolder1/file2 OK
> > +*** testfolder1/file2 OK
> > +*** Verified parent pointer: name:file2, namelen:5
> > +*** Parent pointer OK for child testfolder1/file2
> > -- 
> > 2.25.1
> > 
>
Allison Henderson Oct. 13, 2022, 7:55 p.m. UTC | #4
On Wed, 2022-10-12 at 11:10 +0800, Zorro Lang wrote:
> On Wed, Oct 12, 2022 at 11:02:20AM +0800, Zorro Lang wrote:
> > On Tue, Oct 11, 2022 at 06:38:10PM -0700, Catherine Hoang wrote:
> > > From: Allison Henderson <allison.henderson@oracle.com>
> > > 
> > > Add a test to verify basic parent pointers operations (create,
> > > move, link,
> > > unlink, rename, overwrite).
> > > 
> > > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > > ---
> > >  doc/group-names.txt |   1 +
> > >  tests/xfs/554       | 125
> > > ++++++++++++++++++++++++++++++++++++++++++++
> > >  tests/xfs/554.out   |  59 +++++++++++++++++++++
> > >  3 files changed, 185 insertions(+)
> > >  create mode 100755 tests/xfs/554
> > >  create mode 100644 tests/xfs/554.out
> > > 
> > > diff --git a/doc/group-names.txt b/doc/group-names.txt
> > > index ef411b5e..8e35c699 100644
> > > --- a/doc/group-names.txt
> > > +++ b/doc/group-names.txt
> > > @@ -77,6 +77,7 @@ nfs4_acl              NFSv4 access control
> > > lists
> > >  nonsamefs              overlayfs layers on different filesystems
> > >  online_repair          online repair functionality tests
> > >  other                  dumping ground, do not add more tests to
> > > this group
> > > +parent                 Parent pointer tests
> > >  pattern                        specific IO pattern tests
> > >  perms                  access control and permission checking
> > >  pipe                   pipe functionality
> > > diff --git a/tests/xfs/554 b/tests/xfs/554
> > > new file mode 100755
> > > index 00000000..26914e4c
> > > --- /dev/null
> > > +++ b/tests/xfs/554
> > > @@ -0,0 +1,125 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights
> > > Reserved.
> > > +#
> > > +# FS QA Test 554
> > > +#
> > > +# simple parent pointer test
> > > +#
> > > +
> > > +. ./common/preamble
> > > +_begin_fstest auto quick parent
> > > +
> > > +cleanup()
> > > +{
> > > +       cd /
> > > +       rm -f $tmp.*
> > > +}
> > 
> > This's same with common cleanup function, you can remove this
> > function.
> 
> Same for patch 3 and 4.
> 
> > 
> > > +
> > > +full()
> > > +{
> > > +    echo ""            >>$seqres.full
> > > +    echo "*** $* ***"  >>$seqres.full
> > > +    echo ""            >>$seqres.full
> > > +}
> > 
> > What's this function for? I didn't see this function is called in
> > this case.
> > Am I missing something?
> 
> Same question for patch 3 and 4.
Think I answered these in the other patch review...

> 
> > 
> > > +
> > > +# get standard environment, filters and checks
> > > +. ./common/filter
> > > +. ./common/reflink
> > > +. ./common/inject
> > > +. ./common/parent
> > > +
> > > +# Modify as appropriate
> > > +_supported_fs xfs
> > > +_require_scratch
> > > +_require_xfs_sysfs debug/larp
> > > +_require_xfs_io_error_injection "larp"
> 
> And does this case really do error injection? I didn't find that. If
> not, please
> remove this requirement and above common/inject. 
I think at one point I had all these tests in one file and then later
separated them into multiple tests.  So I think the requirements for
injects can be removed from patch 2 and 3

> Same question for patch 4.
Patch 4 does do injects, so the requirement should stay.

Allison

> 
> Thanks,
> Zorro
> 
> > > +_require_xfs_parent
> > > +_require_xfs_io_command "parent"
> > > +
> > > +# real QA test starts here
> > > +
> > > +# Create a directory tree using a protofile and
> > > +# make sure all inodes created have parent pointers
> > > +
> > > +protofile=$tmp.proto
> > > +
> > > +cat >$protofile <<EOF
> > > +DUMMY1
> > > +0 0
> > > +: root directory
> > > +d--777 3 1
> > > +: a directory
> > > +testfolder1 d--755 3 1
> > > +file1 ---755 3 1 /dev/null
> > > +$
> > > +: back in the root
> > > +testfolder2 d--755 3 1
> > > +file2 ---755 3 1 /dev/null
> > > +: done
> > > +$
> > > +EOF
> > > +
> > > +if [ $? -ne 0 ]
> > > +then
> > > +    _fail "failed to create test protofile"
> > > +fi
> > 
> > It just writes a general file, right? Is there any special reason
> > might cause
> > write fail?
> > 
> > I think we don't need to check each step's return value. And if we
> > fail to write
> > a file, bash helps to output error message to break golden image
> > too.
> > 
> > Thanks,
> > Zorro
> > 
> > > +
> > > +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \
> > > +       || _fail "mkfs failed"
> > > +_check_scratch_fs
> > > +
> > > +_scratch_mount >>$seqres.full 2>&1 \
> > > +       || _fail "mount failed"
> > > +
> > > +testfolder1="testfolder1"
> > > +testfolder2="testfolder2"
> > > +file1="file1"
> > > +file2="file2"
> > > +file3="file3"
> > > +file4="file4"
> > > +file5="file5"
> > > +file1_ln="file1_link"
> > > +
> > > +echo ""
> > > +# Create parent pointer test
> > > +_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1"
> > > +
> > > +echo ""
> > > +# Move parent pointer test
> > > +mv $SCRATCH_MNT/$testfolder1/$file1
> > > $SCRATCH_MNT/$testfolder2/$file1
> > > +_verify_parent "$testfolder2" "$file1" "$testfolder2/$file1"
> > > +
> > > +echo ""
> > > +# Hard link parent pointer test
> > > +ln $SCRATCH_MNT/$testfolder2/$file1
> > > $SCRATCH_MNT/$testfolder1/$file1_ln
> > > +_verify_parent "$testfolder1" "$file1_ln"
> > > "$testfolder1/$file1_ln"
> > > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder2/$file1"
> > > +_verify_parent "$testfolder2" "$file1"   
> > > "$testfolder1/$file1_ln"
> > > +_verify_parent "$testfolder2" "$file1"    "$testfolder2/$file1"
> > > +
> > > +echo ""
> > > +# Remove hard link parent pointer test
> > > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file1)"
> > > +rm $SCRATCH_MNT/$testfolder2/$file1
> > > +_verify_parent "$testfolder1" "$file1_ln"
> > > "$testfolder1/$file1_ln"
> > > +_verify_no_parent "$file1" "$ino" "$testfolder1/$file1_ln"
> > > +
> > > +echo ""
> > > +# Rename parent pointer test
> > > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln)"
> > > +mv $SCRATCH_MNT/$testfolder1/$file1_ln
> > > $SCRATCH_MNT/$testfolder1/$file2
> > > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > > +_verify_no_parent "$file1_ln" "$ino" "$testfolder1/$file2"
> > > +
> > > +echo ""
> > > +# Over write parent pointer test
> > > +touch $SCRATCH_MNT/$testfolder2/$file3
> > > +_verify_parent "$testfolder2" "$file3" "$testfolder2/$file3"
> > > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file3)"
> > > +mv -f $SCRATCH_MNT/$testfolder2/$file3
> > > $SCRATCH_MNT/$testfolder1/$file2
> > > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > > +
> > > +# success, all done
> > > +status=0
> > > +exit
> > > diff --git a/tests/xfs/554.out b/tests/xfs/554.out
> > > new file mode 100644
> > > index 00000000..67ea9f2b
> > > --- /dev/null
> > > +++ b/tests/xfs/554.out
> > > @@ -0,0 +1,59 @@
> > > +QA output created by 554
> > > +
> > > +*** testfolder1 OK
> > > +*** testfolder1/file1 OK
> > > +*** testfolder1/file1 OK
> > > +*** Verified parent pointer: name:file1, namelen:5
> > > +*** Parent pointer OK for child testfolder1/file1
> > > +
> > > +*** testfolder2 OK
> > > +*** testfolder2/file1 OK
> > > +*** testfolder2/file1 OK
> > > +*** Verified parent pointer: name:file1, namelen:5
> > > +*** Parent pointer OK for child testfolder2/file1
> > > +
> > > +*** testfolder1 OK
> > > +*** testfolder1/file1_link OK
> > > +*** testfolder1/file1_link OK
> > > +*** Verified parent pointer: name:file1_link, namelen:10
> > > +*** Parent pointer OK for child testfolder1/file1_link
> > > +*** testfolder1 OK
> > > +*** testfolder2/file1 OK
> > > +*** testfolder1/file1_link OK
> > > +*** Verified parent pointer: name:file1_link, namelen:10
> > > +*** Parent pointer OK for child testfolder2/file1
> > > +*** testfolder2 OK
> > > +*** testfolder1/file1_link OK
> > > +*** testfolder2/file1 OK
> > > +*** Verified parent pointer: name:file1, namelen:5
> > > +*** Parent pointer OK for child testfolder1/file1_link
> > > +*** testfolder2 OK
> > > +*** testfolder2/file1 OK
> > > +*** testfolder2/file1 OK
> > > +*** Verified parent pointer: name:file1, namelen:5
> > > +*** Parent pointer OK for child testfolder2/file1
> > > +
> > > +*** testfolder1 OK
> > > +*** testfolder1/file1_link OK
> > > +*** testfolder1/file1_link OK
> > > +*** Verified parent pointer: name:file1_link, namelen:10
> > > +*** Parent pointer OK for child testfolder1/file1_link
> > > +*** testfolder1/file1_link OK
> > > +
> > > +*** testfolder1 OK
> > > +*** testfolder1/file2 OK
> > > +*** testfolder1/file2 OK
> > > +*** Verified parent pointer: name:file2, namelen:5
> > > +*** Parent pointer OK for child testfolder1/file2
> > > +*** testfolder1/file2 OK
> > > +
> > > +*** testfolder2 OK
> > > +*** testfolder2/file3 OK
> > > +*** testfolder2/file3 OK
> > > +*** Verified parent pointer: name:file3, namelen:5
> > > +*** Parent pointer OK for child testfolder2/file3
> > > +*** testfolder1 OK
> > > +*** testfolder1/file2 OK
> > > +*** testfolder1/file2 OK
> > > +*** Verified parent pointer: name:file2, namelen:5
> > > +*** Parent pointer OK for child testfolder1/file2
> > > -- 
> > > 2.25.1
> > > 
>
Zorro Lang Oct. 14, 2022, 1:24 a.m. UTC | #5
On Thu, Oct 13, 2022 at 07:55:42PM +0000, Allison Henderson wrote:
> On Wed, 2022-10-12 at 11:10 +0800, Zorro Lang wrote:
> > On Wed, Oct 12, 2022 at 11:02:20AM +0800, Zorro Lang wrote:
> > > On Tue, Oct 11, 2022 at 06:38:10PM -0700, Catherine Hoang wrote:
> > > > From: Allison Henderson <allison.henderson@oracle.com>
> > > > 
> > > > Add a test to verify basic parent pointers operations (create,
> > > > move, link,
> > > > unlink, rename, overwrite).
> > > > 
> > > > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > > > Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> > > > ---
> > > >  doc/group-names.txt |   1 +
> > > >  tests/xfs/554       | 125
> > > > ++++++++++++++++++++++++++++++++++++++++++++
> > > >  tests/xfs/554.out   |  59 +++++++++++++++++++++
> > > >  3 files changed, 185 insertions(+)
> > > >  create mode 100755 tests/xfs/554
> > > >  create mode 100644 tests/xfs/554.out
> > > > 
> > > > diff --git a/doc/group-names.txt b/doc/group-names.txt
> > > > index ef411b5e..8e35c699 100644
> > > > --- a/doc/group-names.txt
> > > > +++ b/doc/group-names.txt
> > > > @@ -77,6 +77,7 @@ nfs4_acl              NFSv4 access control
> > > > lists
> > > >  nonsamefs              overlayfs layers on different filesystems
> > > >  online_repair          online repair functionality tests
> > > >  other                  dumping ground, do not add more tests to
> > > > this group
> > > > +parent                 Parent pointer tests
> > > >  pattern                        specific IO pattern tests
> > > >  perms                  access control and permission checking
> > > >  pipe                   pipe functionality
> > > > diff --git a/tests/xfs/554 b/tests/xfs/554
> > > > new file mode 100755
> > > > index 00000000..26914e4c
> > > > --- /dev/null
> > > > +++ b/tests/xfs/554
> > > > @@ -0,0 +1,125 @@
> > > > +#! /bin/bash
> > > > +# SPDX-License-Identifier: GPL-2.0
> > > > +# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights
> > > > Reserved.
> > > > +#
> > > > +# FS QA Test 554
> > > > +#
> > > > +# simple parent pointer test
> > > > +#
> > > > +
> > > > +. ./common/preamble
> > > > +_begin_fstest auto quick parent
> > > > +
> > > > +cleanup()
> > > > +{
> > > > +       cd /
> > > > +       rm -f $tmp.*
> > > > +}
> > > 
> > > This's same with common cleanup function, you can remove this
> > > function.
> > 
> > Same for patch 3 and 4.
> > 
> > > 
> > > > +
> > > > +full()
> > > > +{
> > > > +    echo ""            >>$seqres.full
> > > > +    echo "*** $* ***"  >>$seqres.full
> > > > +    echo ""            >>$seqres.full
> > > > +}
> > > 
> > > What's this function for? I didn't see this function is called in
> > > this case.
> > > Am I missing something?
> > 
> > Same question for patch 3 and 4.
> Think I answered these in the other patch review...
> 
> > 
> > > 
> > > > +
> > > > +# get standard environment, filters and checks
> > > > +. ./common/filter
> > > > +. ./common/reflink
> > > > +. ./common/inject
> > > > +. ./common/parent
> > > > +
> > > > +# Modify as appropriate
> > > > +_supported_fs xfs
> > > > +_require_scratch
> > > > +_require_xfs_sysfs debug/larp
> > > > +_require_xfs_io_error_injection "larp"
> > 
> > And does this case really do error injection? I didn't find that. If
> > not, please
> > remove this requirement and above common/inject. 
> I think at one point I had all these tests in one file and then later
> separated them into multiple tests.  So I think the requirements for
> injects can be removed from patch 2 and 3

Sure, yes, same for patch 3 not 4. I said wrong below:)

> 
> > Same question for patch 4.
> Patch 4 does do injects, so the requirement should stay.
> 
> Allison
> 
> > 
> > Thanks,
> > Zorro
> > 
> > > > +_require_xfs_parent
> > > > +_require_xfs_io_command "parent"
> > > > +
> > > > +# real QA test starts here
> > > > +
> > > > +# Create a directory tree using a protofile and
> > > > +# make sure all inodes created have parent pointers
> > > > +
> > > > +protofile=$tmp.proto
> > > > +
> > > > +cat >$protofile <<EOF
> > > > +DUMMY1
> > > > +0 0
> > > > +: root directory
> > > > +d--777 3 1
> > > > +: a directory
> > > > +testfolder1 d--755 3 1
> > > > +file1 ---755 3 1 /dev/null
> > > > +$
> > > > +: back in the root
> > > > +testfolder2 d--755 3 1
> > > > +file2 ---755 3 1 /dev/null
> > > > +: done
> > > > +$
> > > > +EOF
> > > > +
> > > > +if [ $? -ne 0 ]
> > > > +then
> > > > +    _fail "failed to create test protofile"
> > > > +fi
> > > 
> > > It just writes a general file, right? Is there any special reason
> > > might cause
> > > write fail?
> > > 
> > > I think we don't need to check each step's return value. And if we
> > > fail to write
> > > a file, bash helps to output error message to break golden image
> > > too.
> > > 
> > > Thanks,
> > > Zorro
> > > 
> > > > +
> > > > +_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \
> > > > +       || _fail "mkfs failed"
> > > > +_check_scratch_fs
> > > > +
> > > > +_scratch_mount >>$seqres.full 2>&1 \
> > > > +       || _fail "mount failed"
> > > > +
> > > > +testfolder1="testfolder1"
> > > > +testfolder2="testfolder2"
> > > > +file1="file1"
> > > > +file2="file2"
> > > > +file3="file3"
> > > > +file4="file4"
> > > > +file5="file5"
> > > > +file1_ln="file1_link"
> > > > +
> > > > +echo ""
> > > > +# Create parent pointer test
> > > > +_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1"
> > > > +
> > > > +echo ""
> > > > +# Move parent pointer test
> > > > +mv $SCRATCH_MNT/$testfolder1/$file1
> > > > $SCRATCH_MNT/$testfolder2/$file1
> > > > +_verify_parent "$testfolder2" "$file1" "$testfolder2/$file1"
> > > > +
> > > > +echo ""
> > > > +# Hard link parent pointer test
> > > > +ln $SCRATCH_MNT/$testfolder2/$file1
> > > > $SCRATCH_MNT/$testfolder1/$file1_ln
> > > > +_verify_parent "$testfolder1" "$file1_ln"
> > > > "$testfolder1/$file1_ln"
> > > > +_verify_parent "$testfolder1" "$file1_ln" "$testfolder2/$file1"
> > > > +_verify_parent "$testfolder2" "$file1"   
> > > > "$testfolder1/$file1_ln"
> > > > +_verify_parent "$testfolder2" "$file1"    "$testfolder2/$file1"
> > > > +
> > > > +echo ""
> > > > +# Remove hard link parent pointer test
> > > > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file1)"
> > > > +rm $SCRATCH_MNT/$testfolder2/$file1
> > > > +_verify_parent "$testfolder1" "$file1_ln"
> > > > "$testfolder1/$file1_ln"
> > > > +_verify_no_parent "$file1" "$ino" "$testfolder1/$file1_ln"
> > > > +
> > > > +echo ""
> > > > +# Rename parent pointer test
> > > > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln)"
> > > > +mv $SCRATCH_MNT/$testfolder1/$file1_ln
> > > > $SCRATCH_MNT/$testfolder1/$file2
> > > > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > > > +_verify_no_parent "$file1_ln" "$ino" "$testfolder1/$file2"
> > > > +
> > > > +echo ""
> > > > +# Over write parent pointer test
> > > > +touch $SCRATCH_MNT/$testfolder2/$file3
> > > > +_verify_parent "$testfolder2" "$file3" "$testfolder2/$file3"
> > > > +ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file3)"
> > > > +mv -f $SCRATCH_MNT/$testfolder2/$file3
> > > > $SCRATCH_MNT/$testfolder1/$file2
> > > > +_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
> > > > +
> > > > +# success, all done
> > > > +status=0
> > > > +exit
> > > > diff --git a/tests/xfs/554.out b/tests/xfs/554.out
> > > > new file mode 100644
> > > > index 00000000..67ea9f2b
> > > > --- /dev/null
> > > > +++ b/tests/xfs/554.out
> > > > @@ -0,0 +1,59 @@
> > > > +QA output created by 554
> > > > +
> > > > +*** testfolder1 OK
> > > > +*** testfolder1/file1 OK
> > > > +*** testfolder1/file1 OK
> > > > +*** Verified parent pointer: name:file1, namelen:5
> > > > +*** Parent pointer OK for child testfolder1/file1
> > > > +
> > > > +*** testfolder2 OK
> > > > +*** testfolder2/file1 OK
> > > > +*** testfolder2/file1 OK
> > > > +*** Verified parent pointer: name:file1, namelen:5
> > > > +*** Parent pointer OK for child testfolder2/file1
> > > > +
> > > > +*** testfolder1 OK
> > > > +*** testfolder1/file1_link OK
> > > > +*** testfolder1/file1_link OK
> > > > +*** Verified parent pointer: name:file1_link, namelen:10
> > > > +*** Parent pointer OK for child testfolder1/file1_link
> > > > +*** testfolder1 OK
> > > > +*** testfolder2/file1 OK
> > > > +*** testfolder1/file1_link OK
> > > > +*** Verified parent pointer: name:file1_link, namelen:10
> > > > +*** Parent pointer OK for child testfolder2/file1
> > > > +*** testfolder2 OK
> > > > +*** testfolder1/file1_link OK
> > > > +*** testfolder2/file1 OK
> > > > +*** Verified parent pointer: name:file1, namelen:5
> > > > +*** Parent pointer OK for child testfolder1/file1_link
> > > > +*** testfolder2 OK
> > > > +*** testfolder2/file1 OK
> > > > +*** testfolder2/file1 OK
> > > > +*** Verified parent pointer: name:file1, namelen:5
> > > > +*** Parent pointer OK for child testfolder2/file1
> > > > +
> > > > +*** testfolder1 OK
> > > > +*** testfolder1/file1_link OK
> > > > +*** testfolder1/file1_link OK
> > > > +*** Verified parent pointer: name:file1_link, namelen:10
> > > > +*** Parent pointer OK for child testfolder1/file1_link
> > > > +*** testfolder1/file1_link OK
> > > > +
> > > > +*** testfolder1 OK
> > > > +*** testfolder1/file2 OK
> > > > +*** testfolder1/file2 OK
> > > > +*** Verified parent pointer: name:file2, namelen:5
> > > > +*** Parent pointer OK for child testfolder1/file2
> > > > +*** testfolder1/file2 OK
> > > > +
> > > > +*** testfolder2 OK
> > > > +*** testfolder2/file3 OK
> > > > +*** testfolder2/file3 OK
> > > > +*** Verified parent pointer: name:file3, namelen:5
> > > > +*** Parent pointer OK for child testfolder2/file3
> > > > +*** testfolder1 OK
> > > > +*** testfolder1/file2 OK
> > > > +*** testfolder1/file2 OK
> > > > +*** Verified parent pointer: name:file2, namelen:5
> > > > +*** Parent pointer OK for child testfolder1/file2
> > > > -- 
> > > > 2.25.1
> > > > 
> > 
>
diff mbox series

Patch

diff --git a/doc/group-names.txt b/doc/group-names.txt
index ef411b5e..8e35c699 100644
--- a/doc/group-names.txt
+++ b/doc/group-names.txt
@@ -77,6 +77,7 @@  nfs4_acl		NFSv4 access control lists
 nonsamefs		overlayfs layers on different filesystems
 online_repair		online repair functionality tests
 other			dumping ground, do not add more tests to this group
+parent			Parent pointer tests
 pattern			specific IO pattern tests
 perms			access control and permission checking
 pipe			pipe functionality
diff --git a/tests/xfs/554 b/tests/xfs/554
new file mode 100755
index 00000000..26914e4c
--- /dev/null
+++ b/tests/xfs/554
@@ -0,0 +1,125 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test 554
+#
+# simple parent pointer test
+#
+
+. ./common/preamble
+_begin_fstest auto quick parent
+
+cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+full()
+{
+    echo ""            >>$seqres.full
+    echo "*** $* ***"  >>$seqres.full
+    echo ""            >>$seqres.full
+}
+
+# get standard environment, filters and checks
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+. ./common/parent
+
+# Modify as appropriate
+_supported_fs xfs
+_require_scratch
+_require_xfs_sysfs debug/larp
+_require_xfs_io_error_injection "larp"
+_require_xfs_parent
+_require_xfs_io_command "parent"
+
+# real QA test starts here
+
+# Create a directory tree using a protofile and
+# make sure all inodes created have parent pointers
+
+protofile=$tmp.proto
+
+cat >$protofile <<EOF
+DUMMY1
+0 0
+: root directory
+d--777 3 1
+: a directory
+testfolder1 d--755 3 1
+file1 ---755 3 1 /dev/null
+$
+: back in the root
+testfolder2 d--755 3 1
+file2 ---755 3 1 /dev/null
+: done
+$
+EOF
+
+if [ $? -ne 0 ]
+then
+    _fail "failed to create test protofile"
+fi
+
+_scratch_mkfs -f -n parent=1 -p $protofile >>$seqres.full 2>&1 \
+	|| _fail "mkfs failed"
+_check_scratch_fs
+
+_scratch_mount >>$seqres.full 2>&1 \
+	|| _fail "mount failed"
+
+testfolder1="testfolder1"
+testfolder2="testfolder2"
+file1="file1"
+file2="file2"
+file3="file3"
+file4="file4"
+file5="file5"
+file1_ln="file1_link"
+
+echo ""
+# Create parent pointer test
+_verify_parent "$testfolder1" "$file1" "$testfolder1/$file1"
+
+echo ""
+# Move parent pointer test
+mv $SCRATCH_MNT/$testfolder1/$file1 $SCRATCH_MNT/$testfolder2/$file1
+_verify_parent "$testfolder2" "$file1" "$testfolder2/$file1"
+
+echo ""
+# Hard link parent pointer test
+ln $SCRATCH_MNT/$testfolder2/$file1 $SCRATCH_MNT/$testfolder1/$file1_ln
+_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
+_verify_parent "$testfolder1" "$file1_ln" "$testfolder2/$file1"
+_verify_parent "$testfolder2" "$file1"    "$testfolder1/$file1_ln"
+_verify_parent "$testfolder2" "$file1"    "$testfolder2/$file1"
+
+echo ""
+# Remove hard link parent pointer test
+ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file1)"
+rm $SCRATCH_MNT/$testfolder2/$file1
+_verify_parent "$testfolder1" "$file1_ln" "$testfolder1/$file1_ln"
+_verify_no_parent "$file1" "$ino" "$testfolder1/$file1_ln"
+
+echo ""
+# Rename parent pointer test
+ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder1/$file1_ln)"
+mv $SCRATCH_MNT/$testfolder1/$file1_ln $SCRATCH_MNT/$testfolder1/$file2
+_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
+_verify_no_parent "$file1_ln" "$ino" "$testfolder1/$file2"
+
+echo ""
+# Over write parent pointer test
+touch $SCRATCH_MNT/$testfolder2/$file3
+_verify_parent "$testfolder2" "$file3" "$testfolder2/$file3"
+ino="$(stat -c '%i' $SCRATCH_MNT/$testfolder2/$file3)"
+mv -f $SCRATCH_MNT/$testfolder2/$file3 $SCRATCH_MNT/$testfolder1/$file2
+_verify_parent "$testfolder1" "$file2" "$testfolder1/$file2"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/554.out b/tests/xfs/554.out
new file mode 100644
index 00000000..67ea9f2b
--- /dev/null
+++ b/tests/xfs/554.out
@@ -0,0 +1,59 @@ 
+QA output created by 554
+
+*** testfolder1 OK
+*** testfolder1/file1 OK
+*** testfolder1/file1 OK
+*** Verified parent pointer: name:file1, namelen:5
+*** Parent pointer OK for child testfolder1/file1
+
+*** testfolder2 OK
+*** testfolder2/file1 OK
+*** testfolder2/file1 OK
+*** Verified parent pointer: name:file1, namelen:5
+*** Parent pointer OK for child testfolder2/file1
+
+*** testfolder1 OK
+*** testfolder1/file1_link OK
+*** testfolder1/file1_link OK
+*** Verified parent pointer: name:file1_link, namelen:10
+*** Parent pointer OK for child testfolder1/file1_link
+*** testfolder1 OK
+*** testfolder2/file1 OK
+*** testfolder1/file1_link OK
+*** Verified parent pointer: name:file1_link, namelen:10
+*** Parent pointer OK for child testfolder2/file1
+*** testfolder2 OK
+*** testfolder1/file1_link OK
+*** testfolder2/file1 OK
+*** Verified parent pointer: name:file1, namelen:5
+*** Parent pointer OK for child testfolder1/file1_link
+*** testfolder2 OK
+*** testfolder2/file1 OK
+*** testfolder2/file1 OK
+*** Verified parent pointer: name:file1, namelen:5
+*** Parent pointer OK for child testfolder2/file1
+
+*** testfolder1 OK
+*** testfolder1/file1_link OK
+*** testfolder1/file1_link OK
+*** Verified parent pointer: name:file1_link, namelen:10
+*** Parent pointer OK for child testfolder1/file1_link
+*** testfolder1/file1_link OK
+
+*** testfolder1 OK
+*** testfolder1/file2 OK
+*** testfolder1/file2 OK
+*** Verified parent pointer: name:file2, namelen:5
+*** Parent pointer OK for child testfolder1/file2
+*** testfolder1/file2 OK
+
+*** testfolder2 OK
+*** testfolder2/file3 OK
+*** testfolder2/file3 OK
+*** Verified parent pointer: name:file3, namelen:5
+*** Parent pointer OK for child testfolder2/file3
+*** testfolder1 OK
+*** testfolder1/file2 OK
+*** testfolder1/file2 OK
+*** Verified parent pointer: name:file2, namelen:5
+*** Parent pointer OK for child testfolder1/file2