From owner-svn-src-user@freebsd.org Tue Sep 3 14:06:29 2019 Return-Path: Delivered-To: svn-src-user@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7373DDCA08 for ; Tue, 3 Sep 2019 14:06:29 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N7zS3Xf2z4PbH; Tue, 3 Sep 2019 14:06:28 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id 2C69D1A705; Tue, 3 Sep 2019 14:06:09 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id ED612157EA; Tue, 9 Apr 2019 07:36:44 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 34E788027B; Tue, 9 Apr 2019 07:36:44 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 17613157A8; Tue, 9 Apr 2019 07:36:44 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 3709A157A3 for ; Tue, 9 Apr 2019 07:36:41 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E593380272; Tue, 9 Apr 2019 07:36:40 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C16F87DB4; Tue, 9 Apr 2019 07:36:40 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x397ae8F069597; Tue, 9 Apr 2019 07:36:40 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x397aetu069596; Tue, 9 Apr 2019 07:36:40 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201904090736.x397aetu069596@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r346047 - user/pho/stress2/misc X-SVN-Group: user X-SVN-Commit-Author: pho X-SVN-Commit-Paths: user/pho/stress2/misc X-SVN-Commit-Revision: 346047 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 34E788027B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.993,0]; NEURAL_HAM_SHORT(-0.93)[-0.935,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US] Status: O X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.29 List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:06:29 -0000 X-Original-Date: Tue, 9 Apr 2019 07:36:40 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:06:29 -0000 Author: pho Date: Tue Apr 9 07:36:40 2019 New Revision: 346047 URL: https://svnweb.freebsd.org/changeset/base/346047 Log: Added a msdosfs regression test. PR: 236977 Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/truncate8.sh (contents, props changed) Added: user/pho/stress2/misc/truncate8.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/truncate8.sh Tue Apr 9 07:36:40 2019 (r346047) @@ -0,0 +1,214 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2019 Dell EMC Isilon +# +# 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$ +# + +# Bug 236977 - [msdosfs] returns cached truncated data +# Fixed by r345847 + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +dir=/tmp +odir=`pwd` +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/truncate8.c +mycc -o truncate8 -Wall -Wextra -O0 -g truncate8.c || exit 1 +rm -f truncate8.c +cd $odir + +echo ufs: +mount | grep -q "$mntpoint " && umount $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +(cd $mntpoint; /tmp/truncate8) +s=$? +[ $s -ne 0 ] && { echo "UFS exit status is $s"; status=1; } +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart + +echo nfs: +if ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1; then + mount -t nfs -o tcp -o retrycnt=3 -o intr,soft -o rw $nfs_export \ + $mntpoint + sleep .2 + (cd $mntpoint; /tmp/truncate8) + s=$? + [ $s -ne 0 ] && { echo "NFS exit status is $s"; status=1; } + + umount $mntpoint || umount $mntpoint +fi + +echo msdos: +if [ -x /sbin/mount_msdosfs ]; then + mdconfig -a -t swap -s 1g -u $mdstart + bsdlabel -w md$mdstart auto + newfs_msdos -F 16 -b 8192 /dev/md${mdstart}$part > /dev/null 2>&1 + mount_msdosfs -m 777 /dev/md${mdstart}$part $mntpoint + + (cd /mnt; /tmp/truncate8) + s=$? + [ $s -ne 0 ] && { echo "MSDOS exit status is $s"; status=1; } + while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 + done + mdconfig -d -u $mdstart +fi + +echo tmpfs: +mount -t tmpfs null $mntpoint +chmod 777 $mntpoint + +(cd $mntpoint; /tmp/truncate8) +s=$? +[ $s -ne 0 ] && { echo "TMPFS exit status is $s"; status=1; } +while mount | grep -q "$mntpoint "; do + umount $mntpoint || sleep 1 +done + +rm -rf /tmp/truncate8 +exit $status + +EOF +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +static volatile u_int *share; + +#define BSIZE 5120 +#define FSIZE (128 * 1024 * 1024) +#define PARALLEL 2 +#define RUNTIME (1 * 60) +#define SYNC 0 + +static void +test(void) +{ + time_t start; + off_t pos; + int fd, i, n, r; + char *buf, name[128]; + + atomic_add_int(&share[SYNC], 1); + while (share[SYNC] != PARALLEL) + ; + + srand48(getpid()); + buf = malloc(BSIZE); + for (i = 0; i < (int)sizeof(buf); i++) + buf[i] = 123; + + sprintf(name, "f%05d", getpid()); + if ((fd = open(name, O_RDWR | O_CREAT, 0640)) == -1) + err(1, "%s", name); + for (i = 0; i < FSIZE / BSIZE; i++) + if (write(fd, buf, BSIZE) != BSIZE) + err(1, "write"); + + start = time(NULL); + while (time(NULL) - start < RUNTIME) { + pos = lrand48() % (FSIZE - BSIZE); +// fprintf(stderr, "truncate(%jd)\n", (intmax_t)pos); + if (ftruncate(fd, pos) == -1) + err(1, "ftruncate"); + + if (ftruncate(fd, FSIZE) == -1) + err(1, "ftruncate"); + if (lseek(fd, pos, SEEK_SET) == -1) + err(1, "lseek"); + n = 0; + while ((r = read(fd, buf, BSIZE)) == BSIZE) { + n++; + for (i = 0; i < BSIZE; i++) { + if (buf[i] != 0) + errx(1, "Bad read value @ %jd = %d", + (intmax_t)(pos + i), buf[i]); + } + } + if (r == -1) + err(1, "read"); + if (n != (FSIZE - pos) / BSIZE) + fprintf(stderr, "n = %d, target = %d\n", n, (int)(FSIZE - pos) / BSIZE); + } + unlink(name); + + _exit(0); +} + +int +main(void) +{ + pid_t pids[PARALLEL]; + size_t len; + int e, i, status; + + e = 0; + len = PAGE_SIZE; + if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) + err(1, "mmap"); + + for (i = 0; i < PARALLEL; i++) { + if ((pids[i] = fork()) == 0) + test(); + if (pids[i] == -1) + err(1, "fork()"); + } + for (i = 0; i < PARALLEL; i++) { + if (waitpid(pids[i], &status, 0) == -1) + err(1, "waitpid(%d)", pids[i]); + if (status != 0) { + if (WIFSIGNALED(status)) + fprintf(stderr, + "pid %d exit signal %d\n", + pids[i], WTERMSIG(status)); + } + e += status == 0 ? 0 : 1; + } + + return (e); +}