NetBSD Problem Report #16570
Received: (qmail 29874 invoked from network); 30 Apr 2002 03:25:07 -0000
Message-Id: <200204300325.g3U3P5A08321@firecat.ninthwonder.com>
Date: Mon, 29 Apr 2002 23:25:05 -0400 (EDT)
From: briggs@ninthwonder.com
Reply-To: briggs@ninthwonder.com
To: gnats-bugs@gnats.netbsd.org
Subject: vnd over NFS loses in some cases
X-Send-Pr-Version: 3.95
>Number: 16570
>Category: kern
>Synopsis: vnd over NFS loses in some cases
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: briggs
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 30 03:26:01 +0000 2002
>Closed-Date: Thu May 02 16:28:13 +0000 2002
>Last-Modified: Thu May 02 16:28:13 +0000 2002
>Originator: Allen Briggs
>Release: NetBSD 1.5ZC
>Organization:
Wasabi Systems, Inc.
>Environment:
System: NetBSD firecat.ninthwonder.com 1.5ZC NetBSD 1.5ZC (GENERIC) #0: Thu Apr 18 10:04:36 EDT 2002 briggs@firecat.ninthwonder.com:/e/netbsd/current/clean/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386,macppc,mips at least
>Description:
When a vnd is configured with an NFS-backed file, access to the raw
vnd device fails in some fashion. A simple way to view this is
with the newfs command.
>How-To-Repeat:
In an NFS-mounted directory, run:
# dd count=4 bs=1m if=/dev/zero of=filesys
# vnconfig -c vnd0 filesys
# newfs /dev/rvnd0c
# newfs /dev/vnd0c
# newfs /dev/rvnd0c
# vnconfig -u vnd0
The first newfs will return an error: "cg 0: bad magic number"
The second newfs will work, and the third newfs will also work.
If the second newfs is not present, any number of accesses to
the raw device will fail.
Another simple test:
# dd < /dev/zero > filesys count=10000
# vnconfig -c vnd0 filesys
# dd if=/netbsd of=/dev/rvnd0c count=1
# hexdump -C -n 16 < /dev/rvnd0c
# hexdump -C -n 16 < /dev/vnd0c
# dd if=/usr/share/misc/units.lib of=/dev/vnd0c count=1
# hexdump -C -n 16 < /dev/rvnd0c
# hexdump -C -n 16 < /dev/vnd0c
# dd if=/usr/share/misc/na.phone of=/dev/rvnd0c count=1
# hexdump -C -n 16 < /dev/rvnd0c
# hexdump -C -n 16 < /dev/vnd0c
# dd if=/usr/share/misc/inter.phone of=/dev/rvnd0c count=1
# hexdump -C -n 16 < /dev/rvnd0c
# hexdump -C -n 16 < /dev/vnd0c
# dd if=/netbsd of=/dev/vnd0c count=1
# hexdump -C -n 16 < /dev/rvnd0c
# hexdump -C -n 16 < /dev/vnd0c
# dd if=/usr/share/misc/termcap of=/dev/vnd0c count=1
# hexdump -C -n 16 < /dev/rvnd0c
# hexdump -C -n 16 < /dev/vnd0c
# vnconfig -u vnd0
I've seen two different types of output here.
Type 1:
10000+0 records in
10000+0 records out
5120000 bytes transferred in 0.445 secs (11505617 bytes/sec)
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010
00000000 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010
00000000 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010
and Type 2:
10000+0 records in
10000+0 records out
5120000 bytes transferred in 0.444 secs (11531531 bytes/sec)
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
00000000 2f 09 24 4e 65 74 42 53 44 3a 20 75 6e 69 74 73 |/.$NetBSD: units|
00000010
1+0 records in
1+0 records out
512 bytes transferred in 0.001 secs (512000 bytes/sec)
00000000 23 09 24 4e 65 74 42 53 44 3a 20 74 65 72 6d 63 |#.$NetBSD: termc|
00000010
00000000 23 09 24 4e 65 74 42 53 44 3a 20 74 65 72 6d 63 |#.$NetBSD: termc|
00000010
So it seems to me that writes to the raw device are not
getting flushed somehow and also sometimes the writes to the block
device are not getting flushed. In fact, it seems that it flips
back and forth between the two outputs on successive runs... Weird.
If I play with the writes some, it will get consistent between runs,
but in any case, if I run from a local disk, it looks good.
The newfs behavior has been verified on x86, ppc, and mips -current
clients going to an x86 server (-current and -1.5.3). The later
experiments were done on ppc client.
Addendum...
OK... After looking at this some more with Frank and Jason, it
looks like vnd was breaking some assumptions about the contents
of a struct buf *, and that was hosing NFS. Notably, vnd might
try to pass a buf through with b_bufsize == 0 and b_data not
aligned on a page boundary. NFS will apparently just happen to
do the right thing if b_data is not aligned properly, but it
does really need to have b_bufsize to be set right. The fix
below seems to be sufficient.
>Fix:
Index: vnd.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/vnd.c,v
retrieving revision 1.78
diff -u -r1.78 vnd.c
--- vnd.c 2002/03/08 20:48:37 1.78
+++ vnd.c 2002/05/01 01:15:10
@@ -455,7 +455,7 @@
splx(s);
nbp->vb_buf.b_flags = flags;
nbp->vb_buf.b_bcount = sz;
- nbp->vb_buf.b_bufsize = bp->b_bufsize;
+ nbp->vb_buf.b_bufsize = round_page(addr + sz) - trunc_page(addr);
nbp->vb_buf.b_error = 0;
nbp->vb_buf.b_data = addr;
nbp->vb_buf.b_blkno = nbp->vb_buf.b_rawblkno = nbn + btodb(off);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: briggs
State-Changed-When: Thu May 2 09:21:14 PDT 2002
State-Changed-Why:
Work-around in vnd committed in revision 1.79.
Chuq seems to have a handle on the real problem in NFS's handling of
needcommit on non-pageio buffers.
Responsible-Changed-From-To: kern-bug-people->briggs
Responsible-Changed-By: briggs
Responsible-Changed-When: Thu May 2 09:21:14 PDT 2002
Responsible-Changed-Why:
Why not?
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.