diff options
Diffstat (limited to 'fs/buffer.c')
-rw-r--r-- | fs/buffer.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index 0f51c0f7c266..5fa1512cd9a2 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -1691,11 +1691,13 @@ static int __block_write_full_page(struct inode *inode, struct page *page, | |||
1691 | */ | 1691 | */ |
1692 | clear_buffer_dirty(bh); | 1692 | clear_buffer_dirty(bh); |
1693 | set_buffer_uptodate(bh); | 1693 | set_buffer_uptodate(bh); |
1694 | } else if (!buffer_mapped(bh) && buffer_dirty(bh)) { | 1694 | } else if ((!buffer_mapped(bh) || buffer_delay(bh)) && |
1695 | buffer_dirty(bh)) { | ||
1695 | WARN_ON(bh->b_size != blocksize); | 1696 | WARN_ON(bh->b_size != blocksize); |
1696 | err = get_block(inode, block, bh, 1); | 1697 | err = get_block(inode, block, bh, 1); |
1697 | if (err) | 1698 | if (err) |
1698 | goto recover; | 1699 | goto recover; |
1700 | clear_buffer_delay(bh); | ||
1699 | if (buffer_new(bh)) { | 1701 | if (buffer_new(bh)) { |
1700 | /* blockdev mappings never come here */ | 1702 | /* blockdev mappings never come here */ |
1701 | clear_buffer_new(bh); | 1703 | clear_buffer_new(bh); |
@@ -1774,7 +1776,8 @@ recover: | |||
1774 | bh = head; | 1776 | bh = head; |
1775 | /* Recovery: lock and submit the mapped buffers */ | 1777 | /* Recovery: lock and submit the mapped buffers */ |
1776 | do { | 1778 | do { |
1777 | if (buffer_mapped(bh) && buffer_dirty(bh)) { | 1779 | if (buffer_mapped(bh) && buffer_dirty(bh) && |
1780 | !buffer_delay(bh)) { | ||
1778 | lock_buffer(bh); | 1781 | lock_buffer(bh); |
1779 | mark_buffer_async_write(bh); | 1782 | mark_buffer_async_write(bh); |
1780 | } else { | 1783 | } else { |
@@ -2061,6 +2064,7 @@ int generic_write_end(struct file *file, struct address_space *mapping, | |||
2061 | struct page *page, void *fsdata) | 2064 | struct page *page, void *fsdata) |
2062 | { | 2065 | { |
2063 | struct inode *inode = mapping->host; | 2066 | struct inode *inode = mapping->host; |
2067 | int i_size_changed = 0; | ||
2064 | 2068 | ||
2065 | copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); | 2069 | copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); |
2066 | 2070 | ||
@@ -2073,12 +2077,21 @@ int generic_write_end(struct file *file, struct address_space *mapping, | |||
2073 | */ | 2077 | */ |
2074 | if (pos+copied > inode->i_size) { | 2078 | if (pos+copied > inode->i_size) { |
2075 | i_size_write(inode, pos+copied); | 2079 | i_size_write(inode, pos+copied); |
2076 | mark_inode_dirty(inode); | 2080 | i_size_changed = 1; |
2077 | } | 2081 | } |
2078 | 2082 | ||
2079 | unlock_page(page); | 2083 | unlock_page(page); |
2080 | page_cache_release(page); | 2084 | page_cache_release(page); |
2081 | 2085 | ||
2086 | /* | ||
2087 | * Don't mark the inode dirty under page lock. First, it unnecessarily | ||
2088 | * makes the holding time of page lock longer. Second, it forces lock | ||
2089 | * ordering of page lock and transaction start for journaling | ||
2090 | * filesystems. | ||
2091 | */ | ||
2092 | if (i_size_changed) | ||
2093 | mark_inode_dirty(inode); | ||
2094 | |||
2082 | return copied; | 2095 | return copied; |
2083 | } | 2096 | } |
2084 | EXPORT_SYMBOL(generic_write_end); | 2097 | EXPORT_SYMBOL(generic_write_end); |