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 _begin_fstest auto quick dax
17 # Import common functions.
20 # Modify as appropriate.
23 _require_scratch_dax_mountopt "dax"
24 _require_test_program "t_mmap_write_ro"
25 # running by unpriviliged user is not necessary to reproduce
26 # this bug, just trying to test more.
29 # real QA test starts here
31 _scratch_mkfs >>$seqres.full 2>&1
32 _scratch_mount "-o dax"
34 # remount TEST_DEV wo/ dax
35 export TEST_FS_MOUNT_OPTS=""
38 # prepare a 4k read-only DAX file, save its md5sum
39 $XFS_IO_PROG -f -c "pwrite -S 0xFF 0 4096" \
40 $SCRATCH_MNT/readonlyfile >> $seqres.full 2>&1
41 chmod 0644 $SCRATCH_MNT/readonlyfile
42 md5_1="$(_md5_checksum $SCRATCH_MNT/readonlyfile)"
44 # prepare another 4k non-DAX file
45 $XFS_IO_PROG -f -c "pwrite -S 0x00 0 4096" \
46 $TEST_DIR/${seq}.file >> $seqres.full 2>&1
48 # allow qa_user access
49 chown $qa_user $TEST_DIR/${seq}.file
51 # run test programme, read another file writing into
52 # the read-only file with mmap, which should fail.
54 # don't use $here/src/t_mmap_write_ro, as we're running it as a regular user,
55 # and $here may contain path component that a regular user doesn't have search
57 _user_do "src/t_mmap_write_ro $TEST_DIR/${seq}.file \
58 $SCRATCH_MNT/readonlyfile"
60 # read-only file should not get updated, md5sum again.
61 md5_2="$(_md5_checksum $SCRATCH_MNT/readonlyfile)"
63 [ "$md5_1" != "$md5_2" ] && echo "read only file changed"