From owner-svn-src-user@FreeBSD.ORG Wed Sep 11 06:16:13 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 83D3535E; Wed, 11 Sep 2013 06:16:13 +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 61A772766; Wed, 11 Sep 2013 06:16:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8B6GDRa008250; Wed, 11 Sep 2013 06:16:13 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8B6GDbJ008249; Wed, 11 Sep 2013 06:16:13 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201309110616.r8B6GDbJ008249@svn.freebsd.org> From: Peter Holm Date: Wed, 11 Sep 2013 06:16:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r255466 - 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: Wed, 11 Sep 2013 06:16:13 -0000 Author: pho Date: Wed Sep 11 06:16:12 2013 New Revision: 255466 URL: http://svnweb.freebsd.org/changeset/base/255466 Log: Added one more "umount -f" test scenario. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/umountf7.sh (contents, props changed) Added: user/pho/stress2/misc/umountf7.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/umountf7.sh Wed Sep 11 06:16:12 2013 (r255466) @@ -0,0 +1,170 @@ +#!/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$ +# + +# "panic: handle_written_inodeblock: live inodedep 0xcc731200" seen. +# http://people.freebsd.org/~pho/stress/log/umountf7.txt +# Problem only seen with SU+J. + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +dir=/tmp +odir=`pwd` +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/mv4.c +cc -o mv4 -Wall -Wextra mv4.c -lpthread || exit 1 +rm -f mv4.c +cd $odir + +mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 3g -u $mdstart || exit 1 +bsdlabel -w md$mdstart auto +newfs -j md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +daemon sh -c '(cd ../testcases/swap; ./swap -t 2m -i 4)' +parallel=4 +for j in `jot $parallel`; do + [ -d $mntpoint/$j ] || mkdir $mntpoint/$j +done +for j in `jot $parallel`; do + (cd $mntpoint/$j; /tmp/mv4 100000) & +done +sleep 60 +umount -f $mntpoint +killall mv4 +for j in `jot $parallel`; do + wait +done +while ps auxww | grep -v grep | grep -qw swap; do + killall -9 swap 2>/dev/null +done +find $mntpoint -type f + +while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart +rm -f /tmp/mv4 +exit + +EOF +#include +#include +#include +#include +#include +#include + +pid_t pid; +volatile int n, n2; +int mx; + +void * +cr(void *arg __unused) +{ + char file[80]; + int fd, i; + + for (i = 0; i < mx; i++) { + snprintf(file, sizeof(file), "f%06d.%06d", pid, i); + if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) + err(1, "open(%s)", file); + close(fd); + n++; + } + return (0); + +} + +void * +mv(void *arg __unused) +{ + char from[80], to[80]; + int i; + + for (i = 0; i < mx; i++) { + while (n == -1 || i > n) + pthread_yield(); + snprintf(from, sizeof(from), "f%06d.%06d", pid, i); + snprintf(to , sizeof(to ), "g%06d.%06d", pid, i); + if (rename(from, to) == -1) + warn("rename(%s, %s)", from, to); + n2++; + } + + return (0); +} + +void * +rm(void *arg __unused) +{ + char file[80]; + int i; + + for (i = 0; i < mx; i++) { + while (n2 == -1 || i > n2) + pthread_yield(); + snprintf(file, sizeof(file), "g%06d.%06d", pid, i); + if (unlink(file) == -1) + warn("unlink(%s)", file); + } + + return (0); +} + +int +main(int argc, char **argv) +{ + pthread_t rp[3]; + int i; + + if (argc != 2) + errx(1, "Usage: %s ", argv[0]); + mx = atoi(argv[1]); + n = n2 = -1; + pid = getpid(); + + if (pthread_create(&rp[0], NULL, cr, NULL) != 0) + err(1, "pthread_create"); + usleep(arc4random() % 1000); + if (pthread_create(&rp[1], NULL, mv, NULL) != 0) + err(1, "pthread_mv"); + usleep(arc4random() % 1000); + if (pthread_create(&rp[2], NULL, rm, NULL) != 0) + perror("pthread_rm"); + + for (i = 0; i < 3; i++) + pthread_join(rp[i], NULL); + + return (0); +}