linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/open.c: update {m,c}time for truncate
@ 2019-08-22  7:33 Murphy Zhou
  2019-08-22 12:08 ` Miklos Szeredi
  0 siblings, 1 reply; 3+ messages in thread
From: Murphy Zhou @ 2019-08-22  7:33 UTC (permalink / raw)
  To: miklos, viro, linux-fsdevel

Just like what we do for ftruncate. (Why not)
Without this patch, cifs, sometimes NFS, fail to update timestamps
after truncate call.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
---
 fs/open.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/open.c b/fs/open.c
index a59abe3c669a..f247085aaee4 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -107,7 +107,8 @@ long vfs_truncate(const struct path *path, loff_t length)
 	if (!error)
 		error = security_path_truncate(path);
 	if (!error)
-		error = do_truncate(path->dentry, length, 0, NULL);
+		error = do_truncate(path->dentry, length,
+				ATTR_MTIME|ATTR_CTIME, NULL);
 
 put_write_and_out:
 	put_write_access(inode);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/open.c: update {m,c}time for truncate
  2019-08-22  7:33 [PATCH] fs/open.c: update {m,c}time for truncate Murphy Zhou
@ 2019-08-22 12:08 ` Miklos Szeredi
  2019-08-22 13:03   ` Miklos Szeredi
  0 siblings, 1 reply; 3+ messages in thread
From: Miklos Szeredi @ 2019-08-22 12:08 UTC (permalink / raw)
  To: Murphy Zhou; +Cc: Al Viro, linux-fsdevel

On Thu, Aug 22, 2019 at 9:33 AM Murphy Zhou <jencce.kernel@gmail.com> wrote:
>
> Just like what we do for ftruncate. (Why not)
> Without this patch, cifs, sometimes NFS, fail to update timestamps
> after truncate call.

Digging through history:

4a30131e7dbb ("[PATCH] Fix some problems with truncate and mtime semantics.")
6e656be89999 ("[PATCH] ftruncate does not always update m/ctime")

These are pretty old commits (>10years); has anything changed since
then relative to the required semantics for truncate/ftruncate?

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/open.c: update {m,c}time for truncate
  2019-08-22 12:08 ` Miklos Szeredi
@ 2019-08-22 13:03   ` Miklos Szeredi
  0 siblings, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2019-08-22 13:03 UTC (permalink / raw)
  To: Murphy Zhou; +Cc: Al Viro, linux-fsdevel

On Thu, Aug 22, 2019 at 2:08 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
>
> On Thu, Aug 22, 2019 at 9:33 AM Murphy Zhou <jencce.kernel@gmail.com> wrote:
> >
> > Just like what we do for ftruncate. (Why not)
> > Without this patch, cifs, sometimes NFS, fail to update timestamps
> > after truncate call.
>
> Digging through history:
>
> 4a30131e7dbb ("[PATCH] Fix some problems with truncate and mtime semantics.")
> 6e656be89999 ("[PATCH] ftruncate does not always update m/ctime")
>
> These are pretty old commits (>10years); has anything changed since
> then relative to the required semantics for truncate/ftruncate?

SUSv3/POSIX:2004:

   "Upon successful completion, if the file size is changed, this
function shall mark for update the st_ctime and st_mtime fields of the
file"

SUSv4/POSIX:2008:

   "Upon successful completion, truncate() shall mark for update the
last data modification and last file status change timestamps of the
file..."

Note the omission of the "if the file size is changed" condition...

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-22 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22  7:33 [PATCH] fs/open.c: update {m,c}time for truncate Murphy Zhou
2019-08-22 12:08 ` Miklos Szeredi
2019-08-22 13:03   ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).