diff options
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 233 |
1 files changed, 137 insertions, 96 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index c22ff49b5e33..6e58fd557e5b 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -298,11 +298,13 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = { | |||
298 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, | 298 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, |
299 | struct inode *inode, | 299 | struct inode *inode, |
300 | struct buffer_head *bh, | 300 | struct buffer_head *bh, |
301 | ocfs2_journal_access_func access, | ||
301 | void *obj, | 302 | void *obj, |
302 | struct ocfs2_extent_tree_operations *ops) | 303 | struct ocfs2_extent_tree_operations *ops) |
303 | { | 304 | { |
304 | et->et_ops = ops; | 305 | et->et_ops = ops; |
305 | et->et_root_bh = bh; | 306 | et->et_root_bh = bh; |
307 | et->et_root_journal_access = access; | ||
306 | if (!obj) | 308 | if (!obj) |
307 | obj = (void *)bh->b_data; | 309 | obj = (void *)bh->b_data; |
308 | et->et_object = obj; | 310 | et->et_object = obj; |
@@ -318,15 +320,16 @@ void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, | |||
318 | struct inode *inode, | 320 | struct inode *inode, |
319 | struct buffer_head *bh) | 321 | struct buffer_head *bh) |
320 | { | 322 | { |
321 | __ocfs2_init_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops); | 323 | __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access_di, |
324 | NULL, &ocfs2_dinode_et_ops); | ||
322 | } | 325 | } |
323 | 326 | ||
324 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, | 327 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, |
325 | struct inode *inode, | 328 | struct inode *inode, |
326 | struct buffer_head *bh) | 329 | struct buffer_head *bh) |
327 | { | 330 | { |
328 | __ocfs2_init_extent_tree(et, inode, bh, NULL, | 331 | __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access_xb, |
329 | &ocfs2_xattr_tree_et_ops); | 332 | NULL, &ocfs2_xattr_tree_et_ops); |
330 | } | 333 | } |
331 | 334 | ||
332 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | 335 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, |
@@ -334,7 +337,7 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | |||
334 | struct buffer_head *bh, | 337 | struct buffer_head *bh, |
335 | struct ocfs2_xattr_value_root *xv) | 338 | struct ocfs2_xattr_value_root *xv) |
336 | { | 339 | { |
337 | __ocfs2_init_extent_tree(et, inode, bh, xv, | 340 | __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access, xv, |
338 | &ocfs2_xattr_value_et_ops); | 341 | &ocfs2_xattr_value_et_ops); |
339 | } | 342 | } |
340 | 343 | ||
@@ -356,6 +359,15 @@ static inline void ocfs2_et_update_clusters(struct inode *inode, | |||
356 | et->et_ops->eo_update_clusters(inode, et, clusters); | 359 | et->et_ops->eo_update_clusters(inode, et, clusters); |
357 | } | 360 | } |
358 | 361 | ||
362 | static inline int ocfs2_et_root_journal_access(handle_t *handle, | ||
363 | struct inode *inode, | ||
364 | struct ocfs2_extent_tree *et, | ||
365 | int type) | ||
366 | { | ||
367 | return et->et_root_journal_access(handle, inode, et->et_root_bh, | ||
368 | type); | ||
369 | } | ||
370 | |||
359 | static inline int ocfs2_et_insert_check(struct inode *inode, | 371 | static inline int ocfs2_et_insert_check(struct inode *inode, |
360 | struct ocfs2_extent_tree *et, | 372 | struct ocfs2_extent_tree *et, |
361 | struct ocfs2_extent_rec *rec) | 373 | struct ocfs2_extent_rec *rec) |
@@ -396,12 +408,14 @@ struct ocfs2_path_item { | |||
396 | #define OCFS2_MAX_PATH_DEPTH 5 | 408 | #define OCFS2_MAX_PATH_DEPTH 5 |
397 | 409 | ||
398 | struct ocfs2_path { | 410 | struct ocfs2_path { |
399 | int p_tree_depth; | 411 | int p_tree_depth; |
400 | struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; | 412 | ocfs2_journal_access_func p_root_access; |
413 | struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; | ||
401 | }; | 414 | }; |
402 | 415 | ||
403 | #define path_root_bh(_path) ((_path)->p_node[0].bh) | 416 | #define path_root_bh(_path) ((_path)->p_node[0].bh) |
404 | #define path_root_el(_path) ((_path)->p_node[0].el) | 417 | #define path_root_el(_path) ((_path)->p_node[0].el) |
418 | #define path_root_access(_path)((_path)->p_root_access) | ||
405 | #define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) | 419 | #define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) |
406 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) | 420 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) |
407 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) | 421 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) |
@@ -434,6 +448,8 @@ static void ocfs2_reinit_path(struct ocfs2_path *path, int keep_root) | |||
434 | */ | 448 | */ |
435 | if (keep_root) | 449 | if (keep_root) |
436 | depth = le16_to_cpu(path_root_el(path)->l_tree_depth); | 450 | depth = le16_to_cpu(path_root_el(path)->l_tree_depth); |
451 | else | ||
452 | path_root_access(path) = NULL; | ||
437 | 453 | ||
438 | path->p_tree_depth = depth; | 454 | path->p_tree_depth = depth; |
439 | } | 455 | } |
@@ -459,6 +475,7 @@ static void ocfs2_cp_path(struct ocfs2_path *dest, struct ocfs2_path *src) | |||
459 | 475 | ||
460 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); | 476 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); |
461 | BUG_ON(path_root_el(dest) != path_root_el(src)); | 477 | BUG_ON(path_root_el(dest) != path_root_el(src)); |
478 | BUG_ON(path_root_access(dest) != path_root_access(src)); | ||
462 | 479 | ||
463 | ocfs2_reinit_path(dest, 1); | 480 | ocfs2_reinit_path(dest, 1); |
464 | 481 | ||
@@ -480,6 +497,7 @@ static void ocfs2_mv_path(struct ocfs2_path *dest, struct ocfs2_path *src) | |||
480 | int i; | 497 | int i; |
481 | 498 | ||
482 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); | 499 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); |
500 | BUG_ON(path_root_access(dest) != path_root_access(src)); | ||
483 | 501 | ||
484 | for(i = 1; i < OCFS2_MAX_PATH_DEPTH; i++) { | 502 | for(i = 1; i < OCFS2_MAX_PATH_DEPTH; i++) { |
485 | brelse(dest->p_node[i].bh); | 503 | brelse(dest->p_node[i].bh); |
@@ -515,7 +533,8 @@ static inline void ocfs2_path_insert_eb(struct ocfs2_path *path, int index, | |||
515 | } | 533 | } |
516 | 534 | ||
517 | static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, | 535 | static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, |
518 | struct ocfs2_extent_list *root_el) | 536 | struct ocfs2_extent_list *root_el, |
537 | ocfs2_journal_access_func access) | ||
519 | { | 538 | { |
520 | struct ocfs2_path *path; | 539 | struct ocfs2_path *path; |
521 | 540 | ||
@@ -527,6 +546,7 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, | |||
527 | get_bh(root_bh); | 546 | get_bh(root_bh); |
528 | path_root_bh(path) = root_bh; | 547 | path_root_bh(path) = root_bh; |
529 | path_root_el(path) = root_el; | 548 | path_root_el(path) = root_el; |
549 | path_root_access(path) = access; | ||
530 | } | 550 | } |
531 | 551 | ||
532 | return path; | 552 | return path; |
@@ -534,12 +554,38 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, | |||
534 | 554 | ||
535 | static struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path) | 555 | static struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path) |
536 | { | 556 | { |
537 | return ocfs2_new_path(path_root_bh(path), path_root_el(path)); | 557 | return ocfs2_new_path(path_root_bh(path), path_root_el(path), |
558 | path_root_access(path)); | ||
538 | } | 559 | } |
539 | 560 | ||
540 | static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et) | 561 | static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et) |
541 | { | 562 | { |
542 | return ocfs2_new_path(et->et_root_bh, et->et_root_el); | 563 | return ocfs2_new_path(et->et_root_bh, et->et_root_el, |
564 | et->et_root_journal_access); | ||
565 | } | ||
566 | |||
567 | /* | ||
568 | * Journal the buffer at depth idx. All idx>0 are extent_blocks, | ||
569 | * otherwise it's the root_access function. | ||
570 | * | ||
571 | * I don't like the way this function's name looks next to | ||
572 | * ocfs2_journal_access_path(), but I don't have a better one. | ||
573 | */ | ||
574 | static int ocfs2_path_bh_journal_access(handle_t *handle, | ||
575 | struct inode *inode, | ||
576 | struct ocfs2_path *path, | ||
577 | int idx) | ||
578 | { | ||
579 | ocfs2_journal_access_func access = path_root_access(path); | ||
580 | |||
581 | if (!access) | ||
582 | access = ocfs2_journal_access; | ||
583 | |||
584 | if (idx) | ||
585 | access = ocfs2_journal_access_eb; | ||
586 | |||
587 | return access(handle, inode, path->p_node[idx].bh, | ||
588 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
543 | } | 589 | } |
544 | 590 | ||
545 | /* | 591 | /* |
@@ -554,8 +600,7 @@ static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle, | |||
554 | goto out; | 600 | goto out; |
555 | 601 | ||
556 | for(i = 0; i < path_num_items(path); i++) { | 602 | for(i = 0; i < path_num_items(path); i++) { |
557 | ret = ocfs2_journal_access(handle, inode, path->p_node[i].bh, | 603 | ret = ocfs2_path_bh_journal_access(handle, inode, path, i); |
558 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
559 | if (ret < 0) { | 604 | if (ret < 0) { |
560 | mlog_errno(ret); | 605 | mlog_errno(ret); |
561 | goto out; | 606 | goto out; |
@@ -708,8 +753,11 @@ static int ocfs2_validate_extent_block(struct super_block *sb, | |||
708 | * local to this block. | 753 | * local to this block. |
709 | */ | 754 | */ |
710 | rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &eb->h_check); | 755 | rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &eb->h_check); |
711 | if (rc) | 756 | if (rc) { |
757 | mlog(ML_ERROR, "Checksum failed for extent block %llu\n", | ||
758 | (unsigned long long)bh->b_blocknr); | ||
712 | return rc; | 759 | return rc; |
760 | } | ||
713 | 761 | ||
714 | /* | 762 | /* |
715 | * Errors after here are fatal. | 763 | * Errors after here are fatal. |
@@ -842,8 +890,8 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, | |||
842 | } | 890 | } |
843 | ocfs2_set_new_buffer_uptodate(inode, bhs[i]); | 891 | ocfs2_set_new_buffer_uptodate(inode, bhs[i]); |
844 | 892 | ||
845 | status = ocfs2_journal_access(handle, inode, bhs[i], | 893 | status = ocfs2_journal_access_eb(handle, inode, bhs[i], |
846 | OCFS2_JOURNAL_ACCESS_CREATE); | 894 | OCFS2_JOURNAL_ACCESS_CREATE); |
847 | if (status < 0) { | 895 | if (status < 0) { |
848 | mlog_errno(status); | 896 | mlog_errno(status); |
849 | goto bail; | 897 | goto bail; |
@@ -986,8 +1034,8 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
986 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); | 1034 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); |
987 | eb_el = &eb->h_list; | 1035 | eb_el = &eb->h_list; |
988 | 1036 | ||
989 | status = ocfs2_journal_access(handle, inode, bh, | 1037 | status = ocfs2_journal_access_eb(handle, inode, bh, |
990 | OCFS2_JOURNAL_ACCESS_CREATE); | 1038 | OCFS2_JOURNAL_ACCESS_CREATE); |
991 | if (status < 0) { | 1039 | if (status < 0) { |
992 | mlog_errno(status); | 1040 | mlog_errno(status); |
993 | goto bail; | 1041 | goto bail; |
@@ -1026,21 +1074,21 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
1026 | * journal_dirty erroring as it won't unless we've aborted the | 1074 | * journal_dirty erroring as it won't unless we've aborted the |
1027 | * handle (in which case we would never be here) so reserving | 1075 | * handle (in which case we would never be here) so reserving |
1028 | * the write with journal_access is all we need to do. */ | 1076 | * the write with journal_access is all we need to do. */ |
1029 | status = ocfs2_journal_access(handle, inode, *last_eb_bh, | 1077 | status = ocfs2_journal_access_eb(handle, inode, *last_eb_bh, |
1030 | OCFS2_JOURNAL_ACCESS_WRITE); | 1078 | OCFS2_JOURNAL_ACCESS_WRITE); |
1031 | if (status < 0) { | 1079 | if (status < 0) { |
1032 | mlog_errno(status); | 1080 | mlog_errno(status); |
1033 | goto bail; | 1081 | goto bail; |
1034 | } | 1082 | } |
1035 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | 1083 | status = ocfs2_et_root_journal_access(handle, inode, et, |
1036 | OCFS2_JOURNAL_ACCESS_WRITE); | 1084 | OCFS2_JOURNAL_ACCESS_WRITE); |
1037 | if (status < 0) { | 1085 | if (status < 0) { |
1038 | mlog_errno(status); | 1086 | mlog_errno(status); |
1039 | goto bail; | 1087 | goto bail; |
1040 | } | 1088 | } |
1041 | if (eb_bh) { | 1089 | if (eb_bh) { |
1042 | status = ocfs2_journal_access(handle, inode, eb_bh, | 1090 | status = ocfs2_journal_access_eb(handle, inode, eb_bh, |
1043 | OCFS2_JOURNAL_ACCESS_WRITE); | 1091 | OCFS2_JOURNAL_ACCESS_WRITE); |
1044 | if (status < 0) { | 1092 | if (status < 0) { |
1045 | mlog_errno(status); | 1093 | mlog_errno(status); |
1046 | goto bail; | 1094 | goto bail; |
@@ -1129,8 +1177,8 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
1129 | eb_el = &eb->h_list; | 1177 | eb_el = &eb->h_list; |
1130 | root_el = et->et_root_el; | 1178 | root_el = et->et_root_el; |
1131 | 1179 | ||
1132 | status = ocfs2_journal_access(handle, inode, new_eb_bh, | 1180 | status = ocfs2_journal_access_eb(handle, inode, new_eb_bh, |
1133 | OCFS2_JOURNAL_ACCESS_CREATE); | 1181 | OCFS2_JOURNAL_ACCESS_CREATE); |
1134 | if (status < 0) { | 1182 | if (status < 0) { |
1135 | mlog_errno(status); | 1183 | mlog_errno(status); |
1136 | goto bail; | 1184 | goto bail; |
@@ -1148,8 +1196,8 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
1148 | goto bail; | 1196 | goto bail; |
1149 | } | 1197 | } |
1150 | 1198 | ||
1151 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | 1199 | status = ocfs2_et_root_journal_access(handle, inode, et, |
1152 | OCFS2_JOURNAL_ACCESS_WRITE); | 1200 | OCFS2_JOURNAL_ACCESS_WRITE); |
1153 | if (status < 0) { | 1201 | if (status < 0) { |
1154 | mlog_errno(status); | 1202 | mlog_errno(status); |
1155 | goto bail; | 1203 | goto bail; |
@@ -1918,25 +1966,23 @@ static int ocfs2_rotate_subtree_right(struct inode *inode, | |||
1918 | root_bh = left_path->p_node[subtree_index].bh; | 1966 | root_bh = left_path->p_node[subtree_index].bh; |
1919 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); | 1967 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); |
1920 | 1968 | ||
1921 | ret = ocfs2_journal_access(handle, inode, root_bh, | 1969 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
1922 | OCFS2_JOURNAL_ACCESS_WRITE); | 1970 | subtree_index); |
1923 | if (ret) { | 1971 | if (ret) { |
1924 | mlog_errno(ret); | 1972 | mlog_errno(ret); |
1925 | goto out; | 1973 | goto out; |
1926 | } | 1974 | } |
1927 | 1975 | ||
1928 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { | 1976 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { |
1929 | ret = ocfs2_journal_access(handle, inode, | 1977 | ret = ocfs2_path_bh_journal_access(handle, inode, |
1930 | right_path->p_node[i].bh, | 1978 | right_path, i); |
1931 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
1932 | if (ret) { | 1979 | if (ret) { |
1933 | mlog_errno(ret); | 1980 | mlog_errno(ret); |
1934 | goto out; | 1981 | goto out; |
1935 | } | 1982 | } |
1936 | 1983 | ||
1937 | ret = ocfs2_journal_access(handle, inode, | 1984 | ret = ocfs2_path_bh_journal_access(handle, inode, |
1938 | left_path->p_node[i].bh, | 1985 | left_path, i); |
1939 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
1940 | if (ret) { | 1986 | if (ret) { |
1941 | mlog_errno(ret); | 1987 | mlog_errno(ret); |
1942 | goto out; | 1988 | goto out; |
@@ -2455,9 +2501,9 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2455 | return -EAGAIN; | 2501 | return -EAGAIN; |
2456 | 2502 | ||
2457 | if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) { | 2503 | if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) { |
2458 | ret = ocfs2_journal_access(handle, inode, | 2504 | ret = ocfs2_journal_access_eb(handle, inode, |
2459 | path_leaf_bh(right_path), | 2505 | path_leaf_bh(right_path), |
2460 | OCFS2_JOURNAL_ACCESS_WRITE); | 2506 | OCFS2_JOURNAL_ACCESS_WRITE); |
2461 | if (ret) { | 2507 | if (ret) { |
2462 | mlog_errno(ret); | 2508 | mlog_errno(ret); |
2463 | goto out; | 2509 | goto out; |
@@ -2474,8 +2520,8 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2474 | * We have to update i_last_eb_blk during the meta | 2520 | * We have to update i_last_eb_blk during the meta |
2475 | * data delete. | 2521 | * data delete. |
2476 | */ | 2522 | */ |
2477 | ret = ocfs2_journal_access(handle, inode, et_root_bh, | 2523 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
2478 | OCFS2_JOURNAL_ACCESS_WRITE); | 2524 | OCFS2_JOURNAL_ACCESS_WRITE); |
2479 | if (ret) { | 2525 | if (ret) { |
2480 | mlog_errno(ret); | 2526 | mlog_errno(ret); |
2481 | goto out; | 2527 | goto out; |
@@ -2490,25 +2536,23 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
2490 | */ | 2536 | */ |
2491 | BUG_ON(right_has_empty && !del_right_subtree); | 2537 | BUG_ON(right_has_empty && !del_right_subtree); |
2492 | 2538 | ||
2493 | ret = ocfs2_journal_access(handle, inode, root_bh, | 2539 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
2494 | OCFS2_JOURNAL_ACCESS_WRITE); | 2540 | subtree_index); |
2495 | if (ret) { | 2541 | if (ret) { |
2496 | mlog_errno(ret); | 2542 | mlog_errno(ret); |
2497 | goto out; | 2543 | goto out; |
2498 | } | 2544 | } |
2499 | 2545 | ||
2500 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { | 2546 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { |
2501 | ret = ocfs2_journal_access(handle, inode, | 2547 | ret = ocfs2_path_bh_journal_access(handle, inode, |
2502 | right_path->p_node[i].bh, | 2548 | right_path, i); |
2503 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
2504 | if (ret) { | 2549 | if (ret) { |
2505 | mlog_errno(ret); | 2550 | mlog_errno(ret); |
2506 | goto out; | 2551 | goto out; |
2507 | } | 2552 | } |
2508 | 2553 | ||
2509 | ret = ocfs2_journal_access(handle, inode, | 2554 | ret = ocfs2_path_bh_journal_access(handle, inode, |
2510 | left_path->p_node[i].bh, | 2555 | left_path, i); |
2511 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
2512 | if (ret) { | 2556 | if (ret) { |
2513 | mlog_errno(ret); | 2557 | mlog_errno(ret); |
2514 | goto out; | 2558 | goto out; |
@@ -2653,16 +2697,17 @@ out: | |||
2653 | 2697 | ||
2654 | static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode, | 2698 | static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode, |
2655 | handle_t *handle, | 2699 | handle_t *handle, |
2656 | struct buffer_head *bh, | 2700 | struct ocfs2_path *path) |
2657 | struct ocfs2_extent_list *el) | ||
2658 | { | 2701 | { |
2659 | int ret; | 2702 | int ret; |
2703 | struct buffer_head *bh = path_leaf_bh(path); | ||
2704 | struct ocfs2_extent_list *el = path_leaf_el(path); | ||
2660 | 2705 | ||
2661 | if (!ocfs2_is_empty_extent(&el->l_recs[0])) | 2706 | if (!ocfs2_is_empty_extent(&el->l_recs[0])) |
2662 | return 0; | 2707 | return 0; |
2663 | 2708 | ||
2664 | ret = ocfs2_journal_access(handle, inode, bh, | 2709 | ret = ocfs2_path_bh_journal_access(handle, inode, path, |
2665 | OCFS2_JOURNAL_ACCESS_WRITE); | 2710 | path_num_items(path) - 1); |
2666 | if (ret) { | 2711 | if (ret) { |
2667 | mlog_errno(ret); | 2712 | mlog_errno(ret); |
2668 | goto out; | 2713 | goto out; |
@@ -2744,9 +2789,8 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
2744 | * Caller might still want to make changes to the | 2789 | * Caller might still want to make changes to the |
2745 | * tree root, so re-add it to the journal here. | 2790 | * tree root, so re-add it to the journal here. |
2746 | */ | 2791 | */ |
2747 | ret = ocfs2_journal_access(handle, inode, | 2792 | ret = ocfs2_path_bh_journal_access(handle, inode, |
2748 | path_root_bh(left_path), | 2793 | left_path, 0); |
2749 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
2750 | if (ret) { | 2794 | if (ret) { |
2751 | mlog_errno(ret); | 2795 | mlog_errno(ret); |
2752 | goto out; | 2796 | goto out; |
@@ -2929,8 +2973,7 @@ rightmost_no_delete: | |||
2929 | * it up front. | 2973 | * it up front. |
2930 | */ | 2974 | */ |
2931 | ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, | 2975 | ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, |
2932 | path_leaf_bh(path), | 2976 | path); |
2933 | path_leaf_el(path)); | ||
2934 | if (ret) | 2977 | if (ret) |
2935 | mlog_errno(ret); | 2978 | mlog_errno(ret); |
2936 | goto out; | 2979 | goto out; |
@@ -3164,8 +3207,8 @@ static int ocfs2_merge_rec_right(struct inode *inode, | |||
3164 | root_bh = left_path->p_node[subtree_index].bh; | 3207 | root_bh = left_path->p_node[subtree_index].bh; |
3165 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); | 3208 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); |
3166 | 3209 | ||
3167 | ret = ocfs2_journal_access(handle, inode, root_bh, | 3210 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
3168 | OCFS2_JOURNAL_ACCESS_WRITE); | 3211 | subtree_index); |
3169 | if (ret) { | 3212 | if (ret) { |
3170 | mlog_errno(ret); | 3213 | mlog_errno(ret); |
3171 | goto out; | 3214 | goto out; |
@@ -3173,17 +3216,15 @@ static int ocfs2_merge_rec_right(struct inode *inode, | |||
3173 | 3216 | ||
3174 | for (i = subtree_index + 1; | 3217 | for (i = subtree_index + 1; |
3175 | i < path_num_items(right_path); i++) { | 3218 | i < path_num_items(right_path); i++) { |
3176 | ret = ocfs2_journal_access(handle, inode, | 3219 | ret = ocfs2_path_bh_journal_access(handle, inode, |
3177 | right_path->p_node[i].bh, | 3220 | right_path, i); |
3178 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
3179 | if (ret) { | 3221 | if (ret) { |
3180 | mlog_errno(ret); | 3222 | mlog_errno(ret); |
3181 | goto out; | 3223 | goto out; |
3182 | } | 3224 | } |
3183 | 3225 | ||
3184 | ret = ocfs2_journal_access(handle, inode, | 3226 | ret = ocfs2_path_bh_journal_access(handle, inode, |
3185 | left_path->p_node[i].bh, | 3227 | left_path, i); |
3186 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
3187 | if (ret) { | 3228 | if (ret) { |
3188 | mlog_errno(ret); | 3229 | mlog_errno(ret); |
3189 | goto out; | 3230 | goto out; |
@@ -3195,8 +3236,8 @@ static int ocfs2_merge_rec_right(struct inode *inode, | |||
3195 | right_rec = &el->l_recs[index + 1]; | 3236 | right_rec = &el->l_recs[index + 1]; |
3196 | } | 3237 | } |
3197 | 3238 | ||
3198 | ret = ocfs2_journal_access(handle, inode, bh, | 3239 | ret = ocfs2_path_bh_journal_access(handle, inode, left_path, |
3199 | OCFS2_JOURNAL_ACCESS_WRITE); | 3240 | path_num_items(left_path) - 1); |
3200 | if (ret) { | 3241 | if (ret) { |
3201 | mlog_errno(ret); | 3242 | mlog_errno(ret); |
3202 | goto out; | 3243 | goto out; |
@@ -3335,8 +3376,8 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
3335 | root_bh = left_path->p_node[subtree_index].bh; | 3376 | root_bh = left_path->p_node[subtree_index].bh; |
3336 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); | 3377 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); |
3337 | 3378 | ||
3338 | ret = ocfs2_journal_access(handle, inode, root_bh, | 3379 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
3339 | OCFS2_JOURNAL_ACCESS_WRITE); | 3380 | subtree_index); |
3340 | if (ret) { | 3381 | if (ret) { |
3341 | mlog_errno(ret); | 3382 | mlog_errno(ret); |
3342 | goto out; | 3383 | goto out; |
@@ -3344,17 +3385,15 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
3344 | 3385 | ||
3345 | for (i = subtree_index + 1; | 3386 | for (i = subtree_index + 1; |
3346 | i < path_num_items(right_path); i++) { | 3387 | i < path_num_items(right_path); i++) { |
3347 | ret = ocfs2_journal_access(handle, inode, | 3388 | ret = ocfs2_path_bh_journal_access(handle, inode, |
3348 | right_path->p_node[i].bh, | 3389 | right_path, i); |
3349 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
3350 | if (ret) { | 3390 | if (ret) { |
3351 | mlog_errno(ret); | 3391 | mlog_errno(ret); |
3352 | goto out; | 3392 | goto out; |
3353 | } | 3393 | } |
3354 | 3394 | ||
3355 | ret = ocfs2_journal_access(handle, inode, | 3395 | ret = ocfs2_path_bh_journal_access(handle, inode, |
3356 | left_path->p_node[i].bh, | 3396 | left_path, i); |
3357 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
3358 | if (ret) { | 3397 | if (ret) { |
3359 | mlog_errno(ret); | 3398 | mlog_errno(ret); |
3360 | goto out; | 3399 | goto out; |
@@ -3366,8 +3405,8 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
3366 | has_empty_extent = 1; | 3405 | has_empty_extent = 1; |
3367 | } | 3406 | } |
3368 | 3407 | ||
3369 | ret = ocfs2_journal_access(handle, inode, bh, | 3408 | ret = ocfs2_path_bh_journal_access(handle, inode, left_path, |
3370 | OCFS2_JOURNAL_ACCESS_WRITE); | 3409 | path_num_items(left_path) - 1); |
3371 | if (ret) { | 3410 | if (ret) { |
3372 | mlog_errno(ret); | 3411 | mlog_errno(ret); |
3373 | goto out; | 3412 | goto out; |
@@ -4009,8 +4048,8 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
4009 | 4048 | ||
4010 | el = et->et_root_el; | 4049 | el = et->et_root_el; |
4011 | 4050 | ||
4012 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, | 4051 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
4013 | OCFS2_JOURNAL_ACCESS_WRITE); | 4052 | OCFS2_JOURNAL_ACCESS_WRITE); |
4014 | if (ret) { | 4053 | if (ret) { |
4015 | mlog_errno(ret); | 4054 | mlog_errno(ret); |
4016 | goto out; | 4055 | goto out; |
@@ -4071,8 +4110,8 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
4071 | * ocfs2_rotate_tree_right() might have extended the | 4110 | * ocfs2_rotate_tree_right() might have extended the |
4072 | * transaction without re-journaling our tree root. | 4111 | * transaction without re-journaling our tree root. |
4073 | */ | 4112 | */ |
4074 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, | 4113 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
4075 | OCFS2_JOURNAL_ACCESS_WRITE); | 4114 | OCFS2_JOURNAL_ACCESS_WRITE); |
4076 | if (ret) { | 4115 | if (ret) { |
4077 | mlog_errno(ret); | 4116 | mlog_errno(ret); |
4078 | goto out; | 4117 | goto out; |
@@ -4593,9 +4632,9 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |||
4593 | 4632 | ||
4594 | BUG_ON(num_bits > clusters_to_add); | 4633 | BUG_ON(num_bits > clusters_to_add); |
4595 | 4634 | ||
4596 | /* reserve our write early -- insert_extent may update the inode */ | 4635 | /* reserve our write early -- insert_extent may update the tree root */ |
4597 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | 4636 | status = ocfs2_et_root_journal_access(handle, inode, et, |
4598 | OCFS2_JOURNAL_ACCESS_WRITE); | 4637 | OCFS2_JOURNAL_ACCESS_WRITE); |
4599 | if (status < 0) { | 4638 | if (status < 0) { |
4600 | mlog_errno(status); | 4639 | mlog_errno(status); |
4601 | goto leave; | 4640 | goto leave; |
@@ -5347,8 +5386,8 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
5347 | goto out; | 5386 | goto out; |
5348 | } | 5387 | } |
5349 | 5388 | ||
5350 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, | 5389 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
5351 | OCFS2_JOURNAL_ACCESS_WRITE); | 5390 | OCFS2_JOURNAL_ACCESS_WRITE); |
5352 | if (ret) { | 5391 | if (ret) { |
5353 | mlog_errno(ret); | 5392 | mlog_errno(ret); |
5354 | goto out; | 5393 | goto out; |
@@ -5461,8 +5500,8 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
5461 | goto bail; | 5500 | goto bail; |
5462 | } | 5501 | } |
5463 | 5502 | ||
5464 | status = ocfs2_journal_access(handle, tl_inode, tl_bh, | 5503 | status = ocfs2_journal_access_di(handle, tl_inode, tl_bh, |
5465 | OCFS2_JOURNAL_ACCESS_WRITE); | 5504 | OCFS2_JOURNAL_ACCESS_WRITE); |
5466 | if (status < 0) { | 5505 | if (status < 0) { |
5467 | mlog_errno(status); | 5506 | mlog_errno(status); |
5468 | goto bail; | 5507 | goto bail; |
@@ -5523,8 +5562,8 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | |||
5523 | while (i >= 0) { | 5562 | while (i >= 0) { |
5524 | /* Caller has given us at least enough credits to | 5563 | /* Caller has given us at least enough credits to |
5525 | * update the truncate log dinode */ | 5564 | * update the truncate log dinode */ |
5526 | status = ocfs2_journal_access(handle, tl_inode, tl_bh, | 5565 | status = ocfs2_journal_access_di(handle, tl_inode, tl_bh, |
5527 | OCFS2_JOURNAL_ACCESS_WRITE); | 5566 | OCFS2_JOURNAL_ACCESS_WRITE); |
5528 | if (status < 0) { | 5567 | if (status < 0) { |
5529 | mlog_errno(status); | 5568 | mlog_errno(status); |
5530 | goto bail; | 5569 | goto bail; |
@@ -5780,6 +5819,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
5780 | * tl_used. */ | 5819 | * tl_used. */ |
5781 | tl->tl_used = 0; | 5820 | tl->tl_used = 0; |
5782 | 5821 | ||
5822 | ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check); | ||
5783 | status = ocfs2_write_block(osb, tl_bh, tl_inode); | 5823 | status = ocfs2_write_block(osb, tl_bh, tl_inode); |
5784 | if (status < 0) { | 5824 | if (status < 0) { |
5785 | mlog_errno(status); | 5825 | mlog_errno(status); |
@@ -6546,8 +6586,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb, | |||
6546 | } | 6586 | } |
6547 | 6587 | ||
6548 | if (last_eb_bh) { | 6588 | if (last_eb_bh) { |
6549 | status = ocfs2_journal_access(handle, inode, last_eb_bh, | 6589 | status = ocfs2_journal_access_eb(handle, inode, last_eb_bh, |
6550 | OCFS2_JOURNAL_ACCESS_WRITE); | 6590 | OCFS2_JOURNAL_ACCESS_WRITE); |
6551 | if (status < 0) { | 6591 | if (status < 0) { |
6552 | mlog_errno(status); | 6592 | mlog_errno(status); |
6553 | goto bail; | 6593 | goto bail; |
@@ -6908,8 +6948,8 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
6908 | goto out_unlock; | 6948 | goto out_unlock; |
6909 | } | 6949 | } |
6910 | 6950 | ||
6911 | ret = ocfs2_journal_access(handle, inode, di_bh, | 6951 | ret = ocfs2_journal_access_di(handle, inode, di_bh, |
6912 | OCFS2_JOURNAL_ACCESS_WRITE); | 6952 | OCFS2_JOURNAL_ACCESS_WRITE); |
6913 | if (ret) { | 6953 | if (ret) { |
6914 | mlog_errno(ret); | 6954 | mlog_errno(ret); |
6915 | goto out_commit; | 6955 | goto out_commit; |
@@ -7043,7 +7083,8 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
7043 | new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, | 7083 | new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, |
7044 | i_size_read(inode)); | 7084 | i_size_read(inode)); |
7045 | 7085 | ||
7046 | path = ocfs2_new_path(fe_bh, &di->id2.i_list); | 7086 | path = ocfs2_new_path(fe_bh, &di->id2.i_list, |
7087 | ocfs2_journal_access_di); | ||
7047 | if (!path) { | 7088 | if (!path) { |
7048 | status = -ENOMEM; | 7089 | status = -ENOMEM; |
7049 | mlog_errno(status); | 7090 | mlog_errno(status); |
@@ -7276,8 +7317,8 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, | |||
7276 | goto out; | 7317 | goto out; |
7277 | } | 7318 | } |
7278 | 7319 | ||
7279 | ret = ocfs2_journal_access(handle, inode, di_bh, | 7320 | ret = ocfs2_journal_access_di(handle, inode, di_bh, |
7280 | OCFS2_JOURNAL_ACCESS_WRITE); | 7321 | OCFS2_JOURNAL_ACCESS_WRITE); |
7281 | if (ret) { | 7322 | if (ret) { |
7282 | mlog_errno(ret); | 7323 | mlog_errno(ret); |
7283 | goto out_commit; | 7324 | goto out_commit; |