From owner-freebsd-current@FreeBSD.ORG Wed Nov 10 13:09:37 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1C8EF16A534 for ; Wed, 10 Nov 2004 13:09:37 +0000 (GMT) Received: from ptcnat.era.pl (ptcnat.era.pl [213.158.197.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A67143D2F for ; Wed, 10 Nov 2004 13:09:36 +0000 (GMT) (envelope-from zaks@era.pl) Received: by localhost (Postfix, from userid 1001) id 86CFD11445; Wed, 10 Nov 2004 14:09:33 +0100 (CET) From: =?iso-8859-2?q?S=B3awek_=AFak?= To: current@freebsd.org Date: Wed, 10 Nov 2004 14:09:33 +0100 Message-ID: <86lld9df5e.fsf@thirst.unx.era.pl> User-Agent: Gnus/5.110003 (No Gnus v0.3) XEmacs/21.4 (Reasonable Discussion, berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: MMAP(2) troubles on smbfs X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2004 13:09:37 -0000 --=-=-= Hi, I've noticed that msyncing the mmap pointer or fsyncing the file descriptor is required when filesystem where mmap'ed file resides is smbfs. I use MMAP_SHARED mode for mmap. I attach a small test program. I've tried both 5.3-STABLE and 5.2-CURRENT (built on March 2.) on the client and Samba, Windows XP on the server. The same operation seems to work fine on both local filesystem and NFS (ie. no syncing is necessary). Unmounting the filesystem doesn't help - the changes are not flushed to the file. /S --=-=-= Content-Disposition: inline; filename=mmap.c #include #include #include int main() { int fd; void *ptr; fd = open("/mnt/tmp/file", O_RDWR); if (fd < 0) { perror("open"); exit(1); } ptr = mmap(NULL, 10, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { perror("mmap"); exit(1); } *(char *)ptr = '/'; #if 0 if (msync(ptr, 10, MS_SYNC) < 0) { perror("msync"); exit(1); } if (fsync(fd) < 0) { perror("fsync"); exit(1); } #endif if (munmap(ptr, 10) < 0) { perror("munmap"); exit(1); } if (close(fd) < 0) { perror("close"); exit(1); } return 0; } --=-=-=--