Test to ensure that the EOFBLOCK_FL gets set/unset correctly. As found by Theodore Ts'o: If a 128K file is falloc'ed using the KEEP_SIZE flag, and then write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. This forces e2fsck to complain about that inode.
PATCH 1/1 Test to ensure that the EOFBLOCK_FL gets set/unset correctly. As found by Theodore Ts'o: If a 128K file is falloc'ed using the KEEP_SIZE flag, and then write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. This forces e2fsck to complain about that inode.
Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
--- 243 | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 25 +++++++++++ group | 1 + 3 files changed, 171 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out
243 new file +145 -0
@@ -0,0 +1,145 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This forces e2fsck to complain about that inode. +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is set. +BIT_SET=1 # inode flag - 0x400000 bit is not set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_file_state() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." + status=1 + exit ${status} + fi + + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + else + # Run fsck on the fs. fsck -t ${FSTYP} -fn ${TEST_DEV}. + _check_test_fs + fi + + # Remove test file + rm -f ${TEST_DIR}/${1} +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs generic +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. + +# Using FALLOC_FL_KEEP_SIZE +# Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_file_state test_1 ${BIT_SET} + +# Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_file_state test_2 ${BIT_SET} + +# Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_file_state test_3 ${BIT_NOT_SET} + +# Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_file_state test_4 ${BIT_NOT_SET} + +# Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io). +echo "Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_file_state test_5 ${BIT_NOT_SET} + +# Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_file_state test_6 ${BIT_NOT_SET} + + +status=0 +exit ${status}
243.out new file +25 -0
@@ -0,0 +1,25 @@ +QA output created by 243 +Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io). +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is not set. +Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is not set.
group +1 -0
@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 4 lines · Akshay Lal
As found by Theodore Ts'o: If a 128K file is falloc'ed using the
KEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This forces e2fsck to complain about that inode.
Thanks, a few comments below...
Quoted 28 lines
--- 243 | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 25 +++++++++++ group | 1 + 3 files changed, 171 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out243 new file +14
-0@@ -0,0 +1,145 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This forces e2fsck to complain about that inode. +# +# creator [email protected] + +seq=`basename $0`
243 line 24
Quoted 10 lines
243 new file +10
-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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is set. +BIT_SET=1 # inode flag - 0x400000 bit is not set.
I'm thinking one of the values in the comment is not right :)
243 line 34
Quoted 10 lines
243 new file +10
-0+ +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not.
I guess a little more comment here about why we do this only for ext4 might be good.
Just to make it more obvious in the main test could you maybe call it something like _check_ext4_eof_flag() ? If we ever need to do testing on other filesystems we can adjust it.
Quoted 12 lines
243 new file +12
-0+_check_file_state() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: }
243 line 56
Quoted 10 lines
243 new file +10
-0+ + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." + status=1 + exit ${status} + fi + + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set."
This will cause the test to fail on anything but ext4 because it's expected in the output but only happens for ext4...
You could redirect it into $seq.full, just to have it for analysis if the test ever fails.
Quoted 7 lines
243 new file +7
-0+ bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." + bit_set=0 + fi + + # Check current bit state to expected value.
243 line 73
Quoted 10 lines
243 new file +10
-0+ if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + else + # Run fsck on the fs. fsck -t ${FSTYP} -fn ${TEST_DEV}. + _check_test_fs
Ah now I see why you didn't call it _check_ext4_eof_flag() ;)
This may not be necessary, the harness runs fsck after each test anyway. On a large filesystem this could take a pretty long time if you run fsck 6 times. I'd just drop this and let the post-test-fsck catch any problems.
243 line 77
Quoted 4 lines
243 new file +4
-0+ fi + + # Remove test file + rm -f ${TEST_DIR}/${1}
... but I suppose you'd need to leave the files around for that to work, which is fine; the test_dir is supposed to age anyway.
Thanks,
-Eric
Quoted 104 lines
243 new file +68
-0+} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs generic +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. + +# Using FALLOC_FL_KEEP_SIZE +# Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_file_state test_1 ${BIT_SET} + +# Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_file_state test_2 ${BIT_SET} + +# Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_file_state test_3 ${BIT_NOT_SET} + +# Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_file_state test_4 ${BIT_NOT_SET} + +# Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io). +echo "Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_file_state test_5 ${BIT_NOT_SET} + +# Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_file_state test_6 ${BIT_NOT_SET} + + +status=0 +exit ${status}243.out new file +25
-0@@ -0,0 +1,25 @@ +QA output created by 243 +Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io). +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is not set. +Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is not set.group +0
-0
group deprecated · line 359
Quoted 4 lines
group +1
-0@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is set. +BIT_SET=1 # inode flag - 0x400000 bit is not set.I'm thinking one of the values in the comment is not right :)
Duh. Thats silly of me.
Done.
Quoted 9 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not.I guess a little more comment here about why we do this only for ext4 might be good.
Just to make it more obvious in the main test could you maybe call it something like
_check_ext4_eof_flag()? If we ever need to do testing on other filesystems we can adjust it.
Done.
Quoted 8 lines
Quoted 2 lines
+ if ((${iflags} &
0x400000)); then
+ echo "EOFBLOCK_FLbit is set."This will cause the test to fail on anything but ext4 because it's expected in the output but only happens for ext4...
You could redirect it into $seq.full, just to have it for analysis if the test ever fails.
I've added an else condition to exit the test with the error message that the test is only
supported on ext4 filesystems.
I've also redirected all echo messages to $seq.full
Quoted 9 lines
Quoted 2 lines
+ # Run fsck on the fs. fsck -t ${FSTYP} -fn ${TEST_DEV}.
+ _check_test_fsAh now I see why you didn't call it
_check_ext4_eof_flag();)This may not be necessary, the harness runs fsck after each test anyway. On a large filesystem this could take a pretty long time if you run fsck 6 times. I'd just drop this and let the post-test-fsck catch any problems.
Removed.
---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
Quoted 1 line
From
f1e8df788e4b93ae33e01c48a859f2b21c425357Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Fri, 27 Aug 2010 13:14:18 -0700
Subject: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
As found by Theodore Ts'o:
If a 128K file is falloc'ed using the KEEP_SIZE flag, and then write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. This forces e2fsck to complain about that inode.
Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
--- 243 | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 171 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out
243 new file +157 -0
@@ -0,0 +1,157 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This forces e2fsck to complain about that inode. +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + else + echo "Only EXT4 filesystems supported." >> $seq.full + status=1 + exit ${status} + fi +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs generic +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. + +# Using FALLOC_FL_KEEP_SIZE +# Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +# Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +# Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +# Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +# Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io). +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +# Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + + +status=0 +exit ${status}
243.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
group +1 -0
@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 20 lines · Akshay Lal
Quoted 4 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is set. +BIT_SET=1 # inode flag - 0x400000 bit is not set.I'm thinking one of the values in the comment is not right :)
Duh. Thats silly of me.
Done.Quoted 8 lines
243 line 41
Quoted 2 lines
243 new file +2
-0+# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not.I guess a little more comment here about why we do this only for ext4 might be good.
Just to make it more obvious in the main test could you maybe call it something like
_check_ext4_eof_flag()? If we ever need to do testing on other filesystems we can adjust it.Done.
Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+ if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set."
Quoted 8 lines
Quoted 5 lines
This will cause the test to fail on anything but ext4 because it's expected in the output but only happens for ext4...
You could redirect it into $seq.full, just to have it for analysis if the test ever fails.
I've added an else condition to exit the test with the error message that the test is only
supported on ext4 filesystems.
If you only want to run on ext4, just set _supported_fs ext4
but I think the test is fine to run on other filesystems, it exercises some boundary conditions, it just doesn't do the low-level testing for other filesystems. But that's ok, it's a regression test specifically for ext4 which can be sanity-checked on other filesystems.
I'd prefer to keep it a generic test, and only do the low-level debugfs checks for ext4....
More below.
Quoted 58 lines
I've also redirected all echo messages to $seq.full
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ # Run fsck on the fs. fsck -t ${FSTYP} -fn ${TEST_DEV}. + _check_test_fsAh now I see why you didn't call it
_check_ext4_eof_flag();)This may not be necessary, the harness runs fsck after each test anyway. On a large filesystem this could take a pretty long time if you run fsck 6 times. I'd just drop this and let the post-test-fsck catch any problems.
Removed.
---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------From
f1e8df788e4b93ae33e01c48a859f2b21c425357Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Fri, 27 Aug 2010 13:14:18 -0700
Subject: [PATCH] Test to ensure that theEOFBLOCK_FLgets set/unset correctly.
As found by Theodore Ts'o:
If a 128K file is falloc'ed using theKEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This forces e2fsck to complain about that inode.Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682--- 243 | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 171 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out243 new file +16
-0@@ -0,0 +1,157 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This forces e2fsck to complain about that inode. +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +# creator [email protected] + +seq=`basename $0`
243 line 26
Quoted 10 lines
243 new file +10
-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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set.
still different ;)
Quoted 46 lines
243 new file +46
-0+ +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then
243 line 82
Quoted 10 lines
243 new file +10
-0+ echo "Error: Current bit state incorrect." >> $seq.full + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + else + echo "Only EXT4 filesystems supported." >> $seq.full + status=1 + exit ${status}
this will make it -fail- on other filesystems, at worst we want to not run, but in reality we can just skip the debugfs steps for non-ext4 and do the quick checks on other filesystems, with the built-in fsck backing us up.
So I'd just say "if not ext4 return" and then let the rest of the function do the ext4 checking.
(FYI if/when you ever do want to bail like above, you can either:
_notrun "Sorry, Dave, I'm afraid I can't do that"
or
_fail "Something terrible has gone wrong!"
and the user will see the results during the test run and get the right test status)
243 line 91
Quoted 9 lines
243 new file +9
-0+ fi +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs generic
so you have "generic" supported but it fails on non-ext4 now ;)
Really you probably want to have:
_supported_fs ext4 xfs btrfs gfs2
since those are the ones which support preallocation.
(sorry, I didn't catch that the first time)
-Eric
Quoted 90 lines
243 new file +66
-0+_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. + +# Using FALLOC_FL_KEEP_SIZE +# Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +# Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +# Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +# Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +# Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io). +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +# Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + + +status=0 +exit ${status}243.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)group +0
-0
group deprecated · line 359
Quoted 4 lines
group +1
-0@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 2 lines · Akshay Lal
Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
The test looks good - a few minor things, though. Firstly Can you add a brief description rather than just a URL as this forms the commit message?
Quoted 15 lines
--- 243 | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 25 +++++++++++ group | 1 + 3 files changed, 171 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out243 new file +1
-0@@ -0,0 +1,145 @@ +#! /bin/bash
243 line 11
Quoted 10 lines
243 new file +10
-0+# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This forces e2fsck to complain about that inode. +# +# creator
Please retain the GPL license text here as per the new test template and all other tests.
Quoted 45 lines
243 new file +45
-0[email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x40000 bit is set. +BIT_SET=1 # inode flag - 0x400000 bit is not set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_file_state() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." + status=1 + exit ${status} + fi + + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set."
243 line 66
Quoted 10 lines
243 new file +10
-0+ bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." + exit ${status}
That needs to be:
status=1
exit
For the cleanup trap to set the exit status correctly.
Quoted 9 lines
243 new file +9
-0+ fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + else + # Run fsck on the fs. fsck -t ${FSTYP} -fn ${TEST_DEV}. + _check_test_fs + fi +
243 line 85
Quoted 10 lines
243 new file +10
-0+ # Remove test file + rm -f ${TEST_DIR}/${1} +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs generic
I'm not sure this really is a generic test - it's testing an ext4 specific bug. We've got other generic tests that exercise fallocate, and some filesystems (like XFS) don't have special bits to say there are extents beyond EOF and checking a filesystem repeated won't report any problems. So perhaps if should be '_supported_fs ext4'
243 line 96
Quoted 11 lines
243 new file +11
-0+_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. + +# Using FALLOC_FL_KEEP_SIZE +# Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)."
No need for the comment and the echo. Just remove the comments.
Quoted 97 lines
243 new file +49
-0+${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_file_state test_1 ${BIT_SET} + +# Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_file_state test_2 ${BIT_SET} + +# Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_file_state test_3 ${BIT_NOT_SET} + +# Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_file_state test_4 ${BIT_NOT_SET} + +# Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io). +echo "Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io)." +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_file_state test_5 ${BIT_NOT_SET} + +# Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_file_state test_6 ${BIT_NOT_SET} + + +status=0 +exit ${status}243.out new file +25
-0@@ -0,0 +1,25 @@ +QA output created by 243 +Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io). +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io). +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io). +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io). +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is set. +Test 5: Fallocate 128k, seek to 256k and write a 4k block (buffered io). +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is not set. +Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io). +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +EOFBLOCK_FL bit is not set.group +1
-0@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick preallocSignature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 5 lines · Dave Chinner
I'm not sure this really is a generic test - it's testing an ext4 specific bug. We've got other generic tests that exercise fallocate, and some filesystems (like XFS) don't have special bits to say there are extents beyond EOF and checking a filesystem repeated won't report any problems. So perhaps if should be '
_supported_fsext4'
Oops we're giving conflicting advice :) I thought a test that exercises blocks-past-eof-filling at various boundaries made sense in general, even if the specific regression test is ext4-specific.
Seems like at least ocfs2/btrfs might benefit from the basic exercise, so I was recommending that it be generic.
I don't think there is any other test that makes a point of allocating X blocks past eof and then filling them exactly, overwriting/extending past them, etc. Seems like a good addition in general.
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 9 lines · Eric Sandeen
Quoted 5 lines · Dave Chinner
I'm not sure this really is a generic test - it's testing an ext4 specific bug. We've got other generic tests that exercise fallocate, and some filesystems (like XFS) don't have special bits to say there are extents beyond EOF and checking a filesystem repeated won't report any problems. So perhaps if should be '
_supported_fsext4'
Quoted 6 lines
Oops we're giving conflicting advice :) I thought a test that exercises blocks-past-eof-filling at various boundaries made sense in general, even if the specific regression test is ext4-specific.
Seems like at least ocfs2/btrfs might benefit from the basic exercise, so I was recommending that it be generic.
Ok, that seems reasonable. If the bug results in filesystem corruption, then maybe just relying on the check at the end of the test to fail it would be appropriate?
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 13 lines · Dave Chinner
Quoted 12 lines · Eric Sandeen
Quoted 5 lines · Dave Chinner
I'm not sure this really is a generic test - it's testing an ext4 specific bug. We've got other generic tests that exercise fallocate, and some filesystems (like XFS) don't have special bits to say there are extents beyond EOF and checking a filesystem repeated won't report any problems. So perhaps if should be '
_supported_fsext4'Oops we're giving conflicting advice :) I thought a test that exercises blocks-past-eof-filling at various boundaries made sense in general, even if the specific regression test is ext4-specific.
Quoted 6 lines
Quoted 2 lines
Seems like at least ocfs2/btrfs might benefit from the basic exercise, so I was recommending that it be generic.
Ok, that seems reasonable. If the bug results in filesystem corruption, then maybe just relying on the check at the end of the test to fail it would be appropriate?
That's fine by me, if e2fsck will squawk, that's enough.
-Eric
Quoted 3 lines
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
I reckon I've addressed all the concerns (yes even the comment mismatch)
---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
Quoted 1 line
From
6bf876f2b95e61409abbab24754c80354988bcc9Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Fri, 27 Aug 2010 13:14:18 -0700
Subject: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
As found by Theodore Ts'o:
If a 128K file is falloc'ed using the KEEP_SIZE flag, and then write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. This forces e2fsck to complain about that inode.
Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
--- 243 | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out
243 new file +177 -0
@@ -0,0 +1,177 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}
243.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
group +1 -0
@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
Signature · 7 lines
1.7.1 --- Cheers! Akshay Lal
Quoted 17 lines · Eric Sandeen
Quoted 16 lines · Dave Chinner
Quoted 14 lines · Eric Sandeen
Quoted 5 lines · Dave Chinner
I'm not sure this really is a generic test - it's testing an ext4 specific bug. We've got other generic tests that exercise fallocate, and some filesystems (like XFS) don't have special bits to say there are extents beyond EOF and checking a filesystem repeated won't report any problems. So perhaps if should be '
_supported_fsext4'Oops we're giving conflicting advice :) I thought a test that exercises blocks-past-eof-filling at various boundaries made sense in general, even if the specific regression test is ext4-specific.
Seems like at least ocfs2/btrfs might benefit from the basic exercise, so I was recommending that it be generic.
Quoted 13 lines
Quoted 3 lines
Ok, that seems reasonable. If the bug results in filesystem corruption, then maybe just relying on the check at the end of the test to fail it would be appropriate?
That's fine by me, if e2fsck will squawk, that's enough.
-Eric
Quoted 3 lines
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 1 line · Akshay Lal
I reckon I've addressed all the concerns (yes even the comment mismatch)
perhaps, but there is a syntax error in the test now ;)
Apply the patch & run it and you'll see...
Other than that it looks ok to me.
When you resend, please include a:
after the description and before the:
---
<patch>
Thanks,
-Eric
Quoted 229 lines
---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
From6bf876f2b95e61409abbab24754c80354988bcc9Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Fri, 27 Aug 2010 13:14:18 -0700
Subject: [PATCH] Test to ensure that theEOFBLOCK_FLgets set/unset correctly.
As found by Theodore Ts'o:
If a 128K file is falloc'ed using theKEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This forces e2fsck to complain about that inode.Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682--- 243 | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out243 new file +177
-0@@ -0,0 +1,177 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}243.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)group +0
-0
group deprecated · line 359
Quoted 4 lines
group +1
-0@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
There was a missing fi at the the end of the _check_ext4_eof_flag method.
Also corrected some indentation.
---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
Quoted 1 line
From
e6906071ab6c0ad38d3ee0a463b5c7944e71fd00Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Tue, 7 Sep 2010 12:54:33 -0700
Subject: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
As found by Theodore Ts'o:
If a 128K file is falloc'ed using the KEEP_SIZE flag, and then write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. This is bad since it forces e2fsck to complain about that inode. If you have a large number of inodes that are written with fallocate using KEEP_SIZE, and then fill them up to their expected size, e2fsck will potentially complain about a _huge_ number of inodes. This would also cause a huge increase in the time taken by e2fsck to complete its check.
Test scenarios covered:
1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io)
2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io)
3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io)
These test cases exercise the normal and edge case conditions using falloc (and KEEP_SIZE).
Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
--- 243 | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 192 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out
243 new file +178 -0
@@ -0,0 +1,178 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + bit_set=1 + + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + fi +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}
243.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
group +1 -0
@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
Signature · 7 lines
1.7.1 --- Cheers! Akshay Lal
Quoted 247 lines · Eric Sandeen
Quoted 1 line · Akshay Lal
I reckon I've addressed all the concerns (yes even the comment mismatch)
perhaps, but there is a syntax error in the test now ;)
Apply the patch & run it and you'll see...
Other than that it looks ok to me.
When you resend, please include a:
Signed-off-by Akshay Lal <[email protected]>after the description and before the:
---
<patch>Thanks,
-EricQuoted 225 lines
---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
From6bf876f2b95e61409abbab24754c80354988bcc9Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Fri, 27 Aug 2010 13:14:18 -0700
Subject: [PATCH] Test to ensure that theEOFBLOCK_FLgets set/unset correctly. As found by Theodore Ts'o:
If a 128K file is falloc'ed using theKEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This forces e2fsck to complain about that inode.Bug reference:
http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
---
243 | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++
group | 1 +3 files changed, 191 insertions(+), 0 deletions(-)create mode 100644 243
create mode 100644 243.out243 new file +177
-0@@ -0,0 +1,177 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + bit_set=1 + + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}243.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)group +0
-0
Quoted 10 lines
Quoted 8 lines
index ff16bb3..e6dab13 100644
group +0
-0@@ -356,3 +356,4 @@ deprecated240 auto aio quick rw
241 auto
242 auto quick prealloc
+243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 3 lines · Akshay Lal
There was a missing fi at the the end of the
_check_ext4_eof_flagmethod.Also corrected some indentation.
Thanks, I've committed this version.
In the future, keeping patch resubmissions tidy is helpful, i.e.
Subject: [PATCH Vx] subsystem: description
patch description
Signed-off-by:
---
other information that won't go into the commit
patch itself
... without the other cruft, forwarded snippets, etc :)
see also Documentation/SubmittingPatches
in the kernel tree.
Thanks,
-Eric
Quoted 244 lines
Signed-off-by Akshay Lal <[email protected]>---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
Frome6906071ab6c0ad38d3ee0a463b5c7944e71fd00Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Tue, 7 Sep 2010 12:54:33 -0700
Subject: [PATCH] Test to ensure that theEOFBLOCK_FLgets set/unset correctly.As found by Theodore Ts'o:
If a 128K file is falloc'ed using theKEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This is bad since it forces e2fsck to complain about that inode. If you have a large number of inodes that are written with fallocate usingKEEP_SIZE, and then fill them up to their expected size, e2fsck will potentially complain about a _huge_ number of inodes. This would also cause a huge increase in the time taken by e2fsck to complete its check.Test scenarios covered:
1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io)
2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io)
3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io)These test cases exercise the normal and edge case conditions using falloc (and
KEEP_SIZE).Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
--- 243 | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 192 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out243 new file +178
-0@@ -0,0 +1,178 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + bit_set=1 + + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + fi +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}243.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)group +0
-0
group deprecated · line 359
Quoted 4 lines
group +1
-0@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Thanks Eric, as we move fwd, these patch will be better.
---
Cheers!
Akshay Lal
Quoted 268 lines · Eric Sandeen
Quoted 3 lines · Akshay Lal
There was a missing fi at the the end of the
_check_ext4_eof_flagmethod.Also corrected some indentation.
Thanks, I've committed this version.
In the future, keeping patch resubmissions tidy is helpful, i.e.
Subject: [PATCH Vx] subsystem: description
patch description
Signed-off-by:
---
other information that won't go into the commitpatch itself
... without the other cruft, forwarded snippets, etc :)
see also
Documentation/SubmittingPatches
in the kernel tree.Thanks,
-Eric
Quoted 240 lines
Signed-off-by Akshay Lal <[email protected]>---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
Frome6906071ab6c0ad38d3ee0a463b5c7944e71fd00Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Tue, 7 Sep 2010 12:54:33 -0700
Subject: [PATCH] Test to ensure that theEOFBLOCK_FLgets set/unset correctly.As found by Theodore Ts'o:
If a 128K file is falloc'ed using theKEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This is bad since it forces e2fsck to complain about that inode. If you have a large number of inodes that are written with fallocate usingKEEP_SIZE, and then fill them up to their expected size, e2fsck will potentially complain about a _huge_ number of inodes. This would also cause a huge increase in the time taken by e2fsck to complete its check.Test scenarios covered:
1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io)
2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io)
3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io)These test cases exercise the normal and edge case conditions using falloc (and
KEEP_SIZE).Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
---
243 | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++
group | 1 +3 files changed, 192 insertions(+), 0 deletions(-)create mode 100644 243
create mode 100644 243.out243 new file +178
-0@@ -0,0 +1,178 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + bit_set=1 + + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + fi +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}243.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)group +0
-0
Quoted 10 lines
Quoted 8 lines
index ff16bb3..e6dab13 100644
group +0
-0@@ -356,3 +356,4 @@ deprecated240 auto aio quick rw
241 auto
242 auto quick prealloc
+243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH] Test to ensure that the EOFBLOCK_FL gets set/unset correctly.
Quoted 2 lines · Akshay Lal
Thanks Eric, as we move fwd, these patch will be better.
No problem, I appreciate the testcase... a lot! :)
-Eric
Quoted 6 lines
---
Cheers!
Akshay Lal
Quoted 278 lines
Quoted 276 lines · Eric Sandeen
Quoted 3 lines · Akshay Lal
There was a missing fi at the the end of the
_check_ext4_eof_flagmethod.Also corrected some indentation.
Thanks, I've committed this version.
In the future, keeping patch resubmissions tidy is helpful, i.e.
Subject: [PATCH Vx] subsystem: description
patch description
Signed-off-by:
---
other information that won't go into the commitpatch itself
... without the other cruft, forwarded snippets, etc :)
see also
Documentation/SubmittingPatches
in the kernel tree.Thanks,
-Eric
Quoted 248 lines
Signed-off-by Akshay Lal <[email protected]>---------------------------------------------------------------------------------------
Updated patch:
---------------------------------------------------------------------------------------
Frome6906071ab6c0ad38d3ee0a463b5c7944e71fd00Mon Sep 17 00:00:00 2001
From: Akshay Lal <[email protected]>
Date: Tue, 7 Sep 2010 12:54:33 -0700
Subject: [PATCH] Test to ensure that theEOFBLOCK_FLgets set/unset correctly.As found by Theodore Ts'o:
If a 128K file is falloc'ed using theKEEP_SIZEflag, and then write exactly 128K, theEOFBLOCK_FLdoesn't get cleared correctly. This is bad since it forces e2fsck to complain about that inode. If you have a large number of inodes that are written with fallocate usingKEEP_SIZE, and then fill them up to their expected size, e2fsck will potentially complain about a _huge_ number of inodes. This would also cause a huge increase in the time taken by e2fsck to complete its check.Test scenarios covered:
1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io)
2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io)
3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io)These test cases exercise the normal and edge case conditions using falloc (and
KEEP_SIZE).Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682
--- 243 | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 243.out | 13 +++++ group | 1 + 3 files changed, 192 insertions(+), 0 deletions(-) create mode 100644 243 create mode 100644 243.out243 new file +178
-0@@ -0,0 +1,178 @@ +#! /bin/bash +# FS QA Test No. 243 +# +# Test to ensure that the EOFBLOCK_FL gets set/unset correctly. +# +# As found by Theodore Ts'o: +# If a 128K file is falloc'ed using the KEEP_SIZE flag, and then +# write exactly 128K, the EOFBLOCK_FL doesn't get cleared correctly. +# This is bad since it forces e2fsck to complain about that inode. +# If you have a large number of inodes that are written with fallocate +# using KEEP_SIZE, and then fill them up to their expected size, +# e2fsck will potentially complain about a _huge_ number of inodes. +# This would also cause a huge increase in the time taken by e2fsck +# to complete its check. +# +# Test scenarios covered: +# 1. Fallocating X bytes and writing Y (Y<X) (buffered and direct io) +# 2. Fallocating X bytes and writing Y (Y=X) (buffered and direct io) +# 3. Fallocating X bytes and writing Y (Y>X) (buffered and direct io) +# +# These test cases exercise the normal and edge case conditions using +# falloc (and KEEP_SIZE). +# +# Ref: http://thread.gmane.org/gmane.comp.file-systems.ext4/20682 +# +#----------------------------------------------------------------------- +# Copyright (c) 2010 Google, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +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 + +# Test specific macros. +BIT_NOT_SET=0 # inode flag - 0x400000 bit is not set. +BIT_SET=1 # inode flag - 0x400000 bit is set. + +# Generic test cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Ext4 uses the EOFBLOCKS_FL bit when fallocating blocks with KEEP_SIZE +# enabled. The only time this bit should be set is when extending the allocated +# blocks further than what the i_size represents. In the situations wherein the +# i_size covers all allocated blocks, this bit should be cleared. + +# Checks the state of the sample file in the filesystem and returns whether +# the inode flag 0x400000 is set or not. +_check_ext4_eof_flag() +{ + # Check whether EOFBLOCK_FL is set. + # For ext4 filesystems: use debugfs to check if EOFBLOCKS_FL is set. + # Other filesystems: do nothing. The default fsck at the end of the test + # should catch any potential errors. + if [ "${FSTYP}" == "ext4" ]; then + bit_set=1 + + # Unmount the ${TEST_DEV} + umount ${TEST_DEV} + + # Run debugfs to gather file_parameters - specifically iflags. + file_params=`debugfs ${TEST_DEV} -R "stat ${1}" 2>&1 | grep -e Flags:` + iflags=${file_params#*Flags: } + + # Ensure that the iflags value was parsed correctly. + if [ -z ${iflags} ]; then + echo "iFlags value was not parsed successfully." >> $seq.full + status=1 + exit ${status} + fi + + # Check if EOFBLOCKS_FL is set. + if ((${iflags} & 0x400000)); then + echo "EOFBLOCK_FL bit is set." >> $seq.full + bit_set=1 + else + echo "EOFBLOCK_FL bit is not set." >> $seq.full + bit_set=0 + fi + + # Check current bit state to expected value. + if [ ${bit_set} -ne ${2} ]; then + echo "Error: Current bit state incorrect." >> $seq.full + status=1 + exit ${status} + fi + + # Mount the ${TEST_DEV} + mount ${TEST_DEV} -t ${FSTYP} ${TEST_DIR} + fi +} + +# Get standard environment, filters and checks. +. ./common.rc +. ./common.filter + +# Prerequisites for the test run. +_supported_fs ext4 xfs btrfs gfs2 +_supported_os Linux +_require_xfs_io_falloc + +# Real QA test starts here. +rm -f $seq.full + +# Begin test cases. +echo "Test 1: Fallocate 40960 bytes and write 4096 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_1 | _filter_xfs_io_unique +_check_ext4_eof_flag test_1 ${BIT_SET} + +echo "Test 2: Fallocate 40960 bytes and write 4096 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 4096' \ + ${TEST_DIR}/test_2 | _filter_xfs_io_unique +_check_ext4_eof_flag test_2 ${BIT_SET} + +echo "Test 3: Fallocate 40960 bytes and write 40960 bytes (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_3 | _filter_xfs_io_unique +_check_ext4_eof_flag test_3 ${BIT_NOT_SET} + +echo "Test 4: Fallocate 40960 bytes and write 40960 bytes (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 40960' \ + -c 'pwrite 0 40960' \ + ${TEST_DIR}/test_4 | _filter_xfs_io_unique +_check_ext4_eof_flag test_4 ${BIT_NOT_SET} + +echo "Test 5: Fallocate 128k, seek 256k and write 4k block (buffered io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_5 | _filter_xfs_io_unique +_check_ext4_eof_flag test_5 ${BIT_NOT_SET} + +echo "Test 6: Fallocate 128k, seek to 256k and write a 4k block (direct io)." \ + >> $seq.full +${XFS_IO_PROG} -F -f -d \ + -c 'falloc -k 0 128k' \ + -c 'pwrite 256k 4k' \ + ${TEST_DIR}/test_6 | _filter_xfs_io_unique +_check_ext4_eof_flag test_6 ${BIT_NOT_SET} + +status=0 +exit ${status}243.out new file +13
-0@@ -0,0 +1,13 @@ +QA output created by 243 +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 40960/40960 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 4096/4096 bytes at offset 262144 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)group +1
-0@@ -356,3 +356,4 @@ deprecated 240 auto aio quick rw 241 auto 242 auto quick prealloc +243 auto quick prealloc
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs