]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
ocfs2/reflink: fix file block size reporting
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 5 Jan 2017 01:04:55 +0000 (17:04 -0800)
committerEryu Guan <eguan@redhat.com>
Sun, 15 Jan 2017 05:56:45 +0000 (13:56 +0800)
Some of the reflink tests try to require a specific filesystem block
size so that they can test file block manipulation functions.  That's
straightforward for most filesystems but ocfs2 throws in the additional
twist that data fork block mappings are stored in units of clusters, not
blocks, which causes these reflink tests to fail.

Therefore, introduce a new helper that retrieves the file minimum block
size and adapt the reflink tests to use that instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc
tests/generic/205
tests/generic/206
tests/generic/216
tests/generic/217
tests/generic/218
tests/generic/220
tests/generic/222
tests/generic/227
tests/generic/229
tests/generic/238

index a69aa930b7d7f698bb46fc9ac4a998feb10721cd..67cb8dd4c1c90e67dde9194d1616e62cc04be1ca 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -973,7 +973,7 @@ _scratch_mkfs_blocksized()
        ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
        ;;
     ocfs2)
-       yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
+       yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV
        ;;
     *)
        _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
@@ -3125,13 +3125,30 @@ _sysfs_dev()
        echo /sys/dev/block/$_maj:$_min
 }
 
+# Get the minimum block size of a file.  Usually this is the
+# minimum fs block size, but some filesystems (ocfs2) do block
+# mappings in larger units.
+_get_file_block_size()
+{
+       if [ -z $1 ] || [ ! -d $1 ]; then
+               echo "Missing mount point argument for _get_file_block_size"
+               exit 1
+       fi
+       if [ "$FSTYP" = "ocfs2" ]; then
+               stat -c '%o' $1
+       else
+               _get_block_size $1
+       fi
+}
+
+# Get the minimum block size of an fs.
 _get_block_size()
 {
        if [ -z $1 ] || [ ! -d $1 ]; then
                echo "Missing mount point argument for _get_block_size"
                exit 1
        fi
-       echo `stat -f -c %S $1`
+       stat -f -c %S $1
 }
 
 get_page_size()
index 65e345a8bdaadd8a8fc01025ccb8c38f409f45b6..564afc0ade08f01478c69e28a318248aa04abcca 100755 (executable)
@@ -60,7 +60,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index 181650264cbefb397aeace8ddb50a5e77892d883..3fdbec23f0932a9abfcd1d0247e0ca195d29e3aa 100755 (executable)
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index d85c1e6554a2fbce861969dba937d856c8223056..93b0106f6cfc3813654915bfe07996211077252a 100755 (executable)
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index 19d6f007e8880d87d4e85ba7ebd7504abe82b036..509f2c4f283a79985e4561e565588f34adc30be5 100755 (executable)
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index f69c02a610facbb8b1f523b3b455a040fa4b0525..92bc52137104f3bba6755176a4c2eb1513438ac9 100755 (executable)
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index 0678b5f43ef0e0570a91d3ce64afeb16bdef611b..2bd0e9999f4d79e3a254e1f26c1f3f4a2761d0b2 100755 (executable)
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index 24c54bb7a7303d2edc5d1b33117d3d024012c1d9..eb2169cfaa98d33d862479663c91e0eb93151a37 100755 (executable)
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index eb79bac54fe60681c3e406ce88c541d319ea8107..3fe2490295aa5b12554d0f0f01559377b3d562fd 100755 (executable)
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
index 332e69c66c26ba96914ef68f200ce1c30e0b02f9..55f875dd2052b6ee09259941d263f53eed62e15d 100755 (executable)
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {
index df13c63a02ce476129ed1ced08870ddcd2d23027..c60799d5a19e46ee8838eb81121fae3d1e032ebb 100755 (executable)
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(_get_block_size $testdir)
+real_blksz=$(_get_file_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {