From patchwork Sun Sep 30 19:48:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 188196 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 68CB72C00BA for ; Mon, 1 Oct 2012 05:48:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751511Ab2I3Tsb (ORCPT ); Sun, 30 Sep 2012 15:48:31 -0400 Received: from li9-11.members.linode.com ([67.18.176.11]:53093 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751349Ab2I3Ts3 (ORCPT ); Sun, 30 Sep 2012 15:48:29 -0400 Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.72) (envelope-from ) id 1TIPUt-0001TU-Aa; Sun, 30 Sep 2012 19:48:15 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id 50F762401C8; Sun, 30 Sep 2012 15:48:19 -0400 (EDT) From: Theodore Ts'o To: Ext4 Developers List Cc: linux-nilfs@vger.kernel.org, Theodore Ts'o , Jan Kara , KONISHI Ryusuke , stable@vger.kernel.org Subject: [PATCH REGRESSION FIX] ext4: fix mtime update in nodelalloc mode Date: Sun, 30 Sep 2012 15:48:19 -0400 Message-Id: <1349034499-4731-1-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 1.7.12.rc0.22.gcdd159b X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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. Signed-off-by: "Theodore Ts'o" Cc: Jan Kara Cc: KONISHI Ryusuke Cc: stable@vger.kernel.org Signed-off-by: "Theodore Ts'o" --- 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(-) diff --git a/fs/buffer.c b/fs/buffer.c index 9f6d2e4..1fe3968 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -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); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 09308ad..f18e786 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -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) && diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index a4d56ac..5b387a4 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -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);