Index: user/pho/stress2/misc/tmpfs.sh =================================================================== --- user/pho/stress2/misc/tmpfs.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs.sh (revision 268670) @@ -1,47 +1,47 @@ #!/bin/sh # # Copyright (c) 2009-2011 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # panic: tmpfs_alloc_vp: type 0xc866ce58 0, seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes -(cd ..; ./run.sh marcus.cfg) +(cd ..; ./run.sh marcus.cfg) while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done Index: user/pho/stress2/misc/tmpfs10.sh =================================================================== --- user/pho/stress2/misc/tmpfs10.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs10.sh (revision 268670) @@ -1,157 +1,157 @@ #!/bin/sh # # Copyright (c) 2013 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # tmpfs(5) name lookup problem seen: -# $ ./tmpfs10.sh +# $ ./tmpfs10.sh # tmpfs10: unlink(p01193.14729) at loop #2: No such file or directory # unlink(p01193.14729) succeeded at call #2. # tmpfs10: unlink(p01186.14409) at loop #2: No such file or directory # unlink(p01186.14409) succeeded at call #2. # FAIL -# $ +# $ # Fixed in r253967. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > tmpfs10.c cc -o tmpfs10 -Wall -Wextra -O2 -g tmpfs10.c || exit 1 rm -f tmpfs10.c cd $odir mount | grep -q "on $mntpoint " && umount $mntpoint mount -t tmpfs tmpfs $mntpoint cd $mntpoint /tmp/tmpfs10 || { find $mntpoint ! -type d | xargs ls -il; echo FAIL; } cd $odir umount $mntpoint rm -f /tmp/tmpfs10 exit 0 EOF #include #include #include #include #include #include #include #include #include static int loop; int error; #define PARALLEL 20 #define SIZE 16000 void test2(void) { int i, j, k; pid_t pid; char file[128], dir[128]; loop++; pid = getpid(); sprintf(dir,"%s.%05d", getprogname(), pid); if (mkdir(dir, 0770) < 0) err(1, "mkdir(%s), %s:%d", dir, __FILE__, __LINE__); if (chdir(dir) == -1) err(1, "chdir(%s), %s:%d", dir, __FILE__, __LINE__); for (j = 0; j < SIZE; j++) { sprintf(file,"p%05d.%05d", pid, j); if (symlink("/tmp/not/there", file) == -1) { if (errno != EINTR) { warn("symlink(%s). %s.%d", file, __FILE__, __LINE__); break; } } } for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) { warn("unlink(%s) at loop #%d", file, loop); error++; for (k = 0; k < 10; k++) { usleep(10000); if (unlink(file) == 0) { fprintf(stderr, "unlink(%s) succeeded at call #%d.\n", file, k + 2); break; } } } } (void)chdir(".."); if (rmdir(dir) == -1) warn("rmdir(%s), %s:%d", dir, __FILE__, __LINE__); } void test(void) { sleep(arc4random() % 3 + 1); test2(); if (error == 0) test2(); _exit(error); } int main(void) { int e, i, status; for (i = 0; i < PARALLEL; i++) if (fork() == 0) test(); e = 0; for (i = 0; i < PARALLEL; i++) { wait(&status); e += WEXITSTATUS(status); } return (e); } Index: user/pho/stress2/misc/tmpfs2.sh =================================================================== --- user/pho/stress2/misc/tmpfs2.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs2.sh (revision 268670) @@ -1,68 +1,69 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # panic: vfs_mount_destroy: nonzero writeopcount, seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts if [ $# -eq 0 ]; then # start the parallel tests for i in `jot $mounts`; do + [ -d ${mntpoint}$i ] || mkdir -p ${mntpoint}$i ./$0 $i & ./$0 find & done for i in `jot $mounts`; do wait; wait done else if [ $1 = find ]; then for i in `jot 1024`; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts for i in `jot 1024`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount -t tmpfs tmpfs ${mntpoint}$m cp -r /usr/include/machine/a* ${mntpoint}$m while mount | grep -qw $mntpoint$m; do umount $opt ${mntpoint}$m > /dev/null 2>&1 done done fi fi Index: user/pho/stress2/misc/tmpfs3.sh =================================================================== --- user/pho/stress2/misc/tmpfs3.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs3.sh (revision 268670) @@ -1,46 +1,46 @@ #!/bin/sh # # Copyright (c) 2009-2011 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # panic: tmpfs_alloc_vp: type 0xc866ce58 0, seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes -(cd ..; ./run.sh vfs.cfg) +(cd ..; ./run.sh vfs.cfg) umount $mntpoint mount | grep "$mntpoint" | grep -q tmpfs && umount -f $mntpoint Index: user/pho/stress2/misc/tmpfs4.sh =================================================================== --- user/pho/stress2/misc/tmpfs4.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs4.sh (revision 268670) @@ -1,49 +1,49 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Regression test from kern/122038 by gprspb mail ru [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint for i in `jot 100`; do - mkdir -p /${mntpoint}/1/2 - cd /${mntpoint}/1/2 + mkdir -p /${mntpoint}/1/2 + cd /${mntpoint}/1/2 rm -rf /${mntpoint}/1 cd .. 2>&1 | grep -v "cd to" done umount $mntpoint 2>&1 | grep -v busy mount | grep "$mntpoint" | grep -q tmpfs && umount -f $mntpoint Index: user/pho/stress2/misc/tmpfs6.sh =================================================================== --- user/pho/stress2/misc/tmpfs6.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs6.sh (revision 268670) @@ -1,112 +1,112 @@ #!/bin/sh # # Copyright (c) 2010 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # panic: deadlkres: possible deadlock detected for 0xc8576a00, blocked for 1801792 ticks # Scenario by kib@ [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > tmpfs6.c cc -o tmpfs6 -Wall -Wextra -O2 tmpfs6.c || exit 1 rm -f tmpfs6.c mount | grep $mntpoint | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint (cd $mntpoint; /tmp/tmpfs6) rm -f /tmp/tmpfs6 while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done exit EOF #include #include #include #include #include #include #include #include int pagesize; #define FILESIZE (32 * 1024) char wbuffer[FILESIZE]; -void +void test(void) { int fd; int len; void *addr; char filename[80]; snprintf(filename, sizeof(filename), "file.%07d", getpid()); if ((fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) == -1) err(1, "open(%s)", filename); if ((len = write(fd, wbuffer, FILESIZE)) != FILESIZE) err(1, "write()"); fsync(fd); if ((addr = mmap(NULL, FILESIZE, PROT_READ | PROT_WRITE , MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap()"); if (lseek(fd, 0, SEEK_SET) != 0) err(1, "lseek()"); if ((len = write(fd, addr, FILESIZE)) != FILESIZE) err(1, "write() 2"); if (munmap(addr, FILESIZE) == -1) err(1, "munmap()"); close(fd); unlink(filename); } -int +int main(void) { int i; for (i = 0; i < 10000; i++) test(); return (0); } Index: user/pho/stress2/misc/tmpfs7.sh =================================================================== --- user/pho/stress2/misc/tmpfs7.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs7.sh (revision 268670) @@ -1,250 +1,250 @@ #!/bin/sh # # Copyright (c) 2013 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test scenario by Nate Eldredge neldredge math ucsdnedu # kern/127213: [tmpfs] sendfile on tmpfs data corruption [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg set -e odir=`pwd` cd /tmp cat > server.c < #include #include #include #include "util.h" int main(int argc, char *argv[]) { int f, listener, connection; if (argc < 3) { fprintf(stderr, "Usage: %s filename socketname\n", argv[0]); exit(1); } if ((f = open(argv[1], O_RDONLY)) < 0) { perror(argv[1]); exit(1); } if ((listener = listen_unix_socket(argv[2])) < 0) { exit(1); } if ((connection = accept_unix_socket(listener)) >= 0) { real_sendfile(f, connection); } return 0; } EOF cat > client.c < #include #include #include #include "util.h" int main(int argc, char *argv[]) { int s; if (argc < 2) { fprintf(stderr, "Usage: %s socketname\n", argv[0]); exit(1); } if ((s = connect_unix_socket(argv[1])) < 0) { exit(1); } fake_sendfile(s, 1); return 0; } EOF cat > util.c < #include #include #include #include #include #include #include #include #include int create_unix_socket(void) { int fd; if ((fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { perror("socket"); return -1; } return fd; } int make_unix_sockaddr(const char *pathname, struct sockaddr_un *sa) { memset(sa, 0, sizeof(*sa)); sa->sun_family = PF_LOCAL; if (strlen(pathname) + 1 > sizeof(sa->sun_path)) { // fprintf(stderr, "%s: pathname too long (max %lu)\n", // pathname, sizeof(sa->sun_path)); errno = ENAMETOOLONG; return -1; } strcpy(sa->sun_path, pathname); return 0; } static char *sockname; void delete_socket(void) { unlink(sockname); } int listen_unix_socket(const char *path) { int fd; struct sockaddr_un sa; if (make_unix_sockaddr(path, &sa) < 0) return -1; if ((fd = create_unix_socket()) < 0) return -1; if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) { perror("bind"); close(fd); return -1; } sockname = strdup(path); atexit(delete_socket); if (listen(fd, 5) < 0) { perror("listen"); close(fd); return -1; } return fd; } int accept_unix_socket(int fd) { int s; if ((s = accept(fd, NULL, 0)) < 0) { perror("accept"); return -1; } return s; } int connect_unix_socket(const char *path) { int fd; struct sockaddr_un sa; if (make_unix_sockaddr(path, &sa) < 0) return -1; if ((fd = create_unix_socket()) < 0) return -1; if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) { perror("connect"); return -1; } return fd; } #define BUFSIZE 65536 int fake_sendfile(int from, int to) { char buf[BUFSIZE]; int v; int sent = 0; while ((v = read(from, buf, BUFSIZE)) > 0) { int d = 0; while (d < v) { int w = write(to, buf, v - d); if (w <= 0) { perror("write"); return -1; } d += w; sent += w; } } if (v != 0) { perror("read"); return -1; } return sent; } int real_sendfile(int from, int to) { int v; v = sendfile(from, to, 0, 0, NULL, NULL, 0); if (v < 0) { perror("sendfile"); } return v; } EOF cat > util.h < #include #include #include #include #include #include int create_unix_socket(void); int make_unix_sockaddr(const char *pathname, struct sockaddr_un *sa); int listen_unix_socket(const char *path); int accept_unix_socket(int fd); int connect_unix_socket(const char *path); int fake_sendfile(int from, int to); int real_sendfile(int from, int to); EOF cc -c -Wall -Wextra -O2 util.c cc -o server -Wall -Wextra -O2 server.c util.o cc -o client -Wall -Wextra -O2 client.c util.o rm -f server.c client.c util.c util.o util.h mysocket mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint dd if=/dev/random of=$mntpoint/data bs=123456 count=1 > /dev/null 2>&1 ./server $mntpoint/data mysocket & sleep 0.2 ./client mysocket > data.$$ -cmp $mntpoint/data data.$$ || +cmp $mntpoint/data data.$$ || { echo "FAIL Data mismatch"; ls -l $mntpoint/data data.$$; } rm -f data.$$ server client mysocket while mount | grep "$mntpoint" | grep -q tmpfs; do umount $mntpoint || sleep 1 done Index: user/pho/stress2/misc/tmpfs9.sh =================================================================== --- user/pho/stress2/misc/tmpfs9.sh (revision 268669) +++ user/pho/stress2/misc/tmpfs9.sh (revision 268670) @@ -1,113 +1,113 @@ #!/bin/sh # # Copyright (c) 2013 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Regression test: exec returning EIO problem scenario for tmpfs . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > tmpfs9.c cc -o tmpfs9 -Wall -Wextra -O2 tmpfs9.c rm -f tmpfs9.c cd $here mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint cp /usr/bin/true $mntpoint su ${testuser} -c "/tmp/tmpfs9 $mntpoint" & while kill -0 $! 2>/dev/null; do ../testcases/swap/swap -t 2m -i 40 -h done wait while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done rm -d /tmp/tmpfs9 exit EOF #include #include #include #include #include #include #include #include #define N 5000 #define PARALLEL 10 const char path[] = "./true"; void test(void) { pid_t p; int i; for (i = 0; i < N; i++) { - if ((p = fork()) == 0) + if ((p = fork()) == 0) if (execl(path, path, (char *)0) == -1) err(1, "exec(%s)", path); if (p > 0) wait(NULL); } _exit(0); } int main(int argc, char **argv) { int i, status; if (argc != 2) errx(1, "Usage: %s ", argv[0]); if (chdir(argv[1]) == -1) err(1, "chdir(%s)", argv[1]); for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(); } for (i = 0; i < PARALLEL; i++) { wait(&status); if (status != 0) return (1); } return (0); }