From owner-freebsd-fs@FreeBSD.ORG Wed Jul 4 08:44:13 2012 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DAFD1065670 for ; Wed, 4 Jul 2012 08:44:13 +0000 (UTC) (envelope-from devgs@ukr.net) Received: from ffe17.ukr.net (ffe17.ukr.net [195.214.192.83]) by mx1.freebsd.org (Postfix) with ESMTP id CA2A58FC15 for ; Wed, 4 Jul 2012 08:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ukr.net; s=ffe; h=Date:Message-Id:From:To:References:In-Reply-To:Subject:Cc:Content-Type:Content-Transfer-Encoding:MIME-Version; bh=FX3xa5vxgRONV/Zle7USSmCoOFICE5fwkzmIcrOPqZY=; b=Vcyc2tzWmDElmHsZgOGmHO/0pI4nkq98rMOlM8G1iseTl2hrvZLwiXgS23jx3pQDXRAcmIj5khEi83VbF5rPMNzePUl4W1WKXMH15o6lieO7akl14GD9cWOwsWOoDjyGQrPW266Srf6U08PMcimIyWiYElFihJgU1iK3qkHfkug=; Received: from mail by ffe17.ukr.net with local ID 1SmKca-0006Tx-Pg ; Wed, 04 Jul 2012 11:07:36 +0300 MIME-Version: 1.0 In-Reply-To: <91943.1339669820.1305529125424791552@ffe15.ukr.net> X-New-Users: 0 References: <91943.1339669820.1305529125424791552@ffe15.ukr.net> To: "Pavlo" From: "Pavlo" X-Mailer: freemail.ukr.net 4.0 X-Originating-Ip: [212.42.94.154] Message-Id: <23856.1341389256.6316487571580649472@ffe17.ukr.net> X-Browser: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1 Date: Wed, 04 Jul 2012 11:07:36 +0300 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: binary Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-fs@freebsd.org Subject: Re: mmap() incoherency on hi I/O load (FS is zfs) X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2012 08:44:13 -0000 --- Original message --- From: "Pavlo" To: freebsd-fs@freebsd.org Date: 14 June 2012, 13:30:20 Subject: mmap() incoherency on hi I/O load (FS is zfs) > There's a case when some parts of files that are mapped and then modified getting corrupted. By corrupted I mean some data is ok (one that was written using write()/pwrite()) but some looks like it never existed. Like it was some time in buffers, when several processes simultaneously (of course access was synchronised) used shared pages and reported it's existence. But after time pass they (processes) screamed that it is now lost. Only part of data written with pwrite() was there. Everything that was written via mmap() is zero. > > So as I said it occurs on hi I/O busyness. When in background 4+ processes do indexing of huge ammount of data. Also I want to note, it never occurred in the life of our project while we used mmap() under same I/O stress conditions when mapping was done for a whole file of just a part(header) starting from a beginning of a file. First time we used mapping of individual pages, just to save RAM, and this popped up. > > Solution for this problem is msync() before any munmap(). But man says: > > The msync() system call is usually not needed since BSD implements a coherent file system buffer cache. However, it may be used to associate dirty VM pages with file system buffers and thus cause them to be flushed to physical media sooner rather than later. > > Any thoughts? Thanks. > > So I tracked issue to the place where it occurs. When I commit data to file using mmap() and pwrite() side by side, sometimes 'newest data' is being overwritten by 'elder data'. From time to time 'elder data' can be something written with mmap() either with pwrite(). It never happens when I use exclusively mmap() either pwrite(). Also this issue reproduces on UFS as well. I think there is a problem keeping mmapep pages and FS cache synced. I will try to make test to reliably reproduces issue.