From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 29 23:51:26 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 BBA7A16A4FC for ; Tue, 29 Mar 2005 23:51:26 +0000 (GMT) Received: from smtp805.mail.sc5.yahoo.com (smtp805.mail.sc5.yahoo.com [66.163.168.184]) by mx1.FreeBSD.org (Postfix) with SMTP id 318D643D46 for ; Tue, 29 Mar 2005 23:51:26 +0000 (GMT) (envelope-from rsharpe@richardsharpe.com) Received: from unknown (HELO ns.aus.com) (ngsharpe1@sbcglobal.net@63.206.123.133 with plain) by smtp805.mail.sc5.yahoo.com with SMTP; 29 Mar 2005 23:51:25 -0000 Received: from ns.aus.com (durable [127.0.0.1]) by ns.aus.com (8.12.11/8.12.8) with ESMTP id j2TNfQTf004567 for ; Tue, 29 Mar 2005 15:41:49 -0800 Received: from localhost (rsharpe@localhost) by ns.aus.com (8.12.11/8.12.11/Submit) with ESMTP id j2TNfFQ6004564 for ; Tue, 29 Mar 2005 15:41:26 -0800 X-Authentication-Warning: ns.aus.com: rsharpe owned process doing -bs Date: Tue, 29 Mar 2005 15:41:15 -0800 (PST) From: Richard Sharpe X-X-Sender: rsharpe@durable To: freebsd-hackers@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: 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: Tue, 29 Mar 2005 23:51:26 -0000 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); What I notice is that all the calls to mmap return the same address. A careful reading of the man pages for mmap and munmap does not suggest that I am doing anything wrong. Is it possible that FreeBSD is deferring flushing the dirty data, and then forgets to do it when the same starting address is used etc? Regards ----- Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org, sharpe[at]ethereal.com, http://www.richardsharpe.com