]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
test 194, test tricky mapping/conversion around holes
authorEric Sandeen <sandeen@sandeen.net>
Tue, 30 Dec 2008 22:34:17 +0000 (23:34 +0100)
committerChristoph Hellwig <hch@brick.lst.de>
Tue, 30 Dec 2008 22:34:17 +0000 (23:34 +0100)
Related to
http://oss.sgi.com/bugzilla/show_bug.cgi?id=801

Latest patch posted on that bug makes this testcase pass...

first 2 tests are simple buffred writ tests making sure stale
data isn't exposed, and hole-blocks aren't mapped.

2nd 2 tests are more related to the above bug, tricky testcase
uncovered by fsx on ppc64 which actually re-maps a block
which should be a hole, bringing stale data back into existence.

V2, don't use non-posix awk extensions

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
194 [new file with mode: 0644]
194.out [new file with mode: 0644]
group

diff --git a/194 b/194
new file mode 100644 (file)
index 0000000..47287a4
--- /dev/null
+++ b/194
@@ -0,0 +1,206 @@
+#! /bin/sh
+# FS QA Test No. 194
+#
+# Test mapping around/over holes for sub-page blocks
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2008 Eric Sandeen.  All Rights Reserved.
+#-----------------------------------------------------------------------
+#
+# creator
+owner=sandeen@sandeen.net
+
+seq=`basename $0`
+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
+
+# only xfs supported due to use of xfs_bmap
+_supported_fs xfs
+_supported_os IRIX Linux
+
+# real QA test starts here
+rm -f $seq.full
+
+# For this test we use block size = 1/8 page size
+pgsize=`$here/src/feature -s`
+blksize=`expr $pgsize / 8`
+
+# Filter out file mountpoint and physical location info
+# Input:
+#  EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL
+#  0: [0..63]:         160..223          0 (160..223)          64
+#  1: [64..127]:       hole                                    64
+# Output:
+#  SCRATCH_MNT/testfile4:      TYPE
+#  EXT:        TYPE    TOTAL
+#  0:  blocks  1
+#  1:  hole    1
+
+_filter_bmap()
+{
+    tee -a $seq.full | \
+    sed "s#$SCRATCH_MNT#SCRATCH_MNT#g" | \
+    awk \
+        '$3 ~ /hole/     { print $1 "\t" $3 "\t" ($4 * 512) / blksize; next }
+         $1 ~ /^[0-9]/   { print $1 "\tblocks\t" ($6 * 512) / blksize; next }
+         $1 ~ /^SCRATCH/ { print $1; next }
+                        { print $1 "\tTYPE\t" $6 }' blksize=$blksize
+}
+
+# Filter out offsets, which vary by blocksize
+_filter_od()
+{
+    tee -a $seq.full | \
+    sed -e "s/^[0-9A-Fa-f ]\{7,8\}//"
+}
+
+_require_scratch
+unset MKFS_OPTIONS
+unset XFS_MKFS_OPTIONS
+_scratch_mkfs_xfs -b size=$blksize >/dev/null 2>&1
+_scratch_mount
+
+# 512b block / 4k page example:
+#
+#1) Write 1k of data (buffered):
+#
+# |1111|1111|
+#
+# 2) ftruncate back to 256 bytes:
+#
+# |1100|
+#
+# 3) ftruncate out to 4k: ("H" means hole (expected))
+#
+# |1100|HHHH|HHHH|HHHH|HHHH|HHHH|HHHH|HHHH|
+#
+# So we should have 1 block of data/0, 7 blocks of holes.
+#
+# 4) check what's there with a direct IO read
+#
+# In fact what I get is 1 block of data/0, 1 block of 0's, and 7 blocks of
+# garbage:
+#
+# |1100|0000|GGGG|GGGG|GGGG|GGGG|GGGG|GGGG|
+#
+# The garbage is in fact stale data from the disk.
+#
+# Check that we don't get stale data and that the hole is a hole:
+
+echo "== Test 1 =="
+# Write, truncate in, truncate out
+xfs_io \
+-c "pwrite -S 0x11 -b `expr $pgsize / 2`  0 `expr $pgsize / 2`" \
+-c "truncate `expr $blksize / 2`" \
+-c "truncate $pgsize" \
+-t -f $SCRATCH_MNT/testfile1 >> $seq.full
+
+# directio read of entire file
+xfs_io \
+-c "pread 0 $pgsize" \
+-d $SCRATCH_MNT/testfile1 >> $seq.full
+
+xfs_bmap -v $SCRATCH_MNT/testfile1 | _filter_bmap
+od -x $SCRATCH_MNT/testfile1 | _filter_od
+
+# Similar but write another block to create block/hole/block/hole
+
+echo "== Test 2 =="
+# Write, truncate in, truncate out, write to middle
+xfs_io \
+-c "pwrite -S 0x11 -b `expr $pgsize / 2`  0 `expr $pgsize / 2`" \
+-c "truncate `expr $blksize / 2`" \
+-c "truncate $pgsize" \
+-c "pwrite -S 0x22 -b $blksize `expr $blksize \* 4` $blksize" \
+-t -f $SCRATCH_MNT/testfile2 >> $seq.full
+
+# directio read of entire file
+xfs_io \
+-c "pread 0 $pgsize" \
+-d $SCRATCH_MNT/testfile2 >> $seq.full
+
+xfs_bmap -v $SCRATCH_MNT/testfile2 | _filter_bmap
+od -x $SCRATCH_MNT/testfile2 | _filter_od
+
+# 512 byte block / 4k page example:
+
+# direct write 1 page (8 blocks) of "0x11" to 0x1000
+# map read 1 block, 512 (0x200) at 0
+# truncate to half a block, 256 (0x100)
+# truncate to block+1, 513 (0x201)
+# direct write "0x22" for 1 block at offset 2048 (0x800)
+
+# |1111|1111|1111|1111|1111|1111|1111|1111|     Write 1's
+# |MRMR|1111|1111|1111|1111|1111|1111|1111|     mapread
+# |11--|                                        truncate down
+# |1100|0---|                                   truncate up, block+1
+# |    |    |HHHH|HHHH|2222|                    Write 2's (extending)
+
+#           |uptodate?|
+# |1100|0000|1111|1111|2222|----|----|----|    <- potential badness
+
+# We're looking for this badness due to mapping over a hole:
+# Exposes stale data from 0x400 (1024) through 0x800 (2048)
+
+# 00000000  11 11 11 11 11 11 11 11  11 11 11 11 11 11 11 11  |................|
+# *
+# 00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+# *
+# 00000400  11 11 11 11 11 11 11 11  11 11 11 11 11 11 11 11  |................| <- BAD
+# *
+# 00000800  22 22 22 22 22 22 22 22  22 22 22 22 22 22 22 22  |""""""""""""""""|
+# *
+# 00000a00
+
+# We *should* get:
+# |1100|HHHH|HHHH|HHHH|2222|----|----|----|
+
+echo "== Test 3 =="
+xfs_io \
+-c "pwrite -S 0x11 -b $pgsize 0 $pgsize" \
+-c "mmap -r 0 $blksize" -c "mread 0 $blksize" -c "munmap" \
+-c "truncate `expr $blksize / 2`" \
+-c "truncate `expr $blksize + 1`" \
+-c "pwrite -S 0x22 -b $blksize `expr $pgsize / 2` $blksize" \
+-t -d -f $SCRATCH_MNT/testfile3 >> $seq.full
+
+xfs_bmap -v $SCRATCH_MNT/testfile3 | _filter_bmap
+od -x $SCRATCH_MNT/testfile3 | _filter_od
+
+# Now try the same thing but write a sector in the middle of that hole
+# If things go badly stale data will be exposed either side.
+# This is most interesting for block size > 512 (page size > 4096)
+
+# We *should* get:
+# |1100|HHHH|33HH|HHHH|2222|----|----|----|
+
+echo "== Test 4 =="
+xfs_io \
+-c "pwrite -S 0x11 -b $pgsize 0 $pgsize" \
+-c "mmap -r 0 $blksize" -c "mread 0 $blksize" -c "munmap" \
+-c "truncate `expr $blksize / 2`" \
+-c "truncate `expr $blksize + 1`" \
+-c "pwrite -S 0x22 -b $blksize `expr $pgsize / 2` $blksize" \
+-c "pwrite -S 0x33 -b 512 `expr $blksize \* 2` 512" \
+-t -d -f $SCRATCH_MNT/testfile4 >> $seq.full
+
+xfs_bmap -v $SCRATCH_MNT/testfile4 | _filter_bmap
+od -x $SCRATCH_MNT/testfile4 | _filter_od
+
+# success, all done
+status=0
+exit
diff --git a/194.out b/194.out
new file mode 100644 (file)
index 0000000..a8c5d9b
--- /dev/null
+++ b/194.out
@@ -0,0 +1,59 @@
+QA output created by 194
+== Test 1 ==
+SCRATCH_MNT/testfile1:
+EXT:   TYPE    TOTAL
+0:     blocks  1
+1:     hole    7
+1111 1111 1111 1111 1111 1111 1111 1111
+*
+0000 0000 0000 0000 0000 0000 0000 0000
+*
+
+== Test 2 ==
+SCRATCH_MNT/testfile2:
+EXT:   TYPE    TOTAL
+0:     blocks  1
+1:     hole    3
+2:     blocks  1
+3:     hole    3
+1111 1111 1111 1111 1111 1111 1111 1111
+*
+0000 0000 0000 0000 0000 0000 0000 0000
+*
+2222 2222 2222 2222 2222 2222 2222 2222
+*
+0000 0000 0000 0000 0000 0000 0000 0000
+*
+
+== Test 3 ==
+SCRATCH_MNT/testfile3:
+EXT:   TYPE    TOTAL
+0:     blocks  1
+1:     hole    3
+2:     blocks  1
+1111 1111 1111 1111 1111 1111 1111 1111
+*
+0000 0000 0000 0000 0000 0000 0000 0000
+*
+2222 2222 2222 2222 2222 2222 2222 2222
+*
+
+== Test 4 ==
+SCRATCH_MNT/testfile4:
+EXT:   TYPE    TOTAL
+0:     blocks  1
+1:     hole    1
+2:     blocks  1
+3:     hole    1
+4:     blocks  1
+1111 1111 1111 1111 1111 1111 1111 1111
+*
+0000 0000 0000 0000 0000 0000 0000 0000
+*
+3333 3333 3333 3333 3333 3333 3333 3333
+*
+0000 0000 0000 0000 0000 0000 0000 0000
+*
+2222 2222 2222 2222 2222 2222 2222 2222
+*
+
diff --git a/group b/group
index c1ddf515c2630ee889100286984598f2f539c0ea..832ea7665a99e28238e4bf56464442cad3b2d4e1 100644 (file)
--- a/group
+++ b/group
@@ -296,3 +296,4 @@ atime
 191 nfs4acl auto
 192 atime
 193 metadata auto
+194 rw auto