NFS writes calling FSYNC and ASYNC not consistent

Brent Jones brent at
Fri Jan 30 16:08:03 PST 2009

On Thu, Jan 29, 2009 at 3:02 PM, Alfred Perlstein <alfred at> wrote:
> Apologies for being terse, in a hurry here.
> 1) -o async doesn't work with NFS, don't use that.
> 2) how big are the text versus binary files?

I tested with a 6MB text file, and a 2GB binary file. Text file would
go ~1MB/sec, issuing FSYNCs for every block write size (32KB default)

One thing I found that another FreeBSD user discovered exactly
explains my situation:
In bin/cp/utils.c (source) there is a check, if the file is less than
8MB or so, it uses mmap, if the file is larger, it will use write()

I modified the source and recompiled to -never- use mmap, only to use
write(), and my performance increased about 100 fold (from 1MB/sec
over NFS, to over 100MB/sec).

Changed line 143:
fs->st_size <= 8 * 1048576) {

fs->st_size <= 8 * 8) {

It will use mmap still if the file is larger than 64bytes (if it uses
bytes there, pretty sure it does).
But is much faster for files ~1KB to 8MB now.


> 3) how are you copying them over nfs?
> I suspect, (could be wrong of course) that the ascii files
> are a lot smaller than the binary files, so what's happening
> is that for binary files, the client is issuing write-behind
> async, however for ascii files its issuing the writes at
> close time which will force the sync flag.
> -Alfred

Brent Jones
brent at

More information about the freebsd-performance mailing list