From: Trond Myklebust Subject: Re: ctime set by truncate even if NOCMTIME requested Date: Mon, 19 Sep 2005 14:58:23 -0400 Message-ID: <1127156303.8519.29.camel@lade.trondhjem.org> References: <432EFAB1.4080406@austin.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Return-path: To: Steve French In-Reply-To: <432EFAB1.4080406@austin.rr.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org m=C3=A5 den 19.09.2005 Klokka 12:51 (-0500) skreiv Steve French: > I am seeing requests to set ctime on truncate which does not make any= =20 > sense to me as I was testing with the flag that should have turned th= at=20 > off. ie my inodes having S_NOCMTIME set, as NFS does. >=20 > do_truncate (line 206 of open.c) sets > newattrs.ia_valid =3D ATTR_SIZE | ATTR_CTIME > instead of > newattrs.ia_valid =3D ATTR_SIZE; > if(!IS_NOCMTIME(inode)) > newattrs.ia_valid |=3D ATTR_CTIME; >=20 > I thought that the correct way to handle this for network filesystems= ,=20 > is to let the server set the mtime and ctime unless the application=20 > explicitly sets the attributes (in the case of the sys call truncate = or=20 > ftruncate the application is not explicitly setting the ctime/mtime a= s=20 > it would on a backup/restore so they should be ignored for the networ= k=20 > fs so the server will set it correctl to its time, reducing traffic a= nd=20 > more accurately representing the time it got updated). >=20 > Shouldn't there be a IS_NOCMTIME check in the truncate path in fs/ope= n.c? See the discussion on this a couple of weeks back. It is quite correct for the kernel to request that the filesystem set ctime/mtime on successful calls to open(O_TRUNC). http://www.opengroup.org/onlinepubs/009695399/toc.htm It is _incorrect_ for it to request that ctime/mtime be set (or that th= e suid/sgid mode bit be cleared) if a truncate()/ftruncate() call results in no size change. http://www.opengroup.org/onlinepubs/009695399/toc.htm So the current do_truncate() does have to be changed. Adding a check fo= r IS_NOCMTIME would be wrong, though. Cheers, Trond