Subject: Re: kern/15364
To: None <chs@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: netbsd-bugs
Date: 08/25/2005 02:46:02
The following reply was made to PR kern/15364; it has been noted by GNATS.

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: chs@netbsd.org
Subject: Re: kern/15364
Date: Thu, 25 Aug 2005 11:44:49 +0900

 > Synopsis: panic: softdep_pageiodone
 
 here's a simple test code to trigger the bug.
 
 	% cc a.c
 	% ./a.out > testfile
 
 YAMAMOTO Takashi
 
 
 #include <sys/mman.h>
 
 #include <string.h>
 #include <unistd.h>
 
 #define	MAXPHYS	65536
 #define	BLKSIZ	16384
 #define	FRAGSIZ	2048
 #define	PAGE_SIZE 4096
 
 /* assuming FRAGSIZ < PAGE_SIZE < BLKSIZ < MAXPHYS */
 
 int
 main()
 {
 	char buf[BLKSIZ];
 	char *cp;
 
 	memset(buf, 0xaa, sizeof(buf));
 	pwrite(1, buf, 1, MAXPHYS - 1);
 	cp = mmap(0, MAXPHYS*16, PROT_WRITE, MAP_FILE|MAP_SHARED, 1, 0);
 
 	memset(cp, 0xbb, BLKSIZ);
 	fsync(1);
 
 	memset(cp + PAGE_SIZE, 0xee, MAXPHYS - PAGE_SIZE);
 	/* create a page dep, b_resid == PAGE_SIZE + FRAGSIZE */
 	pwrite(1, buf, PAGE_SIZE + FRAGSIZ, MAXPHYS);
 
 	/* write out the page at the offset MAXPHYS */
 	msync(cp + PAGE_SIZE, 1, MS_SYNC);
 	/* now b_resid == FRAGSIZ */
 
 	/* re-dirty and write the page, b_resid goes to negative. */
 	pwrite(1, buf, PAGE_SIZE + FRAGSIZ, MAXPHYS);
 	fsync(1);
 }