Skip to content

Commit 041bbb6

Browse files
committed
ext4: fix mtime update in nodelalloc mode
Commits 5e8830d and 41c4d25 introduced a regression into v3.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 raspberrypi#215 with a file system mounted with -o nodelalloc. Signed-off-by: "Theodore Ts'o" <[email protected]> Reviewed-by: Jan Kara <[email protected]> Cc: KONISHI Ryusuke <[email protected]> Cc: [email protected]
1 parent 6f2080e commit 041bbb6

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

fs/buffer.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,12 +2318,6 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
23182318
loff_t size;
23192319
int ret;
23202320

2321-
/*
2322-
* Update file times before taking page lock. We may end up failing the
2323-
* fault so this update may be superfluous but who really cares...
2324-
*/
2325-
file_update_time(vma->vm_file);
2326-
23272321
lock_page(page);
23282322
size = i_size_read(inode);
23292323
if ((page->mapping != inode->i_mapping) ||
@@ -2361,6 +2355,13 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
23612355
struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb;
23622356

23632357
sb_start_pagefault(sb);
2358+
2359+
/*
2360+
* Update file times before taking page lock. We may end up failing the
2361+
* fault so this update may be superfluous but who really cares...
2362+
*/
2363+
file_update_time(vma->vm_file);
2364+
23642365
ret = __block_page_mkwrite(vma, vmf, get_block);
23652366
sb_end_pagefault(sb);
23662367
return block_page_mkwrite_return(ret);

fs/ext4/inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4788,6 +4788,7 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
47884788
int retries = 0;
47894789

47904790
sb_start_pagefault(inode->i_sb);
4791+
file_update_time(vma->vm_file);
47914792
/* Delalloc case is easy... */
47924793
if (test_opt(inode->i_sb, DELALLOC) &&
47934794
!ext4_should_journal_data(inode) &&

fs/nilfs2/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
116116
if (unlikely(ret))
117117
goto out;
118118

119+
file_update_time(vma->vm_file);
119120
ret = __block_page_mkwrite(vma, vmf, nilfs_get_block);
120121
if (ret) {
121122
nilfs_transaction_abort(inode->i_sb);

0 commit comments

Comments
 (0)