1*8a272653SPeter Holm#!/bin/sh 2*8a272653SPeter Holm 3*8a272653SPeter Holm# 4*8a272653SPeter Holm# Copyright (c) 2015 EMC Corp. 5*8a272653SPeter Holm# All rights reserved. 6*8a272653SPeter Holm# 7*8a272653SPeter Holm# Redistribution and use in source and binary forms, with or without 8*8a272653SPeter Holm# modification, are permitted provided that the following conditions 9*8a272653SPeter Holm# are met: 10*8a272653SPeter Holm# 1. Redistributions of source code must retain the above copyright 11*8a272653SPeter Holm# notice, this list of conditions and the following disclaimer. 12*8a272653SPeter Holm# 2. Redistributions in binary form must reproduce the above copyright 13*8a272653SPeter Holm# notice, this list of conditions and the following disclaimer in the 14*8a272653SPeter Holm# documentation and/or other materials provided with the distribution. 15*8a272653SPeter Holm# 16*8a272653SPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*8a272653SPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8a272653SPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*8a272653SPeter Holm# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*8a272653SPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*8a272653SPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*8a272653SPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*8a272653SPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*8a272653SPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*8a272653SPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*8a272653SPeter Holm# SUCH DAMAGE. 27*8a272653SPeter Holm# 28*8a272653SPeter Holm 29*8a272653SPeter Holm# Test of unmapped unaligned i/o over the vnode-backed md(4) volume. 30*8a272653SPeter Holm# "panic: vm_fault: fault on nofault entry, addr: fffffe07f302c000" seen. 31*8a272653SPeter Holm# https://people.freebsd.org/~pho/stress/log/md8.txt 32*8a272653SPeter Holm# Fixed in r292128. 33*8a272653SPeter Holm 34*8a272653SPeter Holm# Test scenario by kib@ 35*8a272653SPeter Holm 36*8a272653SPeter Holm[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 37*8a272653SPeter Holm[ -d /usr/src/sys ] || exit 0 38*8a272653SPeter Holm 39*8a272653SPeter Holm. ../default.cfg 40*8a272653SPeter Holm 41*8a272653SPeter Holmrm -f $diskimage 42*8a272653SPeter Holmdir=`dirname $diskimage` 43*8a272653SPeter Holmfree=`df -k $dir | tail -1 | awk '{print $4}'` 44*8a272653SPeter Holm[ $((free / 1024)) -lt 50 ] && echo "Not enough disk space." && exit 45*8a272653SPeter Holm 46*8a272653SPeter Holmodir=`pwd` 47*8a272653SPeter Holmcd /tmp 48*8a272653SPeter Holmsed '1,/^EOF/d' < $odir/$0 > md8.c 49*8a272653SPeter Holmrm -f /tmp/md8 50*8a272653SPeter Holmmycc -o md8 -Wall -Wextra -g -O2 md8.c || exit 1 51*8a272653SPeter Holmrm -f md8.c 52*8a272653SPeter Holm 53*8a272653SPeter Holmcd $odir 54*8a272653SPeter Holmtrap "rm -f $diskimage" EXIT INT 55*8a272653SPeter Holmdd if=/dev/zero of=$diskimage bs=1m count=50 status=none 56*8a272653SPeter Holm[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart 57*8a272653SPeter Holmmdconfig -a -t vnode -f $diskimage -u $mdstart 58*8a272653SPeter Holm 59*8a272653SPeter Holmn=`sysctl -n hw.ncpu` 60*8a272653SPeter Holmn=$((n + 1)) 61*8a272653SPeter Holm(cd /usr/src; make -j $n buildkernel > /dev/null 2>&1) & 62*8a272653SPeter Holmsleep 1 63*8a272653SPeter Holm/tmp/md8 /dev/md$mdstart 64*8a272653SPeter Holmkill $! 65*8a272653SPeter Holmwait 66*8a272653SPeter Holm 67*8a272653SPeter Holmmdconfig -d -u $mdstart 68*8a272653SPeter Holmrm -rf /tmp/md8 69*8a272653SPeter Holmexit 0 70*8a272653SPeter HolmEOF 71*8a272653SPeter Holm#include <sys/param.h> 72*8a272653SPeter Holm 73*8a272653SPeter Holm#include <err.h> 74*8a272653SPeter Holm#include <fcntl.h> 75*8a272653SPeter Holm#include <stdio.h> 76*8a272653SPeter Holm#include <stdlib.h> 77*8a272653SPeter Holm#include <unistd.h> 78*8a272653SPeter Holm 79*8a272653SPeter Holm#define LOOPS 2000 80*8a272653SPeter Holm 81*8a272653SPeter Holmvoid 82*8a272653SPeter Holmtest(char *path) 83*8a272653SPeter Holm{ 84*8a272653SPeter Holm int fd; 85*8a272653SPeter Holm char data[MAXPHYS + 512] __aligned(PAGE_SIZE); 86*8a272653SPeter Holm 87*8a272653SPeter Holm if ((fd = open(path, O_RDONLY)) == -1) 88*8a272653SPeter Holm err(1, "open(%s)", path); 89*8a272653SPeter Holm if (read(fd, data + 512, MAXPHYS) != MAXPHYS) 90*8a272653SPeter Holm err(1, "read"); 91*8a272653SPeter Holm close(fd); 92*8a272653SPeter Holm 93*8a272653SPeter Holm if ((fd = open(path, O_WRONLY)) == -1) 94*8a272653SPeter Holm err(1, "open(%s)", path); 95*8a272653SPeter Holm if (write(fd, data + 512, MAXPHYS) != MAXPHYS) 96*8a272653SPeter Holm err(1, "write"); 97*8a272653SPeter Holm close(fd); 98*8a272653SPeter Holm 99*8a272653SPeter Holm if ((fd = open(path, O_RDONLY)) == -1) 100*8a272653SPeter Holm err(1, "open(%s)", path); 101*8a272653SPeter Holm if (read(fd, data + 512, MAXPHYS) != MAXPHYS) 102*8a272653SPeter Holm err(1, "read"); 103*8a272653SPeter Holm close(fd); 104*8a272653SPeter Holm} 105*8a272653SPeter Holm 106*8a272653SPeter Holmint 107*8a272653SPeter Holmmain(int argc, char *argv[]) 108*8a272653SPeter Holm{ 109*8a272653SPeter Holm int i; 110*8a272653SPeter Holm char *path; 111*8a272653SPeter Holm 112*8a272653SPeter Holm if (argc != 2) 113*8a272653SPeter Holm errx(1, "Usage: %s <path>", argv[0]); 114*8a272653SPeter Holm 115*8a272653SPeter Holm path = argv[1]; 116*8a272653SPeter Holm 117*8a272653SPeter Holm for (i = 0; i < LOOPS; i++) 118*8a272653SPeter Holm test(path); 119*8a272653SPeter Holm 120*8a272653SPeter Holm return (0); 121*8a272653SPeter Holm} 122