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 <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Darrick J. Wong
2017-01-04 17:04:55 -08:00
committed by Eryu Guan
parent 0bfb84110b
commit 3547db8e84
11 changed files with 29 additions and 12 deletions
+19 -2
View File
@@ -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()
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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() {
+1 -1
View File
@@ -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() {