[Ocfs2-test-devel] [PATCH] no hole test v2

Goldwyn Rodrigues rgoldwyn at suse.de
Mon Feb 28 16:26:42 PST 2011


This is to test junk character which come where zeros are expected when
userspace lseeks. The conditions to reproduce the problem are:

1. blocksize(4k) < clustersize(8k)
2.  the previous write ended in a page boundary (12k-1), but not a cluster
boundary. 
3. Something is written at the start of next page (12K)
4. there is a hole created in the page from 12k-16k in *between* say
12290-16384, by a write to 16384.
5. i_size has moved past this page, or 16384.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>

--- 
diff --git a/programs/tailtest/tailtest b/programs/tailtest/tailtest
index 5bf70f7..efce2c1 100755
--- a/programs/tailtest/tailtest
+++ b/programs/tailtest/tailtest
@@ -46,7 +46,7 @@ make_fs()
             ;;
     esac
 
-    mkfs -t ocfs2 -C 1M \
+    mkfs -t ocfs2 -C 8k \
         --fs-features=local"$extra_features" "$device" ||
         die "Unable to create ocfs2 filesystem"
     mount -t ocfs2 "$device" "$mountpoint" ||
@@ -129,6 +129,40 @@ EOCAT
 EOCAT
     [ $? = 0 ] || die "Unable to create \"expected-1K\""
 
+    cat >"${mountpoint}/expected-nohole" <<EOCAT
+00000000  79 0a 79 0a 79 0a 79 0a  79 0a 79 0a 79 0a 79 0a  |y.y.y.y.y.y.y.y.|
+*
+00003000  79 0a 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |y...............|
+00003010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
+*
+00003ff0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 4a  |...............J|
+00004000
+EOCAT
+    [ $? = 0 ] || die "Unable to create \"expected-nohole\""
+}
+
+run_nohole_test()
+{
+    local mountpoint="$1"
+ 
+    local testfile="${mountpoint}/testfile"
+    local comparefile="${mountpoint}/diff"
+    local expectedfile="${mountpoint}/expected-nohole"
+
+    echo "Testing nohole ..."
+    yes | dd of="$testfile" count=12290 bs=1 2>/dev/null
+    echo "J" | dd of="$testfile" count=1 seek=16383 bs=1 conv=notrunc 2>/dev/null
+    dd if="$testfile" 2>/dev/null | hexdump -C >"$comparefile"
+    if diff -q "$comparefile" "$expectedfile" >/dev/null 2>&1;
+    then
+        echo "    Test passed."
+    else
+        echo "    Test failed.  Extent contents:"
+        cat "$comparefile"
+    fi
+
+    echo "Cleaning up after test ..."
+    clean_one_test "$testfile" "$comparefile"
 }
 
 run_tests()
@@ -142,6 +176,8 @@ run_tests()
         die "Unable to create ocfs2 filesystem"
     setup_expected "$mountpoint"
 
+    run_nohole_test "$mountpoint"
+
     local offset
     for offset in 10M 1M 512K 1K
     do



More information about the Ocfs2-test-devel mailing list