linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] ext4: update donor file's ctime/mtime
@ 2009-10-08  8:04 Kazuya Mio
  2009-10-09 17:20 ` Andreas Dilger
  0 siblings, 1 reply; 5+ messages in thread
From: Kazuya Mio @ 2009-10-08  8:04 UTC (permalink / raw)
  To: linux-ext4, Theodore Tso

EXT4_IOC_MOVE_EXT changes donor file data, but doesn't update ctime/mtime.
This patch fixes this problem.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
---

 move_extent.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index e2e99fd..1cb2609 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -1210,6 +1210,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
 	ext4_lblk_t block_end, seq_start, add_blocks, file_end, seq_blocks = 0;
 	ext4_lblk_t rest_blocks;
 	pgoff_t orig_page_offset = 0, seq_end_page;
+	handle_t *handle;
 	int ret1, ret2, depth, last_extent = 0;
 	int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits;
 	int data_offset_in_page;
@@ -1406,6 +1407,25 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp,
 
 	}
 out:
+	/*
+	 * Note that ctime/mtime will not be updated if power failure is
+	 * detected during block replacing.
+	 */
+	if (*moved_len) {
+		handle = ext4_journal_start(donor_inode, 1);
+		if (IS_ERR(handle))
+			ret2 = PTR_ERR(handle);
+		else {
+			donor_inode->i_ctime = donor_inode->i_mtime =
+					ext4_current_time(donor_inode);
+			ret2 = ext4_mark_inode_dirty(handle, donor_inode);
+			ext4_journal_stop(handle);
+		}
+
+		if (!ret1)
+			ret1 = ret2;
+	}
+
 	if (orig_path) {
 		ext4_ext_drop_refs(orig_path);
 		kfree(orig_path);


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

end of thread, other threads:[~2009-10-14 21:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08  8:04 [PATCH 2/2] ext4: update donor file's ctime/mtime Kazuya Mio
2009-10-09 17:20 ` Andreas Dilger
2009-10-14  1:49   ` Kazuya Mio
2009-10-14 18:10     ` Andreas Dilger
2009-10-14 21:19       ` Greg Freemyer

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