4 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 # Copyright (c) 2017 Konstantin Belousov <kib@FreeBSD.org>
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
33 # Variation of nfs_halfpage.sh with a 2GB file.
34 # Mark pages after EOF as clean after pageout.
35 # https://reviews.freebsd.org/D11697
36 # Committed as r321580 + r321581.
41 sed '1,/^EOF/d' < $odir/$0 > $dir/nfs_halfpage.c
42 mycc -o nfs_halfpage -Wall -Wextra -O0 -g nfs_halfpage.c || exit 1
46 [ -z "$nfs_export" ] && exit 0
47 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 ||
50 mount | grep "$mntpoint" | grep -q nfs && umount $mntpoint
51 mount -t nfs -o tcp -o retrycnt=3 -o intr,soft -o rw $nfs_export $mntpoint
53 file=$mntpoint/nfs_halfpage.file
54 /tmp/nfs_halfpage $file
57 echo "Reboot now to trigger syncing disks loop."
62 mount | grep -q "on $mntpoint " || break
63 umount $mntpoint && break || sleep 10
65 [ $i -eq 6 ] && exit 1
66 rm -f /tmp/nfs_halfpage
70 /* $Id: nfs_halfpage.c,v 1.2 2017/07/23 09:36:23 kostik Exp kostik $ */
72 #include <sys/types.h>
73 #include <sys/fcntl.h>
79 main(int argc __unused, char *argv[])
86 fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0666);
88 err(1, "open %s", argv[1]);
90 sz += 2LL * 1024 * 1024 * 1024;
91 error = lseek(fd, sz, SEEK_SET);
94 error = write(fd, "a", 1);
98 errx(1, "short write");
99 m = mmap(NULL, sz + 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);