diff options
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r-- | fs/ocfs2/aops.c | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index a53da1466277..c22543b33420 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -68,9 +68,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, | |||
68 | goto bail; | 68 | goto bail; |
69 | } | 69 | } |
70 | 70 | ||
71 | status = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 71 | status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); |
72 | OCFS2_I(inode)->ip_blkno, | ||
73 | &bh, OCFS2_BH_CACHED, inode); | ||
74 | if (status < 0) { | 72 | if (status < 0) { |
75 | mlog_errno(status); | 73 | mlog_errno(status); |
76 | goto bail; | 74 | goto bail; |
@@ -128,8 +126,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, | |||
128 | err = 0; | 126 | err = 0; |
129 | 127 | ||
130 | bail: | 128 | bail: |
131 | if (bh) | 129 | brelse(bh); |
132 | brelse(bh); | ||
133 | 130 | ||
134 | mlog_exit(err); | 131 | mlog_exit(err); |
135 | return err; | 132 | return err; |
@@ -261,13 +258,11 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page) | |||
261 | { | 258 | { |
262 | int ret; | 259 | int ret; |
263 | struct buffer_head *di_bh = NULL; | 260 | struct buffer_head *di_bh = NULL; |
264 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
265 | 261 | ||
266 | BUG_ON(!PageLocked(page)); | 262 | BUG_ON(!PageLocked(page)); |
267 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); | 263 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); |
268 | 264 | ||
269 | ret = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &di_bh, | 265 | ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); |
270 | OCFS2_BH_CACHED, inode); | ||
271 | if (ret) { | 266 | if (ret) { |
272 | mlog_errno(ret); | 267 | mlog_errno(ret); |
273 | goto out; | 268 | goto out; |
@@ -485,11 +480,14 @@ handle_t *ocfs2_start_walk_page_trans(struct inode *inode, | |||
485 | } | 480 | } |
486 | 481 | ||
487 | if (ocfs2_should_order_data(inode)) { | 482 | if (ocfs2_should_order_data(inode)) { |
483 | ret = ocfs2_jbd2_file_inode(handle, inode); | ||
484 | #ifdef CONFIG_OCFS2_COMPAT_JBD | ||
488 | ret = walk_page_buffers(handle, | 485 | ret = walk_page_buffers(handle, |
489 | page_buffers(page), | 486 | page_buffers(page), |
490 | from, to, NULL, | 487 | from, to, NULL, |
491 | ocfs2_journal_dirty_data); | 488 | ocfs2_journal_dirty_data); |
492 | if (ret < 0) | 489 | #endif |
490 | if (ret < 0) | ||
493 | mlog_errno(ret); | 491 | mlog_errno(ret); |
494 | } | 492 | } |
495 | out: | 493 | out: |
@@ -669,7 +667,7 @@ static void ocfs2_invalidatepage(struct page *page, unsigned long offset) | |||
669 | { | 667 | { |
670 | journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal; | 668 | journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal; |
671 | 669 | ||
672 | journal_invalidatepage(journal, page, offset); | 670 | jbd2_journal_invalidatepage(journal, page, offset); |
673 | } | 671 | } |
674 | 672 | ||
675 | static int ocfs2_releasepage(struct page *page, gfp_t wait) | 673 | static int ocfs2_releasepage(struct page *page, gfp_t wait) |
@@ -678,7 +676,7 @@ static int ocfs2_releasepage(struct page *page, gfp_t wait) | |||
678 | 676 | ||
679 | if (!page_has_buffers(page)) | 677 | if (!page_has_buffers(page)) |
680 | return 0; | 678 | return 0; |
681 | return journal_try_to_free_buffers(journal, page, wait); | 679 | return jbd2_journal_try_to_free_buffers(journal, page, wait); |
682 | } | 680 | } |
683 | 681 | ||
684 | static ssize_t ocfs2_direct_IO(int rw, | 682 | static ssize_t ocfs2_direct_IO(int rw, |
@@ -1074,11 +1072,15 @@ static void ocfs2_write_failure(struct inode *inode, | |||
1074 | tmppage = wc->w_pages[i]; | 1072 | tmppage = wc->w_pages[i]; |
1075 | 1073 | ||
1076 | if (page_has_buffers(tmppage)) { | 1074 | if (page_has_buffers(tmppage)) { |
1077 | if (ocfs2_should_order_data(inode)) | 1075 | if (ocfs2_should_order_data(inode)) { |
1076 | ocfs2_jbd2_file_inode(wc->w_handle, inode); | ||
1077 | #ifdef CONFIG_OCFS2_COMPAT_JBD | ||
1078 | walk_page_buffers(wc->w_handle, | 1078 | walk_page_buffers(wc->w_handle, |
1079 | page_buffers(tmppage), | 1079 | page_buffers(tmppage), |
1080 | from, to, NULL, | 1080 | from, to, NULL, |
1081 | ocfs2_journal_dirty_data); | 1081 | ocfs2_journal_dirty_data); |
1082 | #endif | ||
1083 | } | ||
1082 | 1084 | ||
1083 | block_commit_write(tmppage, from, to); | 1085 | block_commit_write(tmppage, from, to); |
1084 | } | 1086 | } |
@@ -1242,6 +1244,7 @@ static int ocfs2_write_cluster(struct address_space *mapping, | |||
1242 | int ret, i, new, should_zero = 0; | 1244 | int ret, i, new, should_zero = 0; |
1243 | u64 v_blkno, p_blkno; | 1245 | u64 v_blkno, p_blkno; |
1244 | struct inode *inode = mapping->host; | 1246 | struct inode *inode = mapping->host; |
1247 | struct ocfs2_extent_tree et; | ||
1245 | 1248 | ||
1246 | new = phys == 0 ? 1 : 0; | 1249 | new = phys == 0 ? 1 : 0; |
1247 | if (new || unwritten) | 1250 | if (new || unwritten) |
@@ -1255,10 +1258,10 @@ static int ocfs2_write_cluster(struct address_space *mapping, | |||
1255 | * any additional semaphores or cluster locks. | 1258 | * any additional semaphores or cluster locks. |
1256 | */ | 1259 | */ |
1257 | tmp_pos = cpos; | 1260 | tmp_pos = cpos; |
1258 | ret = ocfs2_do_extend_allocation(OCFS2_SB(inode->i_sb), inode, | 1261 | ret = ocfs2_add_inode_data(OCFS2_SB(inode->i_sb), inode, |
1259 | &tmp_pos, 1, 0, wc->w_di_bh, | 1262 | &tmp_pos, 1, 0, wc->w_di_bh, |
1260 | wc->w_handle, data_ac, | 1263 | wc->w_handle, data_ac, |
1261 | meta_ac, NULL); | 1264 | meta_ac, NULL); |
1262 | /* | 1265 | /* |
1263 | * This shouldn't happen because we must have already | 1266 | * This shouldn't happen because we must have already |
1264 | * calculated the correct meta data allocation required. The | 1267 | * calculated the correct meta data allocation required. The |
@@ -1276,7 +1279,8 @@ static int ocfs2_write_cluster(struct address_space *mapping, | |||
1276 | goto out; | 1279 | goto out; |
1277 | } | 1280 | } |
1278 | } else if (unwritten) { | 1281 | } else if (unwritten) { |
1279 | ret = ocfs2_mark_extent_written(inode, wc->w_di_bh, | 1282 | ocfs2_init_dinode_extent_tree(&et, inode, wc->w_di_bh); |
1283 | ret = ocfs2_mark_extent_written(inode, &et, | ||
1280 | wc->w_handle, cpos, 1, phys, | 1284 | wc->w_handle, cpos, 1, phys, |
1281 | meta_ac, &wc->w_dealloc); | 1285 | meta_ac, &wc->w_dealloc); |
1282 | if (ret < 0) { | 1286 | if (ret < 0) { |
@@ -1665,6 +1669,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, | |||
1665 | struct ocfs2_alloc_context *data_ac = NULL; | 1669 | struct ocfs2_alloc_context *data_ac = NULL; |
1666 | struct ocfs2_alloc_context *meta_ac = NULL; | 1670 | struct ocfs2_alloc_context *meta_ac = NULL; |
1667 | handle_t *handle; | 1671 | handle_t *handle; |
1672 | struct ocfs2_extent_tree et; | ||
1668 | 1673 | ||
1669 | ret = ocfs2_alloc_write_ctxt(&wc, osb, pos, len, di_bh); | 1674 | ret = ocfs2_alloc_write_ctxt(&wc, osb, pos, len, di_bh); |
1670 | if (ret) { | 1675 | if (ret) { |
@@ -1712,14 +1717,23 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, | |||
1712 | * ocfs2_lock_allocators(). It greatly over-estimates | 1717 | * ocfs2_lock_allocators(). It greatly over-estimates |
1713 | * the work to be done. | 1718 | * the work to be done. |
1714 | */ | 1719 | */ |
1715 | ret = ocfs2_lock_allocators(inode, di, clusters_to_alloc, | 1720 | mlog(0, "extend inode %llu, i_size = %lld, di->i_clusters = %u," |
1716 | extents_to_split, &data_ac, &meta_ac); | 1721 | " clusters_to_add = %u, extents_to_split = %u\n", |
1722 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
1723 | (long long)i_size_read(inode), le32_to_cpu(di->i_clusters), | ||
1724 | clusters_to_alloc, extents_to_split); | ||
1725 | |||
1726 | ocfs2_init_dinode_extent_tree(&et, inode, wc->w_di_bh); | ||
1727 | ret = ocfs2_lock_allocators(inode, &et, | ||
1728 | clusters_to_alloc, extents_to_split, | ||
1729 | &data_ac, &meta_ac); | ||
1717 | if (ret) { | 1730 | if (ret) { |
1718 | mlog_errno(ret); | 1731 | mlog_errno(ret); |
1719 | goto out; | 1732 | goto out; |
1720 | } | 1733 | } |
1721 | 1734 | ||
1722 | credits = ocfs2_calc_extend_credits(inode->i_sb, di, | 1735 | credits = ocfs2_calc_extend_credits(inode->i_sb, |
1736 | &di->id2.i_list, | ||
1723 | clusters_to_alloc); | 1737 | clusters_to_alloc); |
1724 | 1738 | ||
1725 | } | 1739 | } |
@@ -1905,11 +1919,15 @@ int ocfs2_write_end_nolock(struct address_space *mapping, | |||
1905 | } | 1919 | } |
1906 | 1920 | ||
1907 | if (page_has_buffers(tmppage)) { | 1921 | if (page_has_buffers(tmppage)) { |
1908 | if (ocfs2_should_order_data(inode)) | 1922 | if (ocfs2_should_order_data(inode)) { |
1923 | ocfs2_jbd2_file_inode(wc->w_handle, inode); | ||
1924 | #ifdef CONFIG_OCFS2_COMPAT_JBD | ||
1909 | walk_page_buffers(wc->w_handle, | 1925 | walk_page_buffers(wc->w_handle, |
1910 | page_buffers(tmppage), | 1926 | page_buffers(tmppage), |
1911 | from, to, NULL, | 1927 | from, to, NULL, |
1912 | ocfs2_journal_dirty_data); | 1928 | ocfs2_journal_dirty_data); |
1929 | #endif | ||
1930 | } | ||
1913 | block_commit_write(tmppage, from, to); | 1931 | block_commit_write(tmppage, from, to); |
1914 | } | 1932 | } |
1915 | } | 1933 | } |