From owner-freebsd-arch@FreeBSD.ORG Wed Dec 17 01:07:04 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 78C5077D; Wed, 17 Dec 2014 01:07:04 +0000 (UTC) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 3C2E2D65; Wed, 17 Dec 2014 01:07:03 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id C4A9F4279FE; Wed, 17 Dec 2014 11:39:38 +1100 (AEDT) Date: Wed, 17 Dec 2014 11:39:37 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Jilles Tjoelker Subject: Re: Change default VFS timestamp precision? In-Reply-To: <20141216233844.GA1490@stack.nl> Message-ID: <20141217105256.J1490@besplex.bde.org> References: <201412161348.41219.jhb@freebsd.org> <20141216233844.GA1490@stack.nl> 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=AIISoSx1 c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=VaHR_doENNfmLM0zlY4A:9 a=CjuIK1q_8ugA:10 Cc: arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2014 01:07:04 -0000 On Wed, 17 Dec 2014, Jilles Tjoelker wrote: > Although some breakage may be caused, increasing precision sounds fine > to me, but only to the level of microseconds, since there is no way to > set a timestamp to the nanosecond (this would be futimens/utimensat). It > is easy to be surprised when cp -p creates an file that appears older > than the original. As I said in too many more words in another reply. > To avoid cross-arch surprises with applications that use > second-resolution APIs, either all or no architectures should generate > timestamps more accurate than seconds. That might be a feature for finding bugs. And it doesn't work for avoiding them, because foreign file systems may have uncontrollable timestamp precision. E.g., a foreign nfs server. > There is no benefit for the particular case of make(1), since it only > uses timestamps in seconds. Urk, I now rememeber seeing that 15-20 years ago and deciding that the problem with timestamps for make couldn't be very large. > A quick grep also shows various calls to utime(3) with a non-NULL timep > argument. The ones in contrib/bmake and usr.bin/make definitely look > incorrect. Do you mean that they are incorrect because they use utime(3) and not utimes(3), or just because they use the non-NULL timep? The latter is just a style bug in at least usr.bin/make. Since it hasn't caught up with the existence of utimes(3), it is reasonable for it to also have not caught up with the existence of the non-NULL timep. It just wants to set the time to the current time. It uses its own copy of the current time for this. Perhaps this is technically better too -- it makes "make -t" touch everything with the same time. This reminds me of related bugs in touch(1): - touch also tries first with a non-NULL timep. So it uses its own idea of the current time. This is normally the one returned a little in the past by gettimeofday(). It has microseconds resolution. This normally succeeds, giving a result that is inconsistent with the one that would result from using a NULL timep, since the kernel now honors vfs.timestamp_precision and that is not usually 2. - sometimes the first try fails. Then touch retries with a NULL timep, if the semantics allow this. Sometimes this succeeds. - sometimes both tries fail due to permissions problems. Then touch used to retry using read() and write(). Someone removed this, with the justification that all file systems support utimes(). But this is broken, since touching for read requires only read permission, while utimes() requires some sort of write permission. For touching for write, I don't see any problem now except for the above ordering problems: a NULL timep should be tried first since it requires fewer permissions and gives the best semantics; if it fails then there is no point in retrying with a non-NULL timep. The non-NULL timep in make gives the following bug since make doesn't retry with a NULL timep: make -t fails if the files ar writeable but not owned. Bruce