2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat. All Rights Reserved.
7 # This is a regression test for kernel commit
8 # ef947b2 x86, mm: fix gup_pte_range() vs DAX mappings
9 # created by Jeffrey Moyer <jmoyer@redhat.com>
11 # This is reproducible only when testing on pmem device
12 # which is configured in "memory mode", not in "raw mode".
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
33 # remove previous $seqres.full before test
36 # Modify as appropriate.
41 _require_test_program "t_mmap_write_ro"
42 # running by unpriviliged user is not necessary to reproduce
43 # this bug, just trying to test more.
46 # real QA test starts here
48 _scratch_mkfs >>$seqres.full 2>&1
49 _scratch_mount "-o dax"
51 # remount TEST_DEV wo/ dax
52 export TEST_FS_MOUNT_OPTS=""
55 # prepare a 4k read-only DAX file, save its md5sum
56 $XFS_IO_PROG -f -c "pwrite -S 0xFF 0 4096" \
57 $SCRATCH_MNT/readonlyfile >> $seqres.full 2>&1
58 chmod 0644 $SCRATCH_MNT/readonlyfile
59 md5_1="$(_md5_checksum $SCRATCH_MNT/readonlyfile)"
61 # prepare another 4k non-DAX file
62 $XFS_IO_PROG -f -c "pwrite -S 0x00 0 4096" \
63 $TEST_DIR/${seq}.file >> $seqres.full 2>&1
65 # allow qa_user access
66 chown $qa_user $TEST_DIR/${seq}.file
68 # run test programme, read another file writing into
69 # the read-only file with mmap, which should fail.
71 # don't use $here/src/t_mmap_write_ro, as we're running it as a regular user,
72 # and $here may contain path component that a regular user doesn't have search
74 _user_do "src/t_mmap_write_ro $TEST_DIR/${seq}.file \
75 $SCRATCH_MNT/readonlyfile"
77 # read-only file should not get updated, md5sum again.
78 md5_2="$(_md5_checksum $SCRATCH_MNT/readonlyfile)"
80 [ "$md5_1" != "$md5_2" ] && echo "read only file changed"