From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: linux-mm@vger.kernel.org, npiggin@suse.de, Jan Kara <jack@suse.cz>
Subject: [PATCH 4/5] fs: Move i_size update in write_end() from under page lock
Date: Tue, 11 Aug 2009 00:20:46 +0200 [thread overview]
Message-ID: <1249942847-23851-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1249942847-23851-1-git-send-email-jack@suse.cz>
From: Nick Piggin <npiggin@suse.de>
The previous patch allows us to relax the requirement that the page lock must
be held in order to avoid writepage zeroing out new data beyond isize.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/buffer.c | 28 ++++++++--------------------
mm/shmem.c | 6 +++---
2 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 2b8cabe..15e7f40 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2049,33 +2049,20 @@ int generic_write_end(struct file *file, struct address_space *mapping,
struct page *page, void *fsdata)
{
struct inode *inode = mapping->host;
- int i_size_changed = 0;
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
+ unlock_page(page);
+ page_cache_release(page);
+
/*
* No need to use i_size_read() here, the i_size
* cannot change under us because we hold i_mutex.
- *
- * But it's important to update i_size while still holding page lock:
- * page writeout could otherwise come in and zero beyond i_size.
*/
if (pos+copied > inode->i_size) {
i_size_write(inode, pos+copied);
- i_size_changed = 1;
- }
-
- unlock_page(page);
- page_cache_release(page);
-
- /*
- * Don't mark the inode dirty under page lock. First, it unnecessarily
- * makes the holding time of page lock longer. Second, it forces lock
- * ordering of page lock and transaction start for journaling
- * filesystems.
- */
- if (i_size_changed)
mark_inode_dirty(inode);
+ }
return copied;
}
@@ -2629,14 +2616,15 @@ int nobh_write_end(struct file *file, struct address_space *mapping,
SetPageUptodate(page);
set_page_dirty(page);
+
+ unlock_page(page);
+ page_cache_release(page);
+
if (pos+copied > inode->i_size) {
i_size_write(inode, pos+copied);
mark_inode_dirty(inode);
}
- unlock_page(page);
- page_cache_release(page);
-
while (head) {
bh = head;
head = head->b_this_page;
diff --git a/mm/shmem.c b/mm/shmem.c
index d713239..52ac65c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1627,13 +1627,13 @@ shmem_write_end(struct file *file, struct address_space *mapping,
{
struct inode *inode = mapping->host;
- if (pos + copied > inode->i_size)
- i_size_write(inode, pos + copied);
-
unlock_page(page);
set_page_dirty(page);
page_cache_release(page);
+ if (pos + copied > inode->i_size)
+ i_size_write(inode, pos + copied);
+
return copied;
}
--
1.6.0.2
next prev parent reply other threads:[~2009-08-10 22:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 22:20 [PATCH 0/5] [RFC] Fix page_mkwrite for blocksize < pagesize Jan Kara
2009-08-10 22:20 ` [PATCH 1/5] fs: buffer_head writepage no invalidate Jan Kara
2009-08-10 22:20 ` [PATCH 2/5] fs: Don't zero out page on writepage() Jan Kara
2009-08-10 22:20 ` [PATCH 3/5] vfs: Create dirty buffer only inside i_size Jan Kara
2009-08-10 22:20 ` Jan Kara [this message]
2009-08-10 22:20 ` [PATCH 5/5] vfs: Add better VFS support for page_mkwrite when blocksize < pagesize Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1249942847-23851-5-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@vger.kernel.org \
--cc=npiggin@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).