generic: test adding filesystem-level fscrypt key via key_id
[xfstests-dev.git] / tests / generic / 361
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 361
6 #
7 # Test remount on I/O errors.
8 #
9 # XFS had a bug to hang on remount in this case, this kernel commit fix
10 # the issue.
11 # 5cb13dc cancel the setfilesize transation when io error happen
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         $UMOUNT_PROG $fs_mnt
25         _destroy_loop_device $loop_dev
26         cd /
27         rm -f $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs generic
38 _supported_os Linux
39 _require_scratch
40 _require_block_device $SCRATCH_DEV
41 _require_loop
42
43 # create a small filesystem to hold another filesystem image
44 _scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
45 _scratch_mount
46
47 # create the sparse fs image and mount point
48 fs_img=$SCRATCH_MNT/fs.img
49 fs_mnt=$SCRATCH_MNT/mnt
50 $XFS_IO_PROG -fc "truncate 1g" $fs_img >>$seqres.full 2>&1
51 mkdir -p $fs_mnt
52
53 # mount loop device and create a larger file to hit I/O errors on loop device
54 loop_dev=$(_create_loop_device $fs_img)
55 _mkfs_dev $loop_dev
56 _mount $loop_dev $fs_mnt
57 $XFS_IO_PROG -fc "pwrite 0 520m" $fs_mnt/testfile >>$seqres.full 2>&1
58
59 # remount should not hang
60 $MOUNT_PROG -o remount,ro $fs_mnt >>$seqres.full 2>&1
61
62 # success, all done
63 echo "Silence is golden"
64 status=0
65 exit