From patchwork Mon Jun 11 18:24:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 10458751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 709C960467 for ; Mon, 11 Jun 2018 19:51:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57A49285D1 for ; Mon, 11 Jun 2018 19:51:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55E97286A3; Mon, 11 Jun 2018 19:51:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A50D2860A for ; Mon, 11 Jun 2018 19:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934713AbeFKTvG (ORCPT ); Mon, 11 Jun 2018 15:51:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:35260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932317AbeFKTvF (ORCPT ); Mon, 11 Jun 2018 15:51:05 -0400 Received: from debian3.lan (bl11-80-66.dsl.telepac.pt [85.244.80.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9EF982086D; Mon, 11 Jun 2018 19:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528746665; bh=fUl4VRN5TZDMdvXFInbXcQvuzceATfKDLeBerF1WxAk=; h=From:To:Cc:Subject:Date:From; b=NYZamehf8CsUWJbptB4GklqYBZoS7E4hHrKul7SgcaWK5gPNGvBTV6vpCUmTHCqO0 G+vSGNkQzENjqG7KT7JLSkqeLl8GkdAuhm6CaAkstEyDkf/kIUc/M0ly+0P+n0ASZZ OFuFvDEQCTGBAlYoSFdb8nbPYwdI2M8nPRHB9N3Q= From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH] generic: add test for fsync of directory after creating hard link Date: Mon, 11 Jun 2018 19:24:35 +0100 Message-Id: <20180611182435.18150-1-fdmanana@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana Test that if we create a new hard link for a file which was previously fsync'ed, fsync a parent directory of the new hard link and power fail, the parent directory exists after mounting the filesystem again. The parent directory must be a new directory, not yet persisted. This test is motivated by a bug found in btrfs, where the fsync'ed parent directory was lost after a power failure. The bug in btrfs is fixed by a patch for the linux kernel titled: "Btrfs: sync log after logging new name" Signed-off-by: Filipe Manana --- tests/generic/498 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/498.out | 2 ++ tests/generic/group | 1 + 3 files changed, 68 insertions(+) create mode 100755 tests/generic/498 create mode 100644 tests/generic/498.out diff --git a/tests/generic/498 b/tests/generic/498 new file mode 100755 index 00000000..1cf73bda --- /dev/null +++ b/tests/generic/498 @@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test No. 498 +# +# Test that if we create a new hard link for a file which was previously +# fsync'ed, fsync a parent directory of the new hard link and power fail, +# the parent directory exists after mounting the filesystem again. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + _cleanup_flakey + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/dmflakey + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_scratch +_require_dm_target flakey + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 +_require_metadata_journaling $SCRATCH_DEV +_init_flakey +_mount_flakey + +mkdir $SCRATCH_MNT/A +mkdir $SCRATCH_MNT/B +mkdir $SCRATCH_MNT/A/C +touch $SCRATCH_MNT/B/foo +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/B/foo +# It is important the new hard link is located in a hierarchy of new directories +# (not yet persisted). +ln $SCRATCH_MNT/B/foo $SCRATCH_MNT/A/C/foo +$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/A + +# Simulate a power failure and mount the filesystem to check that what we +# explicitly fsync'ed exists. +_flakey_drop_and_remount + +[ -d $SCRATCH_MNT/A ] || echo "directory A missing" +[ -f $SCRATCH_MNT/B/foo ] || echo "file B/foo is missing" + +_unmount_flakey +_cleanup_flakey + +echo "Silence is golden" +status=0 +exit diff --git a/tests/generic/498.out b/tests/generic/498.out new file mode 100644 index 00000000..31a5ff40 --- /dev/null +++ b/tests/generic/498.out @@ -0,0 +1,2 @@ +QA output created by 498 +Silence is golden diff --git a/tests/generic/group b/tests/generic/group index 397f9c1c..83a6fdab 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -500,3 +500,4 @@ 495 auto quick swap 496 auto quick swap 497 auto quick swap collapse +498 auto quick log