2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
7 # Verify that replacing a xattr's value is an atomic operation.
8 # This is motivated by an issue in btrfs where replacing a xattr's value
9 # wasn't an atomic operation, it consisted of removing the old value and
10 # then inserting the new value in a btree. This made readers (getxattr
11 # and listxattrs) not getting neither the old nor the new value during
12 # a short time window.
14 # The btrfs issue was fixed by the following linux kernel patch:
16 # Btrfs: make xattr replace operations atomic
19 seqres=$RESULT_DIR/$seq
20 echo "QA output created by $seq"
22 status=1 # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # get standard environment, filters and checks
36 # real QA test starts here
44 xattr_name="user.something"
46 xattr_value2="rabbit_hole"
51 local cur_val=$xattr_value1
53 $SETFATTR_PROG -n $xattr_name -v $cur_val $SCRATCH_MNT/$name
54 if [ "$cur_val" == "$xattr_value1" ]; then
64 grep "$xattr_name=" | cut -d '=' -f 2 | \
65 sed -e "s/$xattr_value1/GOOD/" -e "s/$xattr_value2/GOOD/"
68 _scratch_mkfs >>$seqres.full 2>&1
71 test_file="test_xattr_replace"
72 touch $SCRATCH_MNT/$test_file
73 $SETFATTR_PROG -n $xattr_name -v $xattr_value1 $SCRATCH_MNT/$test_file
75 set_xattr_loop $test_file &
78 for ((i = 0; i < 1000; i++)); do
79 $GETFATTR_PROG --absolute-names -n $xattr_name \
80 $SCRATCH_MNT/$test_file | value_filter