linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: update c/mtime on truncate up
@ 2015-07-24  6:56 Eryu Guan
  2015-07-28 19:09 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eryu Guan @ 2015-07-24  6:56 UTC (permalink / raw)
  To: linux-ext4; +Cc: Eryu Guan, Zirong Lang

Commit 3da40c7b0898 ("ext4: only call ext4_truncate when size <= isize")
introduced a bug that c/mtime is not updated on truncate up.

Fix the issue by setting c/mtime explicitly in the truncate up case.

Note that ftruncate(2) is not affected, so you won't see this bug using
truncate(1) and xfs_io(1).

Signed-off-by: Zirong Lang <zorro.lang@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
---
 fs/ext4/inode.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index cecf9aa..2442eb0 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4725,6 +4725,14 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 				error = ext4_orphan_add(handle, inode);
 				orphan = 1;
 			}
+			/*
+			 * Update c/mtime on truncate up, ext4_truncate() will
+			 * update c/mtime in shrink case below
+			 */
+			if (!shrink) {
+				inode->i_mtime = ext4_current_time(inode);
+				inode->i_ctime = inode->i_mtime;
+			}
 			down_write(&EXT4_I(inode)->i_data_sem);
 			EXT4_I(inode)->i_disksize = attr->ia_size;
 			rc = ext4_mark_inode_dirty(handle, inode);
-- 
1.8.3.1


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

* Re: [PATCH] ext4: update c/mtime on truncate up
  2015-07-24  6:56 [PATCH] ext4: update c/mtime on truncate up Eryu Guan
@ 2015-07-28 19:09 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2015-07-28 19:09 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-ext4, Zirong Lang

On Fri, Jul 24, 2015 at 02:56:38PM +0800, Eryu Guan wrote:
> Commit 3da40c7b0898 ("ext4: only call ext4_truncate when size <= isize")
> introduced a bug that c/mtime is not updated on truncate up.
> 
> Fix the issue by setting c/mtime explicitly in the truncate up case.
> 
> Note that ftruncate(2) is not affected, so you won't see this bug using
> truncate(1) and xfs_io(1).
> 
> Signed-off-by: Zirong Lang <zorro.lang@gmail.com>
> Signed-off-by: Eryu Guan <guaneryu@gmail.com>

Applied, thanks.

					- Ted

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

end of thread, other threads:[~2015-07-28 19:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-24  6:56 [PATCH] ext4: update c/mtime on truncate up Eryu Guan
2015-07-28 19:09 ` Theodore Ts'o

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