linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jubin Zhong <zhongjubin@huawei.com>
To: <hch@infradead.org>
Cc: <kechengsong@huawei.com>, <linux-fsdevel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <viro@zeniv.linux.org.uk>,
	<wangfangpeng1@huawei.com>, <zhongjubin@huawei.com>
Subject: Re: [PATCH] fs: Fix truncate never updates m/ctime
Date: Tue, 16 Nov 2021 14:57:28 +0800	[thread overview]
Message-ID: <1637045848-56278-1-git-send-email-zhongjubin@huawei.com> (raw)
In-Reply-To: <YZNADLcSbgKp5Znh@infradead.org>

> 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.

  reply	other threads:[~2021-11-16  6:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 11:00 [PATCH] fs: Fix truncate never updates m/ctime Jubin Zhong
2021-11-15 17:58 ` Christoph Hellwig
2021-11-16  3:58   ` Jubin Zhong
2021-11-16  5:22     ` Christoph Hellwig
2021-11-16  6:57       ` Jubin Zhong [this message]
2021-11-16  7:02         ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1637045848-56278-1-git-send-email-zhongjubin@huawei.com \
    --to=zhongjubin@huawei.com \
    --cc=hch@infradead.org \
    --cc=kechengsong@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wangfangpeng1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).