From patchwork Mon Nov 10 00:48:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 5262041 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B91A79F295 for ; Mon, 10 Nov 2014 00:49:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B34120172 for ; Mon, 10 Nov 2014 00:49:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05AF52016C for ; Mon, 10 Nov 2014 00:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751694AbaKJAtf (ORCPT ); Sun, 9 Nov 2014 19:49:35 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:49416 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751320AbaKJAte (ORCPT ); Sun, 9 Nov 2014 19:49:34 -0500 Received: from debian-vm3.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Sun, 09 Nov 2014 17:49:26 -0700 From: Filipe Manana To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH v2] fstests: add generic test to verify xattr replace operations are atomic Date: Mon, 10 Nov 2014 00:48:21 +0000 Message-Id: <1415580501-26604-1-git-send-email-fdmanana@suse.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415392826-11606-1-git-send-email-fdmanana@suse.com> References: <1415392826-11606-1-git-send-email-fdmanana@suse.com> 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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, UPPERCASE_50_75 autolearn=unavailable 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 This test verifies that replacing a xattr's value is an atomic operation. This is motivated by an issue in btrfs where replacing a xattr's value wasn't an atomic operation, it consisted of removing the old value and then inserting the new value in a btree. This made readers (getxattr and listxattrs) not getting neither the old nor the new value during a short time window. Signed-off-by: Filipe Manana --- V2: Several changes after Dave's review. Renamed test file, added test to the metadata category and filtered xattr value out of getfattr to include it in the golden output. tests/generic/036 | 102 +++++ tests/generic/036.out | 1001 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/group | 1 + 3 files changed, 1104 insertions(+) create mode 100755 tests/generic/036 create mode 100644 tests/generic/036.out diff --git a/tests/generic/036 b/tests/generic/036 new file mode 100755 index 0000000..ff5bef7 --- /dev/null +++ b/tests/generic/036 @@ -0,0 +1,102 @@ +#! /bin/bash +# FSQA Test No. 036 +# +# Verify that replacing a xattr's value is an atomic operation. +# This is motivated by an issue in btrfs where replacing a xattr's value +# wasn't an atomic operation, it consisted of removing the old value and +# then inserting the new value in a btree. This made readers (getxattr +# and listxattrs) not getting neither the old nor the new value during +# a short time window. +# +# The btrfs issue was fixed by the following linux kernel patch: +# +# Btrfs: make xattr replace operations atomic +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved. +# Author: Filipe Manana +# +# 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 +#----------------------------------------------------------------------- +# + +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() +{ + kill $setter_pid + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_need_to_be_root +_supported_fs generic +_supported_os Linux +_require_scratch +_require_attrs + +rm -f $seqres.full + +xattr_name="user.something" +xattr_value1="foobar" +xattr_value2="rabbit_hole" + +set_xattr_loop() +{ + local name=$1 + local cur_val=$xattr_value1 + while true; do + $SETFATTR_PROG -n $xattr_name -v $cur_val $SCRATCH_MNT/$name + if [ "$cur_val" == "$xattr_value1" ]; then + cur_val=$xattr_value2 + else + cur_val=$xattr_value1 + fi + done +} + +value_filter() +{ + grep "$xattr_name=" | cut -d '=' -f 2 | \ + sed -e "s/$xattr_value1/GOOD/" -e "s/$xattr_value2/GOOD/" +} + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +test_file="test_xattr_replace" +touch $SCRATCH_MNT/$test_file +$SETFATTR_PROG -n $xattr_name -v $xattr_value1 $SCRATCH_MNT/$test_file + +set_xattr_loop $test_file & +setter_pid=$! + +for ((i = 0; i < 1000; i++)); do + $GETFATTR_PROG --absolute-names -n $xattr_name \ + $SCRATCH_MNT/$test_file | value_filter +done + +status=0 +exit diff --git a/tests/generic/036.out b/tests/generic/036.out new file mode 100644 index 0000000..c440719 --- /dev/null +++ b/tests/generic/036.out @@ -0,0 +1,1001 @@ +QA output created by 036 +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" +"GOOD" diff --git a/tests/generic/group b/tests/generic/group index 9c82a6f..4b67df7 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -38,6 +38,7 @@ 033 auto quick rw 034 auto quick metadata log 035 auto quick +036 metadata auto quick 053 acl repair auto quick 062 attr udf auto quick 068 other auto freeze dangerous stress