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 _begin_fstest auto quick attr metadata
21 # Override the default cleanup function.
28 # Import common functions.
32 # real QA test starts here
37 xattr_name="user.something"
39 xattr_value2="rabbit_hole"
44 local cur_val=$xattr_value1
46 $SETFATTR_PROG -n $xattr_name -v $cur_val $SCRATCH_MNT/$name
47 if [ "$cur_val" == "$xattr_value1" ]; then
57 grep "$xattr_name=" | cut -d '=' -f 2 | \
58 sed -e "s/$xattr_value1/GOOD/" -e "s/$xattr_value2/GOOD/"
61 _scratch_mkfs >>$seqres.full 2>&1
64 test_file="test_xattr_replace"
65 touch $SCRATCH_MNT/$test_file
66 $SETFATTR_PROG -n $xattr_name -v $xattr_value1 $SCRATCH_MNT/$test_file
68 set_xattr_loop $test_file &
71 for ((i = 0; i < 1000; i++)); do
72 _getfattr --absolute-names -n $xattr_name \
73 $SCRATCH_MNT/$test_file | value_filter