diff options
Diffstat (limited to 'fs/ocfs2/alloc.c')
| -rw-r--r-- | fs/ocfs2/alloc.c | 710 |
1 files changed, 486 insertions, 224 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 0cc2deb9394c..54ff4c77aaa3 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/highmem.h> | 29 | #include <linux/highmem.h> |
| 30 | #include <linux/swap.h> | 30 | #include <linux/swap.h> |
| 31 | #include <linux/quotaops.h> | ||
| 31 | 32 | ||
| 32 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | 33 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC |
| 33 | #include <cluster/masklog.h> | 34 | #include <cluster/masklog.h> |
| @@ -36,6 +37,7 @@ | |||
| 36 | 37 | ||
| 37 | #include "alloc.h" | 38 | #include "alloc.h" |
| 38 | #include "aops.h" | 39 | #include "aops.h" |
| 40 | #include "blockcheck.h" | ||
| 39 | #include "dlmglue.h" | 41 | #include "dlmglue.h" |
| 40 | #include "extent_map.h" | 42 | #include "extent_map.h" |
| 41 | #include "inode.h" | 43 | #include "inode.h" |
| @@ -46,6 +48,7 @@ | |||
| 46 | #include "file.h" | 48 | #include "file.h" |
| 47 | #include "super.h" | 49 | #include "super.h" |
| 48 | #include "uptodate.h" | 50 | #include "uptodate.h" |
| 51 | #include "xattr.h" | ||
| 49 | 52 | ||
| 50 | #include "buffer_head_io.h" | 53 | #include "buffer_head_io.h" |
| 51 | 54 | ||
| @@ -187,20 +190,12 @@ static int ocfs2_dinode_insert_check(struct inode *inode, | |||
| 187 | static int ocfs2_dinode_sanity_check(struct inode *inode, | 190 | static int ocfs2_dinode_sanity_check(struct inode *inode, |
| 188 | struct ocfs2_extent_tree *et) | 191 | struct ocfs2_extent_tree *et) |
| 189 | { | 192 | { |
| 190 | int ret = 0; | 193 | struct ocfs2_dinode *di = et->et_object; |
| 191 | struct ocfs2_dinode *di; | ||
| 192 | 194 | ||
| 193 | BUG_ON(et->et_ops != &ocfs2_dinode_et_ops); | 195 | BUG_ON(et->et_ops != &ocfs2_dinode_et_ops); |
| 196 | BUG_ON(!OCFS2_IS_VALID_DINODE(di)); | ||
| 194 | 197 | ||
| 195 | di = et->et_object; | 198 | return 0; |
| 196 | if (!OCFS2_IS_VALID_DINODE(di)) { | ||
| 197 | ret = -EIO; | ||
| 198 | ocfs2_error(inode->i_sb, | ||
| 199 | "Inode %llu has invalid path root", | ||
| 200 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 201 | } | ||
| 202 | |||
| 203 | return ret; | ||
| 204 | } | 199 | } |
| 205 | 200 | ||
| 206 | static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et) | 201 | static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et) |
| @@ -213,36 +208,33 @@ static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et) | |||
| 213 | 208 | ||
| 214 | static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et) | 209 | static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et) |
| 215 | { | 210 | { |
| 216 | struct ocfs2_xattr_value_root *xv = et->et_object; | 211 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
| 217 | 212 | ||
| 218 | et->et_root_el = &xv->xr_list; | 213 | et->et_root_el = &vb->vb_xv->xr_list; |
| 219 | } | 214 | } |
| 220 | 215 | ||
| 221 | static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, | 216 | static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, |
| 222 | u64 blkno) | 217 | u64 blkno) |
| 223 | { | 218 | { |
| 224 | struct ocfs2_xattr_value_root *xv = | 219 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
| 225 | (struct ocfs2_xattr_value_root *)et->et_object; | ||
| 226 | 220 | ||
| 227 | xv->xr_last_eb_blk = cpu_to_le64(blkno); | 221 | vb->vb_xv->xr_last_eb_blk = cpu_to_le64(blkno); |
| 228 | } | 222 | } |
| 229 | 223 | ||
| 230 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) | 224 | static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) |
| 231 | { | 225 | { |
| 232 | struct ocfs2_xattr_value_root *xv = | 226 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
| 233 | (struct ocfs2_xattr_value_root *) et->et_object; | ||
| 234 | 227 | ||
| 235 | return le64_to_cpu(xv->xr_last_eb_blk); | 228 | return le64_to_cpu(vb->vb_xv->xr_last_eb_blk); |
| 236 | } | 229 | } |
| 237 | 230 | ||
| 238 | static void ocfs2_xattr_value_update_clusters(struct inode *inode, | 231 | static void ocfs2_xattr_value_update_clusters(struct inode *inode, |
| 239 | struct ocfs2_extent_tree *et, | 232 | struct ocfs2_extent_tree *et, |
| 240 | u32 clusters) | 233 | u32 clusters) |
| 241 | { | 234 | { |
| 242 | struct ocfs2_xattr_value_root *xv = | 235 | struct ocfs2_xattr_value_buf *vb = et->et_object; |
| 243 | (struct ocfs2_xattr_value_root *)et->et_object; | ||
| 244 | 236 | ||
| 245 | le32_add_cpu(&xv->xr_clusters, clusters); | 237 | le32_add_cpu(&vb->vb_xv->xr_clusters, clusters); |
| 246 | } | 238 | } |
| 247 | 239 | ||
| 248 | static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = { | 240 | static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = { |
| @@ -304,11 +296,13 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = { | |||
| 304 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, | 296 | static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, |
| 305 | struct inode *inode, | 297 | struct inode *inode, |
| 306 | struct buffer_head *bh, | 298 | struct buffer_head *bh, |
| 299 | ocfs2_journal_access_func access, | ||
| 307 | void *obj, | 300 | void *obj, |
| 308 | struct ocfs2_extent_tree_operations *ops) | 301 | struct ocfs2_extent_tree_operations *ops) |
| 309 | { | 302 | { |
| 310 | et->et_ops = ops; | 303 | et->et_ops = ops; |
| 311 | et->et_root_bh = bh; | 304 | et->et_root_bh = bh; |
| 305 | et->et_root_journal_access = access; | ||
| 312 | if (!obj) | 306 | if (!obj) |
| 313 | obj = (void *)bh->b_data; | 307 | obj = (void *)bh->b_data; |
| 314 | et->et_object = obj; | 308 | et->et_object = obj; |
| @@ -324,23 +318,23 @@ void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et, | |||
| 324 | struct inode *inode, | 318 | struct inode *inode, |
| 325 | struct buffer_head *bh) | 319 | struct buffer_head *bh) |
| 326 | { | 320 | { |
| 327 | __ocfs2_init_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops); | 321 | __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access_di, |
| 322 | NULL, &ocfs2_dinode_et_ops); | ||
| 328 | } | 323 | } |
| 329 | 324 | ||
| 330 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, | 325 | void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, |
| 331 | struct inode *inode, | 326 | struct inode *inode, |
| 332 | struct buffer_head *bh) | 327 | struct buffer_head *bh) |
| 333 | { | 328 | { |
| 334 | __ocfs2_init_extent_tree(et, inode, bh, NULL, | 329 | __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access_xb, |
| 335 | &ocfs2_xattr_tree_et_ops); | 330 | NULL, &ocfs2_xattr_tree_et_ops); |
| 336 | } | 331 | } |
| 337 | 332 | ||
| 338 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, | 333 | void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, |
| 339 | struct inode *inode, | 334 | struct inode *inode, |
| 340 | struct buffer_head *bh, | 335 | struct ocfs2_xattr_value_buf *vb) |
| 341 | struct ocfs2_xattr_value_root *xv) | ||
| 342 | { | 336 | { |
| 343 | __ocfs2_init_extent_tree(et, inode, bh, xv, | 337 | __ocfs2_init_extent_tree(et, inode, vb->vb_bh, vb->vb_access, vb, |
| 344 | &ocfs2_xattr_value_et_ops); | 338 | &ocfs2_xattr_value_et_ops); |
| 345 | } | 339 | } |
| 346 | 340 | ||
| @@ -362,6 +356,15 @@ static inline void ocfs2_et_update_clusters(struct inode *inode, | |||
| 362 | et->et_ops->eo_update_clusters(inode, et, clusters); | 356 | et->et_ops->eo_update_clusters(inode, et, clusters); |
| 363 | } | 357 | } |
| 364 | 358 | ||
| 359 | static inline int ocfs2_et_root_journal_access(handle_t *handle, | ||
| 360 | struct inode *inode, | ||
| 361 | struct ocfs2_extent_tree *et, | ||
| 362 | int type) | ||
| 363 | { | ||
| 364 | return et->et_root_journal_access(handle, inode, et->et_root_bh, | ||
| 365 | type); | ||
| 366 | } | ||
| 367 | |||
| 365 | static inline int ocfs2_et_insert_check(struct inode *inode, | 368 | static inline int ocfs2_et_insert_check(struct inode *inode, |
| 366 | struct ocfs2_extent_tree *et, | 369 | struct ocfs2_extent_tree *et, |
| 367 | struct ocfs2_extent_rec *rec) | 370 | struct ocfs2_extent_rec *rec) |
| @@ -402,12 +405,14 @@ struct ocfs2_path_item { | |||
| 402 | #define OCFS2_MAX_PATH_DEPTH 5 | 405 | #define OCFS2_MAX_PATH_DEPTH 5 |
| 403 | 406 | ||
| 404 | struct ocfs2_path { | 407 | struct ocfs2_path { |
| 405 | int p_tree_depth; | 408 | int p_tree_depth; |
| 406 | struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; | 409 | ocfs2_journal_access_func p_root_access; |
| 410 | struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; | ||
| 407 | }; | 411 | }; |
| 408 | 412 | ||
| 409 | #define path_root_bh(_path) ((_path)->p_node[0].bh) | 413 | #define path_root_bh(_path) ((_path)->p_node[0].bh) |
| 410 | #define path_root_el(_path) ((_path)->p_node[0].el) | 414 | #define path_root_el(_path) ((_path)->p_node[0].el) |
| 415 | #define path_root_access(_path)((_path)->p_root_access) | ||
| 411 | #define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) | 416 | #define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) |
| 412 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) | 417 | #define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) |
| 413 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) | 418 | #define path_num_items(_path) ((_path)->p_tree_depth + 1) |
| @@ -440,6 +445,8 @@ static void ocfs2_reinit_path(struct ocfs2_path *path, int keep_root) | |||
| 440 | */ | 445 | */ |
| 441 | if (keep_root) | 446 | if (keep_root) |
| 442 | depth = le16_to_cpu(path_root_el(path)->l_tree_depth); | 447 | depth = le16_to_cpu(path_root_el(path)->l_tree_depth); |
| 448 | else | ||
| 449 | path_root_access(path) = NULL; | ||
| 443 | 450 | ||
| 444 | path->p_tree_depth = depth; | 451 | path->p_tree_depth = depth; |
| 445 | } | 452 | } |
| @@ -465,6 +472,7 @@ static void ocfs2_cp_path(struct ocfs2_path *dest, struct ocfs2_path *src) | |||
| 465 | 472 | ||
| 466 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); | 473 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); |
| 467 | BUG_ON(path_root_el(dest) != path_root_el(src)); | 474 | BUG_ON(path_root_el(dest) != path_root_el(src)); |
| 475 | BUG_ON(path_root_access(dest) != path_root_access(src)); | ||
| 468 | 476 | ||
| 469 | ocfs2_reinit_path(dest, 1); | 477 | ocfs2_reinit_path(dest, 1); |
| 470 | 478 | ||
| @@ -486,6 +494,7 @@ static void ocfs2_mv_path(struct ocfs2_path *dest, struct ocfs2_path *src) | |||
| 486 | int i; | 494 | int i; |
| 487 | 495 | ||
| 488 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); | 496 | BUG_ON(path_root_bh(dest) != path_root_bh(src)); |
| 497 | BUG_ON(path_root_access(dest) != path_root_access(src)); | ||
| 489 | 498 | ||
| 490 | for(i = 1; i < OCFS2_MAX_PATH_DEPTH; i++) { | 499 | for(i = 1; i < OCFS2_MAX_PATH_DEPTH; i++) { |
| 491 | brelse(dest->p_node[i].bh); | 500 | brelse(dest->p_node[i].bh); |
| @@ -521,7 +530,8 @@ static inline void ocfs2_path_insert_eb(struct ocfs2_path *path, int index, | |||
| 521 | } | 530 | } |
| 522 | 531 | ||
| 523 | static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, | 532 | static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, |
| 524 | struct ocfs2_extent_list *root_el) | 533 | struct ocfs2_extent_list *root_el, |
| 534 | ocfs2_journal_access_func access) | ||
| 525 | { | 535 | { |
| 526 | struct ocfs2_path *path; | 536 | struct ocfs2_path *path; |
| 527 | 537 | ||
| @@ -533,11 +543,48 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, | |||
| 533 | get_bh(root_bh); | 543 | get_bh(root_bh); |
| 534 | path_root_bh(path) = root_bh; | 544 | path_root_bh(path) = root_bh; |
| 535 | path_root_el(path) = root_el; | 545 | path_root_el(path) = root_el; |
| 546 | path_root_access(path) = access; | ||
| 536 | } | 547 | } |
| 537 | 548 | ||
| 538 | return path; | 549 | return path; |
| 539 | } | 550 | } |
| 540 | 551 | ||
| 552 | static struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path) | ||
| 553 | { | ||
| 554 | return ocfs2_new_path(path_root_bh(path), path_root_el(path), | ||
| 555 | path_root_access(path)); | ||
| 556 | } | ||
| 557 | |||
| 558 | static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et) | ||
| 559 | { | ||
| 560 | return ocfs2_new_path(et->et_root_bh, et->et_root_el, | ||
| 561 | et->et_root_journal_access); | ||
| 562 | } | ||
| 563 | |||
| 564 | /* | ||
| 565 | * Journal the buffer at depth idx. All idx>0 are extent_blocks, | ||
| 566 | * otherwise it's the root_access function. | ||
| 567 | * | ||
| 568 | * I don't like the way this function's name looks next to | ||
| 569 | * ocfs2_journal_access_path(), but I don't have a better one. | ||
| 570 | */ | ||
| 571 | static int ocfs2_path_bh_journal_access(handle_t *handle, | ||
| 572 | struct inode *inode, | ||
| 573 | struct ocfs2_path *path, | ||
| 574 | int idx) | ||
| 575 | { | ||
| 576 | ocfs2_journal_access_func access = path_root_access(path); | ||
| 577 | |||
| 578 | if (!access) | ||
| 579 | access = ocfs2_journal_access; | ||
| 580 | |||
| 581 | if (idx) | ||
| 582 | access = ocfs2_journal_access_eb; | ||
| 583 | |||
| 584 | return access(handle, inode, path->p_node[idx].bh, | ||
| 585 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 586 | } | ||
| 587 | |||
| 541 | /* | 588 | /* |
| 542 | * Convenience function to journal all components in a path. | 589 | * Convenience function to journal all components in a path. |
| 543 | */ | 590 | */ |
| @@ -550,8 +597,7 @@ static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle, | |||
| 550 | goto out; | 597 | goto out; |
| 551 | 598 | ||
| 552 | for(i = 0; i < path_num_items(path); i++) { | 599 | for(i = 0; i < path_num_items(path); i++) { |
| 553 | ret = ocfs2_journal_access(handle, inode, path->p_node[i].bh, | 600 | ret = ocfs2_path_bh_journal_access(handle, inode, path, i); |
| 554 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 555 | if (ret < 0) { | 601 | if (ret < 0) { |
| 556 | mlog_errno(ret); | 602 | mlog_errno(ret); |
| 557 | goto out; | 603 | goto out; |
| @@ -686,6 +732,80 @@ struct ocfs2_merge_ctxt { | |||
| 686 | int c_split_covers_rec; | 732 | int c_split_covers_rec; |
| 687 | }; | 733 | }; |
| 688 | 734 | ||
| 735 | static int ocfs2_validate_extent_block(struct super_block *sb, | ||
| 736 | struct buffer_head *bh) | ||
| 737 | { | ||
| 738 | int rc; | ||
| 739 | struct ocfs2_extent_block *eb = | ||
| 740 | (struct ocfs2_extent_block *)bh->b_data; | ||
| 741 | |||
| 742 | mlog(0, "Validating extent block %llu\n", | ||
| 743 | (unsigned long long)bh->b_blocknr); | ||
| 744 | |||
| 745 | BUG_ON(!buffer_uptodate(bh)); | ||
| 746 | |||
| 747 | /* | ||
| 748 | * If the ecc fails, we return the error but otherwise | ||
| 749 | * leave the filesystem running. We know any error is | ||
| 750 | * local to this block. | ||
| 751 | */ | ||
| 752 | rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &eb->h_check); | ||
| 753 | if (rc) { | ||
| 754 | mlog(ML_ERROR, "Checksum failed for extent block %llu\n", | ||
| 755 | (unsigned long long)bh->b_blocknr); | ||
| 756 | return rc; | ||
| 757 | } | ||
| 758 | |||
| 759 | /* | ||
| 760 | * Errors after here are fatal. | ||
| 761 | */ | ||
| 762 | |||
| 763 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | ||
| 764 | ocfs2_error(sb, | ||
| 765 | "Extent block #%llu has bad signature %.*s", | ||
| 766 | (unsigned long long)bh->b_blocknr, 7, | ||
| 767 | eb->h_signature); | ||
| 768 | return -EINVAL; | ||
| 769 | } | ||
| 770 | |||
| 771 | if (le64_to_cpu(eb->h_blkno) != bh->b_blocknr) { | ||
| 772 | ocfs2_error(sb, | ||
| 773 | "Extent block #%llu has an invalid h_blkno " | ||
| 774 | "of %llu", | ||
| 775 | (unsigned long long)bh->b_blocknr, | ||
| 776 | (unsigned long long)le64_to_cpu(eb->h_blkno)); | ||
| 777 | return -EINVAL; | ||
| 778 | } | ||
| 779 | |||
| 780 | if (le32_to_cpu(eb->h_fs_generation) != OCFS2_SB(sb)->fs_generation) { | ||
| 781 | ocfs2_error(sb, | ||
| 782 | "Extent block #%llu has an invalid " | ||
| 783 | "h_fs_generation of #%u", | ||
| 784 | (unsigned long long)bh->b_blocknr, | ||
| 785 | le32_to_cpu(eb->h_fs_generation)); | ||
| 786 | return -EINVAL; | ||
| 787 | } | ||
| 788 | |||
| 789 | return 0; | ||
| 790 | } | ||
| 791 | |||
| 792 | int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno, | ||
| 793 | struct buffer_head **bh) | ||
| 794 | { | ||
| 795 | int rc; | ||
| 796 | struct buffer_head *tmp = *bh; | ||
| 797 | |||
| 798 | rc = ocfs2_read_block(inode, eb_blkno, &tmp, | ||
| 799 | ocfs2_validate_extent_block); | ||
| 800 | |||
| 801 | /* If ocfs2_read_block() got us a new bh, pass it up. */ | ||
| 802 | if (!rc && !*bh) | ||
| 803 | *bh = tmp; | ||
| 804 | |||
| 805 | return rc; | ||
| 806 | } | ||
| 807 | |||
| 808 | |||
| 689 | /* | 809 | /* |
| 690 | * How many free extents have we got before we need more meta data? | 810 | * How many free extents have we got before we need more meta data? |
| 691 | */ | 811 | */ |
| @@ -705,8 +825,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |||
| 705 | last_eb_blk = ocfs2_et_get_last_eb_blk(et); | 825 | last_eb_blk = ocfs2_et_get_last_eb_blk(et); |
| 706 | 826 | ||
| 707 | if (last_eb_blk) { | 827 | if (last_eb_blk) { |
| 708 | retval = ocfs2_read_block(inode, last_eb_blk, | 828 | retval = ocfs2_read_extent_block(inode, last_eb_blk, &eb_bh); |
| 709 | &eb_bh); | ||
| 710 | if (retval < 0) { | 829 | if (retval < 0) { |
| 711 | mlog_errno(retval); | 830 | mlog_errno(retval); |
| 712 | goto bail; | 831 | goto bail; |
| @@ -768,8 +887,8 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, | |||
| 768 | } | 887 | } |
| 769 | ocfs2_set_new_buffer_uptodate(inode, bhs[i]); | 888 | ocfs2_set_new_buffer_uptodate(inode, bhs[i]); |
| 770 | 889 | ||
| 771 | status = ocfs2_journal_access(handle, inode, bhs[i], | 890 | status = ocfs2_journal_access_eb(handle, inode, bhs[i], |
| 772 | OCFS2_JOURNAL_ACCESS_CREATE); | 891 | OCFS2_JOURNAL_ACCESS_CREATE); |
| 773 | if (status < 0) { | 892 | if (status < 0) { |
| 774 | mlog_errno(status); | 893 | mlog_errno(status); |
| 775 | goto bail; | 894 | goto bail; |
| @@ -908,15 +1027,12 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
| 908 | for(i = 0; i < new_blocks; i++) { | 1027 | for(i = 0; i < new_blocks; i++) { |
| 909 | bh = new_eb_bhs[i]; | 1028 | bh = new_eb_bhs[i]; |
| 910 | eb = (struct ocfs2_extent_block *) bh->b_data; | 1029 | eb = (struct ocfs2_extent_block *) bh->b_data; |
| 911 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | 1030 | /* ocfs2_create_new_meta_bhs() should create it right! */ |
| 912 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | 1031 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); |
| 913 | status = -EIO; | ||
| 914 | goto bail; | ||
| 915 | } | ||
| 916 | eb_el = &eb->h_list; | 1032 | eb_el = &eb->h_list; |
| 917 | 1033 | ||
| 918 | status = ocfs2_journal_access(handle, inode, bh, | 1034 | status = ocfs2_journal_access_eb(handle, inode, bh, |
| 919 | OCFS2_JOURNAL_ACCESS_CREATE); | 1035 | OCFS2_JOURNAL_ACCESS_CREATE); |
| 920 | if (status < 0) { | 1036 | if (status < 0) { |
| 921 | mlog_errno(status); | 1037 | mlog_errno(status); |
| 922 | goto bail; | 1038 | goto bail; |
| @@ -955,21 +1071,21 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
| 955 | * journal_dirty erroring as it won't unless we've aborted the | 1071 | * journal_dirty erroring as it won't unless we've aborted the |
| 956 | * handle (in which case we would never be here) so reserving | 1072 | * handle (in which case we would never be here) so reserving |
| 957 | * the write with journal_access is all we need to do. */ | 1073 | * the write with journal_access is all we need to do. */ |
| 958 | status = ocfs2_journal_access(handle, inode, *last_eb_bh, | 1074 | status = ocfs2_journal_access_eb(handle, inode, *last_eb_bh, |
| 959 | OCFS2_JOURNAL_ACCESS_WRITE); | 1075 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 960 | if (status < 0) { | 1076 | if (status < 0) { |
| 961 | mlog_errno(status); | 1077 | mlog_errno(status); |
| 962 | goto bail; | 1078 | goto bail; |
| 963 | } | 1079 | } |
| 964 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | 1080 | status = ocfs2_et_root_journal_access(handle, inode, et, |
| 965 | OCFS2_JOURNAL_ACCESS_WRITE); | 1081 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 966 | if (status < 0) { | 1082 | if (status < 0) { |
| 967 | mlog_errno(status); | 1083 | mlog_errno(status); |
| 968 | goto bail; | 1084 | goto bail; |
| 969 | } | 1085 | } |
| 970 | if (eb_bh) { | 1086 | if (eb_bh) { |
| 971 | status = ocfs2_journal_access(handle, inode, eb_bh, | 1087 | status = ocfs2_journal_access_eb(handle, inode, eb_bh, |
| 972 | OCFS2_JOURNAL_ACCESS_WRITE); | 1088 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 973 | if (status < 0) { | 1089 | if (status < 0) { |
| 974 | mlog_errno(status); | 1090 | mlog_errno(status); |
| 975 | goto bail; | 1091 | goto bail; |
| @@ -1052,17 +1168,14 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
| 1052 | } | 1168 | } |
| 1053 | 1169 | ||
| 1054 | eb = (struct ocfs2_extent_block *) new_eb_bh->b_data; | 1170 | eb = (struct ocfs2_extent_block *) new_eb_bh->b_data; |
| 1055 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | 1171 | /* ocfs2_create_new_meta_bhs() should create it right! */ |
| 1056 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | 1172 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); |
| 1057 | status = -EIO; | ||
| 1058 | goto bail; | ||
| 1059 | } | ||
| 1060 | 1173 | ||
| 1061 | eb_el = &eb->h_list; | 1174 | eb_el = &eb->h_list; |
| 1062 | root_el = et->et_root_el; | 1175 | root_el = et->et_root_el; |
| 1063 | 1176 | ||
| 1064 | status = ocfs2_journal_access(handle, inode, new_eb_bh, | 1177 | status = ocfs2_journal_access_eb(handle, inode, new_eb_bh, |
| 1065 | OCFS2_JOURNAL_ACCESS_CREATE); | 1178 | OCFS2_JOURNAL_ACCESS_CREATE); |
| 1066 | if (status < 0) { | 1179 | if (status < 0) { |
| 1067 | mlog_errno(status); | 1180 | mlog_errno(status); |
| 1068 | goto bail; | 1181 | goto bail; |
| @@ -1080,8 +1193,8 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | |||
| 1080 | goto bail; | 1193 | goto bail; |
| 1081 | } | 1194 | } |
| 1082 | 1195 | ||
| 1083 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | 1196 | status = ocfs2_et_root_journal_access(handle, inode, et, |
| 1084 | OCFS2_JOURNAL_ACCESS_WRITE); | 1197 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 1085 | if (status < 0) { | 1198 | if (status < 0) { |
| 1086 | mlog_errno(status); | 1199 | mlog_errno(status); |
| 1087 | goto bail; | 1200 | goto bail; |
| @@ -1176,18 +1289,13 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb, | |||
| 1176 | brelse(bh); | 1289 | brelse(bh); |
| 1177 | bh = NULL; | 1290 | bh = NULL; |
| 1178 | 1291 | ||
| 1179 | status = ocfs2_read_block(inode, blkno, &bh); | 1292 | status = ocfs2_read_extent_block(inode, blkno, &bh); |
| 1180 | if (status < 0) { | 1293 | if (status < 0) { |
| 1181 | mlog_errno(status); | 1294 | mlog_errno(status); |
| 1182 | goto bail; | 1295 | goto bail; |
| 1183 | } | 1296 | } |
| 1184 | 1297 | ||
| 1185 | eb = (struct ocfs2_extent_block *) bh->b_data; | 1298 | eb = (struct ocfs2_extent_block *) bh->b_data; |
| 1186 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | ||
| 1187 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | ||
| 1188 | status = -EIO; | ||
| 1189 | goto bail; | ||
| 1190 | } | ||
| 1191 | el = &eb->h_list; | 1299 | el = &eb->h_list; |
| 1192 | 1300 | ||
| 1193 | if (le16_to_cpu(el->l_next_free_rec) < | 1301 | if (le16_to_cpu(el->l_next_free_rec) < |
| @@ -1540,7 +1648,7 @@ static int __ocfs2_find_path(struct inode *inode, | |||
| 1540 | 1648 | ||
| 1541 | brelse(bh); | 1649 | brelse(bh); |
| 1542 | bh = NULL; | 1650 | bh = NULL; |
| 1543 | ret = ocfs2_read_block(inode, blkno, &bh); | 1651 | ret = ocfs2_read_extent_block(inode, blkno, &bh); |
| 1544 | if (ret) { | 1652 | if (ret) { |
| 1545 | mlog_errno(ret); | 1653 | mlog_errno(ret); |
| 1546 | goto out; | 1654 | goto out; |
| @@ -1548,11 +1656,6 @@ static int __ocfs2_find_path(struct inode *inode, | |||
| 1548 | 1656 | ||
| 1549 | eb = (struct ocfs2_extent_block *) bh->b_data; | 1657 | eb = (struct ocfs2_extent_block *) bh->b_data; |
| 1550 | el = &eb->h_list; | 1658 | el = &eb->h_list; |
| 1551 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | ||
| 1552 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | ||
| 1553 | ret = -EIO; | ||
| 1554 | goto out; | ||
| 1555 | } | ||
| 1556 | 1659 | ||
| 1557 | if (le16_to_cpu(el->l_next_free_rec) > | 1660 | if (le16_to_cpu(el->l_next_free_rec) > |
| 1558 | le16_to_cpu(el->l_count)) { | 1661 | le16_to_cpu(el->l_count)) { |
| @@ -1860,25 +1963,23 @@ static int ocfs2_rotate_subtree_right(struct inode *inode, | |||
| 1860 | root_bh = left_path->p_node[subtree_index].bh; | 1963 | root_bh = left_path->p_node[subtree_index].bh; |
| 1861 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); | 1964 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); |
| 1862 | 1965 | ||
| 1863 | ret = ocfs2_journal_access(handle, inode, root_bh, | 1966 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
| 1864 | OCFS2_JOURNAL_ACCESS_WRITE); | 1967 | subtree_index); |
| 1865 | if (ret) { | 1968 | if (ret) { |
| 1866 | mlog_errno(ret); | 1969 | mlog_errno(ret); |
| 1867 | goto out; | 1970 | goto out; |
| 1868 | } | 1971 | } |
| 1869 | 1972 | ||
| 1870 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { | 1973 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { |
| 1871 | ret = ocfs2_journal_access(handle, inode, | 1974 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 1872 | right_path->p_node[i].bh, | 1975 | right_path, i); |
| 1873 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 1874 | if (ret) { | 1976 | if (ret) { |
| 1875 | mlog_errno(ret); | 1977 | mlog_errno(ret); |
| 1876 | goto out; | 1978 | goto out; |
| 1877 | } | 1979 | } |
| 1878 | 1980 | ||
| 1879 | ret = ocfs2_journal_access(handle, inode, | 1981 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 1880 | left_path->p_node[i].bh, | 1982 | left_path, i); |
| 1881 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 1882 | if (ret) { | 1983 | if (ret) { |
| 1883 | mlog_errno(ret); | 1984 | mlog_errno(ret); |
| 1884 | goto out; | 1985 | goto out; |
| @@ -2102,8 +2203,7 @@ static int ocfs2_rotate_tree_right(struct inode *inode, | |||
| 2102 | 2203 | ||
| 2103 | *ret_left_path = NULL; | 2204 | *ret_left_path = NULL; |
| 2104 | 2205 | ||
| 2105 | left_path = ocfs2_new_path(path_root_bh(right_path), | 2206 | left_path = ocfs2_new_path_from_path(right_path); |
| 2106 | path_root_el(right_path)); | ||
| 2107 | if (!left_path) { | 2207 | if (!left_path) { |
| 2108 | ret = -ENOMEM; | 2208 | ret = -ENOMEM; |
| 2109 | mlog_errno(ret); | 2209 | mlog_errno(ret); |
| @@ -2398,9 +2498,9 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
| 2398 | return -EAGAIN; | 2498 | return -EAGAIN; |
| 2399 | 2499 | ||
| 2400 | if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) { | 2500 | if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) { |
| 2401 | ret = ocfs2_journal_access(handle, inode, | 2501 | ret = ocfs2_journal_access_eb(handle, inode, |
| 2402 | path_leaf_bh(right_path), | 2502 | path_leaf_bh(right_path), |
| 2403 | OCFS2_JOURNAL_ACCESS_WRITE); | 2503 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 2404 | if (ret) { | 2504 | if (ret) { |
| 2405 | mlog_errno(ret); | 2505 | mlog_errno(ret); |
| 2406 | goto out; | 2506 | goto out; |
| @@ -2417,8 +2517,8 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
| 2417 | * We have to update i_last_eb_blk during the meta | 2517 | * We have to update i_last_eb_blk during the meta |
| 2418 | * data delete. | 2518 | * data delete. |
| 2419 | */ | 2519 | */ |
| 2420 | ret = ocfs2_journal_access(handle, inode, et_root_bh, | 2520 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
| 2421 | OCFS2_JOURNAL_ACCESS_WRITE); | 2521 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 2422 | if (ret) { | 2522 | if (ret) { |
| 2423 | mlog_errno(ret); | 2523 | mlog_errno(ret); |
| 2424 | goto out; | 2524 | goto out; |
| @@ -2433,25 +2533,23 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, | |||
| 2433 | */ | 2533 | */ |
| 2434 | BUG_ON(right_has_empty && !del_right_subtree); | 2534 | BUG_ON(right_has_empty && !del_right_subtree); |
| 2435 | 2535 | ||
| 2436 | ret = ocfs2_journal_access(handle, inode, root_bh, | 2536 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
| 2437 | OCFS2_JOURNAL_ACCESS_WRITE); | 2537 | subtree_index); |
| 2438 | if (ret) { | 2538 | if (ret) { |
| 2439 | mlog_errno(ret); | 2539 | mlog_errno(ret); |
| 2440 | goto out; | 2540 | goto out; |
| 2441 | } | 2541 | } |
| 2442 | 2542 | ||
| 2443 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { | 2543 | for(i = subtree_index + 1; i < path_num_items(right_path); i++) { |
| 2444 | ret = ocfs2_journal_access(handle, inode, | 2544 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 2445 | right_path->p_node[i].bh, | 2545 | right_path, i); |
| 2446 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 2447 | if (ret) { | 2546 | if (ret) { |
| 2448 | mlog_errno(ret); | 2547 | mlog_errno(ret); |
| 2449 | goto out; | 2548 | goto out; |
| 2450 | } | 2549 | } |
| 2451 | 2550 | ||
| 2452 | ret = ocfs2_journal_access(handle, inode, | 2551 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 2453 | left_path->p_node[i].bh, | 2552 | left_path, i); |
| 2454 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 2455 | if (ret) { | 2553 | if (ret) { |
| 2456 | mlog_errno(ret); | 2554 | mlog_errno(ret); |
| 2457 | goto out; | 2555 | goto out; |
| @@ -2596,16 +2694,17 @@ out: | |||
| 2596 | 2694 | ||
| 2597 | static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode, | 2695 | static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode, |
| 2598 | handle_t *handle, | 2696 | handle_t *handle, |
| 2599 | struct buffer_head *bh, | 2697 | struct ocfs2_path *path) |
| 2600 | struct ocfs2_extent_list *el) | ||
| 2601 | { | 2698 | { |
| 2602 | int ret; | 2699 | int ret; |
| 2700 | struct buffer_head *bh = path_leaf_bh(path); | ||
| 2701 | struct ocfs2_extent_list *el = path_leaf_el(path); | ||
| 2603 | 2702 | ||
| 2604 | if (!ocfs2_is_empty_extent(&el->l_recs[0])) | 2703 | if (!ocfs2_is_empty_extent(&el->l_recs[0])) |
| 2605 | return 0; | 2704 | return 0; |
| 2606 | 2705 | ||
| 2607 | ret = ocfs2_journal_access(handle, inode, bh, | 2706 | ret = ocfs2_path_bh_journal_access(handle, inode, path, |
| 2608 | OCFS2_JOURNAL_ACCESS_WRITE); | 2707 | path_num_items(path) - 1); |
| 2609 | if (ret) { | 2708 | if (ret) { |
| 2610 | mlog_errno(ret); | 2709 | mlog_errno(ret); |
| 2611 | goto out; | 2710 | goto out; |
| @@ -2644,8 +2743,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
| 2644 | goto out; | 2743 | goto out; |
| 2645 | } | 2744 | } |
| 2646 | 2745 | ||
| 2647 | left_path = ocfs2_new_path(path_root_bh(path), | 2746 | left_path = ocfs2_new_path_from_path(path); |
| 2648 | path_root_el(path)); | ||
| 2649 | if (!left_path) { | 2747 | if (!left_path) { |
| 2650 | ret = -ENOMEM; | 2748 | ret = -ENOMEM; |
| 2651 | mlog_errno(ret); | 2749 | mlog_errno(ret); |
| @@ -2654,8 +2752,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
| 2654 | 2752 | ||
| 2655 | ocfs2_cp_path(left_path, path); | 2753 | ocfs2_cp_path(left_path, path); |
| 2656 | 2754 | ||
| 2657 | right_path = ocfs2_new_path(path_root_bh(path), | 2755 | right_path = ocfs2_new_path_from_path(path); |
| 2658 | path_root_el(path)); | ||
| 2659 | if (!right_path) { | 2756 | if (!right_path) { |
| 2660 | ret = -ENOMEM; | 2757 | ret = -ENOMEM; |
| 2661 | mlog_errno(ret); | 2758 | mlog_errno(ret); |
| @@ -2689,9 +2786,8 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, | |||
| 2689 | * Caller might still want to make changes to the | 2786 | * Caller might still want to make changes to the |
| 2690 | * tree root, so re-add it to the journal here. | 2787 | * tree root, so re-add it to the journal here. |
| 2691 | */ | 2788 | */ |
| 2692 | ret = ocfs2_journal_access(handle, inode, | 2789 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 2693 | path_root_bh(left_path), | 2790 | left_path, 0); |
| 2694 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 2695 | if (ret) { | 2791 | if (ret) { |
| 2696 | mlog_errno(ret); | 2792 | mlog_errno(ret); |
| 2697 | goto out; | 2793 | goto out; |
| @@ -2785,8 +2881,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | |||
| 2785 | * We have a path to the left of this one - it needs | 2881 | * We have a path to the left of this one - it needs |
| 2786 | * an update too. | 2882 | * an update too. |
| 2787 | */ | 2883 | */ |
| 2788 | left_path = ocfs2_new_path(path_root_bh(path), | 2884 | left_path = ocfs2_new_path_from_path(path); |
| 2789 | path_root_el(path)); | ||
| 2790 | if (!left_path) { | 2885 | if (!left_path) { |
| 2791 | ret = -ENOMEM; | 2886 | ret = -ENOMEM; |
| 2792 | mlog_errno(ret); | 2887 | mlog_errno(ret); |
| @@ -2875,8 +2970,7 @@ rightmost_no_delete: | |||
| 2875 | * it up front. | 2970 | * it up front. |
| 2876 | */ | 2971 | */ |
| 2877 | ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, | 2972 | ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, |
| 2878 | path_leaf_bh(path), | 2973 | path); |
| 2879 | path_leaf_el(path)); | ||
| 2880 | if (ret) | 2974 | if (ret) |
| 2881 | mlog_errno(ret); | 2975 | mlog_errno(ret); |
| 2882 | goto out; | 2976 | goto out; |
| @@ -3027,8 +3121,7 @@ static int ocfs2_get_right_path(struct inode *inode, | |||
| 3027 | /* This function shouldn't be called for the rightmost leaf. */ | 3121 | /* This function shouldn't be called for the rightmost leaf. */ |
| 3028 | BUG_ON(right_cpos == 0); | 3122 | BUG_ON(right_cpos == 0); |
| 3029 | 3123 | ||
| 3030 | right_path = ocfs2_new_path(path_root_bh(left_path), | 3124 | right_path = ocfs2_new_path_from_path(left_path); |
| 3031 | path_root_el(left_path)); | ||
| 3032 | if (!right_path) { | 3125 | if (!right_path) { |
| 3033 | ret = -ENOMEM; | 3126 | ret = -ENOMEM; |
| 3034 | mlog_errno(ret); | 3127 | mlog_errno(ret); |
| @@ -3111,8 +3204,8 @@ static int ocfs2_merge_rec_right(struct inode *inode, | |||
| 3111 | root_bh = left_path->p_node[subtree_index].bh; | 3204 | root_bh = left_path->p_node[subtree_index].bh; |
| 3112 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); | 3205 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); |
| 3113 | 3206 | ||
| 3114 | ret = ocfs2_journal_access(handle, inode, root_bh, | 3207 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
| 3115 | OCFS2_JOURNAL_ACCESS_WRITE); | 3208 | subtree_index); |
| 3116 | if (ret) { | 3209 | if (ret) { |
| 3117 | mlog_errno(ret); | 3210 | mlog_errno(ret); |
| 3118 | goto out; | 3211 | goto out; |
| @@ -3120,17 +3213,15 @@ static int ocfs2_merge_rec_right(struct inode *inode, | |||
| 3120 | 3213 | ||
| 3121 | for (i = subtree_index + 1; | 3214 | for (i = subtree_index + 1; |
| 3122 | i < path_num_items(right_path); i++) { | 3215 | i < path_num_items(right_path); i++) { |
| 3123 | ret = ocfs2_journal_access(handle, inode, | 3216 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 3124 | right_path->p_node[i].bh, | 3217 | right_path, i); |
| 3125 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 3126 | if (ret) { | 3218 | if (ret) { |
| 3127 | mlog_errno(ret); | 3219 | mlog_errno(ret); |
| 3128 | goto out; | 3220 | goto out; |
| 3129 | } | 3221 | } |
| 3130 | 3222 | ||
| 3131 | ret = ocfs2_journal_access(handle, inode, | 3223 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 3132 | left_path->p_node[i].bh, | 3224 | left_path, i); |
| 3133 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 3134 | if (ret) { | 3225 | if (ret) { |
| 3135 | mlog_errno(ret); | 3226 | mlog_errno(ret); |
| 3136 | goto out; | 3227 | goto out; |
| @@ -3142,8 +3233,8 @@ static int ocfs2_merge_rec_right(struct inode *inode, | |||
| 3142 | right_rec = &el->l_recs[index + 1]; | 3233 | right_rec = &el->l_recs[index + 1]; |
| 3143 | } | 3234 | } |
| 3144 | 3235 | ||
| 3145 | ret = ocfs2_journal_access(handle, inode, bh, | 3236 | ret = ocfs2_path_bh_journal_access(handle, inode, left_path, |
| 3146 | OCFS2_JOURNAL_ACCESS_WRITE); | 3237 | path_num_items(left_path) - 1); |
| 3147 | if (ret) { | 3238 | if (ret) { |
| 3148 | mlog_errno(ret); | 3239 | mlog_errno(ret); |
| 3149 | goto out; | 3240 | goto out; |
| @@ -3199,8 +3290,7 @@ static int ocfs2_get_left_path(struct inode *inode, | |||
| 3199 | /* This function shouldn't be called for the leftmost leaf. */ | 3290 | /* This function shouldn't be called for the leftmost leaf. */ |
| 3200 | BUG_ON(left_cpos == 0); | 3291 | BUG_ON(left_cpos == 0); |
| 3201 | 3292 | ||
| 3202 | left_path = ocfs2_new_path(path_root_bh(right_path), | 3293 | left_path = ocfs2_new_path_from_path(right_path); |
| 3203 | path_root_el(right_path)); | ||
| 3204 | if (!left_path) { | 3294 | if (!left_path) { |
| 3205 | ret = -ENOMEM; | 3295 | ret = -ENOMEM; |
| 3206 | mlog_errno(ret); | 3296 | mlog_errno(ret); |
| @@ -3283,8 +3373,8 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
| 3283 | root_bh = left_path->p_node[subtree_index].bh; | 3373 | root_bh = left_path->p_node[subtree_index].bh; |
| 3284 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); | 3374 | BUG_ON(root_bh != right_path->p_node[subtree_index].bh); |
| 3285 | 3375 | ||
| 3286 | ret = ocfs2_journal_access(handle, inode, root_bh, | 3376 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
| 3287 | OCFS2_JOURNAL_ACCESS_WRITE); | 3377 | subtree_index); |
| 3288 | if (ret) { | 3378 | if (ret) { |
| 3289 | mlog_errno(ret); | 3379 | mlog_errno(ret); |
| 3290 | goto out; | 3380 | goto out; |
| @@ -3292,17 +3382,15 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
| 3292 | 3382 | ||
| 3293 | for (i = subtree_index + 1; | 3383 | for (i = subtree_index + 1; |
| 3294 | i < path_num_items(right_path); i++) { | 3384 | i < path_num_items(right_path); i++) { |
| 3295 | ret = ocfs2_journal_access(handle, inode, | 3385 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 3296 | right_path->p_node[i].bh, | 3386 | right_path, i); |
| 3297 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 3298 | if (ret) { | 3387 | if (ret) { |
| 3299 | mlog_errno(ret); | 3388 | mlog_errno(ret); |
| 3300 | goto out; | 3389 | goto out; |
| 3301 | } | 3390 | } |
| 3302 | 3391 | ||
| 3303 | ret = ocfs2_journal_access(handle, inode, | 3392 | ret = ocfs2_path_bh_journal_access(handle, inode, |
| 3304 | left_path->p_node[i].bh, | 3393 | left_path, i); |
| 3305 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 3306 | if (ret) { | 3394 | if (ret) { |
| 3307 | mlog_errno(ret); | 3395 | mlog_errno(ret); |
| 3308 | goto out; | 3396 | goto out; |
| @@ -3314,8 +3402,8 @@ static int ocfs2_merge_rec_left(struct inode *inode, | |||
| 3314 | has_empty_extent = 1; | 3402 | has_empty_extent = 1; |
| 3315 | } | 3403 | } |
| 3316 | 3404 | ||
| 3317 | ret = ocfs2_journal_access(handle, inode, bh, | 3405 | ret = ocfs2_path_bh_journal_access(handle, inode, right_path, |
| 3318 | OCFS2_JOURNAL_ACCESS_WRITE); | 3406 | path_num_items(right_path) - 1); |
| 3319 | if (ret) { | 3407 | if (ret) { |
| 3320 | mlog_errno(ret); | 3408 | mlog_errno(ret); |
| 3321 | goto out; | 3409 | goto out; |
| @@ -3732,8 +3820,7 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, | |||
| 3732 | * leftmost leaf. | 3820 | * leftmost leaf. |
| 3733 | */ | 3821 | */ |
| 3734 | if (left_cpos) { | 3822 | if (left_cpos) { |
| 3735 | left_path = ocfs2_new_path(path_root_bh(right_path), | 3823 | left_path = ocfs2_new_path_from_path(right_path); |
| 3736 | path_root_el(right_path)); | ||
| 3737 | if (!left_path) { | 3824 | if (!left_path) { |
| 3738 | ret = -ENOMEM; | 3825 | ret = -ENOMEM; |
| 3739 | mlog_errno(ret); | 3826 | mlog_errno(ret); |
| @@ -3958,8 +4045,8 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
| 3958 | 4045 | ||
| 3959 | el = et->et_root_el; | 4046 | el = et->et_root_el; |
| 3960 | 4047 | ||
| 3961 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, | 4048 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
| 3962 | OCFS2_JOURNAL_ACCESS_WRITE); | 4049 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 3963 | if (ret) { | 4050 | if (ret) { |
| 3964 | mlog_errno(ret); | 4051 | mlog_errno(ret); |
| 3965 | goto out; | 4052 | goto out; |
| @@ -3970,7 +4057,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
| 3970 | goto out_update_clusters; | 4057 | goto out_update_clusters; |
| 3971 | } | 4058 | } |
| 3972 | 4059 | ||
| 3973 | right_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); | 4060 | right_path = ocfs2_new_path_from_et(et); |
| 3974 | if (!right_path) { | 4061 | if (!right_path) { |
| 3975 | ret = -ENOMEM; | 4062 | ret = -ENOMEM; |
| 3976 | mlog_errno(ret); | 4063 | mlog_errno(ret); |
| @@ -4020,8 +4107,8 @@ static int ocfs2_do_insert_extent(struct inode *inode, | |||
| 4020 | * ocfs2_rotate_tree_right() might have extended the | 4107 | * ocfs2_rotate_tree_right() might have extended the |
| 4021 | * transaction without re-journaling our tree root. | 4108 | * transaction without re-journaling our tree root. |
| 4022 | */ | 4109 | */ |
| 4023 | ret = ocfs2_journal_access(handle, inode, et->et_root_bh, | 4110 | ret = ocfs2_et_root_journal_access(handle, inode, et, |
| 4024 | OCFS2_JOURNAL_ACCESS_WRITE); | 4111 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 4025 | if (ret) { | 4112 | if (ret) { |
| 4026 | mlog_errno(ret); | 4113 | mlog_errno(ret); |
| 4027 | goto out; | 4114 | goto out; |
| @@ -4082,8 +4169,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, | |||
| 4082 | goto out; | 4169 | goto out; |
| 4083 | 4170 | ||
| 4084 | if (left_cpos != 0) { | 4171 | if (left_cpos != 0) { |
| 4085 | left_path = ocfs2_new_path(path_root_bh(path), | 4172 | left_path = ocfs2_new_path_from_path(path); |
| 4086 | path_root_el(path)); | ||
| 4087 | if (!left_path) | 4173 | if (!left_path) |
| 4088 | goto out; | 4174 | goto out; |
| 4089 | 4175 | ||
| @@ -4097,8 +4183,15 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, | |||
| 4097 | le16_to_cpu(new_el->l_count)) { | 4183 | le16_to_cpu(new_el->l_count)) { |
| 4098 | bh = path_leaf_bh(left_path); | 4184 | bh = path_leaf_bh(left_path); |
| 4099 | eb = (struct ocfs2_extent_block *)bh->b_data; | 4185 | eb = (struct ocfs2_extent_block *)bh->b_data; |
| 4100 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, | 4186 | ocfs2_error(inode->i_sb, |
| 4101 | eb); | 4187 | "Extent block #%llu has an " |
| 4188 | "invalid l_next_free_rec of " | ||
| 4189 | "%d. It should have " | ||
| 4190 | "matched the l_count of %d", | ||
| 4191 | (unsigned long long)le64_to_cpu(eb->h_blkno), | ||
| 4192 | le16_to_cpu(new_el->l_next_free_rec), | ||
| 4193 | le16_to_cpu(new_el->l_count)); | ||
| 4194 | status = -EINVAL; | ||
| 4102 | goto out; | 4195 | goto out; |
| 4103 | } | 4196 | } |
| 4104 | rec = &new_el->l_recs[ | 4197 | rec = &new_el->l_recs[ |
| @@ -4132,8 +4225,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, | |||
| 4132 | if (right_cpos == 0) | 4225 | if (right_cpos == 0) |
| 4133 | goto out; | 4226 | goto out; |
| 4134 | 4227 | ||
| 4135 | right_path = ocfs2_new_path(path_root_bh(path), | 4228 | right_path = ocfs2_new_path_from_path(path); |
| 4136 | path_root_el(path)); | ||
| 4137 | if (!right_path) | 4229 | if (!right_path) |
| 4138 | goto out; | 4230 | goto out; |
| 4139 | 4231 | ||
| @@ -4147,8 +4239,12 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, | |||
| 4147 | if (le16_to_cpu(new_el->l_next_free_rec) <= 1) { | 4239 | if (le16_to_cpu(new_el->l_next_free_rec) <= 1) { |
| 4148 | bh = path_leaf_bh(right_path); | 4240 | bh = path_leaf_bh(right_path); |
| 4149 | eb = (struct ocfs2_extent_block *)bh->b_data; | 4241 | eb = (struct ocfs2_extent_block *)bh->b_data; |
| 4150 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, | 4242 | ocfs2_error(inode->i_sb, |
| 4151 | eb); | 4243 | "Extent block #%llu has an " |
| 4244 | "invalid l_next_free_rec of %d", | ||
| 4245 | (unsigned long long)le64_to_cpu(eb->h_blkno), | ||
| 4246 | le16_to_cpu(new_el->l_next_free_rec)); | ||
| 4247 | status = -EINVAL; | ||
| 4152 | goto out; | 4248 | goto out; |
| 4153 | } | 4249 | } |
| 4154 | rec = &new_el->l_recs[1]; | 4250 | rec = &new_el->l_recs[1]; |
| @@ -4294,7 +4390,9 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
| 4294 | * ocfs2_figure_insert_type() and ocfs2_add_branch() | 4390 | * ocfs2_figure_insert_type() and ocfs2_add_branch() |
| 4295 | * may want it later. | 4391 | * may want it later. |
| 4296 | */ | 4392 | */ |
| 4297 | ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh); | 4393 | ret = ocfs2_read_extent_block(inode, |
| 4394 | ocfs2_et_get_last_eb_blk(et), | ||
| 4395 | &bh); | ||
| 4298 | if (ret) { | 4396 | if (ret) { |
| 4299 | mlog_exit(ret); | 4397 | mlog_exit(ret); |
| 4300 | goto out; | 4398 | goto out; |
| @@ -4320,7 +4418,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, | |||
| 4320 | return 0; | 4418 | return 0; |
| 4321 | } | 4419 | } |
| 4322 | 4420 | ||
| 4323 | path = ocfs2_new_path(et->et_root_bh, et->et_root_el); | 4421 | path = ocfs2_new_path_from_et(et); |
| 4324 | if (!path) { | 4422 | if (!path) { |
| 4325 | ret = -ENOMEM; | 4423 | ret = -ENOMEM; |
| 4326 | mlog_errno(ret); | 4424 | mlog_errno(ret); |
| @@ -4531,9 +4629,9 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb, | |||
| 4531 | 4629 | ||
| 4532 | BUG_ON(num_bits > clusters_to_add); | 4630 | BUG_ON(num_bits > clusters_to_add); |
| 4533 | 4631 | ||
| 4534 | /* reserve our write early -- insert_extent may update the inode */ | 4632 | /* reserve our write early -- insert_extent may update the tree root */ |
| 4535 | status = ocfs2_journal_access(handle, inode, et->et_root_bh, | 4633 | status = ocfs2_et_root_journal_access(handle, inode, et, |
| 4536 | OCFS2_JOURNAL_ACCESS_WRITE); | 4634 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 4537 | if (status < 0) { | 4635 | if (status < 0) { |
| 4538 | mlog_errno(status); | 4636 | mlog_errno(status); |
| 4539 | goto leave; | 4637 | goto leave; |
| @@ -4760,20 +4858,15 @@ static int __ocfs2_mark_extent_written(struct inode *inode, | |||
| 4760 | if (path->p_tree_depth) { | 4858 | if (path->p_tree_depth) { |
| 4761 | struct ocfs2_extent_block *eb; | 4859 | struct ocfs2_extent_block *eb; |
| 4762 | 4860 | ||
| 4763 | ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), | 4861 | ret = ocfs2_read_extent_block(inode, |
| 4764 | &last_eb_bh); | 4862 | ocfs2_et_get_last_eb_blk(et), |
| 4863 | &last_eb_bh); | ||
| 4765 | if (ret) { | 4864 | if (ret) { |
| 4766 | mlog_exit(ret); | 4865 | mlog_exit(ret); |
| 4767 | goto out; | 4866 | goto out; |
| 4768 | } | 4867 | } |
| 4769 | 4868 | ||
| 4770 | eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; | 4869 | eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; |
| 4771 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | ||
| 4772 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | ||
| 4773 | ret = -EROFS; | ||
| 4774 | goto out; | ||
| 4775 | } | ||
| 4776 | |||
| 4777 | rightmost_el = &eb->h_list; | 4870 | rightmost_el = &eb->h_list; |
| 4778 | } else | 4871 | } else |
| 4779 | rightmost_el = path_root_el(path); | 4872 | rightmost_el = path_root_el(path); |
| @@ -4854,7 +4947,7 @@ int ocfs2_mark_extent_written(struct inode *inode, | |||
| 4854 | if (et->et_ops == &ocfs2_dinode_et_ops) | 4947 | if (et->et_ops == &ocfs2_dinode_et_ops) |
| 4855 | ocfs2_extent_map_trunc(inode, 0); | 4948 | ocfs2_extent_map_trunc(inode, 0); |
| 4856 | 4949 | ||
| 4857 | left_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); | 4950 | left_path = ocfs2_new_path_from_et(et); |
| 4858 | if (!left_path) { | 4951 | if (!left_path) { |
| 4859 | ret = -ENOMEM; | 4952 | ret = -ENOMEM; |
| 4860 | mlog_errno(ret); | 4953 | mlog_errno(ret); |
| @@ -4918,8 +5011,9 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et, | |||
| 4918 | 5011 | ||
| 4919 | depth = path->p_tree_depth; | 5012 | depth = path->p_tree_depth; |
| 4920 | if (depth > 0) { | 5013 | if (depth > 0) { |
| 4921 | ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), | 5014 | ret = ocfs2_read_extent_block(inode, |
| 4922 | &last_eb_bh); | 5015 | ocfs2_et_get_last_eb_blk(et), |
| 5016 | &last_eb_bh); | ||
| 4923 | if (ret < 0) { | 5017 | if (ret < 0) { |
| 4924 | mlog_errno(ret); | 5018 | mlog_errno(ret); |
| 4925 | goto out; | 5019 | goto out; |
| @@ -5025,8 +5119,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, | |||
| 5025 | } | 5119 | } |
| 5026 | 5120 | ||
| 5027 | if (left_cpos && le16_to_cpu(el->l_next_free_rec) > 1) { | 5121 | if (left_cpos && le16_to_cpu(el->l_next_free_rec) > 1) { |
| 5028 | left_path = ocfs2_new_path(path_root_bh(path), | 5122 | left_path = ocfs2_new_path_from_path(path); |
| 5029 | path_root_el(path)); | ||
| 5030 | if (!left_path) { | 5123 | if (!left_path) { |
| 5031 | ret = -ENOMEM; | 5124 | ret = -ENOMEM; |
| 5032 | mlog_errno(ret); | 5125 | mlog_errno(ret); |
| @@ -5135,7 +5228,7 @@ int ocfs2_remove_extent(struct inode *inode, | |||
| 5135 | 5228 | ||
| 5136 | ocfs2_extent_map_trunc(inode, 0); | 5229 | ocfs2_extent_map_trunc(inode, 0); |
| 5137 | 5230 | ||
| 5138 | path = ocfs2_new_path(et->et_root_bh, et->et_root_el); | 5231 | path = ocfs2_new_path_from_et(et); |
| 5139 | if (!path) { | 5232 | if (!path) { |
| 5140 | ret = -ENOMEM; | 5233 | ret = -ENOMEM; |
| 5141 | mlog_errno(ret); | 5234 | mlog_errno(ret); |
| @@ -5255,6 +5348,78 @@ out: | |||
| 5255 | return ret; | 5348 | return ret; |
| 5256 | } | 5349 | } |
| 5257 | 5350 | ||
| 5351 | int ocfs2_remove_btree_range(struct inode *inode, | ||
| 5352 | struct ocfs2_extent_tree *et, | ||
| 5353 | u32 cpos, u32 phys_cpos, u32 len, | ||
| 5354 | struct ocfs2_cached_dealloc_ctxt *dealloc) | ||
| 5355 | { | ||
| 5356 | int ret; | ||
| 5357 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | ||
| 5358 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
| 5359 | struct inode *tl_inode = osb->osb_tl_inode; | ||
| 5360 | handle_t *handle; | ||
| 5361 | struct ocfs2_alloc_context *meta_ac = NULL; | ||
| 5362 | |||
| 5363 | ret = ocfs2_lock_allocators(inode, et, 0, 1, NULL, &meta_ac); | ||
| 5364 | if (ret) { | ||
| 5365 | mlog_errno(ret); | ||
| 5366 | return ret; | ||
| 5367 | } | ||
| 5368 | |||
| 5369 | mutex_lock(&tl_inode->i_mutex); | ||
| 5370 | |||
| 5371 | if (ocfs2_truncate_log_needs_flush(osb)) { | ||
| 5372 | ret = __ocfs2_flush_truncate_log(osb); | ||
| 5373 | if (ret < 0) { | ||
| 5374 | mlog_errno(ret); | ||
| 5375 | goto out; | ||
| 5376 | } | ||
| 5377 | } | ||
| 5378 | |||
| 5379 | handle = ocfs2_start_trans(osb, ocfs2_remove_extent_credits(osb->sb)); | ||
| 5380 | if (IS_ERR(handle)) { | ||
| 5381 | ret = PTR_ERR(handle); | ||
| 5382 | mlog_errno(ret); | ||
| 5383 | goto out; | ||
| 5384 | } | ||
| 5385 | |||
| 5386 | ret = ocfs2_et_root_journal_access(handle, inode, et, | ||
| 5387 | OCFS2_JOURNAL_ACCESS_WRITE); | ||
| 5388 | if (ret) { | ||
| 5389 | mlog_errno(ret); | ||
| 5390 | goto out; | ||
| 5391 | } | ||
| 5392 | |||
| 5393 | ret = ocfs2_remove_extent(inode, et, cpos, len, handle, meta_ac, | ||
| 5394 | dealloc); | ||
| 5395 | if (ret) { | ||
| 5396 | mlog_errno(ret); | ||
| 5397 | goto out_commit; | ||
| 5398 | } | ||
| 5399 | |||
| 5400 | ocfs2_et_update_clusters(inode, et, -len); | ||
| 5401 | |||
| 5402 | ret = ocfs2_journal_dirty(handle, et->et_root_bh); | ||
| 5403 | if (ret) { | ||
| 5404 | mlog_errno(ret); | ||
| 5405 | goto out_commit; | ||
| 5406 | } | ||
| 5407 | |||
| 5408 | ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len); | ||
| 5409 | if (ret) | ||
| 5410 | mlog_errno(ret); | ||
| 5411 | |||
| 5412 | out_commit: | ||
| 5413 | ocfs2_commit_trans(osb, handle); | ||
| 5414 | out: | ||
| 5415 | mutex_unlock(&tl_inode->i_mutex); | ||
| 5416 | |||
| 5417 | if (meta_ac) | ||
| 5418 | ocfs2_free_alloc_context(meta_ac); | ||
| 5419 | |||
| 5420 | return ret; | ||
| 5421 | } | ||
| 5422 | |||
| 5258 | int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) | 5423 | int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) |
| 5259 | { | 5424 | { |
| 5260 | struct buffer_head *tl_bh = osb->osb_tl_bh; | 5425 | struct buffer_head *tl_bh = osb->osb_tl_bh; |
| @@ -5308,13 +5473,13 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
| 5308 | start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); | 5473 | start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); |
| 5309 | 5474 | ||
| 5310 | di = (struct ocfs2_dinode *) tl_bh->b_data; | 5475 | di = (struct ocfs2_dinode *) tl_bh->b_data; |
| 5311 | tl = &di->id2.i_dealloc; | ||
| 5312 | if (!OCFS2_IS_VALID_DINODE(di)) { | ||
| 5313 | OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); | ||
| 5314 | status = -EIO; | ||
| 5315 | goto bail; | ||
| 5316 | } | ||
| 5317 | 5476 | ||
| 5477 | /* tl_bh is loaded from ocfs2_truncate_log_init(). It's validated | ||
| 5478 | * by the underlying call to ocfs2_read_inode_block(), so any | ||
| 5479 | * corruption is a code bug */ | ||
| 5480 | BUG_ON(!OCFS2_IS_VALID_DINODE(di)); | ||
| 5481 | |||
| 5482 | tl = &di->id2.i_dealloc; | ||
| 5318 | tl_count = le16_to_cpu(tl->tl_count); | 5483 | tl_count = le16_to_cpu(tl->tl_count); |
| 5319 | mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) || | 5484 | mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) || |
| 5320 | tl_count == 0, | 5485 | tl_count == 0, |
| @@ -5332,8 +5497,8 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
| 5332 | goto bail; | 5497 | goto bail; |
| 5333 | } | 5498 | } |
| 5334 | 5499 | ||
| 5335 | status = ocfs2_journal_access(handle, tl_inode, tl_bh, | 5500 | status = ocfs2_journal_access_di(handle, tl_inode, tl_bh, |
| 5336 | OCFS2_JOURNAL_ACCESS_WRITE); | 5501 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 5337 | if (status < 0) { | 5502 | if (status < 0) { |
| 5338 | mlog_errno(status); | 5503 | mlog_errno(status); |
| 5339 | goto bail; | 5504 | goto bail; |
| @@ -5394,8 +5559,8 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | |||
| 5394 | while (i >= 0) { | 5559 | while (i >= 0) { |
| 5395 | /* Caller has given us at least enough credits to | 5560 | /* Caller has given us at least enough credits to |
| 5396 | * update the truncate log dinode */ | 5561 | * update the truncate log dinode */ |
| 5397 | status = ocfs2_journal_access(handle, tl_inode, tl_bh, | 5562 | status = ocfs2_journal_access_di(handle, tl_inode, tl_bh, |
| 5398 | OCFS2_JOURNAL_ACCESS_WRITE); | 5563 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 5399 | if (status < 0) { | 5564 | if (status < 0) { |
| 5400 | mlog_errno(status); | 5565 | mlog_errno(status); |
| 5401 | goto bail; | 5566 | goto bail; |
| @@ -5464,13 +5629,13 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
| 5464 | BUG_ON(mutex_trylock(&tl_inode->i_mutex)); | 5629 | BUG_ON(mutex_trylock(&tl_inode->i_mutex)); |
| 5465 | 5630 | ||
| 5466 | di = (struct ocfs2_dinode *) tl_bh->b_data; | 5631 | di = (struct ocfs2_dinode *) tl_bh->b_data; |
| 5467 | tl = &di->id2.i_dealloc; | ||
| 5468 | if (!OCFS2_IS_VALID_DINODE(di)) { | ||
| 5469 | OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); | ||
| 5470 | status = -EIO; | ||
| 5471 | goto out; | ||
| 5472 | } | ||
| 5473 | 5632 | ||
| 5633 | /* tl_bh is loaded from ocfs2_truncate_log_init(). It's validated | ||
| 5634 | * by the underlying call to ocfs2_read_inode_block(), so any | ||
| 5635 | * corruption is a code bug */ | ||
| 5636 | BUG_ON(!OCFS2_IS_VALID_DINODE(di)); | ||
| 5637 | |||
| 5638 | tl = &di->id2.i_dealloc; | ||
| 5474 | num_to_flush = le16_to_cpu(tl->tl_used); | 5639 | num_to_flush = le16_to_cpu(tl->tl_used); |
| 5475 | mlog(0, "Flush %u records from truncate log #%llu\n", | 5640 | mlog(0, "Flush %u records from truncate log #%llu\n", |
| 5476 | num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); | 5641 | num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); |
| @@ -5586,7 +5751,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, | |||
| 5586 | goto bail; | 5751 | goto bail; |
| 5587 | } | 5752 | } |
| 5588 | 5753 | ||
| 5589 | status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); | 5754 | status = ocfs2_read_inode_block(inode, &bh); |
| 5590 | if (status < 0) { | 5755 | if (status < 0) { |
| 5591 | iput(inode); | 5756 | iput(inode); |
| 5592 | mlog_errno(status); | 5757 | mlog_errno(status); |
| @@ -5625,13 +5790,13 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 5625 | } | 5790 | } |
| 5626 | 5791 | ||
| 5627 | di = (struct ocfs2_dinode *) tl_bh->b_data; | 5792 | di = (struct ocfs2_dinode *) tl_bh->b_data; |
| 5628 | tl = &di->id2.i_dealloc; | ||
| 5629 | if (!OCFS2_IS_VALID_DINODE(di)) { | ||
| 5630 | OCFS2_RO_ON_INVALID_DINODE(tl_inode->i_sb, di); | ||
| 5631 | status = -EIO; | ||
| 5632 | goto bail; | ||
| 5633 | } | ||
| 5634 | 5793 | ||
| 5794 | /* tl_bh is loaded from ocfs2_get_truncate_log_info(). It's | ||
| 5795 | * validated by the underlying call to ocfs2_read_inode_block(), | ||
| 5796 | * so any corruption is a code bug */ | ||
| 5797 | BUG_ON(!OCFS2_IS_VALID_DINODE(di)); | ||
| 5798 | |||
| 5799 | tl = &di->id2.i_dealloc; | ||
| 5635 | if (le16_to_cpu(tl->tl_used)) { | 5800 | if (le16_to_cpu(tl->tl_used)) { |
| 5636 | mlog(0, "We'll have %u logs to recover\n", | 5801 | mlog(0, "We'll have %u logs to recover\n", |
| 5637 | le16_to_cpu(tl->tl_used)); | 5802 | le16_to_cpu(tl->tl_used)); |
| @@ -5651,6 +5816,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 5651 | * tl_used. */ | 5816 | * tl_used. */ |
| 5652 | tl->tl_used = 0; | 5817 | tl->tl_used = 0; |
| 5653 | 5818 | ||
| 5819 | ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check); | ||
| 5654 | status = ocfs2_write_block(osb, tl_bh, tl_inode); | 5820 | status = ocfs2_write_block(osb, tl_bh, tl_inode); |
| 5655 | if (status < 0) { | 5821 | if (status < 0) { |
| 5656 | mlog_errno(status); | 5822 | mlog_errno(status); |
| @@ -5800,7 +5966,10 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb) | |||
| 5800 | */ | 5966 | */ |
| 5801 | 5967 | ||
| 5802 | /* | 5968 | /* |
| 5803 | * Describes a single block free from a suballocator | 5969 | * Describe a single bit freed from a suballocator. For the block |
| 5970 | * suballocators, it represents one block. For the global cluster | ||
| 5971 | * allocator, it represents some clusters and free_bit indicates | ||
| 5972 | * clusters number. | ||
| 5804 | */ | 5973 | */ |
| 5805 | struct ocfs2_cached_block_free { | 5974 | struct ocfs2_cached_block_free { |
| 5806 | struct ocfs2_cached_block_free *free_next; | 5975 | struct ocfs2_cached_block_free *free_next; |
| @@ -5815,10 +5984,10 @@ struct ocfs2_per_slot_free_list { | |||
| 5815 | struct ocfs2_cached_block_free *f_first; | 5984 | struct ocfs2_cached_block_free *f_first; |
| 5816 | }; | 5985 | }; |
| 5817 | 5986 | ||
| 5818 | static int ocfs2_free_cached_items(struct ocfs2_super *osb, | 5987 | static int ocfs2_free_cached_blocks(struct ocfs2_super *osb, |
| 5819 | int sysfile_type, | 5988 | int sysfile_type, |
| 5820 | int slot, | 5989 | int slot, |
| 5821 | struct ocfs2_cached_block_free *head) | 5990 | struct ocfs2_cached_block_free *head) |
| 5822 | { | 5991 | { |
| 5823 | int ret; | 5992 | int ret; |
| 5824 | u64 bg_blkno; | 5993 | u64 bg_blkno; |
| @@ -5893,6 +6062,82 @@ out: | |||
| 5893 | return ret; | 6062 | return ret; |
| 5894 | } | 6063 | } |
| 5895 | 6064 | ||
| 6065 | int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, | ||
| 6066 | u64 blkno, unsigned int bit) | ||
| 6067 | { | ||
| 6068 | int ret = 0; | ||
| 6069 | struct ocfs2_cached_block_free *item; | ||
| 6070 | |||
| 6071 | item = kmalloc(sizeof(*item), GFP_NOFS); | ||
| 6072 | if (item == NULL) { | ||
| 6073 | ret = -ENOMEM; | ||
| 6074 | mlog_errno(ret); | ||
| 6075 | return ret; | ||
| 6076 | } | ||
| 6077 | |||
| 6078 | mlog(0, "Insert clusters: (bit %u, blk %llu)\n", | ||
| 6079 | bit, (unsigned long long)blkno); | ||
| 6080 | |||
| 6081 | item->free_blk = blkno; | ||
| 6082 | item->free_bit = bit; | ||
| 6083 | item->free_next = ctxt->c_global_allocator; | ||
| 6084 | |||
| 6085 | ctxt->c_global_allocator = item; | ||
| 6086 | return ret; | ||
| 6087 | } | ||
| 6088 | |||
| 6089 | static int ocfs2_free_cached_clusters(struct ocfs2_super *osb, | ||
| 6090 | struct ocfs2_cached_block_free *head) | ||
| 6091 | { | ||
| 6092 | struct ocfs2_cached_block_free *tmp; | ||
| 6093 | struct inode *tl_inode = osb->osb_tl_inode; | ||
| 6094 | handle_t *handle; | ||
| 6095 | int ret = 0; | ||
| 6096 | |||
| 6097 | mutex_lock(&tl_inode->i_mutex); | ||
| 6098 | |||
| 6099 | while (head) { | ||
| 6100 | if (ocfs2_truncate_log_needs_flush(osb)) { | ||
| 6101 | ret = __ocfs2_flush_truncate_log(osb); | ||
| 6102 | if (ret < 0) { | ||
| 6103 | mlog_errno(ret); | ||
| 6104 | break; | ||
| 6105 | } | ||
| 6106 | } | ||
| 6107 | |||
| 6108 | handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE); | ||
| 6109 | if (IS_ERR(handle)) { | ||
| 6110 | ret = PTR_ERR(handle); | ||
| 6111 | mlog_errno(ret); | ||
| 6112 | break; | ||
| 6113 | } | ||
| 6114 | |||
| 6115 | ret = ocfs2_truncate_log_append(osb, handle, head->free_blk, | ||
| 6116 | head->free_bit); | ||
| 6117 | |||
| 6118 | ocfs2_commit_trans(osb, handle); | ||
| 6119 | tmp = head; | ||
| 6120 | head = head->free_next; | ||
| 6121 | kfree(tmp); | ||
| 6122 | |||
| 6123 | if (ret < 0) { | ||
| 6124 | mlog_errno(ret); | ||
| 6125 | break; | ||
| 6126 | } | ||
| 6127 | } | ||
| 6128 | |||
| 6129 | mutex_unlock(&tl_inode->i_mutex); | ||
| 6130 | |||
| 6131 | while (head) { | ||
| 6132 | /* Premature exit may have left some dangling items. */ | ||
| 6133 | tmp = head; | ||
| 6134 | head = head->free_next; | ||
| 6135 | kfree(tmp); | ||
| 6136 | } | ||
| 6137 | |||
| 6138 | return ret; | ||
| 6139 | } | ||
| 6140 | |||
| 5896 | int ocfs2_run_deallocs(struct ocfs2_super *osb, | 6141 | int ocfs2_run_deallocs(struct ocfs2_super *osb, |
| 5897 | struct ocfs2_cached_dealloc_ctxt *ctxt) | 6142 | struct ocfs2_cached_dealloc_ctxt *ctxt) |
| 5898 | { | 6143 | { |
| @@ -5908,8 +6153,10 @@ int ocfs2_run_deallocs(struct ocfs2_super *osb, | |||
| 5908 | if (fl->f_first) { | 6153 | if (fl->f_first) { |
| 5909 | mlog(0, "Free items: (type %u, slot %d)\n", | 6154 | mlog(0, "Free items: (type %u, slot %d)\n", |
| 5910 | fl->f_inode_type, fl->f_slot); | 6155 | fl->f_inode_type, fl->f_slot); |
| 5911 | ret2 = ocfs2_free_cached_items(osb, fl->f_inode_type, | 6156 | ret2 = ocfs2_free_cached_blocks(osb, |
| 5912 | fl->f_slot, fl->f_first); | 6157 | fl->f_inode_type, |
| 6158 | fl->f_slot, | ||
| 6159 | fl->f_first); | ||
| 5913 | if (ret2) | 6160 | if (ret2) |
| 5914 | mlog_errno(ret2); | 6161 | mlog_errno(ret2); |
| 5915 | if (!ret) | 6162 | if (!ret) |
| @@ -5920,6 +6167,17 @@ int ocfs2_run_deallocs(struct ocfs2_super *osb, | |||
| 5920 | kfree(fl); | 6167 | kfree(fl); |
| 5921 | } | 6168 | } |
| 5922 | 6169 | ||
| 6170 | if (ctxt->c_global_allocator) { | ||
| 6171 | ret2 = ocfs2_free_cached_clusters(osb, | ||
| 6172 | ctxt->c_global_allocator); | ||
| 6173 | if (ret2) | ||
| 6174 | mlog_errno(ret2); | ||
| 6175 | if (!ret) | ||
| 6176 | ret = ret2; | ||
| 6177 | |||
| 6178 | ctxt->c_global_allocator = NULL; | ||
| 6179 | } | ||
| 6180 | |||
| 5923 | return ret; | 6181 | return ret; |
| 5924 | } | 6182 | } |
| 5925 | 6183 | ||
| @@ -6075,11 +6333,10 @@ static int ocfs2_find_new_last_ext_blk(struct inode *inode, | |||
| 6075 | 6333 | ||
| 6076 | eb = (struct ocfs2_extent_block *) bh->b_data; | 6334 | eb = (struct ocfs2_extent_block *) bh->b_data; |
| 6077 | el = &eb->h_list; | 6335 | el = &eb->h_list; |
| 6078 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | 6336 | |
| 6079 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | 6337 | /* ocfs2_find_leaf() gets the eb from ocfs2_read_extent_block(). |
| 6080 | ret = -EROFS; | 6338 | * Any corruption is a code bug. */ |
| 6081 | goto out; | 6339 | BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb)); |
| 6082 | } | ||
| 6083 | 6340 | ||
| 6084 | *new_last_eb = bh; | 6341 | *new_last_eb = bh; |
| 6085 | get_bh(*new_last_eb); | 6342 | get_bh(*new_last_eb); |
| @@ -6326,8 +6583,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb, | |||
| 6326 | } | 6583 | } |
| 6327 | 6584 | ||
| 6328 | if (last_eb_bh) { | 6585 | if (last_eb_bh) { |
| 6329 | status = ocfs2_journal_access(handle, inode, last_eb_bh, | 6586 | status = ocfs2_journal_access_eb(handle, inode, last_eb_bh, |
| 6330 | OCFS2_JOURNAL_ACCESS_WRITE); | 6587 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 6331 | if (status < 0) { | 6588 | if (status < 0) { |
| 6332 | mlog_errno(status); | 6589 | mlog_errno(status); |
| 6333 | goto bail; | 6590 | goto bail; |
| @@ -6350,6 +6607,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb, | |||
| 6350 | goto bail; | 6607 | goto bail; |
| 6351 | } | 6608 | } |
| 6352 | 6609 | ||
| 6610 | vfs_dq_free_space_nodirty(inode, | ||
| 6611 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_del)); | ||
| 6353 | spin_lock(&OCFS2_I(inode)->ip_lock); | 6612 | spin_lock(&OCFS2_I(inode)->ip_lock); |
| 6354 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - | 6613 | OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - |
| 6355 | clusters_to_del; | 6614 | clusters_to_del; |
| @@ -6436,11 +6695,6 @@ static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | |||
| 6436 | mlog_errno(ret); | 6695 | mlog_errno(ret); |
| 6437 | else if (ocfs2_should_order_data(inode)) { | 6696 | else if (ocfs2_should_order_data(inode)) { |
| 6438 | ret = ocfs2_jbd2_file_inode(handle, inode); | 6697 | ret = ocfs2_jbd2_file_inode(handle, inode); |
| 6439 | #ifdef CONFIG_OCFS2_COMPAT_JBD | ||
| 6440 | ret = walk_page_buffers(handle, page_buffers(page), | ||
| 6441 | from, to, &partial, | ||
| 6442 | ocfs2_journal_dirty_data); | ||
| 6443 | #endif | ||
| 6444 | if (ret < 0) | 6698 | if (ret < 0) |
| 6445 | mlog_errno(ret); | 6699 | mlog_errno(ret); |
| 6446 | } | 6700 | } |
| @@ -6663,6 +6917,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
| 6663 | struct page **pages = NULL; | 6917 | struct page **pages = NULL; |
| 6664 | loff_t end = osb->s_clustersize; | 6918 | loff_t end = osb->s_clustersize; |
| 6665 | struct ocfs2_extent_tree et; | 6919 | struct ocfs2_extent_tree et; |
| 6920 | int did_quota = 0; | ||
| 6666 | 6921 | ||
| 6667 | has_data = i_size_read(inode) ? 1 : 0; | 6922 | has_data = i_size_read(inode) ? 1 : 0; |
| 6668 | 6923 | ||
| @@ -6682,15 +6937,16 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
| 6682 | } | 6937 | } |
| 6683 | } | 6938 | } |
| 6684 | 6939 | ||
| 6685 | handle = ocfs2_start_trans(osb, OCFS2_INLINE_TO_EXTENTS_CREDITS); | 6940 | handle = ocfs2_start_trans(osb, |
| 6941 | ocfs2_inline_to_extents_credits(osb->sb)); | ||
| 6686 | if (IS_ERR(handle)) { | 6942 | if (IS_ERR(handle)) { |
| 6687 | ret = PTR_ERR(handle); | 6943 | ret = PTR_ERR(handle); |
| 6688 | mlog_errno(ret); | 6944 | mlog_errno(ret); |
| 6689 | goto out_unlock; | 6945 | goto out_unlock; |
| 6690 | } | 6946 | } |
| 6691 | 6947 | ||
| 6692 | ret = ocfs2_journal_access(handle, inode, di_bh, | 6948 | ret = ocfs2_journal_access_di(handle, inode, di_bh, |
| 6693 | OCFS2_JOURNAL_ACCESS_WRITE); | 6949 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 6694 | if (ret) { | 6950 | if (ret) { |
| 6695 | mlog_errno(ret); | 6951 | mlog_errno(ret); |
| 6696 | goto out_commit; | 6952 | goto out_commit; |
| @@ -6701,6 +6957,13 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
| 6701 | unsigned int page_end; | 6957 | unsigned int page_end; |
| 6702 | u64 phys; | 6958 | u64 phys; |
| 6703 | 6959 | ||
| 6960 | if (vfs_dq_alloc_space_nodirty(inode, | ||
| 6961 | ocfs2_clusters_to_bytes(osb->sb, 1))) { | ||
| 6962 | ret = -EDQUOT; | ||
| 6963 | goto out_commit; | ||
| 6964 | } | ||
| 6965 | did_quota = 1; | ||
| 6966 | |||
| 6704 | ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, | 6967 | ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, |
| 6705 | &num); | 6968 | &num); |
| 6706 | if (ret) { | 6969 | if (ret) { |
| @@ -6774,6 +7037,10 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, | |||
| 6774 | } | 7037 | } |
| 6775 | 7038 | ||
| 6776 | out_commit: | 7039 | out_commit: |
| 7040 | if (ret < 0 && did_quota) | ||
| 7041 | vfs_dq_free_space_nodirty(inode, | ||
| 7042 | ocfs2_clusters_to_bytes(osb->sb, 1)); | ||
| 7043 | |||
| 6777 | ocfs2_commit_trans(osb, handle); | 7044 | ocfs2_commit_trans(osb, handle); |
| 6778 | 7045 | ||
| 6779 | out_unlock: | 7046 | out_unlock: |
| @@ -6813,7 +7080,8 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
| 6813 | new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, | 7080 | new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, |
| 6814 | i_size_read(inode)); | 7081 | i_size_read(inode)); |
| 6815 | 7082 | ||
| 6816 | path = ocfs2_new_path(fe_bh, &di->id2.i_list); | 7083 | path = ocfs2_new_path(fe_bh, &di->id2.i_list, |
| 7084 | ocfs2_journal_access_di); | ||
| 6817 | if (!path) { | 7085 | if (!path) { |
| 6818 | status = -ENOMEM; | 7086 | status = -ENOMEM; |
| 6819 | mlog_errno(status); | 7087 | mlog_errno(status); |
| @@ -6984,20 +7252,14 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, | |||
| 6984 | ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); | 7252 | ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); |
| 6985 | 7253 | ||
| 6986 | if (fe->id2.i_list.l_tree_depth) { | 7254 | if (fe->id2.i_list.l_tree_depth) { |
| 6987 | status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk), | 7255 | status = ocfs2_read_extent_block(inode, |
| 6988 | &last_eb_bh); | 7256 | le64_to_cpu(fe->i_last_eb_blk), |
| 7257 | &last_eb_bh); | ||
| 6989 | if (status < 0) { | 7258 | if (status < 0) { |
| 6990 | mlog_errno(status); | 7259 | mlog_errno(status); |
| 6991 | goto bail; | 7260 | goto bail; |
| 6992 | } | 7261 | } |
| 6993 | eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; | 7262 | eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; |
| 6994 | if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { | ||
| 6995 | OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); | ||
| 6996 | |||
| 6997 | brelse(last_eb_bh); | ||
| 6998 | status = -EIO; | ||
| 6999 | goto bail; | ||
| 7000 | } | ||
| 7001 | } | 7263 | } |
| 7002 | 7264 | ||
| 7003 | (*tc)->tc_last_eb_bh = last_eb_bh; | 7265 | (*tc)->tc_last_eb_bh = last_eb_bh; |
| @@ -7052,8 +7314,8 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh, | |||
| 7052 | goto out; | 7314 | goto out; |
| 7053 | } | 7315 | } |
| 7054 | 7316 | ||
| 7055 | ret = ocfs2_journal_access(handle, inode, di_bh, | 7317 | ret = ocfs2_journal_access_di(handle, inode, di_bh, |
| 7056 | OCFS2_JOURNAL_ACCESS_WRITE); | 7318 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 7057 | if (ret) { | 7319 | if (ret) { |
| 7058 | mlog_errno(ret); | 7320 | mlog_errno(ret); |
| 7059 | goto out_commit; | 7321 | goto out_commit; |
