generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 116
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 116
6 #
7 # Verify that when a fitrim operation is made against a btrfs filesystem, the
8 # ranges [0, 64Kb[ and [68Kb, 1Mb[ of the device are not discarded, they remain
9 # with the content they had before the fitrim operation. These regions of the
10 # device are reserved for a boot loader to use at its will.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick metadata
14
15 # Import common functions.
16 . ./common/filter
17
18 # real QA test starts here
19 _supported_fs btrfs
20 _require_scratch
21 # Writing non-contiguous data directly to the device
22 _require_non_zoned_device $SCRATCH_DEV
23
24 _scratch_mkfs >>$seqres.full 2>&1
25
26 # Write to the [0, 64Kb[ and [68Kb, 1Mb[ ranges of the device. These ranges are
27 # reserved for a boot loader to use (GRUB for example) and btrfs should never
28 # use them - neither for allocating metadata/data nor should trim/discard them.
29 # The range [64Kb, 68Kb[ is used for the primary superblock of the filesystem.
30 $XFS_IO_PROG -c "pwrite -S 0xfd 0 64K" $SCRATCH_DEV | _filter_xfs_io
31 $XFS_IO_PROG -c "pwrite -S 0xfd 68K 956K" $SCRATCH_DEV | _filter_xfs_io
32
33 # Now mount the filesystem and perform a fitrim against it.
34 _scratch_mount
35 _require_batched_discard $SCRATCH_MNT
36 $FSTRIM_PROG $SCRATCH_MNT
37
38 # Now unmount the filesystem and verify the content of the ranges was not
39 # modified (no trim/discard happened on them).
40 _scratch_unmount
41 echo "Content of the ranges [0, 64Kb] and [68Kb, 1Mb[ after fitrim:"
42 od -t x1 -N $((64 * 1024)) $SCRATCH_DEV
43 od -t x1 -j $((68 * 1024)) -N $((956 * 1024)) $SCRATCH_DEV
44
45 status=0
46 exit