summaryrefslogtreecommitdiff
path: root/tests/generic/489
blob: ec42950c7d8a06728798f75f64c82ed87e09bc26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
#
# FSQA Test No. 489
#
# Test that xattrs are not lost after calling fsync multiple times with a
# filesystem commit in between the fsync calls.
#
. ./common/preamble
_begin_fstest auto quick attr log

# Override the default cleanup function.
_cleanup()
{
	_cleanup_flakey
	cd /
	rm -f $tmp.*
}

# Import common functions.
. ./common/filter
. ./common/dmflakey
. ./common/attr

# real QA test starts here
_supported_fs generic
_require_scratch
_require_dm_target flakey
_require_attrs

_scratch_mkfs >>$seqres.full 2>&1
_require_metadata_journaling $SCRATCH_DEV
_init_flakey
_mount_flakey

touch $SCRATCH_MNT/foobar
$SETFATTR_PROG -n user.xa1 -v qwerty $SCRATCH_MNT/foobar
$SETFATTR_PROG -n user.xa2 -v 'hello world' $SCRATCH_MNT/foobar
$SETFATTR_PROG -n user.xa3 -v test $SCRATCH_MNT/foobar
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar

# Call sync to commit all fileystem metadata.
sync

$XFS_IO_PROG -c "pwrite -S 0xea 0 64K" \
	     -c "fsync" \
	     $SCRATCH_MNT/foobar >>$seqres.full

# Simulate a power failure and mount the filesystem to check that the xattrs
# were not lost and neither was the data we wrote.
_flakey_drop_and_remount
echo "File xattrs after power failure:"
_getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
echo "File data after power failure:"
od -t x1 $SCRATCH_MNT/foobar

_unmount_flakey
_cleanup_flakey

status=0
exit