From patchwork Wed Dec 11 01:25:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 299735 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42F142C009A for ; Wed, 11 Dec 2013 12:25:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751808Ab3LKBZx (ORCPT ); Tue, 10 Dec 2013 20:25:53 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:43979 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751393Ab3LKBZw (ORCPT ); Tue, 10 Dec 2013 20:25:52 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBB1Polv011976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Dec 2013 01:25:50 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1Pn7P002511 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Dec 2013 01:25:49 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1PmcX029106; Wed, 11 Dec 2013 01:25:49 GMT Received: from localhost (/10.145.179.107) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Dec 2013 17:25:48 -0800 Subject: [PATCH 67/74] tests: check correct handling of reading and writing uninit extents To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: linux-ext4@vger.kernel.org Date: Tue, 10 Dec 2013 17:25:46 -0800 Message-ID: <20131211012546.30655.86099.stgit@birch.djwong.org> In-Reply-To: <20131211011813.30655.39624.stgit@birch.djwong.org> References: <20131211011813.30655.39624.stgit@birch.djwong.org> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Check that fallocate actually creates uninitialized extents, that reads from uninit regions don't return garbage data, and that subsequent writes to an uninitalized extent actually get recorded. Signed-off-by: Darrick J. Wong --- tests/metadata-checksum-test.sh | 62 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tests/metadata-checksum-test.sh b/tests/metadata-checksum-test.sh index 987e653..1c73e58 100755 --- a/tests/metadata-checksum-test.sh +++ b/tests/metadata-checksum-test.sh @@ -21,6 +21,7 @@ DIR="$(readlink -f "$(dirname "$0")")" E2FSPROGS="${DIR}/../" export LD_LIBRARY_PATH="${E2FSPROGS}/lib/:${LD_LIBRARY_PATH}" BLK_SZ=4096 +MAX_BLK_SZ=65536 #MOUNT_OPTS="errors=remount-ro" HUGE_DEV_NAME="HUGE" FUZZ_DEV=0 @@ -132,7 +133,7 @@ function msg { fi } -for prog in attr /usr/bin/time truncate fallocate gcc; do +for prog in od attr /usr/bin/time truncate fallocate gcc; do type "${prog}" 2> /dev/null || msg "WARNING: ${prog} not found!" done @@ -3095,6 +3096,65 @@ MKE2FS_CONFIG=/tmp/mke2fs.conf export MKE2FS_CONFIG } +########################## +function fallocate_dirty_test { +msg "fallocate_dirty_test" +$VALGRIND ${E2FSPROGS}/misc/mke2fs -T ext4icsum $MKFS_OPTS $MKFS_FEATURES -F "${DEV}" +test -z "$NO_CSUM" && $VALGRIND ${E2FSPROGS}/misc/tune2fs -O metadata_csum $DEV +${E2FSPROGS}/misc/dumpe2fs -h $DEV 2> /dev/null | egrep -q "^Filesystem state:[ ]*clean$" || ${fsck_cmd} -fDy $DEV || true + +${mount_cmd} ${MOUNT_OPTS} "${DEV}" "${MNT}" -t ext4 -o journal_checksum +echo "moo" > "${MNT}/a" +fallocate -l "$((6 * MAX_BLK_SZ))" "${MNT}/a" +umount "${MNT}" +${fsck_cmd} -f -n "${DEV}" + +str="$(${E2FSPROGS}/debugfs/debugfs -R 'ex /a' "${DEV}")" +echo "${str}" +echo "${str}" | grep -i uninit + +zap="$(${E2FSPROGS}/debugfs/debugfs -R 'bmap /a 1' "${DEV}")" +${E2FSPROGS}/debugfs/debugfs -w -R "zap -p 0x55 ${zap}" "${DEV}" + +${mount_cmd} ${MOUNT_OPTS} "${DEV}" "${MNT}" -t ext4 -o journal_checksum +od -tx1 -Ad -c "${MNT}/a" > /tmp/a +cat > /tmp/b << ENDL +0000000 6d 6f 6f 0a 00 00 00 00 00 00 00 00 00 00 00 00 + m o o \n \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +0000016 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +* +0393216 +ENDL +diff -u /tmp/a /tmp/b +echo "cow" | dd of="${MNT}/a" bs="${BLK_SZ}" count=1 seek=3 conv=notrunc +umount "${MNT}" +${fsck_cmd} -f -n "${DEV}" + +${E2FSPROGS}/debugfs/debugfs -R 'ex /a' "${DEV}" | cat - + +${mount_cmd} ${MOUNT_OPTS} "${DEV}" "${MNT}" -t ext4 -o journal_checksum +od -tx1 -Ad -c "${MNT}/a" > /tmp/a +OFF1="$(printf '%07d\n' "$((3 * BLK_SZ))")" +OFF2="$(printf '%07d\n' "$(((3 * BLK_SZ) + 16))")" +cat > /tmp/b << ENDL +0000000 6d 6f 6f 0a 00 00 00 00 00 00 00 00 00 00 00 00 + m o o \n \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +0000016 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +* +${OFF1} 63 6f 77 0a 00 00 00 00 00 00 00 00 00 00 00 00 + c o w \n \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +${OFF2} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 +* +0393216 +ENDL +diff -u /tmp/a /tmp/b +umount "${MNT}" +${fsck_cmd} -f -n "${DEV}" +} + # This test should be the last one (before speed tests, anyway) #### ALL SPEED TESTS GO AT THE END