NetBSD Problem Report #524

From gnats  Mon Oct 17 16:51:57 1994
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.9/8.6.9) with ESMTP id QAA04728 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Mon, 17 Oct 1994 16:51:56 -0700
Message-Id: <199410180001.NAA05152@orsinis.pc.comp.vuw.ac.nz>
Date: Tue, 18 Oct 1994 13:01:22 +1300
From: Duncan McEwan <duncan@Comp.VUW.AC.NZ>
Reply-To: duncan@Comp.VUW.AC.NZ
To: gnats-bugs@netbsd.org
Subject: Problem with mmap'ed files on nullfs filesystems
X-Send-Pr-Version: 3.2

>Number:         524
>Category:       kern
>Synopsis:       mmap'ed files on nullfs filesystem's don't work properly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 17 17:05:03 +0000 1994
>Closed-Date:    Thu Dec 11 20:41:59 +0000 1997
>Last-Modified:  Thu Dec 11 20:43:00 +0000 1997
>Originator:     Duncan McEwan
>Release:        netbsd-current supped on Oct 11th
>Organization:
"	Computer Science Department, Victoria University of Wellington, NZ"
>Environment:
System: NetBSD orsinis.pc.comp.vuw.ac.nz 1.0_BETA NetBSD 1.0_BETA (ORSINIS) #5: Mon Oct 17 18:50:33 NZDT 1994 duncan@orsinis.pc.comp.vuw.ac.nz:/usr/src/sys/arch/i386/compile/ORSINIS i386

>Description:
	When a file on a nullfs filesystem is mmaped and the mmaped memory
	is changed (such as by using vi) it appears that the on disk version
	of the file and the in memory cached versions become inconsistent.

>How-To-Repeat:
	On a nullfs mounted filesystem:

		orsinis% cat > foobar
		this is a line of text
		^D
		orsinis% vi foobar
		<add a second line of text and exit vi>
		orsinis% vi foobar
		<you should see that the second line you just added is not
		present, and the end of the file contains a number of null
		characters equal to the length of the second line entered.>

	I believe that the 2nd invocation of vi gets stale data from the vm
	cache, but figures out the length of the file from a stat of the
	(correct) on-disk version.  This has the effect that the 2nd line added
	does not appear in the file, and an equivelent number of null bytes
	appears to be added to the end of the file.

>Fix:
	I'm not sure exactly what is happening here.  The problem could be
	related to the fact that the null_inactive() routine in null_vnops.c
	is a stub routine that doesn't pass the vnode operation down to the
	underlying filesystem, so the cached data is not properly invalidated.
	But I don't understand the vm system enough to know whether this is
	the way things work.  I tracked the call sequence back from
	null_inactive(), through VOP_INACTIVE to vrele() and vclean() but
	then got stuck!

	I haven't looked at the vi code, to see if some change could be made
	to the way it uses mmap to work around the problem.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: tv 
State-Changed-When: Thu Dec 11 12:41:59 PST 1997 
State-Changed-Why:  
After extensive testing, I and one other person who opened a PR describing the 
same problem cannot reproduce the problem any longer. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.