diff options
| -rw-r--r-- | fs/ext4/inode.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ff2afc1909b3..b87b68cd3241 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -2578,7 +2578,7 @@ static int ext4_da_writepage(struct page *page, | |||
| 2578 | * all are mapped and non delay. We don't want to | 2578 | * all are mapped and non delay. We don't want to |
| 2579 | * do block allocation here. | 2579 | * do block allocation here. |
| 2580 | */ | 2580 | */ |
| 2581 | ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, | 2581 | ret = block_prepare_write(page, 0, len, |
| 2582 | noalloc_get_block_write); | 2582 | noalloc_get_block_write); |
| 2583 | if (!ret) { | 2583 | if (!ret) { |
| 2584 | page_bufs = page_buffers(page); | 2584 | page_bufs = page_buffers(page); |
| @@ -2600,7 +2600,7 @@ static int ext4_da_writepage(struct page *page, | |||
| 2600 | return 0; | 2600 | return 0; |
| 2601 | } | 2601 | } |
| 2602 | /* now mark the buffer_heads as dirty and uptodate */ | 2602 | /* now mark the buffer_heads as dirty and uptodate */ |
| 2603 | block_commit_write(page, 0, PAGE_CACHE_SIZE); | 2603 | block_commit_write(page, 0, len); |
| 2604 | } | 2604 | } |
| 2605 | 2605 | ||
| 2606 | if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) | 2606 | if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) |
| @@ -3246,6 +3246,8 @@ static int ext4_normal_writepage(struct page *page, | |||
| 3246 | static int __ext4_journalled_writepage(struct page *page, | 3246 | static int __ext4_journalled_writepage(struct page *page, |
| 3247 | struct writeback_control *wbc) | 3247 | struct writeback_control *wbc) |
| 3248 | { | 3248 | { |
| 3249 | loff_t size; | ||
| 3250 | unsigned int len; | ||
| 3249 | struct address_space *mapping = page->mapping; | 3251 | struct address_space *mapping = page->mapping; |
| 3250 | struct inode *inode = mapping->host; | 3252 | struct inode *inode = mapping->host; |
| 3251 | struct buffer_head *page_bufs; | 3253 | struct buffer_head *page_bufs; |
| @@ -3253,14 +3255,17 @@ static int __ext4_journalled_writepage(struct page *page, | |||
| 3253 | int ret = 0; | 3255 | int ret = 0; |
| 3254 | int err; | 3256 | int err; |
| 3255 | 3257 | ||
| 3256 | ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, | 3258 | size = i_size_read(inode); |
| 3257 | noalloc_get_block_write); | 3259 | if (page->index == size >> PAGE_CACHE_SHIFT) |
| 3260 | len = size & ~PAGE_CACHE_MASK; | ||
| 3261 | else | ||
| 3262 | len = PAGE_CACHE_SIZE; | ||
| 3263 | ret = block_prepare_write(page, 0, len, noalloc_get_block_write); | ||
| 3258 | if (ret != 0) | 3264 | if (ret != 0) |
| 3259 | goto out_unlock; | 3265 | goto out_unlock; |
| 3260 | 3266 | ||
| 3261 | page_bufs = page_buffers(page); | 3267 | page_bufs = page_buffers(page); |
| 3262 | walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, NULL, | 3268 | walk_page_buffers(handle, page_bufs, 0, len, NULL, bget_one); |
| 3263 | bget_one); | ||
| 3264 | /* As soon as we unlock the page, it can go away, but we have | 3269 | /* As soon as we unlock the page, it can go away, but we have |
| 3265 | * references to buffers so we are safe */ | 3270 | * references to buffers so we are safe */ |
| 3266 | unlock_page(page); | 3271 | unlock_page(page); |
| @@ -3271,19 +3276,18 @@ static int __ext4_journalled_writepage(struct page *page, | |||
| 3271 | goto out; | 3276 | goto out; |
| 3272 | } | 3277 | } |
| 3273 | 3278 | ||
| 3274 | ret = walk_page_buffers(handle, page_bufs, 0, | 3279 | ret = walk_page_buffers(handle, page_bufs, 0, len, NULL, |
| 3275 | PAGE_CACHE_SIZE, NULL, do_journal_get_write_access); | 3280 | do_journal_get_write_access); |
| 3276 | 3281 | ||
| 3277 | err = walk_page_buffers(handle, page_bufs, 0, | 3282 | err = walk_page_buffers(handle, page_bufs, 0, len, NULL, |
| 3278 | PAGE_CACHE_SIZE, NULL, write_end_fn); | 3283 | write_end_fn); |
| 3279 | if (ret == 0) | 3284 | if (ret == 0) |
| 3280 | ret = err; | 3285 | ret = err; |
| 3281 | err = ext4_journal_stop(handle); | 3286 | err = ext4_journal_stop(handle); |
| 3282 | if (!ret) | 3287 | if (!ret) |
| 3283 | ret = err; | 3288 | ret = err; |
| 3284 | 3289 | ||
| 3285 | walk_page_buffers(handle, page_bufs, 0, | 3290 | walk_page_buffers(handle, page_bufs, 0, len, NULL, bput_one); |
| 3286 | PAGE_CACHE_SIZE, NULL, bput_one); | ||
| 3287 | EXT4_I(inode)->i_state |= EXT4_STATE_JDATA; | 3291 | EXT4_I(inode)->i_state |= EXT4_STATE_JDATA; |
| 3288 | goto out; | 3292 | goto out; |
| 3289 | 3293 | ||
