From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Patrick J. LoPresti" Subject: Re: Proposal: Use hi-res clock for file timestamps Date: Wed, 18 Aug 2010 07:46:57 -0700 Message-ID: References: <87aaolwar8.fsf@basil.nowhere.org> <20100817174134.GA23176@fieldses.org> <20100817182920.GD18161@basil.fritz.box> <20100817190447.GA28049@fieldses.org> <20100817203941.729830b7@lxorguk.ukuu.org.uk> <20100817192937.GD26609@fieldses.org> <20100818155359.66b9ddb6@notabene> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: "J. Bruce Fields" , Alan Cox , Andi Kleen , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel To: Neil Brown Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:48348 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753148Ab0HROq6 convert rfc822-to-8bit (ORCPT ); Wed, 18 Aug 2010 10:46:58 -0400 In-Reply-To: <20100818155359.66b9ddb6@notabene> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Aug 17, 2010 at 10:53 PM, Neil Brown wrote: > > I imagine something like this: > =A0- Create a global struct timespec which is protected by a seqlock > =A0 Call it current_nfsd_time or similar. > =A0- file_update_time reads this and uses it if it is newer than > =A0 current_fs_time. > =A0- nfsd updates it whenever it reads an mtime out of an inode that = matches > =A0 current_fs_time to the granularity of 1/HZ. I think nfsd can simply update current_nfsd_time whenever the mtime it reads from an inode is >=3D current_nfsd_time. (The invariant you need to maintain is that whenever nfsd reads an mtime, any timestamps produced after that have a later time. So just code it that way directly.) > =A0 If the current value is before current_kernel_time, it > =A0 is set to current_kernel_time, otherwise tv_nsec is incremented - > =A0 unless that increases > =A0 beyond jiffies_to_usec(1)*1000 beyond current_kernel_time. > =A0- the global 'struct timespec' is zeroed whenever system time is s= et > =A0 backwards. I believe this works. > [[You could probably make ext3 work reasonably well by adding a mount= option > =A0which: > =A0 =A0- advertises s_time_gran as 1 > =A0 =A0- when storing: rounds timestamps up to the next second if tv_= nsec !=3D 0 > =A0 =A0- when loading, setting the timestamp to the current time if t= he stored > =A0 =A0 =A0number matches current_kernel_time().tv_sec+1 > =A0You would get occasional forward jumps in mtime, but usually when = you > =A0aren't looking, and at least you would not get real changes that a= re not > =A0reflected in mtime > ]] But I do not believe this works. 1) Modify file A 2) Modify file B 3) File A experiences one of those "occasional forward jumps in mtime" (inode evicted + read back within 1 second) 4) mtimes on A and B are now out of order -- very bad As Bruce mentioned, ext3 is a lost cause. Regardless of any of this, however, the first step is to provide a mount option to select the timestamp algorithm... Because it is still absurd that I cannot have accurate timestamps on my files here in the 21st century. Once that is done, the rest is just providing the alternative implementations and choosing defaults. - Pat -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html