diff options
-rw-r--r-- | fs/ocfs2/alloc.c | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 2c4967f7b667..e1479faeb01c 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -460,8 +460,8 @@ struct ocfs2_path { | |||
460 | 460 | ||
461 | static int ocfs2_find_path(struct ocfs2_caching_info *ci, | 461 | static int ocfs2_find_path(struct ocfs2_caching_info *ci, |
462 | struct ocfs2_path *path, u32 cpos); | 462 | struct ocfs2_path *path, u32 cpos); |
463 | static void ocfs2_adjust_rightmost_records(struct inode *inode, | 463 | static void ocfs2_adjust_rightmost_records(handle_t *handle, |
464 | handle_t *handle, | 464 | struct ocfs2_extent_tree *et, |
465 | struct ocfs2_path *path, | 465 | struct ocfs2_path *path, |
466 | struct ocfs2_extent_rec *insert_rec); | 466 | struct ocfs2_extent_rec *insert_rec); |
467 | /* | 467 | /* |
@@ -1009,7 +1009,6 @@ static inline u32 ocfs2_sum_rightmost_rec(struct ocfs2_extent_list *el) | |||
1009 | * extent block's rightmost record. | 1009 | * extent block's rightmost record. |
1010 | */ | 1010 | */ |
1011 | static int ocfs2_adjust_rightmost_branch(handle_t *handle, | 1011 | static int ocfs2_adjust_rightmost_branch(handle_t *handle, |
1012 | struct inode *inode, | ||
1013 | struct ocfs2_extent_tree *et) | 1012 | struct ocfs2_extent_tree *et) |
1014 | { | 1013 | { |
1015 | int status; | 1014 | int status; |
@@ -1036,7 +1035,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle, | |||
1036 | goto out; | 1035 | goto out; |
1037 | } | 1036 | } |
1038 | 1037 | ||
1039 | status = ocfs2_journal_access_path(INODE_CACHE(inode), handle, path); | 1038 | status = ocfs2_journal_access_path(et->et_ci, handle, path); |
1040 | if (status < 0) { | 1039 | if (status < 0) { |
1041 | mlog_errno(status); | 1040 | mlog_errno(status); |
1042 | goto out; | 1041 | goto out; |
@@ -1045,7 +1044,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle, | |||
1045 | el = path_leaf_el(path); | 1044 | el = path_leaf_el(path); |
1046 | rec = &el->l_recs[le32_to_cpu(el->l_next_free_rec) - 1]; | 1045 | rec = &el->l_recs[le32_to_cpu(el->l_next_free_rec) - 1]; |
1047 | 1046 | ||
1048 | ocfs2_adjust_rightmost_records(inode, handle, path, rec); | 1047 | ocfs2_adjust_rightmost_records(handle, et, path, rec); |
1049 | 1048 | ||
1050 | out: | 1049 | out: |
1051 | ocfs2_free_path(path); | 1050 | ocfs2_free_path(path); |
@@ -1054,7 +1053,7 @@ out: | |||
1054 | 1053 | ||
1055 | /* | 1054 | /* |
1056 | * Add an entire tree branch to our inode. eb_bh is the extent block | 1055 | * Add an entire tree branch to our inode. eb_bh is the extent block |
1057 | * to start at, if we don't want to start the branch at the dinode | 1056 | * to start at, if we don't want to start the branch at the root |
1058 | * structure. | 1057 | * structure. |
1059 | * | 1058 | * |
1060 | * last_eb_bh is required as we have to update it's next_leaf pointer | 1059 | * last_eb_bh is required as we have to update it's next_leaf pointer |
@@ -1063,9 +1062,7 @@ out: | |||
1063 | * the new branch will be 'empty' in the sense that every block will | 1062 | * the new branch will be 'empty' in the sense that every block will |
1064 | * contain a single record with cluster count == 0. | 1063 | * contain a single record with cluster count == 0. |
1065 | */ | 1064 | */ |
1066 | static int ocfs2_add_branch(struct ocfs2_super *osb, | 1065 | static int ocfs2_add_branch(handle_t *handle, |
1067 | handle_t *handle, | ||
1068 | struct inode *inode, | ||
1069 | struct ocfs2_extent_tree *et, | 1066 | struct ocfs2_extent_tree *et, |
1070 | struct buffer_head *eb_bh, | 1067 | struct buffer_head *eb_bh, |
1071 | struct buffer_head **last_eb_bh, | 1068 | struct buffer_head **last_eb_bh, |
@@ -1109,7 +1106,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
1109 | if (root_end > new_cpos) { | 1106 | if (root_end > new_cpos) { |
1110 | mlog(0, "adjust the cluster end from %u to %u\n", | 1107 | mlog(0, "adjust the cluster end from %u to %u\n", |
1111 | root_end, new_cpos); | 1108 | root_end, new_cpos); |
1112 | status = ocfs2_adjust_rightmost_branch(handle, inode, et); | 1109 | status = ocfs2_adjust_rightmost_branch(handle, et); |
1113 | if (status) { | 1110 | if (status) { |
1114 | mlog_errno(status); | 1111 | mlog_errno(status); |
1115 | goto bail; | 1112 | goto bail; |
@@ -1147,7 +1144,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
1147 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); | 1144 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); |
1148 | eb_el = &eb->h_list; | 1145 | eb_el = &eb->h_list; |
1149 | 1146 | ||
1150 | status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), bh, | 1147 | status = ocfs2_journal_access_eb(handle, et->et_ci, bh, |
1151 | OCFS2_JOURNAL_ACCESS_CREATE); | 1148 | OCFS2_JOURNAL_ACCESS_CREATE); |
1152 | if (status < 0) { | 1149 | if (status < 0) { |
1153 | mlog_errno(status); | 1150 | mlog_errno(status); |
@@ -1187,7 +1184,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
1187 | * journal_dirty erroring as it won't unless we've aborted the | 1184 | * journal_dirty erroring as it won't unless we've aborted the |
1188 | * handle (in which case we would never be here) so reserving | 1185 | * handle (in which case we would never be here) so reserving |
1189 | * the write with journal_access is all we need to do. */ | 1186 | * the write with journal_access is all we need to do. */ |
1190 | status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), *last_eb_bh, | 1187 | status = ocfs2_journal_access_eb(handle, et->et_ci, *last_eb_bh, |
1191 | OCFS2_JOURNAL_ACCESS_WRITE); | 1188 | OCFS2_JOURNAL_ACCESS_WRITE); |
1192 | if (status < 0) { | 1189 | if (status < 0) { |
1193 | mlog_errno(status); | 1190 | mlog_errno(status); |
@@ -1200,7 +1197,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
1200 | goto bail; | 1197 | goto bail; |
1201 | } | 1198 | } |
1202 | if (eb_bh) { | 1199 | if (eb_bh) { |
1203 | status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), eb_bh, | 1200 | status = ocfs2_journal_access_eb(handle, et->et_ci, eb_bh, |
1204 | OCFS2_JOURNAL_ACCESS_WRITE); | 1201 | OCFS2_JOURNAL_ACCESS_WRITE); |
1205 | if (status < 0) { | 1202 | if (status < 0) { |
1206 | mlog_errno(status); | 1203 | mlog_errno(status); |
@@ -1260,9 +1257,7 @@ bail: | |||
1260 | * returns back the new extent block so you can add a branch to it | 1257 | * returns back the new extent block so you can add a branch to it |
1261 | * after this call. | 1258 | * after this call. |
1262 | */ | 1259 | */ |
1263 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | 1260 | static int ocfs2_shift_tree_depth(handle_t *handle, |
1264 | handle_t *handle, | ||
1265 | struct inode *inode, | ||
1266 | struct ocfs2_extent_tree *et, | 1261 | struct ocfs2_extent_tree *et, |
1267 | struct ocfs2_alloc_context *meta_ac, | 1262 | struct ocfs2_alloc_context *meta_ac, |
1268 | struct buffer_head **ret_new_eb_bh) | 1263 | struct buffer_head **ret_new_eb_bh) |
@@ -1290,7 +1285,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
1290 | eb_el = &eb->h_list; | 1285 | eb_el = &eb->h_list; |
1291 | root_el = et->et_root_el; | 1286 | root_el = et->et_root_el; |
1292 | 1287 | ||
1293 | status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), new_eb_bh, | 1288 | status = ocfs2_journal_access_eb(handle, et->et_ci, new_eb_bh, |
1294 | OCFS2_JOURNAL_ACCESS_CREATE); | 1289 | OCFS2_JOURNAL_ACCESS_CREATE); |
1295 | if (status < 0) { | 1290 | if (status < 0) { |
1296 | mlog_errno(status); | 1291 | mlog_errno(status); |
@@ -1365,8 +1360,7 @@ bail: | |||
1365 | * | 1360 | * |
1366 | * return status < 0 indicates an error. | 1361 | * return status < 0 indicates an error. |
1367 | */ | 1362 | */ |
1368 | static int ocfs2_find_branch_target(struct ocfs2_super *osb, | 1363 | static int ocfs2_find_branch_target(struct ocfs2_extent_tree *et, |
1369 | struct ocfs2_extent_tree *et, | ||
1370 | struct buffer_head **target_bh) | 1364 | struct buffer_head **target_bh) |
1371 | { | 1365 | { |
1372 | int status = 0, i; | 1366 | int status = 0, i; |
@@ -1447,20 +1441,18 @@ bail: | |||
1447 | * | 1441 | * |
1448 | * *last_eb_bh will be updated by ocfs2_add_branch(). | 1442 | * *last_eb_bh will be updated by ocfs2_add_branch(). |
1449 | */ | 1443 | */ |
1450 | static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | 1444 | static int ocfs2_grow_tree(handle_t *handle, struct ocfs2_extent_tree *et, |
1451 | struct ocfs2_extent_tree *et, int *final_depth, | 1445 | int *final_depth, struct buffer_head **last_eb_bh, |
1452 | struct buffer_head **last_eb_bh, | ||
1453 | struct ocfs2_alloc_context *meta_ac) | 1446 | struct ocfs2_alloc_context *meta_ac) |
1454 | { | 1447 | { |
1455 | int ret, shift; | 1448 | int ret, shift; |
1456 | struct ocfs2_extent_list *el = et->et_root_el; | 1449 | struct ocfs2_extent_list *el = et->et_root_el; |
1457 | int depth = le16_to_cpu(el->l_tree_depth); | 1450 | int depth = le16_to_cpu(el->l_tree_depth); |
1458 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1459 | struct buffer_head *bh = NULL; | 1451 | struct buffer_head *bh = NULL; |
1460 | 1452 | ||
1461 | BUG_ON(meta_ac == NULL); | 1453 | BUG_ON(meta_ac == NULL); |
1462 | 1454 | ||
1463 | shift = ocfs2_find_branch_target(osb, et, &bh); | 1455 | shift = ocfs2_find_branch_target(et, &bh); |
1464 | if (shift < 0) { | 1456 | if (shift < 0) { |
1465 | ret = shift; | 1457 | ret = shift; |
1466 | mlog_errno(ret); | 1458 | mlog_errno(ret); |
@@ -1477,8 +1469,7 @@ static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | |||
1477 | /* ocfs2_shift_tree_depth will return us a buffer with | 1469 | /* ocfs2_shift_tree_depth will return us a buffer with |
1478 | * the new extent block (so we can pass that to | 1470 | * the new extent block (so we can pass that to |
1479 | * ocfs2_add_branch). */ | 1471 | * ocfs2_add_branch). */ |
1480 | ret = ocfs2_shift_tree_depth(osb, handle, inode, et, | 1472 | ret = ocfs2_shift_tree_depth(handle, et, meta_ac, &bh); |
1481 | meta_ac, &bh); | ||
1482 | if (ret < 0) { | 1473 | if (ret < 0) { |
1483 | mlog_errno(ret); | 1474 | mlog_errno(ret); |
1484 | goto out; | 1475 | goto out; |
@@ -1504,7 +1495,7 @@ static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | |||
1504 | /* call ocfs2_add_branch to add the final part of the tree with | 1495 | /* call ocfs2_add_branch to add the final part of the tree with |
1505 | * the new data. */ | 1496 | * the new data. */ |
1506 | mlog(0, "add branch. bh = %p\n", bh); | 1497 | mlog(0, "add branch. bh = %p\n", bh); |
1507 | ret = ocfs2_add_branch(osb, handle, inode, et, bh, last_eb_bh, | 1498 | ret = ocfs2_add_branch(handle, et, bh, last_eb_bh, |
1508 | meta_ac); | 1499 | meta_ac); |
1509 | if (ret < 0) { | 1500 | if (ret < 0) { |
1510 | mlog_errno(ret); | 1501 | mlog_errno(ret); |
@@ -3881,8 +3872,8 @@ rotate: | |||
3881 | ocfs2_rotate_leaf(el, insert_rec); | 3872 | ocfs2_rotate_leaf(el, insert_rec); |
3882 | } | 3873 | } |
3883 | 3874 | ||
3884 | static void ocfs2_adjust_rightmost_records(struct inode *inode, | 3875 | static void ocfs2_adjust_rightmost_records(handle_t *handle, |
3885 | handle_t *handle, | 3876 | struct ocfs2_extent_tree *et, |
3886 | struct ocfs2_path *path, | 3877 | struct ocfs2_path *path, |
3887 | struct ocfs2_extent_rec *insert_rec) | 3878 | struct ocfs2_extent_rec *insert_rec) |
3888 | { | 3879 | { |
@@ -3900,9 +3891,9 @@ static void ocfs2_adjust_rightmost_records(struct inode *inode, | |||
3900 | 3891 | ||
3901 | next_free = le16_to_cpu(el->l_next_free_rec); | 3892 | next_free = le16_to_cpu(el->l_next_free_rec); |
3902 | if (next_free == 0) { | 3893 | if (next_free == 0) { |
3903 | ocfs2_error(inode->i_sb, | 3894 | ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci), |
3904 | "Dinode %llu has a bad extent list", | 3895 | "Owner %llu has a bad extent list", |
3905 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 3896 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci)); |
3906 | ret = -EIO; | 3897 | ret = -EIO; |
3907 | return; | 3898 | return; |
3908 | } | 3899 | } |
@@ -3922,7 +3913,8 @@ static void ocfs2_adjust_rightmost_records(struct inode *inode, | |||
3922 | } | 3913 | } |
3923 | } | 3914 | } |
3924 | 3915 | ||
3925 | static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, | 3916 | static int ocfs2_append_rec_to_path(handle_t *handle, |
3917 | struct ocfs2_extent_tree *et, | ||
3926 | struct ocfs2_extent_rec *insert_rec, | 3918 | struct ocfs2_extent_rec *insert_rec, |
3927 | struct ocfs2_path *right_path, | 3919 | struct ocfs2_path *right_path, |
3928 | struct ocfs2_path **ret_left_path) | 3920 | struct ocfs2_path **ret_left_path) |
@@ -3950,8 +3942,8 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, | |||
3950 | (next_free == 1 && ocfs2_is_empty_extent(&el->l_recs[0]))) { | 3942 | (next_free == 1 && ocfs2_is_empty_extent(&el->l_recs[0]))) { |
3951 | u32 left_cpos; | 3943 | u32 left_cpos; |
3952 | 3944 | ||
3953 | ret = ocfs2_find_cpos_for_left_leaf(inode->i_sb, right_path, | 3945 | ret = ocfs2_find_cpos_for_left_leaf(ocfs2_metadata_cache_get_super(et->et_ci), |
3954 | &left_cpos); | 3946 | right_path, &left_cpos); |
3955 | if (ret) { | 3947 | if (ret) { |
3956 | mlog_errno(ret); | 3948 | mlog_errno(ret); |
3957 | goto out; | 3949 | goto out; |
@@ -3973,7 +3965,7 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, | |||
3973 | goto out; | 3965 | goto out; |
3974 | } | 3966 | } |
3975 | 3967 | ||
3976 | ret = ocfs2_find_path(INODE_CACHE(inode), left_path, | 3968 | ret = ocfs2_find_path(et->et_ci, left_path, |
3977 | left_cpos); | 3969 | left_cpos); |
3978 | if (ret) { | 3970 | if (ret) { |
3979 | mlog_errno(ret); | 3971 | mlog_errno(ret); |
@@ -3987,13 +3979,13 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, | |||
3987 | } | 3979 | } |
3988 | } | 3980 | } |
3989 | 3981 | ||
3990 | ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, right_path); | 3982 | ret = ocfs2_journal_access_path(et->et_ci, handle, right_path); |
3991 | if (ret) { | 3983 | if (ret) { |
3992 | mlog_errno(ret); | 3984 | mlog_errno(ret); |
3993 | goto out; | 3985 | goto out; |
3994 | } | 3986 | } |
3995 | 3987 | ||
3996 | ocfs2_adjust_rightmost_records(inode, handle, right_path, insert_rec); | 3988 | ocfs2_adjust_rightmost_records(handle, et, right_path, insert_rec); |
3997 | 3989 | ||
3998 | *ret_left_path = left_path; | 3990 | *ret_left_path = left_path; |
3999 | ret = 0; | 3991 | ret = 0; |
@@ -4263,7 +4255,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
4263 | } | 4255 | } |
4264 | } else if (type->ins_appending == APPEND_TAIL | 4256 | } else if (type->ins_appending == APPEND_TAIL |
4265 | && type->ins_contig != CONTIG_LEFT) { | 4257 | && type->ins_contig != CONTIG_LEFT) { |
4266 | ret = ocfs2_append_rec_to_path(inode, handle, insert_rec, | 4258 | ret = ocfs2_append_rec_to_path(handle, et, insert_rec, |
4267 | right_path, &left_path); | 4259 | right_path, &left_path); |
4268 | if (ret) { | 4260 | if (ret) { |
4269 | mlog_errno(ret); | 4261 | mlog_errno(ret); |
@@ -4689,7 +4681,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, | |||
4689 | free_records, insert.ins_tree_depth); | 4681 | free_records, insert.ins_tree_depth); |
4690 | 4682 | ||
4691 | if (insert.ins_contig == CONTIG_NONE && free_records == 0) { | 4683 | if (insert.ins_contig == CONTIG_NONE && free_records == 0) { |
4692 | status = ocfs2_grow_tree(inode, handle, et, | 4684 | status = ocfs2_grow_tree(handle, et, |
4693 | &insert.ins_tree_depth, &last_eb_bh, | 4685 | &insert.ins_tree_depth, &last_eb_bh, |
4694 | meta_ac); | 4686 | meta_ac); |
4695 | if (status) { | 4687 | if (status) { |
@@ -4876,7 +4868,7 @@ leftright: | |||
4876 | 4868 | ||
4877 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == | 4869 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == |
4878 | le16_to_cpu(rightmost_el->l_count)) { | 4870 | le16_to_cpu(rightmost_el->l_count)) { |
4879 | ret = ocfs2_grow_tree(inode, handle, et, | 4871 | ret = ocfs2_grow_tree(handle, et, |
4880 | &depth, last_eb_bh, meta_ac); | 4872 | &depth, last_eb_bh, meta_ac); |
4881 | if (ret) { | 4873 | if (ret) { |
4882 | mlog_errno(ret); | 4874 | mlog_errno(ret); |
@@ -5208,7 +5200,7 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et, | |||
5208 | 5200 | ||
5209 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == | 5201 | if (le16_to_cpu(rightmost_el->l_next_free_rec) == |
5210 | le16_to_cpu(rightmost_el->l_count)) { | 5202 | le16_to_cpu(rightmost_el->l_count)) { |
5211 | ret = ocfs2_grow_tree(inode, handle, et, &depth, &last_eb_bh, | 5203 | ret = ocfs2_grow_tree(handle, et, &depth, &last_eb_bh, |
5212 | meta_ac); | 5204 | meta_ac); |
5213 | if (ret) { | 5205 | if (ret) { |
5214 | mlog_errno(ret); | 5206 | mlog_errno(ret); |
@@ -5346,7 +5338,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | |||
5346 | * be deleted by the rotate code. | 5338 | * be deleted by the rotate code. |
5347 | */ | 5339 | */ |
5348 | rec = &el->l_recs[next_free - 1]; | 5340 | rec = &el->l_recs[next_free - 1]; |
5349 | ocfs2_adjust_rightmost_records(inode, handle, path, | 5341 | ocfs2_adjust_rightmost_records(handle, et, path, |
5350 | rec); | 5342 | rec); |
5351 | } | 5343 | } |
5352 | } else if (le32_to_cpu(rec->e_cpos) == cpos) { | 5344 | } else if (le32_to_cpu(rec->e_cpos) == cpos) { |
@@ -5358,7 +5350,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | |||
5358 | /* Remove rightmost portion of the record */ | 5350 | /* Remove rightmost portion of the record */ |
5359 | le16_add_cpu(&rec->e_leaf_clusters, -len); | 5351 | le16_add_cpu(&rec->e_leaf_clusters, -len); |
5360 | if (is_rightmost_tree_rec) | 5352 | if (is_rightmost_tree_rec) |
5361 | ocfs2_adjust_rightmost_records(inode, handle, path, rec); | 5353 | ocfs2_adjust_rightmost_records(handle, et, path, rec); |
5362 | } else { | 5354 | } else { |
5363 | /* Caller should have trapped this. */ | 5355 | /* Caller should have trapped this. */ |
5364 | mlog(ML_ERROR, "Inode %llu: Invalid record truncate: (%u, %u) " | 5356 | mlog(ML_ERROR, "Inode %llu: Invalid record truncate: (%u, %u) " |