aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d47264cafee0..c4da98a959ae 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -120,6 +120,12 @@ void ext4_evict_inode(struct inode *inode)
120 int err; 120 int err;
121 121
122 trace_ext4_evict_inode(inode); 122 trace_ext4_evict_inode(inode);
123
124 mutex_lock(&inode->i_mutex);
125 ext4_flush_completed_IO(inode);
126 mutex_unlock(&inode->i_mutex);
127 ext4_ioend_wait(inode);
128
123 if (inode->i_nlink) { 129 if (inode->i_nlink) {
124 /* 130 /*
125 * When journalling data dirty buffers are tracked only in the 131 * When journalling data dirty buffers are tracked only in the
@@ -983,6 +989,8 @@ static int ext4_journalled_write_end(struct file *file,
983 from = pos & (PAGE_CACHE_SIZE - 1); 989 from = pos & (PAGE_CACHE_SIZE - 1);
984 to = from + len; 990 to = from + len;
985 991
992 BUG_ON(!ext4_handle_valid(handle));
993
986 if (copied < len) { 994 if (copied < len) {
987 if (!PageUptodate(page)) 995 if (!PageUptodate(page))
988 copied = 0; 996 copied = 0;
@@ -1283,7 +1291,12 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
1283 else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT)) 1291 else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT))
1284 err = ext4_bio_write_page(&io_submit, page, 1292 err = ext4_bio_write_page(&io_submit, page,
1285 len, mpd->wbc); 1293 len, mpd->wbc);
1286 else 1294 else if (buffer_uninit(page_bufs)) {
1295 ext4_set_bh_endio(page_bufs, inode);
1296 err = block_write_full_page_endio(page,
1297 noalloc_get_block_write,
1298 mpd->wbc, ext4_end_io_buffer_write);
1299 } else
1287 err = block_write_full_page(page, 1300 err = block_write_full_page(page,
1288 noalloc_get_block_write, mpd->wbc); 1301 noalloc_get_block_write, mpd->wbc);
1289 1302
@@ -1699,6 +1712,8 @@ static int __ext4_journalled_writepage(struct page *page,
1699 goto out; 1712 goto out;
1700 } 1713 }
1701 1714
1715 BUG_ON(!ext4_handle_valid(handle));
1716
1702 ret = walk_page_buffers(handle, page_bufs, 0, len, NULL, 1717 ret = walk_page_buffers(handle, page_bufs, 0, len, NULL,
1703 do_journal_get_write_access); 1718 do_journal_get_write_access);
1704 1719
@@ -2668,8 +2683,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate)
2668 goto out; 2683 goto out;
2669 } 2684 }
2670 2685
2671 io_end->flag = EXT4_IO_END_UNWRITTEN; 2686 /*
2687 * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now,
2688 * but being more careful is always safe for the future change.
2689 */
2672 inode = io_end->inode; 2690 inode = io_end->inode;
2691 if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
2692 io_end->flag |= EXT4_IO_END_UNWRITTEN;
2693 atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
2694 }
2673 2695
2674 /* Add the io_end to per-inode completed io list*/ 2696 /* Add the io_end to per-inode completed io list*/
2675 spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); 2697 spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags);