From: Darrick J. Wong Date: Thu, 5 Jan 2017 01:04:55 +0000 (-0800) Subject: ocfs2/reflink: fix file block size reporting X-Git-Tag: v2022.05.01~2235 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3547db8e8440568d974b00495ab2e15dcce4faec;p=users%2Fhch%2Fxfstests-dev.git ocfs2/reflink: fix file block size reporting 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 Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/common/rc b/common/rc index a69aa930b..67cb8dd4c 100644 --- 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() diff --git a/tests/generic/205 b/tests/generic/205 index 65e345a8b..564afc0ad 100755 --- a/tests/generic/205 +++ b/tests/generic/205 @@ -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" diff --git a/tests/generic/206 b/tests/generic/206 index 181650264..3fdbec23f 100755 --- a/tests/generic/206 +++ b/tests/generic/206 @@ -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" diff --git a/tests/generic/216 b/tests/generic/216 index d85c1e655..93b0106f6 100755 --- a/tests/generic/216 +++ b/tests/generic/216 @@ -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" diff --git a/tests/generic/217 b/tests/generic/217 index 19d6f007e..509f2c4f2 100755 --- a/tests/generic/217 +++ b/tests/generic/217 @@ -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" diff --git a/tests/generic/218 b/tests/generic/218 index f69c02a61..92bc52137 100755 --- a/tests/generic/218 +++ b/tests/generic/218 @@ -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" diff --git a/tests/generic/220 b/tests/generic/220 index 0678b5f43..2bd0e9999 100755 --- a/tests/generic/220 +++ b/tests/generic/220 @@ -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" diff --git a/tests/generic/222 b/tests/generic/222 index 24c54bb7a..eb2169cfa 100755 --- a/tests/generic/222 +++ b/tests/generic/222 @@ -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" diff --git a/tests/generic/227 b/tests/generic/227 index eb79bac54..3fe249029 100755 --- a/tests/generic/227 +++ b/tests/generic/227 @@ -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" diff --git a/tests/generic/229 b/tests/generic/229 index 332e69c66..55f875dd2 100755 --- a/tests/generic/229 +++ b/tests/generic/229 @@ -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() { diff --git a/tests/generic/238 b/tests/generic/238 index df13c63a0..c60799d5a 100755 --- a/tests/generic/238 +++ b/tests/generic/238 @@ -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() {