From owner-freebsd-fs@freebsd.org Sat Feb 27 06:27:09 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ADBB8AB656F for ; Sat, 27 Feb 2016 06:27:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 9CA1E273 for ; Sat, 27 Feb 2016 06:27:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id 96A5EAB656E; Sat, 27 Feb 2016 06:27:09 +0000 (UTC) Delivered-To: fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 963EBAB656D for ; Sat, 27 Feb 2016 06:27:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 61527272 for ; Sat, 27 Feb 2016 06:27:09 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c110-21-41-193.carlnfd1.nsw.optusnet.com.au (c110-21-41-193.carlnfd1.nsw.optusnet.com.au [110.21.41.193]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id 2E6581A19A9; Sat, 27 Feb 2016 17:27:00 +1100 (AEDT) Date: Sat, 27 Feb 2016 17:27:00 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Rick Macklem cc: fs@freebsd.org Subject: Re: silly write caching in nfs3 In-Reply-To: <1347742231.11086226.1456545647628.JavaMail.zimbra@uoguelph.ca> Message-ID: <20160227171437.N1735@besplex.bde.org> References: <20160226164613.N2180@besplex.bde.org> <1347742231.11086226.1456545647628.JavaMail.zimbra@uoguelph.ca> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=73JWPhLeruqQCjN69UNZtQ==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=aJNDa8-r2z69CfcSr0sA:9 a=CjuIK1q_8ugA:10 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2016 06:27:09 -0000 On Fri, 26 Feb 2016, Rick Macklem wrote: > Bruce Evans wrote: >> nfs3 is slower than in old versions of FreeBSD. I debugged one of the >> reasons today. >... >> nfs_open() does the discarding for different reasons in the NMODIFIED >> and !NMODIFIED cases. In the NMODIFED case, it discard unconditionally. >> This case can be avoided by fsync() before close or setting the sysctl >> to commit in close. iozone does he fsync(). This helps in oldnfs but >> not in newfs. With it, iozone on newfs now behaves like it did on oldnfs >> 10-20 years ago. Something (perhaps just the timestamp bugs discussed >> later) "fixed" the discarding on oldnfs 5-10 years ago. >... >> The other reason for discarding is because the timestamps changed -- you >> just wrote them, so the timestamps should have changed. Different bugs >> in comparing the timestamps gave different misbehaviours. >> > You could easily test to see if second-resolution timestamps make a > difference by redefining the NFS_TIMESPEC_COMPARE() macro > { in sys/fs/nfsclient/nfsnode.h } so that it only compares the > tv_sec field and not the tv_nsec field. > --> Then the client would only think the mtime has changed when tv_sec > changes. My server has vfs.timestamp_precision for other reasons, so I get this automatically. So the fixes to use NFS_TIMESTAMP_COMPARE() don't actually work. This together with enabling write commit gives a useful optimization for compiling (it reduces the build time for a FreeBSD-4 kernel from 4.5 seconds to 4.4 seconds. Very useful for compiling hundreds of these :-). Write commit clears NMODIFIED and the buggy timestamp compare then avoids most cache invalidations. BTW, I don't kike the NFS_TIMESTAMP_COMPARE() macro. FreeBSD has a better standard macro timespeccmp(). The names of these macros have different bugs, but timespeccmp() is easier to use since it is shorter and you can see the comparison operator in it and it is not limited to comparing for inequality. NFS_TIMESTAMP_COMPARE() looks like it compares for equality, but actually compares for inequality. Bruce