lkml.org 
[lkml]   [2021]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH] fs: Fix truncate never updates m/ctime
Date
> It seems like you need to fix jffs2 to implement the proper semantics in its ->setattr.

Yes I have thought of this solution. However, when I tried to
track this problem down, I found that ftruncate() had similar
problem and it was fixed by commit 6e656be89999 ("ftruncate
does not always update m/ctime"):

diff --git a/fs/open.c b/fs/open.c
index 5fb16e5267dc..303f06d2a7b9 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -322,7 +322,7 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)

error = locks_verify_truncate(inode, file, length);
if (!error)
- error = do_truncate(dentry, length, 0, file);
+ error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
out_putf:
fput(file);
out:

In my opinion, there are two advantages if we fix it in
vfs_truncate():

1. All filesystems can reuse the scheme without adapting
Separately, just like what we did for ftruncate().
2. In the case when old_size = new_size, we can avoid
calling do_truncate() and return without doing anything.

Hope that you can consider my suggestion, thanks.

\
 
 \ /
  Last update: 2021-11-16 07:58    [W:0.034 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site