diff mbox series

[03/24] generic/607: don't break on filesystems that don't support FSGETXATTR on dirs

Message ID 160013419510.2923511.4577521065964693699.stgit@magnolia
State Accepted
Headers show
Series fstests: tons of random fixes | expand

Commit Message

Darrick J. Wong Sept. 15, 2020, 1:43 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

This test requires that the filesystem support calling FSGETXATTR on
regular files and directories to make sure the FS_XFLAG_DAX flag works.
The _require_xfs_io_command tests a regular file but doesn't check
directories, so generic/607 should do that itself.  Also fix some typos.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc         |   10 ++++++++--
 tests/generic/607 |    5 +++++
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Xiao Yang Sept. 17, 2020, 1:41 a.m. UTC | #1
On 2020/9/15 9:43, Darrick J. Wong wrote:
> From: Darrick J. Wong<darrick.wong@oracle.com>
>
> This test requires that the filesystem support calling FSGETXATTR on
> regular files and directories to make sure the FS_XFLAG_DAX flag works.
> The _require_xfs_io_command tests a regular file but doesn't check
> directories, so generic/607 should do that itself.  Also fix some typos.
>
> Signed-off-by: Darrick J. Wong<darrick.wong@oracle.com>
> ---
>   common/rc         |   10 ++++++++--
>   tests/generic/607 |    5 +++++
>   2 files changed, 13 insertions(+), 2 deletions(-)
>
>
> diff --git a/common/rc b/common/rc
> index aa5a7409..f78b1cfc 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2162,6 +2162,12 @@ _require_xfs_io_command()
>   	local testfile=$TEST_DIR/$$.xfs_io
>   	local testio
>   	case $command in
> +	"lsattr")
> +		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
> +		# support.
> +		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
> +		param_checked="$param"
> +		;;
>   	"chattr")
>   		if [ -z "$param" ]; then
>   			param=s
> @@ -3205,7 +3211,7 @@ _check_s_dax()
>   	if [ $exp_s_dax -eq 0 ]; then
>   		(( attributes&  0x2000 ))&&  echo "$target has unexpected S_DAX flag"
>   	else
> -		(( attributes&  0x2000 )) || echo "$target doen't have expected S_DAX flag"
> +		(( attributes&  0x2000 )) || echo "$target doesn't have expected S_DAX flag"
>   	fi
>   }
>
> @@ -3217,7 +3223,7 @@ _check_xflag()
>   	if [ $exp_xflag -eq 0 ]; then
>   		_test_inode_flag dax $target&&  echo "$target has unexpected FS_XFLAG_DAX flag"
>   	else
> -		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
> +		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
>   	fi
>   }
>
> diff --git a/tests/generic/607 b/tests/generic/607
> index b15085ea..14d2c05f 100755
> --- a/tests/generic/607
> +++ b/tests/generic/607
> @@ -38,6 +38,11 @@ _require_scratch
>   _require_dax_iflag
>   _require_xfs_io_command "lsattr" "-v"
>
> +# Make sure we can call FSGETXATTR on a directory...
> +output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
> +echo "$output" | grep -q "Inappropriate ioctl for device"&&  \
> +	_notrun "$FSTYP: FSGETXATTR not supported on directories."
Hi Darrick,

Could you tell me which kernel version gets the issue? :-)

Best Regards,
Xiao Yang
> +
>   # If a/ is +x, check that a's new children
>   # inherit +x from a/.
>   test_xflag_inheritance1()
>
>
>
> .
>
Darrick J. Wong Sept. 17, 2020, 3:27 a.m. UTC | #2
On Thu, Sep 17, 2020 at 09:41:01AM +0800, Xiao Yang wrote:
> On 2020/9/15 9:43, Darrick J. Wong wrote:
> > From: Darrick J. Wong<darrick.wong@oracle.com>
> > 
> > This test requires that the filesystem support calling FSGETXATTR on
> > regular files and directories to make sure the FS_XFLAG_DAX flag works.
> > The _require_xfs_io_command tests a regular file but doesn't check
> > directories, so generic/607 should do that itself.  Also fix some typos.
> > 
> > Signed-off-by: Darrick J. Wong<darrick.wong@oracle.com>
> > ---
> >   common/rc         |   10 ++++++++--
> >   tests/generic/607 |    5 +++++
> >   2 files changed, 13 insertions(+), 2 deletions(-)
> > 
> > 
> > diff --git a/common/rc b/common/rc
> > index aa5a7409..f78b1cfc 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -2162,6 +2162,12 @@ _require_xfs_io_command()
> >   	local testfile=$TEST_DIR/$$.xfs_io
> >   	local testio
> >   	case $command in
> > +	"lsattr")
> > +		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
> > +		# support.
> > +		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
> > +		param_checked="$param"
> > +		;;
> >   	"chattr")
> >   		if [ -z "$param" ]; then
> >   			param=s
> > @@ -3205,7 +3211,7 @@ _check_s_dax()
> >   	if [ $exp_s_dax -eq 0 ]; then
> >   		(( attributes&  0x2000 ))&&  echo "$target has unexpected S_DAX flag"
> >   	else
> > -		(( attributes&  0x2000 )) || echo "$target doen't have expected S_DAX flag"
> > +		(( attributes&  0x2000 )) || echo "$target doesn't have expected S_DAX flag"
> >   	fi
> >   }
> > 
> > @@ -3217,7 +3223,7 @@ _check_xflag()
> >   	if [ $exp_xflag -eq 0 ]; then
> >   		_test_inode_flag dax $target&&  echo "$target has unexpected FS_XFLAG_DAX flag"
> >   	else
> > -		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
> > +		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
> >   	fi
> >   }
> > 
> > diff --git a/tests/generic/607 b/tests/generic/607
> > index b15085ea..14d2c05f 100755
> > --- a/tests/generic/607
> > +++ b/tests/generic/607
> > @@ -38,6 +38,11 @@ _require_scratch
> >   _require_dax_iflag
> >   _require_xfs_io_command "lsattr" "-v"
> > 
> > +# Make sure we can call FSGETXATTR on a directory...
> > +output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
> > +echo "$output" | grep -q "Inappropriate ioctl for device"&&  \
> > +	_notrun "$FSTYP: FSGETXATTR not supported on directories."
> Hi Darrick,
> 
> Could you tell me which kernel version gets the issue? :-)

ext4.

--D

> Best Regards,
> Xiao Yang
> > +
> >   # If a/ is +x, check that a's new children
> >   # inherit +x from a/.
> >   test_xflag_inheritance1()
> > 
> > 
> > 
> > .
> > 
> 
> 
>
Xiao Yang Sept. 17, 2020, 3:43 a.m. UTC | #3
于 2020/9/17 11:27, Darrick J. Wong 写道:
> On Thu, Sep 17, 2020 at 09:41:01AM +0800, Xiao Yang wrote:
>> On 2020/9/15 9:43, Darrick J. Wong wrote:
>>> From: Darrick J. Wong<darrick.wong@oracle.com>
>>>
>>> This test requires that the filesystem support calling FSGETXATTR on
>>> regular files and directories to make sure the FS_XFLAG_DAX flag works.
>>> The _require_xfs_io_command tests a regular file but doesn't check
>>> directories, so generic/607 should do that itself.  Also fix some typos.
>>>
>>> Signed-off-by: Darrick J. Wong<darrick.wong@oracle.com>
>>> ---
>>>    common/rc         |   10 ++++++++--
>>>    tests/generic/607 |    5 +++++
>>>    2 files changed, 13 insertions(+), 2 deletions(-)
>>>
>>>
>>> diff --git a/common/rc b/common/rc
>>> index aa5a7409..f78b1cfc 100644
>>> --- a/common/rc
>>> +++ b/common/rc
>>> @@ -2162,6 +2162,12 @@ _require_xfs_io_command()
>>>    	local testfile=$TEST_DIR/$$.xfs_io
>>>    	local testio
>>>    	case $command in
>>> +	"lsattr")
>>> +		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
>>> +		# support.
>>> +		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
>>> +		param_checked="$param"
>>> +		;;
>>>    	"chattr")
>>>    		if [ -z "$param" ]; then
>>>    			param=s
>>> @@ -3205,7 +3211,7 @@ _check_s_dax()
>>>    	if [ $exp_s_dax -eq 0 ]; then
>>>    		(( attributes&   0x2000 ))&&   echo "$target has unexpected S_DAX flag"
>>>    	else
>>> -		(( attributes&   0x2000 )) || echo "$target doen't have expected S_DAX flag"
>>> +		(( attributes&   0x2000 )) || echo "$target doesn't have expected S_DAX flag"
>>>    	fi
>>>    }
>>>
>>> @@ -3217,7 +3223,7 @@ _check_xflag()
>>>    	if [ $exp_xflag -eq 0 ]; then
>>>    		_test_inode_flag dax $target&&   echo "$target has unexpected FS_XFLAG_DAX flag"
>>>    	else
>>> -		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
>>> +		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
>>>    	fi
>>>    }
>>>
>>> diff --git a/tests/generic/607 b/tests/generic/607
>>> index b15085ea..14d2c05f 100755
>>> --- a/tests/generic/607
>>> +++ b/tests/generic/607
>>> @@ -38,6 +38,11 @@ _require_scratch
>>>    _require_dax_iflag
>>>    _require_xfs_io_command "lsattr" "-v"
>>>
>>> +# Make sure we can call FSGETXATTR on a directory...
>>> +output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
>>> +echo "$output" | grep -q "Inappropriate ioctl for device"&&   \
>>> +	_notrun "$FSTYP: FSGETXATTR not supported on directories."
>> Hi Darrick,
>>
>> Could you tell me which kernel version gets the issue? :-)
> ext4.
Hi Darrick,

I didn't get the issue by v5.7.0 xfs_io on v5.8.0 kernel:
----------------------------------------------------------------------------------
# blkid /dev/pmem0
/dev/pmem0: UUID="181f4d76-bc21-45b7-a6d2-e486f6cc479b" TYPE="ext4"
# df -h | grep pmem0
/dev/pmem0 2.0G 28K 1.8G 1% /mnt/xfstests/test
# strace -e ioctl xfs_io -c "lsattr -v" /mnt/xfstests/test
ioctl(3, FS_IOC_FSGETXATTR, 0x7ffdc7061d10) = 0
[] /mnt/xfstests/test
----------------------------------------------------------------------------------
Do I miss something?

Thanks,
Xiao Yang
> --D
>
>> Best Regards,
>> Xiao Yang
>>> +
>>>    # If a/ is +x, check that a's new children
>>>    # inherit +x from a/.
>>>    test_xflag_inheritance1()
>>>
>>>
>>>
>>> .
>>>
>>
>>
>
> .
>
Darrick J. Wong Sept. 17, 2020, 3:56 a.m. UTC | #4
On Thu, Sep 17, 2020 at 11:43:10AM +0800, Xiao Yang wrote:
> 于 2020/9/17 11:27, Darrick J. Wong 写道:
> > On Thu, Sep 17, 2020 at 09:41:01AM +0800, Xiao Yang wrote:
> > > On 2020/9/15 9:43, Darrick J. Wong wrote:
> > > > From: Darrick J. Wong<darrick.wong@oracle.com>
> > > > 
> > > > This test requires that the filesystem support calling FSGETXATTR on
> > > > regular files and directories to make sure the FS_XFLAG_DAX flag works.
> > > > The _require_xfs_io_command tests a regular file but doesn't check
> > > > directories, so generic/607 should do that itself.  Also fix some typos.
> > > > 
> > > > Signed-off-by: Darrick J. Wong<darrick.wong@oracle.com>
> > > > ---
> > > >    common/rc         |   10 ++++++++--
> > > >    tests/generic/607 |    5 +++++
> > > >    2 files changed, 13 insertions(+), 2 deletions(-)
> > > > 
> > > > 
> > > > diff --git a/common/rc b/common/rc
> > > > index aa5a7409..f78b1cfc 100644
> > > > --- a/common/rc
> > > > +++ b/common/rc
> > > > @@ -2162,6 +2162,12 @@ _require_xfs_io_command()
> > > >    	local testfile=$TEST_DIR/$$.xfs_io
> > > >    	local testio
> > > >    	case $command in
> > > > +	"lsattr")
> > > > +		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
> > > > +		# support.
> > > > +		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
> > > > +		param_checked="$param"
> > > > +		;;
> > > >    	"chattr")
> > > >    		if [ -z "$param" ]; then
> > > >    			param=s
> > > > @@ -3205,7 +3211,7 @@ _check_s_dax()
> > > >    	if [ $exp_s_dax -eq 0 ]; then
> > > >    		(( attributes&   0x2000 ))&&   echo "$target has unexpected S_DAX flag"
> > > >    	else
> > > > -		(( attributes&   0x2000 )) || echo "$target doen't have expected S_DAX flag"
> > > > +		(( attributes&   0x2000 )) || echo "$target doesn't have expected S_DAX flag"
> > > >    	fi
> > > >    }
> > > > 
> > > > @@ -3217,7 +3223,7 @@ _check_xflag()
> > > >    	if [ $exp_xflag -eq 0 ]; then
> > > >    		_test_inode_flag dax $target&&   echo "$target has unexpected FS_XFLAG_DAX flag"
> > > >    	else
> > > > -		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
> > > > +		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
> > > >    	fi
> > > >    }
> > > > 
> > > > diff --git a/tests/generic/607 b/tests/generic/607
> > > > index b15085ea..14d2c05f 100755
> > > > --- a/tests/generic/607
> > > > +++ b/tests/generic/607
> > > > @@ -38,6 +38,11 @@ _require_scratch
> > > >    _require_dax_iflag
> > > >    _require_xfs_io_command "lsattr" "-v"
> > > > 
> > > > +# Make sure we can call FSGETXATTR on a directory...
> > > > +output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
> > > > +echo "$output" | grep -q "Inappropriate ioctl for device"&&   \
> > > > +	_notrun "$FSTYP: FSGETXATTR not supported on directories."
> > > Hi Darrick,
> > > 
> > > Could you tell me which kernel version gets the issue? :-)
> > ext4.
> Hi Darrick,
> 
> I didn't get the issue by v5.7.0 xfs_io on v5.8.0 kernel:
> ----------------------------------------------------------------------------------
> # blkid /dev/pmem0
> /dev/pmem0: UUID="181f4d76-bc21-45b7-a6d2-e486f6cc479b" TYPE="ext4"
> # df -h | grep pmem0
> /dev/pmem0 2.0G 28K 1.8G 1% /mnt/xfstests/test
> # strace -e ioctl xfs_io -c "lsattr -v" /mnt/xfstests/test
> ioctl(3, FS_IOC_FSGETXATTR, 0x7ffdc7061d10) = 0
> [] /mnt/xfstests/test
> ----------------------------------------------------------------------------------
> Do I miss something?

Oops, sorry, I was reading the wrong VM report.  It's overlayfs (atop
xfs though I don't think that matters) that doesn't support FSGETXATTR
on directories.

--D

> Thanks,
> Xiao Yang
> > --D
> > 
> > > Best Regards,
> > > Xiao Yang
> > > > +
> > > >    # If a/ is +x, check that a's new children
> > > >    # inherit +x from a/.
> > > >    test_xflag_inheritance1()
> > > > 
> > > > 
> > > > 
> > > > .
> > > > 
> > > 
> > > 
> > 
> > .
> > 
> 
> 
>
Christoph Hellwig Sept. 17, 2020, 7:52 a.m. UTC | #5
On Wed, Sep 16, 2020 at 08:56:20PM -0700, Darrick J. Wong wrote:
> Oops, sorry, I was reading the wrong VM report.  It's overlayfs (atop
> xfs though I don't think that matters) that doesn't support FSGETXATTR
> on directories.

I think we should overlayfs to support FSGETXATTR on all files that
can be opened instead.
Darrick J. Wong Sept. 17, 2020, 3:54 p.m. UTC | #6
On Thu, Sep 17, 2020 at 08:52:45AM +0100, Christoph Hellwig wrote:
> On Wed, Sep 16, 2020 at 08:56:20PM -0700, Darrick J. Wong wrote:
> > Oops, sorry, I was reading the wrong VM report.  It's overlayfs (atop
> > xfs though I don't think that matters) that doesn't support FSGETXATTR
> > on directories.
> 
> I think we should overlayfs to support FSGETXATTR on all files that
> can be opened instead.

Heh, yes, that would be a better option. :)

Even if they do add it, though, I still think we need to be able to
_notrun this test to avoid failures on unpatched kernels?

This also makes me wonder, we lose all the FSGETXATTR state on copy-up,
don't we?  Since the VFS doesn't have a primitive for cloning all the
metadata?

--D
Christoph Hellwig Sept. 17, 2020, 4:02 p.m. UTC | #7
On Thu, Sep 17, 2020 at 08:54:39AM -0700, Darrick J. Wong wrote:
> On Thu, Sep 17, 2020 at 08:52:45AM +0100, Christoph Hellwig wrote:
> > On Wed, Sep 16, 2020 at 08:56:20PM -0700, Darrick J. Wong wrote:
> > > Oops, sorry, I was reading the wrong VM report.  It's overlayfs (atop
> > > xfs though I don't think that matters) that doesn't support FSGETXATTR
> > > on directories.
> > 
> > I think we should overlayfs to support FSGETXATTR on all files that
> > can be opened instead.
> 
> Heh, yes, that would be a better option. :)
> 
> Even if they do add it, though, I still think we need to be able to
> _notrun this test to avoid failures on unpatched kernels?

I think supporting FSGETXATTR only on regular files is a bug and should
fail.

> This also makes me wonder, we lose all the FSGETXATTR state on copy-up,
> don't we?  Since the VFS doesn't have a primitive for cloning all the
> metadata?

Good question.
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index aa5a7409..f78b1cfc 100644
--- a/common/rc
+++ b/common/rc
@@ -2162,6 +2162,12 @@  _require_xfs_io_command()
 	local testfile=$TEST_DIR/$$.xfs_io
 	local testio
 	case $command in
+	"lsattr")
+		# Test xfs_io lsattr support and filesystem FS_IOC_FSSETXATTR
+		# support.
+		testio=`$XFS_IO_PROG -F -f -c "lsattr $param" $testfile 2>&1`
+		param_checked="$param"
+		;;
 	"chattr")
 		if [ -z "$param" ]; then
 			param=s
@@ -3205,7 +3211,7 @@  _check_s_dax()
 	if [ $exp_s_dax -eq 0 ]; then
 		(( attributes & 0x2000 )) && echo "$target has unexpected S_DAX flag"
 	else
-		(( attributes & 0x2000 )) || echo "$target doen't have expected S_DAX flag"
+		(( attributes & 0x2000 )) || echo "$target doesn't have expected S_DAX flag"
 	fi
 }
 
@@ -3217,7 +3223,7 @@  _check_xflag()
 	if [ $exp_xflag -eq 0 ]; then
 		_test_inode_flag dax $target && echo "$target has unexpected FS_XFLAG_DAX flag"
 	else
-		_test_inode_flag dax $target || echo "$target doen't have expected FS_XFLAG_DAX flag"
+		_test_inode_flag dax $target || echo "$target doesn't have expected FS_XFLAG_DAX flag"
 	fi
 }
 
diff --git a/tests/generic/607 b/tests/generic/607
index b15085ea..14d2c05f 100755
--- a/tests/generic/607
+++ b/tests/generic/607
@@ -38,6 +38,11 @@  _require_scratch
 _require_dax_iflag
 _require_xfs_io_command "lsattr" "-v"
 
+# Make sure we can call FSGETXATTR on a directory...
+output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
+echo "$output" | grep -q "Inappropriate ioctl for device" && \
+	_notrun "$FSTYP: FSGETXATTR not supported on directories."
+
 # If a/ is +x, check that a's new children
 # inherit +x from a/.
 test_xflag_inheritance1()