diff options
author | Jan Kara <jack@suse.cz> | 2008-07-11 19:27:31 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-07-11 19:27:31 -0400 |
commit | c7d206b3379f7d6462e778b74f475c470ee3dcaf (patch) | |
tree | 71d11797c72e2e4ee04e6690c048fd26f25ae90d /fs/buffer.c | |
parent | 2e9ee850355593e311d9a26542290fe51e152f74 (diff) |
vfs: Move mark_inode_dirty() from under page lock in generic_write_end()
There's no need to call mark_inode_dirty() under page lock in
generic_write_end(). It unnecessarily makes hold time of page lock longer
and more importantly it forces locking order of page lock and transaction
start for journaling filesystems.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/buffer.c')
-rw-r--r-- | fs/buffer.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index 0f51c0f7c266..f4b033237a02 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -2061,6 +2061,7 @@ int generic_write_end(struct file *file, struct address_space *mapping, | |||
2061 | struct page *page, void *fsdata) | 2061 | struct page *page, void *fsdata) |
2062 | { | 2062 | { |
2063 | struct inode *inode = mapping->host; | 2063 | struct inode *inode = mapping->host; |
2064 | int i_size_changed = 0; | ||
2064 | 2065 | ||
2065 | copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); | 2066 | copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); |
2066 | 2067 | ||
@@ -2073,12 +2074,21 @@ int generic_write_end(struct file *file, struct address_space *mapping, | |||
2073 | */ | 2074 | */ |
2074 | if (pos+copied > inode->i_size) { | 2075 | if (pos+copied > inode->i_size) { |
2075 | i_size_write(inode, pos+copied); | 2076 | i_size_write(inode, pos+copied); |
2076 | mark_inode_dirty(inode); | 2077 | i_size_changed = 1; |
2077 | } | 2078 | } |
2078 | 2079 | ||
2079 | unlock_page(page); | 2080 | unlock_page(page); |
2080 | page_cache_release(page); | 2081 | page_cache_release(page); |
2081 | 2082 | ||
2083 | /* | ||
2084 | * Don't mark the inode dirty under page lock. First, it unnecessarily | ||
2085 | * makes the holding time of page lock longer. Second, it forces lock | ||
2086 | * ordering of page lock and transaction start for journaling | ||
2087 | * filesystems. | ||
2088 | */ | ||
2089 | if (i_size_changed) | ||
2090 | mark_inode_dirty(inode); | ||
2091 | |||
2082 | return copied; | 2092 | return copied; |
2083 | } | 2093 | } |
2084 | EXPORT_SYMBOL(generic_write_end); | 2094 | EXPORT_SYMBOL(generic_write_end); |