From: Nick Piggin <npiggin@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, cmm@us.ibm.com,
Badari Pulavarty <pbadari@gmail.com>,
Dmitriy Monakhov <dmonakhov@sw.ru>,
mark.fasheh@oracle.com
Subject: [patch 4/8] 2.6.22-rc4-mm2 buffered write fixes
Date: Thu, 14 Jun 2007 04:37:49 +0200 [thread overview]
Message-ID: <20070614023749.GD30943@wotan.suse.de> (raw)
In-Reply-To: <20070614023444.GA30943@wotan.suse.de>
Don't move journal_stop from under page lock.
Fixes: ext4-convert-to-new-aops.patch
Signed-off-by: Nick Piggin <npiggin@suse.de>
Index: linux-2.6/fs/ext4/inode.c
===================================================================
--- linux-2.6.orig/fs/ext4/inode.c
+++ linux-2.6/fs/ext4/inode.c
@@ -36,6 +36,7 @@
#include <linux/mpage.h>
#include <linux/uio.h>
#include <linux/bio.h>
+#include <linux/swap.h> /* mark_page_accessed */
#include "xattr.h"
#include "acl.h"
@@ -1215,6 +1216,31 @@ static int write_end_fn(handle_t *handle
}
/*
+ * Generic write_end handler for ordered and writeback ext4 journal modes.
+ * We can't use generic_write_end, because that unlocks the page and we need to
+ * unlock the page after ext4_journal_stop, but ext4_journal_stop must run
+ * after block_write_end.
+ */
+static int ext4_generic_write_end(struct file *file,
+ struct address_space *mapping,
+ loff_t pos, unsigned len, unsigned copied,
+ struct page *page, void *fsdata)
+{
+ struct inode *inode = file->f_mapping->host;
+
+ copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
+
+ mark_page_accessed(page);
+
+ if (pos+copied > inode->i_size) {
+ i_size_write(inode, pos+copied);
+ mark_inode_dirty(inode);
+ }
+
+ return copied;
+}
+
+/*
* We need to pick up the new inode size which generic_commit_write gave us
* `file' can be NULL - eg, when called from page_symlink().
*
@@ -1248,17 +1274,17 @@ static int ext4_ordered_write_end(struct
new_i_size = pos + copied;
if (new_i_size > EXT4_I(inode)->i_disksize)
EXT4_I(inode)->i_disksize = new_i_size;
- copied = generic_write_end(file, mapping, pos, len, copied,
+ copied = ext4_generic_write_end(file, mapping, pos, len, copied,
page, fsdata);
if (copied < 0)
ret = copied;
- } else {
- unlock_page(page);
- page_cache_release(page);
}
ret2 = ext4_journal_stop(handle);
if (!ret)
ret = ret2;
+ unlock_page(page);
+ page_cache_release(page);
+
return ret ? ret : copied;
}
@@ -1276,7 +1302,7 @@ static int ext4_writeback_write_end(stru
if (new_i_size > EXT4_I(inode)->i_disksize)
EXT4_I(inode)->i_disksize = new_i_size;
- copied = generic_write_end(file, mapping, pos, len, copied,
+ copied = ext4_generic_write_end(file, mapping, pos, len, copied,
page, fsdata);
if (copied < 0)
ret = copied;
@@ -1284,6 +1310,9 @@ static int ext4_writeback_write_end(stru
ret2 = ext4_journal_stop(handle);
if (!ret)
ret = ret2;
+ unlock_page(page);
+ page_cache_release(page);
+
return ret ? ret : copied;
}
@@ -1311,8 +1340,6 @@ static int ext4_journalled_write_end(str
to, &partial, write_end_fn);
if (!partial)
SetPageUptodate(page);
- unlock_page(page);
- page_cache_release(page);
if (pos+copied > inode->i_size)
i_size_write(inode, pos+copied);
EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
@@ -1326,6 +1353,9 @@ static int ext4_journalled_write_end(str
ret2 = ext4_journal_stop(handle);
if (!ret)
ret = ret2;
+ unlock_page(page);
+ page_cache_release(page);
+
return ret ? ret : copied;
}
next prev parent reply other threads:[~2007-06-14 2:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-14 2:34 [patch 1/8] 2.6.22-rc4-mm2 buffered write fixes Nick Piggin
2007-06-14 2:35 ` [patch 2/8] " Nick Piggin
2007-06-14 2:36 ` [patch 3/8] " Nick Piggin
2007-06-14 2:37 ` Nick Piggin [this message]
2007-06-14 2:39 ` [patch 4/8] minix: convert to new aops fix Nick Piggin
2007-06-14 2:40 ` [patch 6/8] sysv: " Nick Piggin
2007-06-14 2:41 ` [patch 7/8] ufs: " Nick Piggin
2007-06-14 2:42 ` [patch 8/8] reiser4: fix for new aops patches Nick Piggin
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=20070614023749.GD30943@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=cmm@us.ibm.com \
--cc=dmonakhov@sw.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mark.fasheh@oracle.com \
--cc=pbadari@gmail.com \
/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).