Skip to contentSkip to conversation

ext4: fix mtime update in nodelalloc mode

PATCH In review Theodore Ts'o 5 participants 7 messages Sep 30, 2012 – Oct 1, 2012 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Theodore Ts'o

author maintainer
#0 lore raw

PATCH 1/1 ext4: fix mtime update in nodelalloc mode

Commits 41c4d25f78c0 and 41c4d25f78c0 introduced a regression into 3.6-rc1 for ext4 in nodealloc mode, such that mtime updates would not take place for files modified via mmap if the page was already in the page cache.

The problem was that ext4_page_mkwrite() had a shortcut which would avoid calling __block_page_mkwrite() under some circumstances, and the above two commit transferred the responsibility of calling file_update_time() to __block_page_mkwrite --- which woudln't get called in some circumstances.

Since __block_page_mkwrite() only has three years, block_page_mkwrite(), ext4_page_mkwrite, and nilfs_page_mkwrite(), the best way to solve this is to move the responsibility for calling file_update_time() to its caller.

---

NOTE: Since this is a 3.6 regression, I may push this to Linus ahead of the merge window, since it will also affect distibutions which use ext4 to mount ext3-formatted partitions.

 fs/buffer.c      | 13 +++++++------
 fs/ext4/inode.c  |  1 +
 fs/nilfs2/file.c |  1 +
 3 files changed, 9 insertions(+), 6 deletions(-)
fs/buffer.c +7 -6
index 9f6d2e4..1fe3968 100644
@@ -2318,12 +2318,6 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
 	loff_t size;
 	int ret;
 
-	/*
-	 * Update file times before taking page lock. We may end up failing the
-	 * fault so this update may be superfluous but who really cares...
-	 */
-	file_update_time(vma->vm_file);
-
 	lock_page(page);
 	size = i_size_read(inode);
 	if ((page->mapping != inode->i_mapping) ||
@@ -2361,6 +2355,13 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
 	struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb;
 
 	sb_start_pagefault(sb);
+
+	/*
+	 * Update file times before taking page lock. We may end up failing the
+	 * fault so this update may be superfluous but who really cares...
+	 */
+	file_update_time(vma->vm_file);
+
 	ret = __block_page_mkwrite(vma, vmf, get_block);
 	sb_end_pagefault(sb);
 	return block_page_mkwrite_return(ret);
fs/ext4/inode.c +1 -0
index 09308ad..f18e786 100644
@@ -4788,6 +4788,7 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	int retries = 0;
 
 	sb_start_pagefault(inode->i_sb);
+	file_update_time(vma->vm_file);
 	/* Delalloc case is easy... */
 	if (test_opt(inode->i_sb, DELALLOC) &&
 	    !ext4_should_journal_data(inode) &&
fs/nilfs2/file.c +1 -0
index a4d56ac..5b387a4 100644
@@ -116,6 +116,7 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (unlikely(ret))
 		goto out;
 
+	file_update_time(vma->vm_file);
 	ret = __block_page_mkwrite(vma, vmf, nilfs_get_block);
 	if (ret) {
 		nilfs_transaction_abort(inode->i_sb);
Signature · 1 line
1.7.12.rc0.22.gcdd159b
#1 lore raw
Quoted 2 lines · Theodore Ts'o

Since __block_page_mkwrite() only has three years, block_page_mkwrite(), ext4_page_mkwrite, and nilfs_page_mkwrite(), the

years = callers?

#3 lore raw
In reply to a message not in the archive

Note: this fixes a failure in xfstests #215 for ext3 file systems mounted using ext4 and ext4 file systems mounted with -o nodelalloc.

- Ted

Quoted 16 lines · Theodore Ts'o

Commits 41c4d25f78c0 and 41c4d25f78c0 introduced a regression into 3.6-rc1 for ext4 in nodealloc mode, such that mtime updates would not take place for files modified via mmap if the page was already in the page cache.

The problem was that ext4_page_mkwrite() had a shortcut which would avoid calling __block_page_mkwrite() under some circumstances, and the above two commit transferred the responsibility of calling file_update_time() to __block_page_mkwrite --- which woudln't get called in some circumstances.

Since __block_page_mkwrite() only has three years, block_page_mkwrite(), ext4_page_mkwrite, and nilfs_page_mkwrite(), the best way to solve this is to move the responsibility for calling file_update_time() to its caller.

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#5 lore raw
Quoted 6 lines · Jonathan Nieder
Quoted 2 lines · Theodore Ts'o

Since __block_page_mkwrite() only has three years, block_page_mkwrite(), ext4_page_mkwrite, and nilfs_page_mkwrite(), the

years = callers?

Yes, thanks for pointing that out. I'll fix the commit description.

Quoted 4 lines · Willy Tarreau
Quoted 1 line · Theodore Ts'o

Commits 41c4d25f78c0 and 41c4d25f78c0 introduced a regression

you mistakenly wrote the same commit ID twice.

Sorry, the two commit ID's are:

5e8830dc85d0 and 41c4d25f78c0

- Ted

#7 lore raw
In reply to a message not in the archive

The rewritten commit description:

ext4: fix mtime update in nodelalloc mode

Commits 5e8830dc85d0 and 41c4d25f78c0 introduced a regression into 3.6-rc1 for ext4 in nodealloc mode, such that mtime updates would not take place for files modified via mmap if the page was already in the page cache. This would also affect ext3 file systems mounted using the ext4 file system driver.

The problem was that ext4_page_mkwrite() had a shortcut which would avoid calling __block_page_mkwrite() under some circumstances, and the above two commit transferred the responsibility of calling file_update_time() to __block_page_mkwrite --- which woudln't get called in some circumstances.

Since __block_page_mkwrite() only has three callers, block_page_mkwrite(), ext4_page_mkwrite, and nilfs_page_mkwrite(), the best way to solve this is to move the responsibility for calling file_update_time() to its caller.

This problem was found via xfstests #215 with a file system mounted with -o nodelalloc.

Note: If this gets pushed to Linus before the merge window opens, I'll drop the cc of [email protected], since the regression was introduced in 3.6-rc1.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by
#9 lore raw
In reply to a message not in the archive
Quoted 24 lines · Ted Tso

The rewritten commit description:

ext4: fix mtime update in nodelalloc mode

Commits 5e8830dc85d0 and 41c4d25f78c0 introduced a regression into 3.6-rc1 for ext4 in nodealloc mode, such that mtime updates would not take place for files modified via mmap if the page was already in the page cache. This would also affect ext3 file systems mounted using the ext4 file system driver.

The problem was that ext4_page_mkwrite() had a shortcut which would avoid calling __block_page_mkwrite() under some circumstances, and the above two commit transferred the responsibility of calling file_update_time() to __block_page_mkwrite --- which woudln't get called in some circumstances.

Since __block_page_mkwrite() only has three callers, block_page_mkwrite(), ext4_page_mkwrite, and nilfs_page_mkwrite(), the best way to solve this is to move the responsibility for calling file_update_time() to its caller.

This problem was found via xfstests #215 with a file system mounted with -o nodelalloc.

Quoted 8 lines

Note: If this gets pushed to Linus before the merge window opens, I'll drop the cc of [email protected], since the regression was introduced in 3.6-rc1.

Ah, good catch. Thanks for fixing this. I agree with the fix so you can
add:

Honza
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html