From: Nick Piggin <npiggin@suse.de>
To: linux-fsdevel@vger.kernel.org
Cc: hch@infradead.org, viro@zeniv.linux.org.uk, jack@suse.cz,
linux-mm@kvack.org
Subject: [patch 3/3] fs: buffer_head page_lock i_size relax
Date: Fri, 10 Jul 2009 11:35:08 +0200 [thread overview]
Message-ID: <20090710093508.GI14666@wotan.suse.de> (raw)
In-Reply-To: <20090710093325.GG14666@wotan.suse.de>
The previous patch allows us to relax the buffer.c requirement that the page
lock be held in order to avoid writepage zeroing out new data beyond isize.
[actually as I said I think it still has a bug due to writepage requiring
i_size_read]
---
fs/buffer.c | 28 ++++++++--------------------
mm/shmem.c | 6 +++---
2 files changed, 11 insertions(+), 23 deletions(-)
Index: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c
+++ linux-2.6/fs/buffer.c
@@ -2049,33 +2049,20 @@ int generic_write_end(struct file *file,
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;
}
@@ -2624,14 +2611,15 @@ int nobh_write_end(struct file *file, st
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;
Index: linux-2.6/mm/shmem.c
===================================================================
--- linux-2.6.orig/mm/shmem.c
+++ linux-2.6/mm/shmem.c
@@ -1631,13 +1631,13 @@ shmem_write_end(struct file *file, struc
{
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;
}
WARNING: multiple messages have this Message-ID (diff)
From: Nick Piggin <npiggin@suse.de>
To: linux-fsdevel@vger.kernel.org
Cc: hch@infradead.org, viro@zeniv.linux.org.uk, jack@suse.cz,
linux-mm@kvack.org
Subject: [patch 3/3] fs: buffer_head page_lock i_size relax
Date: Fri, 10 Jul 2009 11:35:08 +0200 [thread overview]
Message-ID: <20090710093508.GI14666@wotan.suse.de> (raw)
In-Reply-To: <20090710093325.GG14666@wotan.suse.de>
The previous patch allows us to relax the buffer.c requirement that the page
lock be held in order to avoid writepage zeroing out new data beyond isize.
[actually as I said I think it still has a bug due to writepage requiring
i_size_read]
---
fs/buffer.c | 28 ++++++++--------------------
mm/shmem.c | 6 +++---
2 files changed, 11 insertions(+), 23 deletions(-)
Index: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c
+++ linux-2.6/fs/buffer.c
@@ -2049,33 +2049,20 @@ int generic_write_end(struct file *file,
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;
}
@@ -2624,14 +2611,15 @@ int nobh_write_end(struct file *file, st
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;
Index: linux-2.6/mm/shmem.c
===================================================================
--- linux-2.6.orig/mm/shmem.c
+++ linux-2.6/mm/shmem.c
@@ -1631,13 +1631,13 @@ shmem_write_end(struct file *file, struc
{
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;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-07-10 9:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-10 7:30 [patch 0/5] new truncate sequence patchset npiggin
2009-07-10 7:30 ` [patch 1/5] fs: new truncate helpers npiggin
2009-07-10 7:30 ` [patch 2/5] fs: use " npiggin
2009-07-10 7:30 ` npiggin-l3A5Bk7waGM
2009-07-10 7:30 ` [patch 3/5] fs: introduce new truncate sequence npiggin
2009-07-10 7:30 ` [patch 4/5] tmpfs: convert to use the new truncate convention npiggin
2009-07-10 7:30 ` [patch 5/5] ext2: " npiggin
2009-09-01 18:29 ` Jan Kara
2009-09-02 9:14 ` Nick Piggin
2009-09-02 11:14 ` Jan Kara
2009-07-10 9:33 ` [patch 1/3] fs: buffer_head writepage no invalidate Nick Piggin
2009-07-10 9:33 ` Nick Piggin
2009-07-10 9:34 ` [patch 2/3] fs: buffer_head writepage no zero Nick Piggin
2009-07-10 9:34 ` Nick Piggin
2009-07-10 11:46 ` Jan Kara
2009-07-10 11:46 ` Jan Kara
2009-07-13 6:54 ` Nick Piggin
2009-07-13 6:54 ` Nick Piggin
2009-07-10 9:35 ` Nick Piggin [this message]
2009-07-10 9:35 ` [patch 3/3] fs: buffer_head page_lock i_size relax Nick Piggin
2009-07-10 11:08 ` [patch 1/3] fs: buffer_head writepage no invalidate Jan Kara
2009-07-10 11:08 ` Jan Kara
2009-07-10 14:31 ` [patch 0/5] new truncate sequence patchset Christoph Hellwig
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=20090710093508.GI14666@wotan.suse.de \
--to=npiggin@suse.de \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.