All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Murphy Zhou <jencce.kernel@gmail.com>
Cc: fstests <fstests@vger.kernel.org>,
	linux-xfs <linux-xfs@vger.kernel.org>,
	Linux-Fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [xfstests PATCH] generic/693: add basic change attr test
Date: Fri, 02 Sep 2022 05:41:29 -0400	[thread overview]
Message-ID: <5167c66c0a3285d2d3188871250af77df3919635.camel@kernel.org> (raw)
In-Reply-To: <CADJHv_ufx=k+HGbL8wChLVXLsv-HOgzdMMfU4eUfnV3dZFMnaQ@mail.gmail.com>

Thanks for having a look. I should probably have marked this as an RFC
patch. The infrastructure for this is still being debated on the mailing
lists. Until that's settled we won't want to merge this.

Cheers,
Jeff

On Fri, 2022-09-02 at 09:28 +0800, Murphy Zhou wrote:
> Hi Jeff,
> 
> Thanks for the patch!
> 
> On Tue, Aug 16, 2022 at 9:43 PM Jeff Layton <jlayton@kernel.org> wrote:
> > 
> > Now that we have the ability to query the change attribute in userland,
> > test that the filesystems implement it correctly. Fetch the change
> > attribute before and after various operations and validate that it
> > changes (or doesn't change) as expected.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  common/rc             |  17 ++++++
> >  tests/generic/693     | 138 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/693.out |   1 +
> >  3 files changed, 156 insertions(+)
> >  create mode 100755 tests/generic/693
> >  create mode 100644 tests/generic/693.out
> > 
> > Please look and make sure I'm not missing other operations that we
> > should be testing here!
> > 
> > diff --git a/common/rc b/common/rc
> > index 197c94157025..b9cb47f99016 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -5052,6 +5052,23 @@ hexdump()
> >         _fail "Use _hexdump(), please!"
> >  }
> > 
> > +_require_change_attr ()
> > +{
> > +
> > +       _mask=$($XFS_IO_PROG -f -c "statx -m 0x2000 -r" $TEST_DIR/change_attr_test.$$ \
> > +               | grep "^stat.mask" | cut -d' ' -f 3)
> > +       rm -f $TEST_DIR/change_attr_test.$$
> > +       if [ $(( ${_mask}&0x2000 )) -eq 0 ]; then
> > +               _notrun "$FSTYP does not support inode change attribute"
> > +       fi
> > +}
> > +
> > +_get_change_attr ()
> > +{
> > +       $XFS_IO_PROG -r -c "statx -m 0x2000 -r" $1 | grep '^stat.change_attr' | \
> > +               cut -d' ' -f3
> > +}
> > +
> >  init_rc
> > 
> >  ################################################################################
> > diff --git a/tests/generic/693 b/tests/generic/693
> > new file mode 100755
> > index 000000000000..fa92931d2ac8
> > --- /dev/null
> > +++ b/tests/generic/693
> > @@ -0,0 +1,138 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2021, Jeff Layton <jlayton@redhat.com>
> > +#
> > +# FS QA Test No. 693
> > +#
> > +# Test the behavior of the inode change attribute
> > +#
> > +. ./common/preamble
> > +_begin_fstest auto quick rw
> > +
> > +# Import common functions.
> > +. ./common/filter
> > +
> > +# real QA test starts here
> > +_supported_fs generic
> > +_require_test
> > +_require_change_attr
> > +
> > +# from the stat.h header file
> > +UTIME_OMIT=1073741822
> > +
> > +testdir="$TEST_DIR/test_iversion_dir.$$"
> > +testfile="$testdir/test_iversion_file.$$"
> > +
> > +mkdir $testdir
> > +
> > +# DIRECTORY TESTS
> > +#################
> > +# Does dir change attr change on a create?
> > +old=$(_get_change_attr $testdir)
> > +touch $testfile
> > +new=$(_get_change_attr $testdir)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr of dir did not change after create!"
> > +fi
> > +
> > +# on a hardlink?
> > +old=$new
> > +ln $testfile $testdir/linky
> 
> We may need to clean up these temporary testing files.
> 
> Other parts look good to me.
> 
> Regards~
> 
> > +new=$(_get_change_attr $testdir)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr of dir did not change after hardlink!"
> > +fi
> > +
> > +# on an unlink?
> > +old=$new
> > +rm -f $testfile
> > +new=$(_get_change_attr $testdir)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr of dir did not change after unlink!"
> > +fi
> > +
> > +# on a rename (within same dir)
> > +old=$new
> > +mv $testdir/linky $testfile
> > +new=$(_get_change_attr $testdir)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr of dir did not change after rename!"
> > +fi
> > +
> > +# on a mknod
> > +old=$new
> > +mknod $testdir/pipe p
> > +new=$(_get_change_attr $testdir)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr of dir did not change after mknod!"
> > +fi
> > +
> > +
> > +# REGULAR FILE TESTS
> > +####################
> > +# ensure change_attr changes after a write
> > +old=$(_get_change_attr $testfile)
> > +$XFS_IO_PROG -c "pwrite -W -q 0 32" $testfile
> > +new=$(_get_change_attr $testfile)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr did not change after write!"
> > +fi
> > +
> > +# ensure it doesn't change after a sync
> > +old=$new
> > +sync
> > +new=$(_get_change_attr $testfile)
> > +if [ $old != $new ]; then
> > +       _fail "Change attr changed after sync!"
> > +fi
> > +
> > +# ensure change_attr does not change after read
> > +old=$new
> > +cat $testfile > /dev/null
> > +new=$(_get_change_attr $testfile)
> > +if [ $old != $new ]; then
> > +       _fail "Change attr changed after read!"
> > +fi
> > +
> > +# ensure it changes after truncate
> > +old=$new
> > +truncate --size 0 $testfile
> > +new=$(_get_change_attr $testfile)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr did not change after truncate!"
> > +fi
> > +
> > +# ensure it changes after only atime update
> > +old=$new
> > +$XFS_IO_PROG -c "utimes 1 1 $UTIME_OMIT $UTIME_OMIT" $testfile
> > +new=$(_get_change_attr $testfile)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr did not change after atime update!"
> > +fi
> > +
> > +# ensure it changes after utimes atime/mtime update
> > +old=$new
> > +$XFS_IO_PROG -c "utimes 1 1 1 1" $testfile
> > +new=$(_get_change_attr $testfile)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr did not change after mtime update!"
> > +fi
> > +
> > +# after setting xattr
> > +old=$new
> > +setfattr -n user.foo -v bar $testfile
> > +new=$(_get_change_attr $testfile)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr did not change after setxattr!"
> > +fi
> > +
> > +# after removing xattr
> > +old=$new
> > +setfattr -x user.foo $testfile
> > +new=$(_get_change_attr $testfile)
> > +if [ $old = $new ]; then
> > +       _fail "Change attr did not change after rmxattr!"
> > +fi
> > +
> > +status=0
> > +exit
> > diff --git a/tests/generic/693.out b/tests/generic/693.out
> > new file mode 100644
> > index 000000000000..89ad553d911c
> > --- /dev/null
> > +++ b/tests/generic/693.out
> > @@ -0,0 +1 @@
> > +QA output created by 693
> > --
> > 2.37.2
> > 

-- 
Jeff Layton <jlayton@kernel.org>

      reply	other threads:[~2022-09-02  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 13:34 [xfstests PATCH] generic/693: add basic change attr test Jeff Layton
2022-09-02  1:28 ` Murphy Zhou
2022-09-02  9:41   ` Jeff Layton [this message]

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=5167c66c0a3285d2d3188871250af77df3919635.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=jencce.kernel@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.