Add two tests that check for correct behaviour of XFS_IOC_FSSETXATTR: - 307: check that extent size can always be set on a directory - 308: check that setting a non-zero extent size directly via the ioctl sets the expected flags (EXTSIZE and EXTSZINHERIT) Signed-off-by: Iustin Pop <iusty@xxxxxxxxx> --- tests/xfs/307 | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/307.out | 3 ++ tests/xfs/308 | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/308.out | 3 ++ tests/xfs/group | 2 ++ 5 files changed, 193 insertions(+) create mode 100755 tests/xfs/307 create mode 100644 tests/xfs/307.out create mode 100755 tests/xfs/308 create mode 100644 tests/xfs/308.out diff --git a/tests/xfs/307 b/tests/xfs/307 new file mode 100755 index 0000000..e8f3576 --- /dev/null +++ b/tests/xfs/307 @@ -0,0 +1,87 @@ +#! /bin/bash +# FS QA Test No. 307 +# +# Test that setting extent size on directories work even for large +# directories. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Google Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_test +_require_scratch + +_scratch_mkfs_xfs >/dev/null 2>&1 +_scratch_mount + +small=$SCRATCH_MNT/small +big=$SCRATCH_MNT/big + +# sanity check on a small directory +mkdir $small +# expect that an empty directory has no extents +xfs_bmap $small | grep -q "no extents" +# and that we can set an extent size on it +xfs_io -c 'extsize 8m' $small +# and finally check that the extent size update has taken place +(cd $SCRATCH_MNT; xfs_io -c 'extsize' small) + +# now create a 'big' (with extents) directory +mkdir $big +idx=1 +while xfs_bmap $big | grep -q "no extents"; do + touch $big/$idx + idx=$((idx+1)) + if [ "$idx" -gt 1048576 ]; then + # still no extents? giving up + echo "Can't make a directory to have extents even after 1M files" 1>&2 + exit + fi +done + +# expect that we can set the extent size on $big as well +xfs_io -c 'extsize 8m' $big +# and that it took effect +(cd $SCRATCH_MNT; xfs_io -c 'extsize' big) + +# success, all done +status=0 +exit diff --git a/tests/xfs/307.out b/tests/xfs/307.out new file mode 100644 index 0000000..f825525 --- /dev/null +++ b/tests/xfs/307.out @@ -0,0 +1,3 @@ +QA output created by 307 +[8388608] small +[8388608] big diff --git a/tests/xfs/308 b/tests/xfs/308 new file mode 100755 index 0000000..7b43836 --- /dev/null +++ b/tests/xfs/308 @@ -0,0 +1,98 @@ +#! /bin/bash +# FS QA Test No. 308 +# +# Test that setting extent size on files and directories (directly via +# ioctl and not via xfs_io) sets the correct flags. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Google Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_test +_require_scratch + +_scratch_mkfs_xfs >/dev/null 2>&1 +_scratch_mount + +file=$SCRATCH_MNT/file +dir=$SCRATCH_MNT/dir +cprog=$tmp.get_structs.c +oprog=$tmp.get_structs + +touch $file +mkdir $dir + +cat > $cprog << EOF +#include <stdio.h> +#include <xfs/xfs.h> + +int main(int argc, char **argv) { + struct fsxattr fa; + int fd = open(argv[1], O_RDONLY); + if (fd < 0) { + perror("open"); + return 1; + } + fa.fsx_xflags = 0; + fa.fsx_extsize = 1048576 * 8; + int r = xfsctl(argv[1], fd, XFS_IOC_FSSETXATTR, &fa); + if (r < 0) { + perror("xfsctl"); + return 1; + } + return 0; +} +EOF +cc -o $oprog $cprog >> $seqres.full 2>&1 || \ + _notrun "Could not compile test program (see end of $seqres.full)" + +$oprog $file +$oprog $dir +(cd $SCRATCH_MNT; + xfs_io -c 'lsattr' file; + xfs_io -c 'lsattr' dir) + +rm $file +rmdir $dir + +# success, all done +status=0 +exit diff --git a/tests/xfs/308.out b/tests/xfs/308.out new file mode 100644 index 0000000..ef2d5fd --- /dev/null +++ b/tests/xfs/308.out @@ -0,0 +1,3 @@ +QA output created by 308 +----------e--- file +-----------E-- dir diff --git a/tests/xfs/group b/tests/xfs/group index 4d35df5..35f1e6a 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -197,3 +197,5 @@ 304 auto quick quota 305 auto quota 306 auto stress log metadata repair +307 ioctl quick +308 ioctl quick -- 2.1.0 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs