diff options
author | Joel Becker <joel.becker@oracle.com> | 2009-02-12 21:08:48 -0500 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2009-09-04 19:07:53 -0400 |
commit | facdb77f54f09a33baf6b649496f5dd1d7922a7e (patch) | |
tree | 676de8877773ae38b8379bc3d50073c0710e2d8c /fs/ocfs2/alloc.c | |
parent | 3d03a305ded8057155bd3c801e64ffef9f534827 (diff) |
ocfs2: ocfs2_find_path() only needs the caching info
ocfs2_find_path and ocfs2_find_leaf() walk our btrees, reading extent
blocks. They need struct ocfs2_caching_info for that, but not struct
inode.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 1ff13d3958dd..ecd97309493f 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -475,8 +475,8 @@ struct ocfs2_path { | |||
475 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) | 475 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) |
476 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) | 476 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) |
477 | 477 | ||
478 | static int ocfs2_find_path(struct inode *inode, struct ocfs2_path *path, | 478 | static int ocfs2_find_path(struct ocfs2_caching_info *ci, |
479 | u32 cpos); | 479 | struct ocfs2_path *path, u32 cpos); |
480 | static void ocfs2_adjust_rightmost_records(struct inode *inode, | 480 | static void ocfs2_adjust_rightmost_records(struct inode *inode, |
481 | handle_t *handle, | 481 | handle_t *handle, |
482 | struct ocfs2_path *path, | 482 | struct ocfs2_path *path, |
@@ -1039,7 +1039,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle, | |||
1039 | return status; | 1039 | return status; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | status = ocfs2_find_path(inode, path, UINT_MAX); | 1042 | status = ocfs2_find_path(et->et_ci, path, UINT_MAX); |
1043 | if (status < 0) { | 1043 | if (status < 0) { |
1044 | mlog_errno(status); | 1044 | mlog_errno(status); |
1045 | goto out; | 1045 | goto out; |
@@ -1728,7 +1728,7 @@ typedef void (path_insert_t)(void *, struct buffer_head *); | |||
1728 | * This code can be called with a cpos larger than the tree, in which | 1728 | * This code can be called with a cpos larger than the tree, in which |
1729 | * case it will return the rightmost path. | 1729 | * case it will return the rightmost path. |
1730 | */ | 1730 | */ |
1731 | static int __ocfs2_find_path(struct inode *inode, | 1731 | static int __ocfs2_find_path(struct ocfs2_caching_info *ci, |
1732 | struct ocfs2_extent_list *root_el, u32 cpos, | 1732 | struct ocfs2_extent_list *root_el, u32 cpos, |
1733 | path_insert_t *func, void *data) | 1733 | path_insert_t *func, void *data) |
1734 | { | 1734 | { |
@@ -1739,15 +1739,14 @@ static int __ocfs2_find_path(struct inode *inode, | |||
1739 | struct ocfs2_extent_block *eb; | 1739 | struct ocfs2_extent_block *eb; |
1740 | struct ocfs2_extent_list *el; | 1740 | struct ocfs2_extent_list *el; |
1741 | struct ocfs2_extent_rec *rec; | 1741 | struct ocfs2_extent_rec *rec; |
1742 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
1743 | 1742 | ||
1744 | el = root_el; | 1743 | el = root_el; |
1745 | while (el->l_tree_depth) { | 1744 | while (el->l_tree_depth) { |
1746 | if (le16_to_cpu(el->l_next_free_rec) == 0) { | 1745 | if (le16_to_cpu(el->l_next_free_rec) == 0) { |
1747 | ocfs2_error(inode->i_sb, | 1746 | ocfs2_error(ocfs2_metadata_cache_get_super(ci), |
1748 | "Inode %llu has empty extent list at " | 1747 | "Owner %llu has empty extent list at " |
1749 | "depth %u\n", | 1748 | "depth %u\n", |
1750 | (unsigned long long)oi->ip_blkno, | 1749 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
1751 | le16_to_cpu(el->l_tree_depth)); | 1750 | le16_to_cpu(el->l_tree_depth)); |
1752 | ret = -EROFS; | 1751 | ret = -EROFS; |
1753 | goto out; | 1752 | goto out; |
@@ -1770,10 +1769,10 @@ static int __ocfs2_find_path(struct inode *inode, | |||
1770 | 1769 | ||
1771 | blkno = le64_to_cpu(el->l_recs[i].e_blkno); | 1770 | blkno = le64_to_cpu(el->l_recs[i].e_blkno); |
1772 | if (blkno == 0) { | 1771 | if (blkno == 0) { |
1773 | ocfs2_error(inode->i_sb, | 1772 | ocfs2_error(ocfs2_metadata_cache_get_super(ci), |
1774 | "Inode %llu has bad blkno in extent list " | 1773 | "Owner %llu has bad blkno in extent list " |
1775 | "at depth %u (index %d)\n", | 1774 | "at depth %u (index %d)\n", |
1776 | (unsigned long long)oi->ip_blkno, | 1775 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
1777 | le16_to_cpu(el->l_tree_depth), i); | 1776 | le16_to_cpu(el->l_tree_depth), i); |
1778 | ret = -EROFS; | 1777 | ret = -EROFS; |
1779 | goto out; | 1778 | goto out; |
@@ -1781,7 +1780,7 @@ static int __ocfs2_find_path(struct inode *inode, | |||
1781 | 1780 | ||
1782 | brelse(bh); | 1781 | brelse(bh); |
1783 | bh = NULL; | 1782 | bh = NULL; |
1784 | ret = ocfs2_read_extent_block(INODE_CACHE(inode), blkno, &bh); | 1783 | ret = ocfs2_read_extent_block(ci, blkno, &bh); |
1785 | if (ret) { | 1784 | if (ret) { |
1786 | mlog_errno(ret); | 1785 | mlog_errno(ret); |
1787 | goto out; | 1786 | goto out; |
@@ -1792,10 +1791,10 @@ static int __ocfs2_find_path(struct inode *inode, | |||
1792 | 1791 | ||
1793 | if (le16_to_cpu(el->l_next_free_rec) > | 1792 | if (le16_to_cpu(el->l_next_free_rec) > |
1794 | le16_to_cpu(el->l_count)) { | 1793 | le16_to_cpu(el->l_count)) { |
1795 | ocfs2_error(inode->i_sb, | 1794 | ocfs2_error(ocfs2_metadata_cache_get_super(ci), |
1796 | "Inode %llu has bad count in extent list " | 1795 | "Owner %llu has bad count in extent list " |
1797 | "at block %llu (next free=%u, count=%u)\n", | 1796 | "at block %llu (next free=%u, count=%u)\n", |
1798 | (unsigned long long)oi->ip_blkno, | 1797 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
1799 | (unsigned long long)bh->b_blocknr, | 1798 | (unsigned long long)bh->b_blocknr, |
1800 | le16_to_cpu(el->l_next_free_rec), | 1799 | le16_to_cpu(el->l_next_free_rec), |
1801 | le16_to_cpu(el->l_count)); | 1800 | le16_to_cpu(el->l_count)); |
@@ -1839,14 +1838,14 @@ static void find_path_ins(void *data, struct buffer_head *bh) | |||
1839 | ocfs2_path_insert_eb(fp->path, fp->index, bh); | 1838 | ocfs2_path_insert_eb(fp->path, fp->index, bh); |
1840 | fp->index++; | 1839 | fp->index++; |
1841 | } | 1840 | } |
1842 | static int ocfs2_find_path(struct inode *inode, struct ocfs2_path *path, | 1841 | static int ocfs2_find_path(struct ocfs2_caching_info *ci, |
1843 | u32 cpos) | 1842 | struct ocfs2_path *path, u32 cpos) |
1844 | { | 1843 | { |
1845 | struct find_path_data data; | 1844 | struct find_path_data data; |
1846 | 1845 | ||
1847 | data.index = 1; | 1846 | data.index = 1; |
1848 | data.path = path; | 1847 | data.path = path; |
1849 | return __ocfs2_find_path(inode, path_root_el(path), cpos, | 1848 | return __ocfs2_find_path(ci, path_root_el(path), cpos, |
1850 | find_path_ins, &data); | 1849 | find_path_ins, &data); |
1851 | } | 1850 | } |
1852 | 1851 | ||
@@ -1871,13 +1870,14 @@ static void find_leaf_ins(void *data, struct buffer_head *bh) | |||
1871 | * | 1870 | * |
1872 | * This function doesn't handle non btree extent lists. | 1871 | * This function doesn't handle non btree extent lists. |
1873 | */ | 1872 | */ |
1874 | int ocfs2_find_leaf(struct inode *inode, struct ocfs2_extent_list *root_el, | 1873 | int ocfs2_find_leaf(struct ocfs2_caching_info *ci, |
1875 | u32 cpos, struct buffer_head **leaf_bh) | 1874 | struct ocfs2_extent_list *root_el, u32 cpos, |
1875 | struct buffer_head **leaf_bh) | ||
1876 | { | 1876 | { |
1877 | int ret; | 1877 | int ret; |
1878 | struct buffer_head *bh = NULL; | 1878 | struct buffer_head *bh = NULL; |
1879 | 1879 | ||
1880 | ret = __ocfs2_find_path(inode, root_el, cpos, find_leaf_ins, &bh); | 1880 | ret = __ocfs2_find_path(ci, root_el, cpos, find_leaf_ins, &bh); |
1881 | if (ret) { | 1881 | if (ret) { |
1882 | mlog_errno(ret); | 1882 | mlog_errno(ret); |
1883 | goto out; | 1883 | goto out; |
@@ -2382,7 +2382,7 @@ static int ocfs2_rotate_tree_right(struct inode *inode, | |||
2382 | mlog(0, "Rotating a tree: ins. cpos: %u, left path cpos: %u\n", | 2382 | mlog(0, "Rotating a tree: ins. cpos: %u, left path cpos: %u\n", |
2383 | insert_cpos, cpos); | 2383 | insert_cpos, cpos); |
2384 | 2384 | ||
2385 | ret = ocfs2_find_path(inode, left_path, cpos); | 2385 | ret = ocfs2_find_path(INODE_CACHE(inode), left_path, cpos); |
2386 | if (ret) { | 2386 | if (ret) { |
2387 | mlog_errno(ret); | 2387 | mlog_errno(ret); |
2388 | goto out; | 2388 | goto out; |
@@ -2923,7 +2923,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
2923 | } | 2923 | } |
2924 | 2924 | ||
2925 | while (right_cpos) { | 2925 | while (right_cpos) { |
2926 | ret = ocfs2_find_path(inode, right_path, right_cpos); | 2926 | ret = ocfs2_find_path(et->et_ci, right_path, right_cpos); |
2927 | if (ret) { | 2927 | if (ret) { |
2928 | mlog_errno(ret); | 2928 | mlog_errno(ret); |
2929 | goto out; | 2929 | goto out; |
@@ -3052,7 +3052,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | |||
3052 | goto out; | 3052 | goto out; |
3053 | } | 3053 | } |
3054 | 3054 | ||
3055 | ret = ocfs2_find_path(inode, left_path, cpos); | 3055 | ret = ocfs2_find_path(et->et_ci, left_path, cpos); |
3056 | if (ret) { | 3056 | if (ret) { |
3057 | mlog_errno(ret); | 3057 | mlog_errno(ret); |
3058 | goto out; | 3058 | goto out; |
@@ -3297,7 +3297,7 @@ static int ocfs2_get_right_path(struct inode *inode, | |||
3297 | goto out; | 3297 | goto out; |
3298 | } | 3298 | } |
3299 | 3299 | ||
3300 | ret = ocfs2_find_path(inode, right_path, right_cpos); | 3300 | ret = ocfs2_find_path(INODE_CACHE(inode), right_path, right_cpos); |
3301 | if (ret) { | 3301 | if (ret) { |
3302 | mlog_errno(ret); | 3302 | mlog_errno(ret); |
3303 | goto out; | 3303 | goto out; |
@@ -3466,7 +3466,7 @@ static int ocfs2_get_left_path(struct inode *inode, | |||
3466 | goto out; | 3466 | goto out; |
3467 | } | 3467 | } |
3468 | 3468 | ||
3469 | ret = ocfs2_find_path(inode, left_path, left_cpos); | 3469 | ret = ocfs2_find_path(INODE_CACHE(inode), left_path, left_cpos); |
3470 | if (ret) { | 3470 | if (ret) { |
3471 | mlog_errno(ret); | 3471 | mlog_errno(ret); |
3472 | goto out; | 3472 | goto out; |
@@ -3996,7 +3996,8 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, | |||
3996 | goto out; | 3996 | goto out; |
3997 | } | 3997 | } |
3998 | 3998 | ||
3999 | ret = ocfs2_find_path(inode, left_path, left_cpos); | 3999 | ret = ocfs2_find_path(INODE_CACHE(inode), left_path, |
4000 | left_cpos); | ||
4000 | if (ret) { | 4001 | if (ret) { |
4001 | mlog_errno(ret); | 4002 | mlog_errno(ret); |
4002 | goto out; | 4003 | goto out; |
@@ -4245,7 +4246,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
4245 | cpos = UINT_MAX; | 4246 | cpos = UINT_MAX; |
4246 | } | 4247 | } |
4247 | 4248 | ||
4248 | ret = ocfs2_find_path(inode, right_path, cpos); | 4249 | ret = ocfs2_find_path(et->et_ci, right_path, cpos); |
4249 | if (ret) { | 4250 | if (ret) { |
4250 | mlog_errno(ret); | 4251 | mlog_errno(ret); |
4251 | goto out; | 4252 | goto out; |
@@ -4342,7 +4343,8 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, | |||
4342 | if (!left_path) | 4343 | if (!left_path) |
4343 | goto out; | 4344 | goto out; |
4344 | 4345 | ||
4345 | status = ocfs2_find_path(inode, left_path, left_cpos); | 4346 | status = ocfs2_find_path(INODE_CACHE(inode), |
4347 | left_path, left_cpos); | ||
4346 | if (status) | 4348 | if (status) |
4347 | goto out; | 4349 | goto out; |
4348 | 4350 | ||
@@ -4398,7 +4400,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, | |||
4398 | if (!right_path) | 4400 | if (!right_path) |
4399 | goto out; | 4401 | goto out; |
4400 | 4402 | ||
4401 | status = ocfs2_find_path(inode, right_path, right_cpos); | 4403 | status = ocfs2_find_path(INODE_CACHE(inode), right_path, right_cpos); |
4402 | if (status) | 4404 | if (status) |
4403 | goto out; | 4405 | goto out; |
4404 | 4406 | ||
@@ -4600,7 +4602,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
4600 | * us the rightmost tree path. This is accounted for below in | 4602 | * us the rightmost tree path. This is accounted for below in |
4601 | * the appending code. | 4603 | * the appending code. |
4602 | */ | 4604 | */ |
4603 | ret = ocfs2_find_path(inode, path, le32_to_cpu(insert_rec->e_cpos)); | 4605 | ret = ocfs2_find_path(et->et_ci, path, le32_to_cpu(insert_rec->e_cpos)); |
4604 | if (ret) { | 4606 | if (ret) { |
4605 | mlog_errno(ret); | 4607 | mlog_errno(ret); |
4606 | goto out; | 4608 | goto out; |
@@ -4950,7 +4952,7 @@ leftright: | |||
4950 | ocfs2_reinit_path(path, 1); | 4952 | ocfs2_reinit_path(path, 1); |
4951 | 4953 | ||
4952 | cpos = le32_to_cpu(split_rec.e_cpos); | 4954 | cpos = le32_to_cpu(split_rec.e_cpos); |
4953 | ret = ocfs2_find_path(inode, path, cpos); | 4955 | ret = ocfs2_find_path(et->et_ci, path, cpos); |
4954 | if (ret) { | 4956 | if (ret) { |
4955 | mlog_errno(ret); | 4957 | mlog_errno(ret); |
4956 | goto out; | 4958 | goto out; |
@@ -5148,7 +5150,7 @@ int ocfs2_mark_extent_written(struct inode *inode, | |||
5148 | goto out; | 5150 | goto out; |
5149 | } | 5151 | } |
5150 | 5152 | ||
5151 | ret = ocfs2_find_path(inode, left_path, cpos); | 5153 | ret = ocfs2_find_path(et->et_ci, left_path, cpos); |
5152 | if (ret) { | 5154 | if (ret) { |
5153 | mlog_errno(ret); | 5155 | mlog_errno(ret); |
5154 | goto out; | 5156 | goto out; |
@@ -5320,7 +5322,8 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | |||
5320 | goto out; | 5322 | goto out; |
5321 | } | 5323 | } |
5322 | 5324 | ||
5323 | ret = ocfs2_find_path(inode, left_path, left_cpos); | 5325 | ret = ocfs2_find_path(et->et_ci, left_path, |
5326 | left_cpos); | ||
5324 | if (ret) { | 5327 | if (ret) { |
5325 | mlog_errno(ret); | 5328 | mlog_errno(ret); |
5326 | goto out; | 5329 | goto out; |
@@ -5429,7 +5432,7 @@ int ocfs2_remove_extent(struct inode *inode, | |||
5429 | goto out; | 5432 | goto out; |
5430 | } | 5433 | } |
5431 | 5434 | ||
5432 | ret = ocfs2_find_path(inode, path, cpos); | 5435 | ret = ocfs2_find_path(et->et_ci, path, cpos); |
5433 | if (ret) { | 5436 | if (ret) { |
5434 | mlog_errno(ret); | 5437 | mlog_errno(ret); |
5435 | goto out; | 5438 | goto out; |
@@ -5494,7 +5497,7 @@ int ocfs2_remove_extent(struct inode *inode, | |||
5494 | */ | 5497 | */ |
5495 | ocfs2_reinit_path(path, 1); | 5498 | ocfs2_reinit_path(path, 1); |
5496 | 5499 | ||
5497 | ret = ocfs2_find_path(inode, path, cpos); | 5500 | ret = ocfs2_find_path(et->et_ci, path, cpos); |
5498 | if (ret) { | 5501 | if (ret) { |
5499 | mlog_errno(ret); | 5502 | mlog_errno(ret); |
5500 | goto out; | 5503 | goto out; |
@@ -6522,7 +6525,7 @@ static int ocfs2_find_new_last_ext_blk(struct inode *inode, | |||
6522 | goto out; | 6525 | goto out; |
6523 | } | 6526 | } |
6524 | 6527 | ||
6525 | ret = ocfs2_find_leaf(inode, path_root_el(path), cpos, &bh); | 6528 | ret = ocfs2_find_leaf(INODE_CACHE(inode), path_root_el(path), cpos, &bh); |
6526 | if (ret) { | 6529 | if (ret) { |
6527 | mlog_errno(ret); | 6530 | mlog_errno(ret); |
6528 | goto out; | 6531 | goto out; |
@@ -7299,7 +7302,7 @@ start: | |||
7299 | /* | 7302 | /* |
7300 | * Truncate always works against the rightmost tree branch. | 7303 | * Truncate always works against the rightmost tree branch. |
7301 | */ | 7304 | */ |
7302 | status = ocfs2_find_path(inode, path, UINT_MAX); | 7305 | status = ocfs2_find_path(INODE_CACHE(inode), path, UINT_MAX); |
7303 | if (status) { | 7306 | if (status) { |
7304 | mlog_errno(status); | 7307 | mlog_errno(status); |
7305 | goto bail; | 7308 | goto bail; |