From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 30 17:05:15 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 84E4116A4D2 for ; Wed, 30 Mar 2005 17:05:15 +0000 (GMT) Received: from smtp811.mail.sc5.yahoo.com (smtp811.mail.sc5.yahoo.com [66.163.170.81]) by mx1.FreeBSD.org (Postfix) with SMTP id 98F4B43D2D for ; Wed, 30 Mar 2005 17:05:14 +0000 (GMT) (envelope-from rsharpe@richardsharpe.com) Received: from unknown (HELO ns.aus.com) (ngsharpe1@sbcglobal.net@67.122.205.175 with plain) by smtp811.mail.sc5.yahoo.com with SMTP; 30 Mar 2005 17:04:57 -0000 Received: from ns.aus.com (durable [127.0.0.1]) by ns.aus.com (8.12.11/8.12.8) with ESMTP id j2UGtGlu003482; Wed, 30 Mar 2005 08:55:18 -0800 Received: from localhost (rsharpe@localhost) by ns.aus.com (8.12.11/8.12.11/Submit) with ESMTP id j2UGtDZ5003479; Wed, 30 Mar 2005 08:55:16 -0800 X-Authentication-Warning: ns.aus.com: rsharpe owned process doing -bs Date: Wed, 30 Mar 2005 08:55:13 -0800 (PST) From: Richard Sharpe X-X-Sender: rsharpe@durable To: David Schultz In-Reply-To: <20050330021831.GA26006@VARK.MIT.EDU> Message-ID: References: <20050330021831.GA26006@VARK.MIT.EDU> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: alc@FreeBSD.ORG cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Possible problems with mmap/munmap on FreeBSD ... X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2005 17:05:15 -0000 On Tue, 29 Mar 2005, David Schultz wrote: > On Tue, Mar 29, 2005, Richard Sharpe wrote: > > Hi, > > > > I am having some problems with the tdb package on FreeBSD 4.6.2 and 4.10. > > > > One of the things the above package does is: > > > > mmap the tdb file to a region of memory > > store stuff in the region (memmov etc). > > when it needs to extend the size of the region { > > munmap the region > > write data at the end of the file > > mmap the region again with a larger size > > } > > > > What I am seeing is that after the munmap the data written to the region > > is gone. > > > > However, if I insert an msync before the munmap, everything is nicely > > coherent. This seems odd (in the sense that it works without the msync > > under Linux). > > > > The region is mmapped with: > > > > mmap(NULL, tdb->map_size, > > PROT_READ|(tdb->read_only? 0:PROT_WRITE), > > MAP_SHARED|MAP_FILE, tdb->fd, 0); > > It looks like all of the underlying pages are getting invalidated > in vm_object_page_remove(). This is clearly the right thing to do > for private mappings, but it seems wrong for shared mappings. > Perhaps Alan has some insight. OK, a simple test program that: writes some content C1 to a file mmaps file to S1 writes content C2 to S1 munmaps S1 mmaps S1 compares shows expected behavior writes content C1 to S1 munmaps S1 mmaps S1 compares shows expected behavior So, now to do things like extend the file after mmapping etc to see where the problem lies. Regards ----- Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org, sharpe[at]ethereal.com, http://www.richardsharpe.com