4 # Test that xattrs are not lost after calling fsync multiple times with a
5 # filesystem commit in between the fsync calls.
7 #-----------------------------------------------------------------------
9 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
10 # Author: Filipe Manana <fdmanana@suse.com>
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_dm_target flakey
56 _scratch_mkfs >>$seqres.full 2>&1
57 _require_metadata_journaling $SCRATCH_DEV
61 touch $SCRATCH_MNT/foobar
62 $SETFATTR_PROG -n user.xa1 -v qwerty $SCRATCH_MNT/foobar
63 $SETFATTR_PROG -n user.xa2 -v 'hello world' $SCRATCH_MNT/foobar
64 $SETFATTR_PROG -n user.xa3 -v test $SCRATCH_MNT/foobar
65 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar
67 # Call sync to commit all fileystem metadata.
70 $XFS_IO_PROG -c "pwrite -S 0xea 0 64K" \
72 $SCRATCH_MNT/foobar >>$seqres.full
74 # Simulate a power failure and mount the filesystem to check that the xattrs
75 # were not lost and neither was the data we wrote.
76 _flakey_drop_and_remount
77 echo "File xattrs after power failure:"
78 $GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
79 echo "File data after power failure:"
80 od -t x1 $SCRATCH_MNT/foobar