From owner-svn-src-user@FreeBSD.ORG Tue Jul 30 07:03:52 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E223BA7E; Tue, 30 Jul 2013 07:03:52 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BFFA7270C; Tue, 30 Jul 2013 07:03:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6U73qbj013769; Tue, 30 Jul 2013 07:03:52 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6U73qF3013766; Tue, 30 Jul 2013 07:03:52 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201307300703.r6U73qF3013766@svn.freebsd.org> From: Peter Holm Date: Tue, 30 Jul 2013 07:03:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r253794 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jul 2013 07:03:53 -0000 Author: pho Date: Tue Jul 30 07:03:52 2013 New Revision: 253794 URL: http://svnweb.freebsd.org/changeset/base/253794 Log: Added two old tmpfs(5) test cases. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/tmpfs5.sh (contents, props changed) user/pho/stress2/misc/tmpfs8.sh (contents, props changed) Added: user/pho/stress2/misc/tmpfs5.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/tmpfs5.sh Tue Jul 30 07:03:52 2013 (r253794) @@ -0,0 +1,55 @@ +#!/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$ +# + +# tmpfs + fsx test scenario. + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +src=`uname -v | sed 's/.*:.*:\(.*\)\/sys\/.*/\1/'` +[ -r $src/tools/regression/fsx/fsx.c ] || exit 1 +cd /tmp +cc -o fsx -Wall $src/tools/regression/fsx/fsx.c + +mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint +mount -t tmpfs tmpfs $mntpoint + +( + /tmp/fsx -q -N 100000 $mntpoint/file.1 & + /tmp/fsx -q -N 100000 $mntpoint/file.2 & +) | grep -v A-OK +wait;wait + +while mount | grep "$mntpoint" | grep -q tmpfs; do + umount $mntpoint || sleep 1 +done +rm -f /tmp/fsx Added: user/pho/stress2/misc/tmpfs8.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/tmpfs8.sh Tue Jul 30 07:03:52 2013 (r253794) @@ -0,0 +1,174 @@ +#!/bin/sh + +# +# Copyright (c) 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$ +# + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +# Demonstrate rename(2) cache problem for tmpfs(5). Fixed in r226987. +# Variation of rename6.sh + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > tmpfs8.c +cc -o tmpfs8 -Wall -Wextra -O2 tmpfs8.c +rm -f tmpfs8.c +cd $here + +mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint +mount -t tmpfs tmpfs $mntpoint +chmod 777 $mntpoint + +su ${testuser} -c "cd $mntpoint; /tmp/tmpfs8" + +while mount | grep $mntpoint | grep -q tmpfs; do + umount $mntpoint || sleep 1 +done +rm -f /tmp/tmpfs8 +exit +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +pid_t spid; +const char *logfile = "test.log"; +char new[128]; + +void +cleanup() +{ + kill(spid, SIGINT); +} + +static void +Stat() +{ + struct stat sb; + int i; + + setproctitle("Stat"); + for (;;) { + for (i = 0; i < 1000; i++) { + stat(logfile, &sb); + stat(new, &sb); + } +// usleep(1000); + usleep(100); + } +} + +int +main(void) +{ + struct stat sb1, sb2, sb3; + int fd, i, r1, r2, r3; + + if ((spid = fork()) == 0) + Stat(); + + setproctitle("main"); + atexit(cleanup); + for (i = 0; i < 200000; i++) { + bzero(&sb1, sizeof(sb1)); + bzero(&sb2, sizeof(sb2)); + if ((fd = open(logfile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) + err(1, "creat(%s)", logfile); + close(fd); + + sprintf(new, "test.log.%05d", i); + if ((fd = open(new, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) + err(1, "creat(%s)", new); + write(fd, "xxx", 3); + close(fd); + if ((r3 = stat(new, &sb3)) == -1) + err(1, "stat(%s)", new); +#if 1 + if (rename(logfile, new) == -1) + warn("rename(%s, %s)", logfile, new); +#else + /* No cache problem is seen */ + if (link(logfile, new) == -1) + err(1, "link(%s, %s)", logfile, new); + if (unlink(logfile) == -1) + err(1, "unlink(%s)", logfile); +#endif + /* + * stat() for logfile and new will be identical sometimes, + * but only when Stat() is running. + */ + r1 = stat(logfile, &sb1); + r2 = stat(new, &sb2); + if (r1 == 0 && r2 == 0 && + bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { + fprintf(stderr, "FAIL 1\n"); + fprintf(stderr, "%-15s: ino = %4d, nlink = %d, size = %jd\n", + logfile, sb1.st_ino, sb1.st_nlink, sb1.st_blocks); + fprintf(stderr, "%-15s: ino = %4d, nlink = %d, size = %jd\n", + new , sb2.st_ino, sb2.st_nlink, sb2.st_blocks); + } + if (bcmp(&sb2, &sb3, sizeof(sb2)) == 0) { + fprintf(stderr, "Old to file is lingering\n"); + } + if (sb2.st_ino == sb3.st_ino) { + fprintf(stderr, "FAIL 2\n"); + if (r1 == 0) + fprintf(stderr, + "sb1: %-15s: ino = %4d, nlink = %d, size = %jd\n", + logfile, sb1.st_ino, sb1.st_nlink, sb1.st_blocks); + if (r2 == 0) + fprintf(stderr, + "sb2: %-15s: ino = %4d, nlink = %d, size = %jd\n", + new, sb2.st_ino, sb2.st_nlink, sb2.st_blocks); + if (r3 == 0) + fprintf(stderr, + "sb3: %-15s: ino = %4d, nlink = %d, size = %jd\n", + new , sb3.st_ino, sb3.st_nlink, sb3.st_blocks); + exit(1); + } + unlink(new); + } + + kill(spid, SIGINT); + wait(NULL); + + return (0); +}