From owner-svn-src-user@FreeBSD.ORG Mon Dec 30 20:23:41 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 20F94626; Mon, 30 Dec 2013 20:23:41 +0000 (UTC) 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 0D34A1C8F; Mon, 30 Dec 2013 20:23:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBUKNewf003308; Mon, 30 Dec 2013 20:23:40 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBUKNeQ7003307; Mon, 30 Dec 2013 20:23:40 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201312302023.rBUKNeQ7003307@svn.freebsd.org> From: Peter Holm Date: Mon, 30 Dec 2013 20:23:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r260098 - 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.17 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: Mon, 30 Dec 2013 20:23:41 -0000 Author: pho Date: Mon Dec 30 20:23:40 2013 New Revision: 260098 URL: http://svnweb.freebsd.org/changeset/base/260098 Log: Added old iosize_max test scenario. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/rdwr.sh (contents, props changed) Added: user/pho/stress2/misc/rdwr.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/rdwr.sh Mon Dec 30 20:23:40 2013 (r260098) @@ -0,0 +1,122 @@ +#!/bin/sh + +# +# Copyright (c) 2012 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 with read/write length of INT_MAX (i386) or INT_MAX+1 (amd64) + +. ../default.cfg + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +odir=`pwd` +cd /tmp +sed '1,/^EOF/d' < $odir/$0 > rdwr.c +cc -o rdwr -Wall rdwr.c || exit +rm -f rdwr.c + +oldclamp=`sysctl debug.devfs_iosize_max_clamp 2>/dev/null | + awk '{print $NF}'` +if [ `uname -m` = amd64 ]; then + [ "$oldclamp" = "1" ] && sysctl debug.devfs_iosize_max_clamp=0 +fi +for j in `jot 10`; do + /tmp/rdwr || { echo FAIL; break; } +done +if [ `uname -m` = amd64 ]; then + [ "$oldclamp" = "1" ] && sysctl debug.devfs_iosize_max_clamp=1 +fi + +rm -f /tmp/rdwr +exit +EOF +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int fd1, fd2; + size_t len; + void *p; + struct iovec iov; + + alarm(120); + if ((fd1 = open("/dev/null", O_RDWR, 0)) == -1) + err(1, "open /dev/null"); + + if ((fd2 = open("/dev/zero", O_RDONLY)) == -1) + err(1, "open /dev/zero"); + + if (sizeof(size_t) == sizeof(int32_t)) + len = (size_t)INT_MAX; /* i386 */ + else + len = (size_t)INT_MAX + 1; /* amd64 */ + + if ((p = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd2, 0)) == + MAP_FAILED) + err(1, "mmap"); + + if (read(fd2, p, len) != len) + err(1, "read"); + + if (write(fd1, p, len) != len) + err(1, "write"); + + if (pread(fd2, p, len, 0) != len) + err(1, "pread"); + + if (pwrite(fd1, p, len, 0) != len) + err(1, "pwrite"); + + + iov.iov_base = p; + iov.iov_len = len; + if (readv(fd2, &iov, 1) != len) + err(1, "readv"); + + if (writev(fd1, &iov, 1) != len) + err(1, "writev"); + + if (preadv(fd2, &iov, 1, 0) != len) + err(1, "preadv"); + + if (pwritev(fd1, &iov, 1, 0) != len) + err(1, "pwritev"); + + close(fd1); + close(fd2); + + + return (0); +}