From patchwork Wed Sep 11 19:47:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2874281 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6989EBF43F for ; Wed, 11 Sep 2013 19:47:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABAAF202F9 for ; Wed, 11 Sep 2013 19:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB87C202EC for ; Wed, 11 Sep 2013 19:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757142Ab3IKTrc (ORCPT ); Wed, 11 Sep 2013 15:47:32 -0400 Received: from dkim1.fusionio.com ([66.114.96.53]:48591 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756920Ab3IKTrb (ORCPT ); Wed, 11 Sep 2013 15:47:31 -0400 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id C4E887C0697 for ; Wed, 11 Sep 2013 13:47:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1378928850; bh=05CBYKv+FdBadq5JXTr8y6HMy/LnPlf7VjEc+mCWmNM=; h=From:To:Subject:Date; b=a4KlPqOvlrcGdA5nGCYvcqfCsZq0l7k2WqhjWtDx2egDBSdvVF7GZF56T9La8rUZe 064t77zuM1ME1S9SzDjHSujofheobZMkT1QdEdnRtJvwrsatzH1Udf5WAAhZe5yQHz UBIe5aCStVJXqUeMkHQLpKz6AMv5kV8/TsbycKd0= X-ASG-Debug-ID: 1378928850-0421b50220398d20001-6jHSXT Received: from CAS1.int.fusionio.com (cas1.int.fusionio.com [10.101.1.40]) by mx2.fusionio.com with ESMTP id WB2KvVKQ96Gy9u8e (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Wed, 11 Sep 2013 13:47:30 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (10.101.1.160) by mail.fusionio.com (10.101.1.40) with Microsoft SMTP Server (TLS) id 14.3.158.1; Wed, 11 Sep 2013 13:47:29 -0600 From: Josef Bacik To: , Subject: [PATCH] xfstests: generic/311: add a few more test cases Date: Wed, 11 Sep 2013 15:47:27 -0400 X-ASG-Orig-Subj: [PATCH] xfstests: generic/311: add a few more test cases Message-ID: <1378928847-2349-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Originating-IP: [10.101.1.160] X-Barracuda-Connect: cas1.int.fusionio.com[10.101.1.40] X-Barracuda-Start-Time: 1378928850 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=MARKETING_SUBJECT X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.140529 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.60 MARKETING_SUBJECT Subject contains popular marketing words Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Btrfs had some issues with fsync()'ing directories and fsync()'ing after renames. These three new tests cover the 3 different issues we were seeing. Thanks, Signed-off-by: Josef Bacik --- tests/generic/311 | 89 +++++++++++++++++++++++++++++++++++++++++++++++- tests/generic/311.out | 8 ++++ 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/tests/generic/311 b/tests/generic/311 index 675d927..002ad57 100644 --- a/tests/generic/311 +++ b/tests/generic/311 @@ -70,6 +70,8 @@ testfile=$SCRATCH_MNT/$seq.fsync FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 180 0" FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 drop_writes" _TEST_OPTIONS="" +allow_writes=0 +drop_writes=1 _mount_flakey() { @@ -104,8 +106,6 @@ _load_flakey_table() _run_test() { # _run_test <0 - buffered | 1 - O_DIRECT> - allow_writes=0 - drop_writes=1 test_num=$1 direct_opt="" @@ -131,6 +131,83 @@ _run_test() _mount_flakey } +_clean_working_dir() +{ + _mount_flakey + rm -rf $SCRATCH_MNT/* + _unmount_flakey +} + +# Btrfs wasn't making sure the directory survived fsync +_directory_test() +{ + echo "fsync new directory" + _mount_flakey + mkdir $SCRATCH_MNT/bar + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar + _load_flakey_table $drop_writes + _unmount_flakey + + _load_flakey_table $allow_writes + _mount_flakey + _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }' + _unmount_flakey + _check_scratch_fs $FLAKEY_DEV + [ $? -ne 0 ] && _fatal "fsck failed" +} + +# Btrfs was losing a rename into a new directory +_rename_test() +{ + echo "rename fsync test" + _mount_flakey + touch $SCRATCH_MNT/foo + mkdir $SCRATCH_MNT/bar + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo + mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo + _load_flakey_table $drop_writes + _unmount_flakey + + _load_flakey_table $allow_writes + _mount_flakey + _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }' + _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }' + _unmount_flakey + _check_scratch_fs $FLAKEY_DEV + [ $? -ne 0 ] && _fatal "fsck failed" +} + +# Btrfs was failing to replay a log when we had a inode with a smaller inode +# number that is renamed into a directory with a higher inode number +_replay_rename_test() +{ + echo "replay rename fsync test" + _mount_flakey + touch $SCRATCH_MNT/foo + mkdir $SCRATCH_MNT/bar + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo + mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar + + # This is to force btrfs to relog the entire inode including the ref so + # we are sure to try and replay the ref along with the dir_index item + setfattr -n user.foo -v blah $SCRATCH_MNT/bar/foo >> $seqres.full 2>&1 + + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo + _load_flakey_table $drop_writes + _unmount_flakey + + _load_flakey_table $allow_writes + _mount_flakey + _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }' + _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }' + _unmount_flakey + _check_scratch_fs $FLAKEY_DEV + [ $? -ne 0 ] && _fatal "fsck failed" +} + _scratch_mkfs >> $seqres.full 2>&1 # Create a basic flakey device that will never error out @@ -157,5 +234,13 @@ for i in $(seq 1 20); do _run_test $i $direct done +rm -rf $SCRATCH_MNT/* +_unmount_flakey +_directory_test +_clean_working_dir +_rename_test +_clean_working_dir +_replay_rename_test + status=0 exit diff --git a/tests/generic/311.out b/tests/generic/311.out index 5bad6a7..8a0d5c8 100644 --- a/tests/generic/311.out +++ b/tests/generic/311.out @@ -319,3 +319,11 @@ Running test 20 direct, nolockfs Random seed is 20 a16ac2b84456d41a15a1a4cc1202179f a16ac2b84456d41a15a1a4cc1202179f +fsync new directory +drwxr-xr-x bar +rename fsync test +drwxr-xr-x bar +-rw-r--r-- foo +replay rename fsync test +drwxr-xr-x bar +-rw-r--r-- foo