alloc.c (811f933df1e55615fd0bb4818f31e3868a8e6e23) | alloc.c (e7d4cb6bc19658646357eeff134645cd9bc3479f) |
---|---|
1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * alloc.c 5 * 6 * Extent allocs and frees 7 * 8 * Copyright (C) 2002, 2004 Oracle. All rights reserved. --- 35 unchanged lines hidden (view full) --- 44#include "suballoc.h" 45#include "sysfile.h" 46#include "file.h" 47#include "super.h" 48#include "uptodate.h" 49 50#include "buffer_head_io.h" 51 | 1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * alloc.c 5 * 6 * Extent allocs and frees 7 * 8 * Copyright (C) 2002, 2004 Oracle. All rights reserved. --- 35 unchanged lines hidden (view full) --- 44#include "suballoc.h" 45#include "sysfile.h" 46#include "file.h" 47#include "super.h" 48#include "uptodate.h" 49 50#include "buffer_head_io.h" 51 |
52/* 53 * ocfs2_extent_tree and ocfs2_extent_tree_operations are used to abstract 54 * the b-tree operations in ocfs2. Now all the b-tree operations are not 55 * limited to ocfs2_dinode only. Any data which need to allocate clusters 56 * to store can use b-tree. And it only needs to implement its ocfs2_extent_tree 57 * and operation. 58 * 59 * ocfs2_extent_tree contains info for the root of the b-tree, it must have a 60 * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree 61 * functions. 62 * ocfs2_extent_tree_operations abstract the normal operations we do for 63 * the root of extent b-tree. 64 */ 65struct ocfs2_extent_tree; 66 67struct ocfs2_extent_tree_operations { 68 void (*set_last_eb_blk) (struct ocfs2_extent_tree *et, u64 blkno); 69 u64 (*get_last_eb_blk) (struct ocfs2_extent_tree *et); 70 void (*update_clusters) (struct inode *inode, 71 struct ocfs2_extent_tree *et, 72 u32 new_clusters); 73 int (*sanity_check) (struct inode *inode, struct ocfs2_extent_tree *et); 74}; 75 76struct ocfs2_extent_tree { 77 enum ocfs2_extent_tree_type type; 78 struct ocfs2_extent_tree_operations *eops; 79 struct buffer_head *root_bh; 80 struct ocfs2_extent_list *root_el; 81}; 82 83static void ocfs2_dinode_set_last_eb_blk(struct ocfs2_extent_tree *et, 84 u64 blkno) 85{ 86 struct ocfs2_dinode *di = (struct ocfs2_dinode *)et->root_bh->b_data; 87 88 BUG_ON(et->type != OCFS2_DINODE_EXTENT); 89 di->i_last_eb_blk = cpu_to_le64(blkno); 90} 91 92static u64 ocfs2_dinode_get_last_eb_blk(struct ocfs2_extent_tree *et) 93{ 94 struct ocfs2_dinode *di = (struct ocfs2_dinode *)et->root_bh->b_data; 95 96 BUG_ON(et->type != OCFS2_DINODE_EXTENT); 97 return le64_to_cpu(di->i_last_eb_blk); 98} 99 100static void ocfs2_dinode_update_clusters(struct inode *inode, 101 struct ocfs2_extent_tree *et, 102 u32 clusters) 103{ 104 struct ocfs2_dinode *di = 105 (struct ocfs2_dinode *)et->root_bh->b_data; 106 107 le32_add_cpu(&di->i_clusters, clusters); 108 spin_lock(&OCFS2_I(inode)->ip_lock); 109 OCFS2_I(inode)->ip_clusters = le32_to_cpu(di->i_clusters); 110 spin_unlock(&OCFS2_I(inode)->ip_lock); 111} 112 113static int ocfs2_dinode_sanity_check(struct inode *inode, 114 struct ocfs2_extent_tree *et) 115{ 116 int ret = 0; 117 struct ocfs2_dinode *di; 118 119 BUG_ON(et->type != OCFS2_DINODE_EXTENT); 120 121 di = (struct ocfs2_dinode *)et->root_bh->b_data; 122 if (!OCFS2_IS_VALID_DINODE(di)) { 123 ret = -EIO; 124 ocfs2_error(inode->i_sb, 125 "Inode %llu has invalid path root", 126 (unsigned long long)OCFS2_I(inode)->ip_blkno); 127 } 128 129 return ret; 130} 131 132static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = { 133 .set_last_eb_blk = ocfs2_dinode_set_last_eb_blk, 134 .get_last_eb_blk = ocfs2_dinode_get_last_eb_blk, 135 .update_clusters = ocfs2_dinode_update_clusters, 136 .sanity_check = ocfs2_dinode_sanity_check, 137}; 138 139static struct ocfs2_extent_tree* 140 ocfs2_new_extent_tree(struct buffer_head *bh, 141 enum ocfs2_extent_tree_type et_type) 142{ 143 struct ocfs2_extent_tree *et; 144 145 et = kzalloc(sizeof(*et), GFP_NOFS); 146 if (!et) 147 return NULL; 148 149 et->type = et_type; 150 get_bh(bh); 151 et->root_bh = bh; 152 153 /* current we only support dinode extent. */ 154 BUG_ON(et->type != OCFS2_DINODE_EXTENT); 155 if (et_type == OCFS2_DINODE_EXTENT) { 156 et->root_el = &((struct ocfs2_dinode *)bh->b_data)->id2.i_list; 157 et->eops = &ocfs2_dinode_et_ops; 158 } 159 160 return et; 161} 162 163static void ocfs2_free_extent_tree(struct ocfs2_extent_tree *et) 164{ 165 if (et) { 166 brelse(et->root_bh); 167 kfree(et); 168 } 169} 170 171static inline void ocfs2_set_last_eb_blk(struct ocfs2_extent_tree *et, 172 u64 new_last_eb_blk) 173{ 174 et->eops->set_last_eb_blk(et, new_last_eb_blk); 175} 176 177static inline u64 ocfs2_get_last_eb_blk(struct ocfs2_extent_tree *et) 178{ 179 return et->eops->get_last_eb_blk(et); 180} 181 182static inline void ocfs2_update_clusters(struct inode *inode, 183 struct ocfs2_extent_tree *et, 184 u32 clusters) 185{ 186 et->eops->update_clusters(inode, et, clusters); 187} 188 |
|
52static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc); 53static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt, 54 struct ocfs2_extent_block *eb); 55 56/* 57 * Structures which describe a path through a btree, and functions to 58 * manipulate them. 59 * --- 140 unchanged lines hidden (view full) --- 200 path_root_bh(path) = root_bh; 201 path_root_el(path) = root_el; 202 } 203 204 return path; 205} 206 207/* | 189static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc); 190static int ocfs2_cache_extent_block_free(struct ocfs2_cached_dealloc_ctxt *ctxt, 191 struct ocfs2_extent_block *eb); 192 193/* 194 * Structures which describe a path through a btree, and functions to 195 * manipulate them. 196 * --- 140 unchanged lines hidden (view full) --- 337 path_root_bh(path) = root_bh; 338 path_root_el(path) = root_el; 339 } 340 341 return path; 342} 343 344/* |
208 * Allocate and initialize a new path based on a disk inode tree. 209 */ 210static struct ocfs2_path *ocfs2_new_inode_path(struct buffer_head *di_bh) 211{ 212 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 213 struct ocfs2_extent_list *el = &di->id2.i_list; 214 215 return ocfs2_new_path(di_bh, el); 216} 217 218/* | |
219 * Convenience function to journal all components in a path. 220 */ 221static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle, 222 struct ocfs2_path *path) 223{ 224 int i, ret = 0; 225 226 if (!path) --- 136 unchanged lines hidden (view full) --- 363 int c_split_covers_rec; 364}; 365 366/* 367 * How many free extents have we got before we need more meta data? 368 */ 369int ocfs2_num_free_extents(struct ocfs2_super *osb, 370 struct inode *inode, | 345 * Convenience function to journal all components in a path. 346 */ 347static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle, 348 struct ocfs2_path *path) 349{ 350 int i, ret = 0; 351 352 if (!path) --- 136 unchanged lines hidden (view full) --- 489 int c_split_covers_rec; 490}; 491 492/* 493 * How many free extents have we got before we need more meta data? 494 */ 495int ocfs2_num_free_extents(struct ocfs2_super *osb, 496 struct inode *inode, |
371 struct buffer_head *bh) | 497 struct buffer_head *root_bh, 498 enum ocfs2_extent_tree_type type) |
372{ 373 int retval; | 499{ 500 int retval; |
374 struct ocfs2_extent_list *el; | 501 struct ocfs2_extent_list *el = NULL; |
375 struct ocfs2_extent_block *eb; 376 struct buffer_head *eb_bh = NULL; | 502 struct ocfs2_extent_block *eb; 503 struct buffer_head *eb_bh = NULL; |
377 struct ocfs2_dinode *fe = (struct ocfs2_dinode *)bh->b_data; | 504 u64 last_eb_blk = 0; |
378 379 mlog_entry_void(); 380 | 505 506 mlog_entry_void(); 507 |
381 if (!OCFS2_IS_VALID_DINODE(fe)) { 382 OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); 383 retval = -EIO; 384 goto bail; | 508 if (type == OCFS2_DINODE_EXTENT) { 509 struct ocfs2_dinode *fe = 510 (struct ocfs2_dinode *)root_bh->b_data; 511 if (!OCFS2_IS_VALID_DINODE(fe)) { 512 OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); 513 retval = -EIO; 514 goto bail; 515 } 516 517 if (fe->i_last_eb_blk) 518 last_eb_blk = le64_to_cpu(fe->i_last_eb_blk); 519 el = &fe->id2.i_list; |
385 } 386 | 520 } 521 |
387 if (fe->i_last_eb_blk) { 388 retval = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), | 522 if (last_eb_blk) { 523 retval = ocfs2_read_block(osb, last_eb_blk, |
389 &eb_bh, OCFS2_BH_CACHED, inode); 390 if (retval < 0) { 391 mlog_errno(retval); 392 goto bail; 393 } 394 eb = (struct ocfs2_extent_block *) eb_bh->b_data; 395 el = &eb->h_list; | 524 &eb_bh, OCFS2_BH_CACHED, inode); 525 if (retval < 0) { 526 mlog_errno(retval); 527 goto bail; 528 } 529 eb = (struct ocfs2_extent_block *) eb_bh->b_data; 530 el = &eb->h_list; |
396 } else 397 el = &fe->id2.i_list; | 531 } |
398 399 BUG_ON(el->l_tree_depth != 0); 400 401 retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); 402bail: 403 if (eb_bh) 404 brelse(eb_bh); 405 --- 121 unchanged lines hidden (view full) --- 527 * for the new last extent block. 528 * 529 * the new branch will be 'empty' in the sense that every block will 530 * contain a single record with cluster count == 0. 531 */ 532static int ocfs2_add_branch(struct ocfs2_super *osb, 533 handle_t *handle, 534 struct inode *inode, | 532 533 BUG_ON(el->l_tree_depth != 0); 534 535 retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); 536bail: 537 if (eb_bh) 538 brelse(eb_bh); 539 --- 121 unchanged lines hidden (view full) --- 661 * for the new last extent block. 662 * 663 * the new branch will be 'empty' in the sense that every block will 664 * contain a single record with cluster count == 0. 665 */ 666static int ocfs2_add_branch(struct ocfs2_super *osb, 667 handle_t *handle, 668 struct inode *inode, |
535 struct buffer_head *fe_bh, | 669 struct ocfs2_extent_tree *et, |
536 struct buffer_head *eb_bh, 537 struct buffer_head **last_eb_bh, 538 struct ocfs2_alloc_context *meta_ac) 539{ 540 int status, new_blocks, i; 541 u64 next_blkno, new_last_eb_blk; 542 struct buffer_head *bh; 543 struct buffer_head **new_eb_bhs = NULL; | 670 struct buffer_head *eb_bh, 671 struct buffer_head **last_eb_bh, 672 struct ocfs2_alloc_context *meta_ac) 673{ 674 int status, new_blocks, i; 675 u64 next_blkno, new_last_eb_blk; 676 struct buffer_head *bh; 677 struct buffer_head **new_eb_bhs = NULL; |
544 struct ocfs2_dinode *fe; | |
545 struct ocfs2_extent_block *eb; 546 struct ocfs2_extent_list *eb_el; 547 struct ocfs2_extent_list *el; 548 u32 new_cpos; 549 550 mlog_entry_void(); 551 552 BUG_ON(!last_eb_bh || !*last_eb_bh); 553 | 678 struct ocfs2_extent_block *eb; 679 struct ocfs2_extent_list *eb_el; 680 struct ocfs2_extent_list *el; 681 u32 new_cpos; 682 683 mlog_entry_void(); 684 685 BUG_ON(!last_eb_bh || !*last_eb_bh); 686 |
554 fe = (struct ocfs2_dinode *) fe_bh->b_data; 555 | |
556 if (eb_bh) { 557 eb = (struct ocfs2_extent_block *) eb_bh->b_data; 558 el = &eb->h_list; 559 } else | 687 if (eb_bh) { 688 eb = (struct ocfs2_extent_block *) eb_bh->b_data; 689 el = &eb->h_list; 690 } else |
560 el = &fe->id2.i_list; | 691 el = et->root_el; |
561 562 /* we never add a branch to a leaf. */ 563 BUG_ON(!el->l_tree_depth); 564 565 new_blocks = le16_to_cpu(el->l_tree_depth); 566 567 /* allocate the number of new eb blocks we need */ 568 new_eb_bhs = kcalloc(new_blocks, sizeof(struct buffer_head *), --- 73 unchanged lines hidden (view full) --- 642 * handle (in which case we would never be here) so reserving 643 * the write with journal_access is all we need to do. */ 644 status = ocfs2_journal_access(handle, inode, *last_eb_bh, 645 OCFS2_JOURNAL_ACCESS_WRITE); 646 if (status < 0) { 647 mlog_errno(status); 648 goto bail; 649 } | 692 693 /* we never add a branch to a leaf. */ 694 BUG_ON(!el->l_tree_depth); 695 696 new_blocks = le16_to_cpu(el->l_tree_depth); 697 698 /* allocate the number of new eb blocks we need */ 699 new_eb_bhs = kcalloc(new_blocks, sizeof(struct buffer_head *), --- 73 unchanged lines hidden (view full) --- 773 * handle (in which case we would never be here) so reserving 774 * the write with journal_access is all we need to do. */ 775 status = ocfs2_journal_access(handle, inode, *last_eb_bh, 776 OCFS2_JOURNAL_ACCESS_WRITE); 777 if (status < 0) { 778 mlog_errno(status); 779 goto bail; 780 } |
650 status = ocfs2_journal_access(handle, inode, fe_bh, | 781 status = ocfs2_journal_access(handle, inode, et->root_bh, |
651 OCFS2_JOURNAL_ACCESS_WRITE); 652 if (status < 0) { 653 mlog_errno(status); 654 goto bail; 655 } 656 if (eb_bh) { 657 status = ocfs2_journal_access(handle, inode, eb_bh, 658 OCFS2_JOURNAL_ACCESS_WRITE); 659 if (status < 0) { 660 mlog_errno(status); 661 goto bail; 662 } 663 } 664 665 /* Link the new branch into the rest of the tree (el will | 782 OCFS2_JOURNAL_ACCESS_WRITE); 783 if (status < 0) { 784 mlog_errno(status); 785 goto bail; 786 } 787 if (eb_bh) { 788 status = ocfs2_journal_access(handle, inode, eb_bh, 789 OCFS2_JOURNAL_ACCESS_WRITE); 790 if (status < 0) { 791 mlog_errno(status); 792 goto bail; 793 } 794 } 795 796 /* Link the new branch into the rest of the tree (el will |
666 * either be on the fe, or the extent block passed in. */ | 797 * either be on the root_bh, or the extent block passed in. */ |
667 i = le16_to_cpu(el->l_next_free_rec); 668 el->l_recs[i].e_blkno = cpu_to_le64(next_blkno); 669 el->l_recs[i].e_cpos = cpu_to_le32(new_cpos); 670 el->l_recs[i].e_int_clusters = 0; 671 le16_add_cpu(&el->l_next_free_rec, 1); 672 673 /* fe needs a new last extent block pointer, as does the 674 * next_leaf on the previously last-extent-block. */ | 798 i = le16_to_cpu(el->l_next_free_rec); 799 el->l_recs[i].e_blkno = cpu_to_le64(next_blkno); 800 el->l_recs[i].e_cpos = cpu_to_le32(new_cpos); 801 el->l_recs[i].e_int_clusters = 0; 802 le16_add_cpu(&el->l_next_free_rec, 1); 803 804 /* fe needs a new last extent block pointer, as does the 805 * next_leaf on the previously last-extent-block. */ |
675 fe->i_last_eb_blk = cpu_to_le64(new_last_eb_blk); | 806 ocfs2_set_last_eb_blk(et, new_last_eb_blk); |
676 677 eb = (struct ocfs2_extent_block *) (*last_eb_bh)->b_data; 678 eb->h_next_leaf_blk = cpu_to_le64(new_last_eb_blk); 679 680 status = ocfs2_journal_dirty(handle, *last_eb_bh); 681 if (status < 0) 682 mlog_errno(status); | 807 808 eb = (struct ocfs2_extent_block *) (*last_eb_bh)->b_data; 809 eb->h_next_leaf_blk = cpu_to_le64(new_last_eb_blk); 810 811 status = ocfs2_journal_dirty(handle, *last_eb_bh); 812 if (status < 0) 813 mlog_errno(status); |
683 status = ocfs2_journal_dirty(handle, fe_bh); | 814 status = ocfs2_journal_dirty(handle, et->root_bh); |
684 if (status < 0) 685 mlog_errno(status); 686 if (eb_bh) { 687 status = ocfs2_journal_dirty(handle, eb_bh); 688 if (status < 0) 689 mlog_errno(status); 690 } 691 --- 21 unchanged lines hidden (view full) --- 713/* 714 * adds another level to the allocation tree. 715 * returns back the new extent block so you can add a branch to it 716 * after this call. 717 */ 718static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, 719 handle_t *handle, 720 struct inode *inode, | 815 if (status < 0) 816 mlog_errno(status); 817 if (eb_bh) { 818 status = ocfs2_journal_dirty(handle, eb_bh); 819 if (status < 0) 820 mlog_errno(status); 821 } 822 --- 21 unchanged lines hidden (view full) --- 844/* 845 * adds another level to the allocation tree. 846 * returns back the new extent block so you can add a branch to it 847 * after this call. 848 */ 849static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, 850 handle_t *handle, 851 struct inode *inode, |
721 struct buffer_head *fe_bh, | 852 struct ocfs2_extent_tree *et, |
722 struct ocfs2_alloc_context *meta_ac, 723 struct buffer_head **ret_new_eb_bh) 724{ 725 int status, i; 726 u32 new_clusters; 727 struct buffer_head *new_eb_bh = NULL; | 853 struct ocfs2_alloc_context *meta_ac, 854 struct buffer_head **ret_new_eb_bh) 855{ 856 int status, i; 857 u32 new_clusters; 858 struct buffer_head *new_eb_bh = NULL; |
728 struct ocfs2_dinode *fe; | |
729 struct ocfs2_extent_block *eb; | 859 struct ocfs2_extent_block *eb; |
730 struct ocfs2_extent_list *fe_el; | 860 struct ocfs2_extent_list *root_el; |
731 struct ocfs2_extent_list *eb_el; 732 733 mlog_entry_void(); 734 735 status = ocfs2_create_new_meta_bhs(osb, handle, inode, 1, meta_ac, 736 &new_eb_bh); 737 if (status < 0) { 738 mlog_errno(status); 739 goto bail; 740 } 741 742 eb = (struct ocfs2_extent_block *) new_eb_bh->b_data; 743 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { 744 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); 745 status = -EIO; 746 goto bail; 747 } 748 749 eb_el = &eb->h_list; | 861 struct ocfs2_extent_list *eb_el; 862 863 mlog_entry_void(); 864 865 status = ocfs2_create_new_meta_bhs(osb, handle, inode, 1, meta_ac, 866 &new_eb_bh); 867 if (status < 0) { 868 mlog_errno(status); 869 goto bail; 870 } 871 872 eb = (struct ocfs2_extent_block *) new_eb_bh->b_data; 873 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { 874 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); 875 status = -EIO; 876 goto bail; 877 } 878 879 eb_el = &eb->h_list; |
750 fe = (struct ocfs2_dinode *) fe_bh->b_data; 751 fe_el = &fe->id2.i_list; | 880 root_el = et->root_el; |
752 753 status = ocfs2_journal_access(handle, inode, new_eb_bh, 754 OCFS2_JOURNAL_ACCESS_CREATE); 755 if (status < 0) { 756 mlog_errno(status); 757 goto bail; 758 } 759 | 881 882 status = ocfs2_journal_access(handle, inode, new_eb_bh, 883 OCFS2_JOURNAL_ACCESS_CREATE); 884 if (status < 0) { 885 mlog_errno(status); 886 goto bail; 887 } 888 |
760 /* copy the fe data into the new extent block */ 761 eb_el->l_tree_depth = fe_el->l_tree_depth; 762 eb_el->l_next_free_rec = fe_el->l_next_free_rec; 763 for(i = 0; i < le16_to_cpu(fe_el->l_next_free_rec); i++) 764 eb_el->l_recs[i] = fe_el->l_recs[i]; | 889 /* copy the root extent list data into the new extent block */ 890 eb_el->l_tree_depth = root_el->l_tree_depth; 891 eb_el->l_next_free_rec = root_el->l_next_free_rec; 892 for (i = 0; i < le16_to_cpu(root_el->l_next_free_rec); i++) 893 eb_el->l_recs[i] = root_el->l_recs[i]; |
765 766 status = ocfs2_journal_dirty(handle, new_eb_bh); 767 if (status < 0) { 768 mlog_errno(status); 769 goto bail; 770 } 771 | 894 895 status = ocfs2_journal_dirty(handle, new_eb_bh); 896 if (status < 0) { 897 mlog_errno(status); 898 goto bail; 899 } 900 |
772 status = ocfs2_journal_access(handle, inode, fe_bh, | 901 status = ocfs2_journal_access(handle, inode, et->root_bh, |
773 OCFS2_JOURNAL_ACCESS_WRITE); 774 if (status < 0) { 775 mlog_errno(status); 776 goto bail; 777 } 778 779 new_clusters = ocfs2_sum_rightmost_rec(eb_el); 780 | 902 OCFS2_JOURNAL_ACCESS_WRITE); 903 if (status < 0) { 904 mlog_errno(status); 905 goto bail; 906 } 907 908 new_clusters = ocfs2_sum_rightmost_rec(eb_el); 909 |
781 /* update fe now */ 782 le16_add_cpu(&fe_el->l_tree_depth, 1); 783 fe_el->l_recs[0].e_cpos = 0; 784 fe_el->l_recs[0].e_blkno = eb->h_blkno; 785 fe_el->l_recs[0].e_int_clusters = cpu_to_le32(new_clusters); 786 for(i = 1; i < le16_to_cpu(fe_el->l_next_free_rec); i++) 787 memset(&fe_el->l_recs[i], 0, sizeof(struct ocfs2_extent_rec)); 788 fe_el->l_next_free_rec = cpu_to_le16(1); | 910 /* update root_bh now */ 911 le16_add_cpu(&root_el->l_tree_depth, 1); 912 root_el->l_recs[0].e_cpos = 0; 913 root_el->l_recs[0].e_blkno = eb->h_blkno; 914 root_el->l_recs[0].e_int_clusters = cpu_to_le32(new_clusters); 915 for (i = 1; i < le16_to_cpu(root_el->l_next_free_rec); i++) 916 memset(&root_el->l_recs[i], 0, sizeof(struct ocfs2_extent_rec)); 917 root_el->l_next_free_rec = cpu_to_le16(1); |
789 790 /* If this is our 1st tree depth shift, then last_eb_blk 791 * becomes the allocated extent block */ | 918 919 /* If this is our 1st tree depth shift, then last_eb_blk 920 * becomes the allocated extent block */ |
792 if (fe_el->l_tree_depth == cpu_to_le16(1)) 793 fe->i_last_eb_blk = eb->h_blkno; | 921 if (root_el->l_tree_depth == cpu_to_le16(1)) 922 ocfs2_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); |
794 | 923 |
795 status = ocfs2_journal_dirty(handle, fe_bh); | 924 status = ocfs2_journal_dirty(handle, et->root_bh); |
796 if (status < 0) { 797 mlog_errno(status); 798 goto bail; 799 } 800 801 *ret_new_eb_bh = new_eb_bh; 802 new_eb_bh = NULL; 803 status = 0; --- 9 unchanged lines hidden (view full) --- 813 * Should only be called when there is no space left in any of the 814 * leaf nodes. What we want to do is find the lowest tree depth 815 * non-leaf extent block with room for new records. There are three 816 * valid results of this search: 817 * 818 * 1) a lowest extent block is found, then we pass it back in 819 * *lowest_eb_bh and return '0' 820 * | 925 if (status < 0) { 926 mlog_errno(status); 927 goto bail; 928 } 929 930 *ret_new_eb_bh = new_eb_bh; 931 new_eb_bh = NULL; 932 status = 0; --- 9 unchanged lines hidden (view full) --- 942 * Should only be called when there is no space left in any of the 943 * leaf nodes. What we want to do is find the lowest tree depth 944 * non-leaf extent block with room for new records. There are three 945 * valid results of this search: 946 * 947 * 1) a lowest extent block is found, then we pass it back in 948 * *lowest_eb_bh and return '0' 949 * |
821 * 2) the search fails to find anything, but the dinode has room. We | 950 * 2) the search fails to find anything, but the root_el has room. We |
822 * pass NULL back in *lowest_eb_bh, but still return '0' 823 * | 951 * pass NULL back in *lowest_eb_bh, but still return '0' 952 * |
824 * 3) the search fails to find anything AND the dinode is full, in | 953 * 3) the search fails to find anything AND the root_el is full, in |
825 * which case we return > 0 826 * 827 * return status < 0 indicates an error. 828 */ 829static int ocfs2_find_branch_target(struct ocfs2_super *osb, 830 struct inode *inode, | 954 * which case we return > 0 955 * 956 * return status < 0 indicates an error. 957 */ 958static int ocfs2_find_branch_target(struct ocfs2_super *osb, 959 struct inode *inode, |
831 struct buffer_head *fe_bh, | 960 struct ocfs2_extent_tree *et, |
832 struct buffer_head **target_bh) 833{ 834 int status = 0, i; 835 u64 blkno; | 961 struct buffer_head **target_bh) 962{ 963 int status = 0, i; 964 u64 blkno; |
836 struct ocfs2_dinode *fe; | |
837 struct ocfs2_extent_block *eb; 838 struct ocfs2_extent_list *el; 839 struct buffer_head *bh = NULL; 840 struct buffer_head *lowest_bh = NULL; 841 842 mlog_entry_void(); 843 844 *target_bh = NULL; 845 | 965 struct ocfs2_extent_block *eb; 966 struct ocfs2_extent_list *el; 967 struct buffer_head *bh = NULL; 968 struct buffer_head *lowest_bh = NULL; 969 970 mlog_entry_void(); 971 972 *target_bh = NULL; 973 |
846 fe = (struct ocfs2_dinode *) fe_bh->b_data; 847 el = &fe->id2.i_list; | 974 el = et->root_el; |
848 849 while(le16_to_cpu(el->l_tree_depth) > 1) { 850 if (le16_to_cpu(el->l_next_free_rec) == 0) { 851 ocfs2_error(inode->i_sb, "Dinode %llu has empty " 852 "extent list (next_free_rec == 0)", 853 (unsigned long long)OCFS2_I(inode)->ip_blkno); 854 status = -EIO; 855 goto bail; --- 35 unchanged lines hidden (view full) --- 891 brelse(lowest_bh); 892 lowest_bh = bh; 893 get_bh(lowest_bh); 894 } 895 } 896 897 /* If we didn't find one and the fe doesn't have any room, 898 * then return '1' */ | 975 976 while(le16_to_cpu(el->l_tree_depth) > 1) { 977 if (le16_to_cpu(el->l_next_free_rec) == 0) { 978 ocfs2_error(inode->i_sb, "Dinode %llu has empty " 979 "extent list (next_free_rec == 0)", 980 (unsigned long long)OCFS2_I(inode)->ip_blkno); 981 status = -EIO; 982 goto bail; --- 35 unchanged lines hidden (view full) --- 1018 brelse(lowest_bh); 1019 lowest_bh = bh; 1020 get_bh(lowest_bh); 1021 } 1022 } 1023 1024 /* If we didn't find one and the fe doesn't have any room, 1025 * then return '1' */ |
899 if (!lowest_bh 900 && (fe->id2.i_list.l_next_free_rec == fe->id2.i_list.l_count)) | 1026 el = et->root_el; 1027 if (!lowest_bh && (el->l_next_free_rec == el->l_count)) |
901 status = 1; 902 903 *target_bh = lowest_bh; 904bail: 905 if (bh) 906 brelse(bh); 907 908 mlog_exit(status); --- 6 unchanged lines hidden (view full) --- 915 * We might shift the tree depth in which case existing paths should 916 * be considered invalid. 917 * 918 * Tree depth after the grow is returned via *final_depth. 919 * 920 * *last_eb_bh will be updated by ocfs2_add_branch(). 921 */ 922static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, | 1028 status = 1; 1029 1030 *target_bh = lowest_bh; 1031bail: 1032 if (bh) 1033 brelse(bh); 1034 1035 mlog_exit(status); --- 6 unchanged lines hidden (view full) --- 1042 * We might shift the tree depth in which case existing paths should 1043 * be considered invalid. 1044 * 1045 * Tree depth after the grow is returned via *final_depth. 1046 * 1047 * *last_eb_bh will be updated by ocfs2_add_branch(). 1048 */ 1049static int ocfs2_grow_tree(struct inode *inode, handle_t *handle, |
923 struct buffer_head *di_bh, int *final_depth, | 1050 struct ocfs2_extent_tree *et, int *final_depth, |
924 struct buffer_head **last_eb_bh, 925 struct ocfs2_alloc_context *meta_ac) 926{ 927 int ret, shift; | 1051 struct buffer_head **last_eb_bh, 1052 struct ocfs2_alloc_context *meta_ac) 1053{ 1054 int ret, shift; |
928 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 929 int depth = le16_to_cpu(di->id2.i_list.l_tree_depth); | 1055 struct ocfs2_extent_list *el = et->root_el; 1056 int depth = le16_to_cpu(el->l_tree_depth); |
930 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 931 struct buffer_head *bh = NULL; 932 933 BUG_ON(meta_ac == NULL); 934 | 1057 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1058 struct buffer_head *bh = NULL; 1059 1060 BUG_ON(meta_ac == NULL); 1061 |
935 shift = ocfs2_find_branch_target(osb, inode, di_bh, &bh); | 1062 shift = ocfs2_find_branch_target(osb, inode, et, &bh); |
936 if (shift < 0) { 937 ret = shift; 938 mlog_errno(ret); 939 goto out; 940 } 941 942 /* We traveled all the way to the bottom of the allocation tree 943 * and didn't find room for any more extents - we need to add 944 * another tree level */ 945 if (shift) { 946 BUG_ON(bh); 947 mlog(0, "need to shift tree depth (current = %d)\n", depth); 948 949 /* ocfs2_shift_tree_depth will return us a buffer with 950 * the new extent block (so we can pass that to 951 * ocfs2_add_branch). */ | 1063 if (shift < 0) { 1064 ret = shift; 1065 mlog_errno(ret); 1066 goto out; 1067 } 1068 1069 /* We traveled all the way to the bottom of the allocation tree 1070 * and didn't find room for any more extents - we need to add 1071 * another tree level */ 1072 if (shift) { 1073 BUG_ON(bh); 1074 mlog(0, "need to shift tree depth (current = %d)\n", depth); 1075 1076 /* ocfs2_shift_tree_depth will return us a buffer with 1077 * the new extent block (so we can pass that to 1078 * ocfs2_add_branch). */ |
952 ret = ocfs2_shift_tree_depth(osb, handle, inode, di_bh, | 1079 ret = ocfs2_shift_tree_depth(osb, handle, inode, et, |
953 meta_ac, &bh); 954 if (ret < 0) { 955 mlog_errno(ret); 956 goto out; 957 } 958 depth++; 959 if (depth == 1) { 960 /* --- 10 unchanged lines hidden (view full) --- 971 *last_eb_bh = bh; 972 goto out; 973 } 974 } 975 976 /* call ocfs2_add_branch to add the final part of the tree with 977 * the new data. */ 978 mlog(0, "add branch. bh = %p\n", bh); | 1080 meta_ac, &bh); 1081 if (ret < 0) { 1082 mlog_errno(ret); 1083 goto out; 1084 } 1085 depth++; 1086 if (depth == 1) { 1087 /* --- 10 unchanged lines hidden (view full) --- 1098 *last_eb_bh = bh; 1099 goto out; 1100 } 1101 } 1102 1103 /* call ocfs2_add_branch to add the final part of the tree with 1104 * the new data. */ 1105 mlog(0, "add branch. bh = %p\n", bh); |
979 ret = ocfs2_add_branch(osb, handle, inode, di_bh, bh, last_eb_bh, | 1106 ret = ocfs2_add_branch(osb, handle, inode, et, bh, last_eb_bh, |
980 meta_ac); 981 if (ret < 0) { 982 mlog_errno(ret); 983 goto out; 984 } 985 986out: 987 if (final_depth) --- 1066 unchanged lines hidden (view full) --- 2054 subtree_index + 1); 2055} 2056 2057static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, 2058 struct ocfs2_path *left_path, 2059 struct ocfs2_path *right_path, 2060 int subtree_index, 2061 struct ocfs2_cached_dealloc_ctxt *dealloc, | 1107 meta_ac); 1108 if (ret < 0) { 1109 mlog_errno(ret); 1110 goto out; 1111 } 1112 1113out: 1114 if (final_depth) --- 1066 unchanged lines hidden (view full) --- 2181 subtree_index + 1); 2182} 2183 2184static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle, 2185 struct ocfs2_path *left_path, 2186 struct ocfs2_path *right_path, 2187 int subtree_index, 2188 struct ocfs2_cached_dealloc_ctxt *dealloc, |
2062 int *deleted) | 2189 int *deleted, 2190 struct ocfs2_extent_tree *et) |
2063{ 2064 int ret, i, del_right_subtree = 0, right_has_empty = 0; | 2191{ 2192 int ret, i, del_right_subtree = 0, right_has_empty = 0; |
2065 struct buffer_head *root_bh, *di_bh = path_root_bh(right_path); 2066 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | 2193 struct buffer_head *root_bh, *et_root_bh = path_root_bh(right_path); |
2067 struct ocfs2_extent_list *right_leaf_el, *left_leaf_el; 2068 struct ocfs2_extent_block *eb; 2069 2070 *deleted = 0; 2071 2072 right_leaf_el = path_leaf_el(right_path); 2073 left_leaf_el = path_leaf_el(left_path); 2074 root_bh = left_path->p_node[subtree_index].bh; --- 35 unchanged lines hidden (view full) --- 2110 } 2111 2112 if (eb->h_next_leaf_blk == 0ULL && 2113 le16_to_cpu(right_leaf_el->l_next_free_rec) == 1) { 2114 /* 2115 * We have to update i_last_eb_blk during the meta 2116 * data delete. 2117 */ | 2194 struct ocfs2_extent_list *right_leaf_el, *left_leaf_el; 2195 struct ocfs2_extent_block *eb; 2196 2197 *deleted = 0; 2198 2199 right_leaf_el = path_leaf_el(right_path); 2200 left_leaf_el = path_leaf_el(left_path); 2201 root_bh = left_path->p_node[subtree_index].bh; --- 35 unchanged lines hidden (view full) --- 2237 } 2238 2239 if (eb->h_next_leaf_blk == 0ULL && 2240 le16_to_cpu(right_leaf_el->l_next_free_rec) == 1) { 2241 /* 2242 * We have to update i_last_eb_blk during the meta 2243 * data delete. 2244 */ |
2118 ret = ocfs2_journal_access(handle, inode, di_bh, | 2245 ret = ocfs2_journal_access(handle, inode, et_root_bh, |
2119 OCFS2_JOURNAL_ACCESS_WRITE); 2120 if (ret) { 2121 mlog_errno(ret); 2122 goto out; 2123 } 2124 2125 del_right_subtree = 1; 2126 } --- 58 unchanged lines hidden (view full) --- 2185 mlog_errno(ret); 2186 2187 if (del_right_subtree) { 2188 ocfs2_unlink_subtree(inode, handle, left_path, right_path, 2189 subtree_index, dealloc); 2190 ocfs2_update_edge_lengths(inode, handle, left_path); 2191 2192 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; | 2246 OCFS2_JOURNAL_ACCESS_WRITE); 2247 if (ret) { 2248 mlog_errno(ret); 2249 goto out; 2250 } 2251 2252 del_right_subtree = 1; 2253 } --- 58 unchanged lines hidden (view full) --- 2312 mlog_errno(ret); 2313 2314 if (del_right_subtree) { 2315 ocfs2_unlink_subtree(inode, handle, left_path, right_path, 2316 subtree_index, dealloc); 2317 ocfs2_update_edge_lengths(inode, handle, left_path); 2318 2319 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; |
2193 di->i_last_eb_blk = eb->h_blkno; | 2320 ocfs2_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); |
2194 2195 /* 2196 * Removal of the extent in the left leaf was skipped 2197 * above so we could delete the right path 2198 * 1st. 2199 */ 2200 if (right_has_empty) 2201 ocfs2_remove_empty_extent(left_leaf_el); 2202 | 2321 2322 /* 2323 * Removal of the extent in the left leaf was skipped 2324 * above so we could delete the right path 2325 * 1st. 2326 */ 2327 if (right_has_empty) 2328 ocfs2_remove_empty_extent(left_leaf_el); 2329 |
2203 ret = ocfs2_journal_dirty(handle, di_bh); | 2330 ret = ocfs2_journal_dirty(handle, et_root_bh); |
2204 if (ret) 2205 mlog_errno(ret); 2206 2207 *deleted = 1; 2208 } else 2209 ocfs2_complete_edge_insert(inode, handle, left_path, right_path, 2210 subtree_index); 2211 --- 106 unchanged lines hidden (view full) --- 2318out: 2319 return ret; 2320} 2321 2322static int __ocfs2_rotate_tree_left(struct inode *inode, 2323 handle_t *handle, int orig_credits, 2324 struct ocfs2_path *path, 2325 struct ocfs2_cached_dealloc_ctxt *dealloc, | 2331 if (ret) 2332 mlog_errno(ret); 2333 2334 *deleted = 1; 2335 } else 2336 ocfs2_complete_edge_insert(inode, handle, left_path, right_path, 2337 subtree_index); 2338 --- 106 unchanged lines hidden (view full) --- 2445out: 2446 return ret; 2447} 2448 2449static int __ocfs2_rotate_tree_left(struct inode *inode, 2450 handle_t *handle, int orig_credits, 2451 struct ocfs2_path *path, 2452 struct ocfs2_cached_dealloc_ctxt *dealloc, |
2326 struct ocfs2_path **empty_extent_path) | 2453 struct ocfs2_path **empty_extent_path, 2454 struct ocfs2_extent_tree *et) |
2327{ 2328 int ret, subtree_root, deleted; 2329 u32 right_cpos; 2330 struct ocfs2_path *left_path = NULL; 2331 struct ocfs2_path *right_path = NULL; 2332 2333 BUG_ON(!ocfs2_is_empty_extent(&(path_leaf_el(path)->l_recs[0]))); 2334 --- 56 unchanged lines hidden (view full) --- 2391 OCFS2_JOURNAL_ACCESS_WRITE); 2392 if (ret) { 2393 mlog_errno(ret); 2394 goto out; 2395 } 2396 2397 ret = ocfs2_rotate_subtree_left(inode, handle, left_path, 2398 right_path, subtree_root, | 2455{ 2456 int ret, subtree_root, deleted; 2457 u32 right_cpos; 2458 struct ocfs2_path *left_path = NULL; 2459 struct ocfs2_path *right_path = NULL; 2460 2461 BUG_ON(!ocfs2_is_empty_extent(&(path_leaf_el(path)->l_recs[0]))); 2462 --- 56 unchanged lines hidden (view full) --- 2519 OCFS2_JOURNAL_ACCESS_WRITE); 2520 if (ret) { 2521 mlog_errno(ret); 2522 goto out; 2523 } 2524 2525 ret = ocfs2_rotate_subtree_left(inode, handle, left_path, 2526 right_path, subtree_root, |
2399 dealloc, &deleted); | 2527 dealloc, &deleted, et); |
2400 if (ret == -EAGAIN) { 2401 /* 2402 * The rotation has to temporarily stop due to 2403 * the right subtree having an empty 2404 * extent. Pass it back to the caller for a 2405 * fixup. 2406 */ 2407 *empty_extent_path = right_path; --- 26 unchanged lines hidden (view full) --- 2434out: 2435 ocfs2_free_path(right_path); 2436 ocfs2_free_path(left_path); 2437 2438 return ret; 2439} 2440 2441static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, | 2528 if (ret == -EAGAIN) { 2529 /* 2530 * The rotation has to temporarily stop due to 2531 * the right subtree having an empty 2532 * extent. Pass it back to the caller for a 2533 * fixup. 2534 */ 2535 *empty_extent_path = right_path; --- 26 unchanged lines hidden (view full) --- 2562out: 2563 ocfs2_free_path(right_path); 2564 ocfs2_free_path(left_path); 2565 2566 return ret; 2567} 2568 2569static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, |
2442 struct ocfs2_path *path, 2443 struct ocfs2_cached_dealloc_ctxt *dealloc) | 2570 struct ocfs2_path *path, 2571 struct ocfs2_cached_dealloc_ctxt *dealloc, 2572 struct ocfs2_extent_tree *et) |
2444{ 2445 int ret, subtree_index; 2446 u32 cpos; 2447 struct ocfs2_path *left_path = NULL; | 2573{ 2574 int ret, subtree_index; 2575 u32 cpos; 2576 struct ocfs2_path *left_path = NULL; |
2448 struct ocfs2_dinode *di; | |
2449 struct ocfs2_extent_block *eb; 2450 struct ocfs2_extent_list *el; 2451 | 2577 struct ocfs2_extent_block *eb; 2578 struct ocfs2_extent_list *el; 2579 |
2452 /* 2453 * XXX: This code assumes that the root is an inode, which is 2454 * true for now but may change as tree code gets generic. 2455 */ 2456 di = (struct ocfs2_dinode *)path_root_bh(path)->b_data; 2457 if (!OCFS2_IS_VALID_DINODE(di)) { 2458 ret = -EIO; 2459 ocfs2_error(inode->i_sb, 2460 "Inode %llu has invalid path root", 2461 (unsigned long long)OCFS2_I(inode)->ip_blkno); 2462 goto out; 2463 } | |
2464 | 2580 |
2581 ret = et->eops->sanity_check(inode, et); 2582 if (ret) 2583 goto out; |
|
2465 /* 2466 * There's two ways we handle this depending on 2467 * whether path is the only existing one. 2468 */ 2469 ret = ocfs2_extend_rotate_transaction(handle, 0, 2470 handle->h_buffer_credits, 2471 path); 2472 if (ret) { --- 40 unchanged lines hidden (view full) --- 2513 2514 subtree_index = ocfs2_find_subtree_root(inode, left_path, path); 2515 2516 ocfs2_unlink_subtree(inode, handle, left_path, path, 2517 subtree_index, dealloc); 2518 ocfs2_update_edge_lengths(inode, handle, left_path); 2519 2520 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; | 2584 /* 2585 * There's two ways we handle this depending on 2586 * whether path is the only existing one. 2587 */ 2588 ret = ocfs2_extend_rotate_transaction(handle, 0, 2589 handle->h_buffer_credits, 2590 path); 2591 if (ret) { --- 40 unchanged lines hidden (view full) --- 2632 2633 subtree_index = ocfs2_find_subtree_root(inode, left_path, path); 2634 2635 ocfs2_unlink_subtree(inode, handle, left_path, path, 2636 subtree_index, dealloc); 2637 ocfs2_update_edge_lengths(inode, handle, left_path); 2638 2639 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; |
2521 di->i_last_eb_blk = eb->h_blkno; | 2640 ocfs2_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); |
2522 } else { 2523 /* 2524 * 'path' is also the leftmost path which 2525 * means it must be the only one. This gets 2526 * handled differently because we want to 2527 * revert the inode back to having extents 2528 * in-line. 2529 */ 2530 ocfs2_unlink_path(inode, handle, dealloc, path, 1); 2531 | 2641 } else { 2642 /* 2643 * 'path' is also the leftmost path which 2644 * means it must be the only one. This gets 2645 * handled differently because we want to 2646 * revert the inode back to having extents 2647 * in-line. 2648 */ 2649 ocfs2_unlink_path(inode, handle, dealloc, path, 1); 2650 |
2532 el = &di->id2.i_list; | 2651 el = et->root_el; |
2533 el->l_tree_depth = 0; 2534 el->l_next_free_rec = 0; 2535 memset(&el->l_recs[0], 0, sizeof(struct ocfs2_extent_rec)); 2536 | 2652 el->l_tree_depth = 0; 2653 el->l_next_free_rec = 0; 2654 memset(&el->l_recs[0], 0, sizeof(struct ocfs2_extent_rec)); 2655 |
2537 di->i_last_eb_blk = 0; | 2656 ocfs2_set_last_eb_blk(et, 0); |
2538 } 2539 2540 ocfs2_journal_dirty(handle, path_root_bh(path)); 2541 2542out: 2543 ocfs2_free_path(left_path); 2544 return ret; 2545} --- 11 unchanged lines hidden (view full) --- 2557 * leftmost list position. 2558 * 2559 * This won't handle a length update of the rightmost path records if 2560 * the rightmost tree leaf record is removed so the caller is 2561 * responsible for detecting and correcting that. 2562 */ 2563static int ocfs2_rotate_tree_left(struct inode *inode, handle_t *handle, 2564 struct ocfs2_path *path, | 2657 } 2658 2659 ocfs2_journal_dirty(handle, path_root_bh(path)); 2660 2661out: 2662 ocfs2_free_path(left_path); 2663 return ret; 2664} --- 11 unchanged lines hidden (view full) --- 2676 * leftmost list position. 2677 * 2678 * This won't handle a length update of the rightmost path records if 2679 * the rightmost tree leaf record is removed so the caller is 2680 * responsible for detecting and correcting that. 2681 */ 2682static int ocfs2_rotate_tree_left(struct inode *inode, handle_t *handle, 2683 struct ocfs2_path *path, |
2565 struct ocfs2_cached_dealloc_ctxt *dealloc) | 2684 struct ocfs2_cached_dealloc_ctxt *dealloc, 2685 struct ocfs2_extent_tree *et) |
2566{ 2567 int ret, orig_credits = handle->h_buffer_credits; 2568 struct ocfs2_path *tmp_path = NULL, *restart_path = NULL; 2569 struct ocfs2_extent_block *eb; 2570 struct ocfs2_extent_list *el; 2571 2572 el = path_leaf_el(path); 2573 if (!ocfs2_is_empty_extent(&el->l_recs[0])) 2574 return 0; 2575 2576 if (path->p_tree_depth == 0) { 2577rightmost_no_delete: 2578 /* | 2686{ 2687 int ret, orig_credits = handle->h_buffer_credits; 2688 struct ocfs2_path *tmp_path = NULL, *restart_path = NULL; 2689 struct ocfs2_extent_block *eb; 2690 struct ocfs2_extent_list *el; 2691 2692 el = path_leaf_el(path); 2693 if (!ocfs2_is_empty_extent(&el->l_recs[0])) 2694 return 0; 2695 2696 if (path->p_tree_depth == 0) { 2697rightmost_no_delete: 2698 /* |
2579 * In-inode extents. This is trivially handled, so do | 2699 * Inline extents. This is trivially handled, so do |
2580 * it up front. 2581 */ 2582 ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, 2583 path_leaf_bh(path), 2584 path_leaf_el(path)); 2585 if (ret) 2586 mlog_errno(ret); 2587 goto out; --- 37 unchanged lines hidden (view full) --- 2625 * this as it will have been deleted. What do we do? 2626 * 2627 * In theory the rotate-for-merge code will never get 2628 * here because it'll always ask for a rotate in a 2629 * nonempty list. 2630 */ 2631 2632 ret = ocfs2_remove_rightmost_path(inode, handle, path, | 2700 * it up front. 2701 */ 2702 ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, 2703 path_leaf_bh(path), 2704 path_leaf_el(path)); 2705 if (ret) 2706 mlog_errno(ret); 2707 goto out; --- 37 unchanged lines hidden (view full) --- 2745 * this as it will have been deleted. What do we do? 2746 * 2747 * In theory the rotate-for-merge code will never get 2748 * here because it'll always ask for a rotate in a 2749 * nonempty list. 2750 */ 2751 2752 ret = ocfs2_remove_rightmost_path(inode, handle, path, |
2633 dealloc); | 2753 dealloc, et); |
2634 if (ret) 2635 mlog_errno(ret); 2636 goto out; 2637 } 2638 2639 /* 2640 * Now we can loop, remembering the path we get from -EAGAIN 2641 * and restarting from there. 2642 */ 2643try_rotate: 2644 ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, path, | 2754 if (ret) 2755 mlog_errno(ret); 2756 goto out; 2757 } 2758 2759 /* 2760 * Now we can loop, remembering the path we get from -EAGAIN 2761 * and restarting from there. 2762 */ 2763try_rotate: 2764 ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, path, |
2645 dealloc, &restart_path); | 2765 dealloc, &restart_path, et); |
2646 if (ret && ret != -EAGAIN) { 2647 mlog_errno(ret); 2648 goto out; 2649 } 2650 2651 while (ret == -EAGAIN) { 2652 tmp_path = restart_path; 2653 restart_path = NULL; 2654 2655 ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, 2656 tmp_path, dealloc, | 2766 if (ret && ret != -EAGAIN) { 2767 mlog_errno(ret); 2768 goto out; 2769 } 2770 2771 while (ret == -EAGAIN) { 2772 tmp_path = restart_path; 2773 restart_path = NULL; 2774 2775 ret = __ocfs2_rotate_tree_left(inode, handle, orig_credits, 2776 tmp_path, dealloc, |
2657 &restart_path); | 2777 &restart_path, et); |
2658 if (ret && ret != -EAGAIN) { 2659 mlog_errno(ret); 2660 goto out; 2661 } 2662 2663 ocfs2_free_path(tmp_path); 2664 tmp_path = NULL; 2665 --- 269 unchanged lines hidden (view full) --- 2935 * remove the rightmost leaf extent block in the right_path and change 2936 * the right path to indicate the new rightmost path. 2937 */ 2938static int ocfs2_merge_rec_left(struct inode *inode, 2939 struct ocfs2_path *right_path, 2940 handle_t *handle, 2941 struct ocfs2_extent_rec *split_rec, 2942 struct ocfs2_cached_dealloc_ctxt *dealloc, | 2778 if (ret && ret != -EAGAIN) { 2779 mlog_errno(ret); 2780 goto out; 2781 } 2782 2783 ocfs2_free_path(tmp_path); 2784 tmp_path = NULL; 2785 --- 269 unchanged lines hidden (view full) --- 3055 * remove the rightmost leaf extent block in the right_path and change 3056 * the right path to indicate the new rightmost path. 3057 */ 3058static int ocfs2_merge_rec_left(struct inode *inode, 3059 struct ocfs2_path *right_path, 3060 handle_t *handle, 3061 struct ocfs2_extent_rec *split_rec, 3062 struct ocfs2_cached_dealloc_ctxt *dealloc, |
3063 struct ocfs2_extent_tree *et, |
|
2943 int index) 2944{ 2945 int ret, i, subtree_index = 0, has_empty_extent = 0; 2946 unsigned int split_clusters = le16_to_cpu(split_rec->e_leaf_clusters); 2947 struct ocfs2_extent_rec *left_rec; 2948 struct ocfs2_extent_rec *right_rec; 2949 struct ocfs2_extent_list *el = path_leaf_el(right_path); 2950 struct buffer_head *bh = path_leaf_bh(right_path); --- 104 unchanged lines hidden (view full) --- 3055 * In the situation that the right_rec is empty and the extent 3056 * block is empty also, ocfs2_complete_edge_insert can't handle 3057 * it and we need to delete the right extent block. 3058 */ 3059 if (le16_to_cpu(right_rec->e_leaf_clusters) == 0 && 3060 le16_to_cpu(el->l_next_free_rec) == 1) { 3061 3062 ret = ocfs2_remove_rightmost_path(inode, handle, | 3064 int index) 3065{ 3066 int ret, i, subtree_index = 0, has_empty_extent = 0; 3067 unsigned int split_clusters = le16_to_cpu(split_rec->e_leaf_clusters); 3068 struct ocfs2_extent_rec *left_rec; 3069 struct ocfs2_extent_rec *right_rec; 3070 struct ocfs2_extent_list *el = path_leaf_el(right_path); 3071 struct buffer_head *bh = path_leaf_bh(right_path); --- 104 unchanged lines hidden (view full) --- 3176 * In the situation that the right_rec is empty and the extent 3177 * block is empty also, ocfs2_complete_edge_insert can't handle 3178 * it and we need to delete the right extent block. 3179 */ 3180 if (le16_to_cpu(right_rec->e_leaf_clusters) == 0 && 3181 le16_to_cpu(el->l_next_free_rec) == 1) { 3182 3183 ret = ocfs2_remove_rightmost_path(inode, handle, |
3063 right_path, dealloc); | 3184 right_path, 3185 dealloc, et); |
3064 if (ret) { 3065 mlog_errno(ret); 3066 goto out; 3067 } 3068 3069 /* Now the rightmost extent block has been deleted. 3070 * So we use the new rightmost path. 3071 */ --- 10 unchanged lines hidden (view full) --- 3082} 3083 3084static int ocfs2_try_to_merge_extent(struct inode *inode, 3085 handle_t *handle, 3086 struct ocfs2_path *path, 3087 int split_index, 3088 struct ocfs2_extent_rec *split_rec, 3089 struct ocfs2_cached_dealloc_ctxt *dealloc, | 3186 if (ret) { 3187 mlog_errno(ret); 3188 goto out; 3189 } 3190 3191 /* Now the rightmost extent block has been deleted. 3192 * So we use the new rightmost path. 3193 */ --- 10 unchanged lines hidden (view full) --- 3204} 3205 3206static int ocfs2_try_to_merge_extent(struct inode *inode, 3207 handle_t *handle, 3208 struct ocfs2_path *path, 3209 int split_index, 3210 struct ocfs2_extent_rec *split_rec, 3211 struct ocfs2_cached_dealloc_ctxt *dealloc, |
3090 struct ocfs2_merge_ctxt *ctxt) | 3212 struct ocfs2_merge_ctxt *ctxt, 3213 struct ocfs2_extent_tree *et) |
3091 3092{ 3093 int ret = 0; 3094 struct ocfs2_extent_list *el = path_leaf_el(path); 3095 struct ocfs2_extent_rec *rec = &el->l_recs[split_index]; 3096 3097 BUG_ON(ctxt->c_contig_type == CONTIG_NONE); 3098 3099 if (ctxt->c_split_covers_rec && ctxt->c_has_empty_extent) { 3100 /* 3101 * The merge code will need to create an empty 3102 * extent to take the place of the newly 3103 * emptied slot. Remove any pre-existing empty 3104 * extents - having more than one in a leaf is 3105 * illegal. 3106 */ 3107 ret = ocfs2_rotate_tree_left(inode, handle, path, | 3214 3215{ 3216 int ret = 0; 3217 struct ocfs2_extent_list *el = path_leaf_el(path); 3218 struct ocfs2_extent_rec *rec = &el->l_recs[split_index]; 3219 3220 BUG_ON(ctxt->c_contig_type == CONTIG_NONE); 3221 3222 if (ctxt->c_split_covers_rec && ctxt->c_has_empty_extent) { 3223 /* 3224 * The merge code will need to create an empty 3225 * extent to take the place of the newly 3226 * emptied slot. Remove any pre-existing empty 3227 * extents - having more than one in a leaf is 3228 * illegal. 3229 */ 3230 ret = ocfs2_rotate_tree_left(inode, handle, path, |
3108 dealloc); | 3231 dealloc, et); |
3109 if (ret) { 3110 mlog_errno(ret); 3111 goto out; 3112 } 3113 split_index--; 3114 rec = &el->l_recs[split_index]; 3115 } 3116 --- 26 unchanged lines hidden (view full) --- 3143 } 3144 3145 /* 3146 * We can only get this from logic error above. 3147 */ 3148 BUG_ON(!ocfs2_is_empty_extent(&el->l_recs[0])); 3149 3150 /* The merge left us with an empty extent, remove it. */ | 3232 if (ret) { 3233 mlog_errno(ret); 3234 goto out; 3235 } 3236 split_index--; 3237 rec = &el->l_recs[split_index]; 3238 } 3239 --- 26 unchanged lines hidden (view full) --- 3266 } 3267 3268 /* 3269 * We can only get this from logic error above. 3270 */ 3271 BUG_ON(!ocfs2_is_empty_extent(&el->l_recs[0])); 3272 3273 /* The merge left us with an empty extent, remove it. */ |
3151 ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc); | 3274 ret = ocfs2_rotate_tree_left(inode, handle, path, 3275 dealloc, et); |
3152 if (ret) { 3153 mlog_errno(ret); 3154 goto out; 3155 } 3156 3157 rec = &el->l_recs[split_index]; 3158 3159 /* 3160 * Note that we don't pass split_rec here on purpose - 3161 * we've merged it into the rec already. 3162 */ 3163 ret = ocfs2_merge_rec_left(inode, path, 3164 handle, rec, | 3276 if (ret) { 3277 mlog_errno(ret); 3278 goto out; 3279 } 3280 3281 rec = &el->l_recs[split_index]; 3282 3283 /* 3284 * Note that we don't pass split_rec here on purpose - 3285 * we've merged it into the rec already. 3286 */ 3287 ret = ocfs2_merge_rec_left(inode, path, 3288 handle, rec, |
3165 dealloc, | 3289 dealloc, et, |
3166 split_index); 3167 3168 if (ret) { 3169 mlog_errno(ret); 3170 goto out; 3171 } 3172 3173 ret = ocfs2_rotate_tree_left(inode, handle, path, | 3290 split_index); 3291 3292 if (ret) { 3293 mlog_errno(ret); 3294 goto out; 3295 } 3296 3297 ret = ocfs2_rotate_tree_left(inode, handle, path, |
3174 dealloc); | 3298 dealloc, et); |
3175 /* 3176 * Error from this last rotate is not critical, so 3177 * print but don't bubble it up. 3178 */ 3179 if (ret) 3180 mlog_errno(ret); 3181 ret = 0; 3182 } else { 3183 /* 3184 * Merge a record to the left or right. 3185 * 3186 * 'contig_type' is relative to the existing record, 3187 * so for example, if we're "right contig", it's to 3188 * the record on the left (hence the left merge). 3189 */ 3190 if (ctxt->c_contig_type == CONTIG_RIGHT) { 3191 ret = ocfs2_merge_rec_left(inode, 3192 path, 3193 handle, split_rec, | 3299 /* 3300 * Error from this last rotate is not critical, so 3301 * print but don't bubble it up. 3302 */ 3303 if (ret) 3304 mlog_errno(ret); 3305 ret = 0; 3306 } else { 3307 /* 3308 * Merge a record to the left or right. 3309 * 3310 * 'contig_type' is relative to the existing record, 3311 * so for example, if we're "right contig", it's to 3312 * the record on the left (hence the left merge). 3313 */ 3314 if (ctxt->c_contig_type == CONTIG_RIGHT) { 3315 ret = ocfs2_merge_rec_left(inode, 3316 path, 3317 handle, split_rec, |
3194 dealloc, | 3318 dealloc, et, |
3195 split_index); 3196 if (ret) { 3197 mlog_errno(ret); 3198 goto out; 3199 } 3200 } else { 3201 ret = ocfs2_merge_rec_right(inode, 3202 path, --- 6 unchanged lines hidden (view full) --- 3209 } 3210 3211 if (ctxt->c_split_covers_rec) { 3212 /* 3213 * The merge may have left an empty extent in 3214 * our leaf. Try to rotate it away. 3215 */ 3216 ret = ocfs2_rotate_tree_left(inode, handle, path, | 3319 split_index); 3320 if (ret) { 3321 mlog_errno(ret); 3322 goto out; 3323 } 3324 } else { 3325 ret = ocfs2_merge_rec_right(inode, 3326 path, --- 6 unchanged lines hidden (view full) --- 3333 } 3334 3335 if (ctxt->c_split_covers_rec) { 3336 /* 3337 * The merge may have left an empty extent in 3338 * our leaf. Try to rotate it away. 3339 */ 3340 ret = ocfs2_rotate_tree_left(inode, handle, path, |
3217 dealloc); | 3341 dealloc, et); |
3218 if (ret) 3219 mlog_errno(ret); 3220 ret = 0; 3221 } 3222 } 3223 3224out: 3225 return ret; --- 117 unchanged lines hidden (view full) --- 3343 * above. 3344 * 3345 * This leaf needs to have space, either by the empty 1st 3346 * extent record, or by virtue of an l_next_rec < l_count. 3347 */ 3348 ocfs2_rotate_leaf(el, insert_rec); 3349} 3350 | 3342 if (ret) 3343 mlog_errno(ret); 3344 ret = 0; 3345 } 3346 } 3347 3348out: 3349 return ret; --- 117 unchanged lines hidden (view full) --- 3467 * above. 3468 * 3469 * This leaf needs to have space, either by the empty 1st 3470 * extent record, or by virtue of an l_next_rec < l_count. 3471 */ 3472 ocfs2_rotate_leaf(el, insert_rec); 3473} 3474 |
3351static inline void ocfs2_update_dinode_clusters(struct inode *inode, 3352 struct ocfs2_dinode *di, 3353 u32 clusters) 3354{ 3355 le32_add_cpu(&di->i_clusters, clusters); 3356 spin_lock(&OCFS2_I(inode)->ip_lock); 3357 OCFS2_I(inode)->ip_clusters = le32_to_cpu(di->i_clusters); 3358 spin_unlock(&OCFS2_I(inode)->ip_lock); 3359} 3360 | |
3361static void ocfs2_adjust_rightmost_records(struct inode *inode, 3362 handle_t *handle, 3363 struct ocfs2_path *path, 3364 struct ocfs2_extent_rec *insert_rec) 3365{ 3366 int ret, i, next_free; 3367 struct buffer_head *bh; 3368 struct ocfs2_extent_list *el; --- 185 unchanged lines hidden (view full) --- 3554 } 3555 3556 rec = &el->l_recs[index]; 3557 ocfs2_subtract_from_rec(inode->i_sb, split, rec, split_rec); 3558 ocfs2_rotate_leaf(insert_el, split_rec); 3559} 3560 3561/* | 3475static void ocfs2_adjust_rightmost_records(struct inode *inode, 3476 handle_t *handle, 3477 struct ocfs2_path *path, 3478 struct ocfs2_extent_rec *insert_rec) 3479{ 3480 int ret, i, next_free; 3481 struct buffer_head *bh; 3482 struct ocfs2_extent_list *el; --- 185 unchanged lines hidden (view full) --- 3668 } 3669 3670 rec = &el->l_recs[index]; 3671 ocfs2_subtract_from_rec(inode->i_sb, split, rec, split_rec); 3672 ocfs2_rotate_leaf(insert_el, split_rec); 3673} 3674 3675/* |
3562 * This function only does inserts on an allocation b-tree. For dinode 3563 * lists, ocfs2_insert_at_leaf() is called directly. | 3676 * This function only does inserts on an allocation b-tree. For tree 3677 * depth = 0, ocfs2_insert_at_leaf() is called directly. |
3564 * 3565 * right_path is the path we want to do the actual insert 3566 * in. left_path should only be passed in if we need to update that 3567 * portion of the tree after an edge insert. 3568 */ 3569static int ocfs2_insert_path(struct inode *inode, 3570 handle_t *handle, 3571 struct ocfs2_path *left_path, --- 80 unchanged lines hidden (view full) --- 3652 3653 ret = 0; 3654out: 3655 return ret; 3656} 3657 3658static int ocfs2_do_insert_extent(struct inode *inode, 3659 handle_t *handle, | 3678 * 3679 * right_path is the path we want to do the actual insert 3680 * in. left_path should only be passed in if we need to update that 3681 * portion of the tree after an edge insert. 3682 */ 3683static int ocfs2_insert_path(struct inode *inode, 3684 handle_t *handle, 3685 struct ocfs2_path *left_path, --- 80 unchanged lines hidden (view full) --- 3766 3767 ret = 0; 3768out: 3769 return ret; 3770} 3771 3772static int ocfs2_do_insert_extent(struct inode *inode, 3773 handle_t *handle, |
3660 struct buffer_head *di_bh, | 3774 struct ocfs2_extent_tree *et, |
3661 struct ocfs2_extent_rec *insert_rec, 3662 struct ocfs2_insert_type *type) 3663{ 3664 int ret, rotate = 0; 3665 u32 cpos; 3666 struct ocfs2_path *right_path = NULL; 3667 struct ocfs2_path *left_path = NULL; | 3775 struct ocfs2_extent_rec *insert_rec, 3776 struct ocfs2_insert_type *type) 3777{ 3778 int ret, rotate = 0; 3779 u32 cpos; 3780 struct ocfs2_path *right_path = NULL; 3781 struct ocfs2_path *left_path = NULL; |
3668 struct ocfs2_dinode *di; | |
3669 struct ocfs2_extent_list *el; 3670 | 3782 struct ocfs2_extent_list *el; 3783 |
3671 di = (struct ocfs2_dinode *) di_bh->b_data; 3672 el = &di->id2.i_list; | 3784 el = et->root_el; |
3673 | 3785 |
3674 ret = ocfs2_journal_access(handle, inode, di_bh, | 3786 ret = ocfs2_journal_access(handle, inode, et->root_bh, |
3675 OCFS2_JOURNAL_ACCESS_WRITE); 3676 if (ret) { 3677 mlog_errno(ret); 3678 goto out; 3679 } 3680 3681 if (le16_to_cpu(el->l_tree_depth) == 0) { 3682 ocfs2_insert_at_leaf(insert_rec, el, type, inode); 3683 goto out_update_clusters; 3684 } 3685 | 3787 OCFS2_JOURNAL_ACCESS_WRITE); 3788 if (ret) { 3789 mlog_errno(ret); 3790 goto out; 3791 } 3792 3793 if (le16_to_cpu(el->l_tree_depth) == 0) { 3794 ocfs2_insert_at_leaf(insert_rec, el, type, inode); 3795 goto out_update_clusters; 3796 } 3797 |
3686 right_path = ocfs2_new_inode_path(di_bh); | 3798 right_path = ocfs2_new_path(et->root_bh, et->root_el); |
3687 if (!right_path) { 3688 ret = -ENOMEM; 3689 mlog_errno(ret); 3690 goto out; 3691 } 3692 3693 /* 3694 * Determine the path to start with. Rotations need the --- 33 unchanged lines hidden (view full) --- 3728 mlog_errno(ret); 3729 goto out; 3730 } 3731 3732 /* 3733 * ocfs2_rotate_tree_right() might have extended the 3734 * transaction without re-journaling our tree root. 3735 */ | 3799 if (!right_path) { 3800 ret = -ENOMEM; 3801 mlog_errno(ret); 3802 goto out; 3803 } 3804 3805 /* 3806 * Determine the path to start with. Rotations need the --- 33 unchanged lines hidden (view full) --- 3840 mlog_errno(ret); 3841 goto out; 3842 } 3843 3844 /* 3845 * ocfs2_rotate_tree_right() might have extended the 3846 * transaction without re-journaling our tree root. 3847 */ |
3736 ret = ocfs2_journal_access(handle, inode, di_bh, | 3848 ret = ocfs2_journal_access(handle, inode, et->root_bh, |
3737 OCFS2_JOURNAL_ACCESS_WRITE); 3738 if (ret) { 3739 mlog_errno(ret); 3740 goto out; 3741 } 3742 } else if (type->ins_appending == APPEND_TAIL 3743 && type->ins_contig != CONTIG_LEFT) { 3744 ret = ocfs2_append_rec_to_path(inode, handle, insert_rec, --- 8 unchanged lines hidden (view full) --- 3753 insert_rec, type); 3754 if (ret) { 3755 mlog_errno(ret); 3756 goto out; 3757 } 3758 3759out_update_clusters: 3760 if (type->ins_split == SPLIT_NONE) | 3849 OCFS2_JOURNAL_ACCESS_WRITE); 3850 if (ret) { 3851 mlog_errno(ret); 3852 goto out; 3853 } 3854 } else if (type->ins_appending == APPEND_TAIL 3855 && type->ins_contig != CONTIG_LEFT) { 3856 ret = ocfs2_append_rec_to_path(inode, handle, insert_rec, --- 8 unchanged lines hidden (view full) --- 3865 insert_rec, type); 3866 if (ret) { 3867 mlog_errno(ret); 3868 goto out; 3869 } 3870 3871out_update_clusters: 3872 if (type->ins_split == SPLIT_NONE) |
3761 ocfs2_update_dinode_clusters(inode, di, 3762 le16_to_cpu(insert_rec->e_leaf_clusters)); | 3873 ocfs2_update_clusters(inode, et, 3874 le16_to_cpu(insert_rec->e_leaf_clusters)); |
3763 | 3875 |
3764 ret = ocfs2_journal_dirty(handle, di_bh); | 3876 ret = ocfs2_journal_dirty(handle, et->root_bh); |
3765 if (ret) 3766 mlog_errno(ret); 3767 3768out: 3769 ocfs2_free_path(left_path); 3770 ocfs2_free_path(right_path); 3771 3772 return ret; --- 137 unchanged lines hidden (view full) --- 3910} 3911 3912/* 3913 * This should only be called against the righmost leaf extent list. 3914 * 3915 * ocfs2_figure_appending_type() will figure out whether we'll have to 3916 * insert at the tail of the rightmost leaf. 3917 * | 3877 if (ret) 3878 mlog_errno(ret); 3879 3880out: 3881 ocfs2_free_path(left_path); 3882 ocfs2_free_path(right_path); 3883 3884 return ret; --- 137 unchanged lines hidden (view full) --- 4022} 4023 4024/* 4025 * This should only be called against the righmost leaf extent list. 4026 * 4027 * ocfs2_figure_appending_type() will figure out whether we'll have to 4028 * insert at the tail of the rightmost leaf. 4029 * |
3918 * This should also work against the dinode list for tree's with 0 3919 * depth. If we consider the dinode list to be the rightmost leaf node | 4030 * This should also work against the root extent list for tree's with 0 4031 * depth. If we consider the root extent list to be the rightmost leaf node |
3920 * then the logic here makes sense. 3921 */ 3922static void ocfs2_figure_appending_type(struct ocfs2_insert_type *insert, 3923 struct ocfs2_extent_list *el, 3924 struct ocfs2_extent_rec *insert_rec) 3925{ 3926 int i; 3927 u32 cpos = le32_to_cpu(insert_rec->e_cpos); --- 34 unchanged lines hidden (view full) --- 3962 * - The current tree depth. 3963 * - Whether the insert is an appending one. 3964 * - The total # of free records in the tree. 3965 * 3966 * All of the information is stored on the ocfs2_insert_type 3967 * structure. 3968 */ 3969static int ocfs2_figure_insert_type(struct inode *inode, | 4032 * then the logic here makes sense. 4033 */ 4034static void ocfs2_figure_appending_type(struct ocfs2_insert_type *insert, 4035 struct ocfs2_extent_list *el, 4036 struct ocfs2_extent_rec *insert_rec) 4037{ 4038 int i; 4039 u32 cpos = le32_to_cpu(insert_rec->e_cpos); --- 34 unchanged lines hidden (view full) --- 4074 * - The current tree depth. 4075 * - Whether the insert is an appending one. 4076 * - The total # of free records in the tree. 4077 * 4078 * All of the information is stored on the ocfs2_insert_type 4079 * structure. 4080 */ 4081static int ocfs2_figure_insert_type(struct inode *inode, |
3970 struct buffer_head *di_bh, | 4082 struct ocfs2_extent_tree *et, |
3971 struct buffer_head **last_eb_bh, 3972 struct ocfs2_extent_rec *insert_rec, 3973 int *free_records, 3974 struct ocfs2_insert_type *insert) 3975{ 3976 int ret; | 4083 struct buffer_head **last_eb_bh, 4084 struct ocfs2_extent_rec *insert_rec, 4085 int *free_records, 4086 struct ocfs2_insert_type *insert) 4087{ 4088 int ret; |
3977 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | |
3978 struct ocfs2_extent_block *eb; 3979 struct ocfs2_extent_list *el; 3980 struct ocfs2_path *path = NULL; 3981 struct buffer_head *bh = NULL; 3982 3983 insert->ins_split = SPLIT_NONE; 3984 | 4089 struct ocfs2_extent_block *eb; 4090 struct ocfs2_extent_list *el; 4091 struct ocfs2_path *path = NULL; 4092 struct buffer_head *bh = NULL; 4093 4094 insert->ins_split = SPLIT_NONE; 4095 |
3985 el = &di->id2.i_list; | 4096 el = et->root_el; |
3986 insert->ins_tree_depth = le16_to_cpu(el->l_tree_depth); 3987 3988 if (el->l_tree_depth) { 3989 /* 3990 * If we have tree depth, we read in the 3991 * rightmost extent block ahead of time as 3992 * ocfs2_figure_insert_type() and ocfs2_add_branch() 3993 * may want it later. 3994 */ 3995 ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 4097 insert->ins_tree_depth = le16_to_cpu(el->l_tree_depth); 4098 4099 if (el->l_tree_depth) { 4100 /* 4101 * If we have tree depth, we read in the 4102 * rightmost extent block ahead of time as 4103 * ocfs2_figure_insert_type() and ocfs2_add_branch() 4104 * may want it later. 4105 */ 4106 ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), |
3996 le64_to_cpu(di->i_last_eb_blk), &bh, | 4107 ocfs2_get_last_eb_blk(et), &bh, |
3997 OCFS2_BH_CACHED, inode); 3998 if (ret) { 3999 mlog_exit(ret); 4000 goto out; 4001 } 4002 eb = (struct ocfs2_extent_block *) bh->b_data; 4003 el = &eb->h_list; 4004 } --- 10 unchanged lines hidden (view full) --- 4015 le16_to_cpu(el->l_next_free_rec); 4016 4017 if (!insert->ins_tree_depth) { 4018 ocfs2_figure_contig_type(inode, insert, el, insert_rec); 4019 ocfs2_figure_appending_type(insert, el, insert_rec); 4020 return 0; 4021 } 4022 | 4108 OCFS2_BH_CACHED, inode); 4109 if (ret) { 4110 mlog_exit(ret); 4111 goto out; 4112 } 4113 eb = (struct ocfs2_extent_block *) bh->b_data; 4114 el = &eb->h_list; 4115 } --- 10 unchanged lines hidden (view full) --- 4126 le16_to_cpu(el->l_next_free_rec); 4127 4128 if (!insert->ins_tree_depth) { 4129 ocfs2_figure_contig_type(inode, insert, el, insert_rec); 4130 ocfs2_figure_appending_type(insert, el, insert_rec); 4131 return 0; 4132 } 4133 |
4023 path = ocfs2_new_inode_path(di_bh); | 4134 path = ocfs2_new_path(et->root_bh, et->root_el); |
4024 if (!path) { 4025 ret = -ENOMEM; 4026 mlog_errno(ret); 4027 goto out; 4028 } 4029 4030 /* 4031 * In the case that we're inserting past what the tree --- 33 unchanged lines hidden (view full) --- 4065 insert->ins_contig = CONTIG_NONE; 4066 4067 /* 4068 * Ok, so we can simply compare against last_eb to figure out 4069 * whether the path doesn't exist. This will only happen in 4070 * the case that we're doing a tail append, so maybe we can 4071 * take advantage of that information somehow. 4072 */ | 4135 if (!path) { 4136 ret = -ENOMEM; 4137 mlog_errno(ret); 4138 goto out; 4139 } 4140 4141 /* 4142 * In the case that we're inserting past what the tree --- 33 unchanged lines hidden (view full) --- 4176 insert->ins_contig = CONTIG_NONE; 4177 4178 /* 4179 * Ok, so we can simply compare against last_eb to figure out 4180 * whether the path doesn't exist. This will only happen in 4181 * the case that we're doing a tail append, so maybe we can 4182 * take advantage of that information somehow. 4183 */ |
4073 if (le64_to_cpu(di->i_last_eb_blk) == path_leaf_bh(path)->b_blocknr) { | 4184 if (ocfs2_get_last_eb_blk(et) == 4185 path_leaf_bh(path)->b_blocknr) { |
4074 /* 4075 * Ok, ocfs2_find_path() returned us the rightmost 4076 * tree path. This might be an appending insert. There are 4077 * two cases: 4078 * 1) We're doing a true append at the tail: 4079 * -This might even be off the end of the leaf 4080 * 2) We're "appending" by rotating in the tail 4081 */ --- 13 unchanged lines hidden (view full) --- 4095/* 4096 * Insert an extent into an inode btree. 4097 * 4098 * The caller needs to update fe->i_clusters 4099 */ 4100int ocfs2_insert_extent(struct ocfs2_super *osb, 4101 handle_t *handle, 4102 struct inode *inode, | 4186 /* 4187 * Ok, ocfs2_find_path() returned us the rightmost 4188 * tree path. This might be an appending insert. There are 4189 * two cases: 4190 * 1) We're doing a true append at the tail: 4191 * -This might even be off the end of the leaf 4192 * 2) We're "appending" by rotating in the tail 4193 */ --- 13 unchanged lines hidden (view full) --- 4207/* 4208 * Insert an extent into an inode btree. 4209 * 4210 * The caller needs to update fe->i_clusters 4211 */ 4212int ocfs2_insert_extent(struct ocfs2_super *osb, 4213 handle_t *handle, 4214 struct inode *inode, |
4103 struct buffer_head *fe_bh, | 4215 struct buffer_head *root_bh, |
4104 u32 cpos, 4105 u64 start_blk, 4106 u32 new_clusters, 4107 u8 flags, | 4216 u32 cpos, 4217 u64 start_blk, 4218 u32 new_clusters, 4219 u8 flags, |
4108 struct ocfs2_alloc_context *meta_ac) | 4220 struct ocfs2_alloc_context *meta_ac, 4221 enum ocfs2_extent_tree_type et_type) |
4109{ 4110 int status; 4111 int uninitialized_var(free_records); 4112 struct buffer_head *last_eb_bh = NULL; 4113 struct ocfs2_insert_type insert = {0, }; 4114 struct ocfs2_extent_rec rec; | 4222{ 4223 int status; 4224 int uninitialized_var(free_records); 4225 struct buffer_head *last_eb_bh = NULL; 4226 struct ocfs2_insert_type insert = {0, }; 4227 struct ocfs2_extent_rec rec; |
4228 struct ocfs2_extent_tree *et = NULL; |
|
4115 4116 BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL); 4117 | 4229 4230 BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL); 4231 |
4232 et = ocfs2_new_extent_tree(root_bh, et_type); 4233 if (!et) { 4234 status = -ENOMEM; 4235 mlog_errno(status); 4236 goto bail; 4237 } 4238 |
|
4118 mlog(0, "add %u clusters at position %u to inode %llu\n", 4119 new_clusters, cpos, (unsigned long long)OCFS2_I(inode)->ip_blkno); 4120 4121 mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) && 4122 (OCFS2_I(inode)->ip_clusters != cpos), 4123 "Device %s, asking for sparse allocation: inode %llu, " 4124 "cpos %u, clusters %u\n", 4125 osb->dev_str, 4126 (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos, 4127 OCFS2_I(inode)->ip_clusters); 4128 4129 memset(&rec, 0, sizeof(rec)); 4130 rec.e_cpos = cpu_to_le32(cpos); 4131 rec.e_blkno = cpu_to_le64(start_blk); 4132 rec.e_leaf_clusters = cpu_to_le16(new_clusters); 4133 rec.e_flags = flags; 4134 | 4239 mlog(0, "add %u clusters at position %u to inode %llu\n", 4240 new_clusters, cpos, (unsigned long long)OCFS2_I(inode)->ip_blkno); 4241 4242 mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) && 4243 (OCFS2_I(inode)->ip_clusters != cpos), 4244 "Device %s, asking for sparse allocation: inode %llu, " 4245 "cpos %u, clusters %u\n", 4246 osb->dev_str, 4247 (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos, 4248 OCFS2_I(inode)->ip_clusters); 4249 4250 memset(&rec, 0, sizeof(rec)); 4251 rec.e_cpos = cpu_to_le32(cpos); 4252 rec.e_blkno = cpu_to_le64(start_blk); 4253 rec.e_leaf_clusters = cpu_to_le16(new_clusters); 4254 rec.e_flags = flags; 4255 |
4135 status = ocfs2_figure_insert_type(inode, fe_bh, &last_eb_bh, &rec, | 4256 status = ocfs2_figure_insert_type(inode, et, &last_eb_bh, &rec, |
4136 &free_records, &insert); 4137 if (status < 0) { 4138 mlog_errno(status); 4139 goto bail; 4140 } 4141 4142 mlog(0, "Insert.appending: %u, Insert.Contig: %u, " 4143 "Insert.contig_index: %d, Insert.free_records: %d, " 4144 "Insert.tree_depth: %d\n", 4145 insert.ins_appending, insert.ins_contig, insert.ins_contig_index, 4146 free_records, insert.ins_tree_depth); 4147 4148 if (insert.ins_contig == CONTIG_NONE && free_records == 0) { | 4257 &free_records, &insert); 4258 if (status < 0) { 4259 mlog_errno(status); 4260 goto bail; 4261 } 4262 4263 mlog(0, "Insert.appending: %u, Insert.Contig: %u, " 4264 "Insert.contig_index: %d, Insert.free_records: %d, " 4265 "Insert.tree_depth: %d\n", 4266 insert.ins_appending, insert.ins_contig, insert.ins_contig_index, 4267 free_records, insert.ins_tree_depth); 4268 4269 if (insert.ins_contig == CONTIG_NONE && free_records == 0) { |
4149 status = ocfs2_grow_tree(inode, handle, fe_bh, | 4270 status = ocfs2_grow_tree(inode, handle, et, |
4150 &insert.ins_tree_depth, &last_eb_bh, 4151 meta_ac); 4152 if (status) { 4153 mlog_errno(status); 4154 goto bail; 4155 } 4156 } 4157 4158 /* Finally, we can add clusters. This might rotate the tree for us. */ | 4271 &insert.ins_tree_depth, &last_eb_bh, 4272 meta_ac); 4273 if (status) { 4274 mlog_errno(status); 4275 goto bail; 4276 } 4277 } 4278 4279 /* Finally, we can add clusters. This might rotate the tree for us. */ |
4159 status = ocfs2_do_insert_extent(inode, handle, fe_bh, &rec, &insert); | 4280 status = ocfs2_do_insert_extent(inode, handle, et, &rec, &insert); |
4160 if (status < 0) 4161 mlog_errno(status); | 4281 if (status < 0) 4282 mlog_errno(status); |
4162 else | 4283 else if (et->type == OCFS2_DINODE_EXTENT) |
4163 ocfs2_extent_map_insert_rec(inode, &rec); 4164 4165bail: 4166 if (last_eb_bh) 4167 brelse(last_eb_bh); 4168 | 4284 ocfs2_extent_map_insert_rec(inode, &rec); 4285 4286bail: 4287 if (last_eb_bh) 4288 brelse(last_eb_bh); 4289 |
4290 if (et) 4291 ocfs2_free_extent_tree(et); |
|
4169 mlog_exit(status); 4170 return status; 4171} 4172 4173static void ocfs2_make_right_split_rec(struct super_block *sb, 4174 struct ocfs2_extent_rec *split_rec, 4175 u32 cpos, 4176 struct ocfs2_extent_rec *rec) --- 11 unchanged lines hidden (view full) --- 4188 ocfs2_clusters_to_blocks(sb, cpos - rec_cpos)); 4189 4190 split_rec->e_flags = rec->e_flags; 4191} 4192 4193static int ocfs2_split_and_insert(struct inode *inode, 4194 handle_t *handle, 4195 struct ocfs2_path *path, | 4292 mlog_exit(status); 4293 return status; 4294} 4295 4296static void ocfs2_make_right_split_rec(struct super_block *sb, 4297 struct ocfs2_extent_rec *split_rec, 4298 u32 cpos, 4299 struct ocfs2_extent_rec *rec) --- 11 unchanged lines hidden (view full) --- 4311 ocfs2_clusters_to_blocks(sb, cpos - rec_cpos)); 4312 4313 split_rec->e_flags = rec->e_flags; 4314} 4315 4316static int ocfs2_split_and_insert(struct inode *inode, 4317 handle_t *handle, 4318 struct ocfs2_path *path, |
4196 struct buffer_head *di_bh, | 4319 struct ocfs2_extent_tree *et, |
4197 struct buffer_head **last_eb_bh, 4198 int split_index, 4199 struct ocfs2_extent_rec *orig_split_rec, 4200 struct ocfs2_alloc_context *meta_ac) 4201{ 4202 int ret = 0, depth; 4203 unsigned int insert_range, rec_range, do_leftright = 0; 4204 struct ocfs2_extent_rec tmprec; 4205 struct ocfs2_extent_list *rightmost_el; 4206 struct ocfs2_extent_rec rec; 4207 struct ocfs2_extent_rec split_rec = *orig_split_rec; 4208 struct ocfs2_insert_type insert; 4209 struct ocfs2_extent_block *eb; | 4320 struct buffer_head **last_eb_bh, 4321 int split_index, 4322 struct ocfs2_extent_rec *orig_split_rec, 4323 struct ocfs2_alloc_context *meta_ac) 4324{ 4325 int ret = 0, depth; 4326 unsigned int insert_range, rec_range, do_leftright = 0; 4327 struct ocfs2_extent_rec tmprec; 4328 struct ocfs2_extent_list *rightmost_el; 4329 struct ocfs2_extent_rec rec; 4330 struct ocfs2_extent_rec split_rec = *orig_split_rec; 4331 struct ocfs2_insert_type insert; 4332 struct ocfs2_extent_block *eb; |
4210 struct ocfs2_dinode *di; | |
4211 4212leftright: 4213 /* 4214 * Store a copy of the record on the stack - it might move 4215 * around as the tree is manipulated below. 4216 */ 4217 rec = path_leaf_el(path)->l_recs[split_index]; 4218 | 4333 4334leftright: 4335 /* 4336 * Store a copy of the record on the stack - it might move 4337 * around as the tree is manipulated below. 4338 */ 4339 rec = path_leaf_el(path)->l_recs[split_index]; 4340 |
4219 di = (struct ocfs2_dinode *)di_bh->b_data; 4220 rightmost_el = &di->id2.i_list; | 4341 rightmost_el = et->root_el; |
4221 4222 depth = le16_to_cpu(rightmost_el->l_tree_depth); 4223 if (depth) { 4224 BUG_ON(!(*last_eb_bh)); 4225 eb = (struct ocfs2_extent_block *) (*last_eb_bh)->b_data; 4226 rightmost_el = &eb->h_list; 4227 } 4228 4229 if (le16_to_cpu(rightmost_el->l_next_free_rec) == 4230 le16_to_cpu(rightmost_el->l_count)) { | 4342 4343 depth = le16_to_cpu(rightmost_el->l_tree_depth); 4344 if (depth) { 4345 BUG_ON(!(*last_eb_bh)); 4346 eb = (struct ocfs2_extent_block *) (*last_eb_bh)->b_data; 4347 rightmost_el = &eb->h_list; 4348 } 4349 4350 if (le16_to_cpu(rightmost_el->l_next_free_rec) == 4351 le16_to_cpu(rightmost_el->l_count)) { |
4231 ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, last_eb_bh, 4232 meta_ac); | 4352 ret = ocfs2_grow_tree(inode, handle, et, 4353 &depth, last_eb_bh, meta_ac); |
4233 if (ret) { 4234 mlog_errno(ret); 4235 goto out; 4236 } 4237 } 4238 4239 memset(&insert, 0, sizeof(struct ocfs2_insert_type)); 4240 insert.ins_appending = APPEND_NONE; --- 20 unchanged lines hidden (view full) --- 4261 &rec); 4262 4263 split_rec = tmprec; 4264 4265 BUG_ON(do_leftright); 4266 do_leftright = 1; 4267 } 4268 | 4354 if (ret) { 4355 mlog_errno(ret); 4356 goto out; 4357 } 4358 } 4359 4360 memset(&insert, 0, sizeof(struct ocfs2_insert_type)); 4361 insert.ins_appending = APPEND_NONE; --- 20 unchanged lines hidden (view full) --- 4382 &rec); 4383 4384 split_rec = tmprec; 4385 4386 BUG_ON(do_leftright); 4387 do_leftright = 1; 4388 } 4389 |
4269 ret = ocfs2_do_insert_extent(inode, handle, di_bh, &split_rec, 4270 &insert); | 4390 ret = ocfs2_do_insert_extent(inode, handle, et, &split_rec, &insert); |
4271 if (ret) { 4272 mlog_errno(ret); 4273 goto out; 4274 } 4275 4276 if (do_leftright == 1) { 4277 u32 cpos; 4278 struct ocfs2_extent_list *el; --- 25 unchanged lines hidden (view full) --- 4304 * extent flag. 4305 * 4306 * Care is taken to handle contiguousness so as to not grow the tree. 4307 * 4308 * meta_ac is not strictly necessary - we only truly need it if growth 4309 * of the tree is required. All other cases will degrade into a less 4310 * optimal tree layout. 4311 * | 4391 if (ret) { 4392 mlog_errno(ret); 4393 goto out; 4394 } 4395 4396 if (do_leftright == 1) { 4397 u32 cpos; 4398 struct ocfs2_extent_list *el; --- 25 unchanged lines hidden (view full) --- 4424 * extent flag. 4425 * 4426 * Care is taken to handle contiguousness so as to not grow the tree. 4427 * 4428 * meta_ac is not strictly necessary - we only truly need it if growth 4429 * of the tree is required. All other cases will degrade into a less 4430 * optimal tree layout. 4431 * |
4312 * last_eb_bh should be the rightmost leaf block for any inode with a 4313 * btree. Since a split may grow the tree or a merge might shrink it, the caller cannot trust the contents of that buffer after this call. | 4432 * last_eb_bh should be the rightmost leaf block for any extent 4433 * btree. Since a split may grow the tree or a merge might shrink it, 4434 * the caller cannot trust the contents of that buffer after this call. |
4314 * 4315 * This code is optimized for readability - several passes might be 4316 * made over certain portions of the tree. All of those blocks will 4317 * have been brought into cache (and pinned via the journal), so the 4318 * extra overhead is not expressed in terms of disk reads. 4319 */ 4320static int __ocfs2_mark_extent_written(struct inode *inode, | 4435 * 4436 * This code is optimized for readability - several passes might be 4437 * made over certain portions of the tree. All of those blocks will 4438 * have been brought into cache (and pinned via the journal), so the 4439 * extra overhead is not expressed in terms of disk reads. 4440 */ 4441static int __ocfs2_mark_extent_written(struct inode *inode, |
4321 struct buffer_head *di_bh, | 4442 struct ocfs2_extent_tree *et, |
4322 handle_t *handle, 4323 struct ocfs2_path *path, 4324 int split_index, 4325 struct ocfs2_extent_rec *split_rec, 4326 struct ocfs2_alloc_context *meta_ac, 4327 struct ocfs2_cached_dealloc_ctxt *dealloc) 4328{ 4329 int ret = 0; --- 23 unchanged lines hidden (view full) --- 4353 4354 /* 4355 * The core merge / split code wants to know how much room is 4356 * left in this inodes allocation tree, so we pass the 4357 * rightmost extent list. 4358 */ 4359 if (path->p_tree_depth) { 4360 struct ocfs2_extent_block *eb; | 4443 handle_t *handle, 4444 struct ocfs2_path *path, 4445 int split_index, 4446 struct ocfs2_extent_rec *split_rec, 4447 struct ocfs2_alloc_context *meta_ac, 4448 struct ocfs2_cached_dealloc_ctxt *dealloc) 4449{ 4450 int ret = 0; --- 23 unchanged lines hidden (view full) --- 4474 4475 /* 4476 * The core merge / split code wants to know how much room is 4477 * left in this inodes allocation tree, so we pass the 4478 * rightmost extent list. 4479 */ 4480 if (path->p_tree_depth) { 4481 struct ocfs2_extent_block *eb; |
4361 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | |
4362 4363 ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 4482 4483 ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), |
4364 le64_to_cpu(di->i_last_eb_blk), | 4484 ocfs2_get_last_eb_blk(et), |
4365 &last_eb_bh, OCFS2_BH_CACHED, inode); 4366 if (ret) { 4367 mlog_exit(ret); 4368 goto out; 4369 } 4370 4371 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; 4372 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { --- 17 unchanged lines hidden (view full) --- 4390 mlog(0, "index: %d, contig: %u, has_empty: %u, split_covers: %u\n", 4391 split_index, ctxt.c_contig_type, ctxt.c_has_empty_extent, 4392 ctxt.c_split_covers_rec); 4393 4394 if (ctxt.c_contig_type == CONTIG_NONE) { 4395 if (ctxt.c_split_covers_rec) 4396 el->l_recs[split_index] = *split_rec; 4397 else | 4485 &last_eb_bh, OCFS2_BH_CACHED, inode); 4486 if (ret) { 4487 mlog_exit(ret); 4488 goto out; 4489 } 4490 4491 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; 4492 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { --- 17 unchanged lines hidden (view full) --- 4510 mlog(0, "index: %d, contig: %u, has_empty: %u, split_covers: %u\n", 4511 split_index, ctxt.c_contig_type, ctxt.c_has_empty_extent, 4512 ctxt.c_split_covers_rec); 4513 4514 if (ctxt.c_contig_type == CONTIG_NONE) { 4515 if (ctxt.c_split_covers_rec) 4516 el->l_recs[split_index] = *split_rec; 4517 else |
4398 ret = ocfs2_split_and_insert(inode, handle, path, di_bh, | 4518 ret = ocfs2_split_and_insert(inode, handle, path, et, |
4399 &last_eb_bh, split_index, 4400 split_rec, meta_ac); 4401 if (ret) 4402 mlog_errno(ret); 4403 } else { 4404 ret = ocfs2_try_to_merge_extent(inode, handle, path, 4405 split_index, split_rec, | 4519 &last_eb_bh, split_index, 4520 split_rec, meta_ac); 4521 if (ret) 4522 mlog_errno(ret); 4523 } else { 4524 ret = ocfs2_try_to_merge_extent(inode, handle, path, 4525 split_index, split_rec, |
4406 dealloc, &ctxt); | 4526 dealloc, &ctxt, et); |
4407 if (ret) 4408 mlog_errno(ret); 4409 } 4410 4411out: 4412 brelse(last_eb_bh); 4413 return ret; 4414} 4415 4416/* 4417 * Mark the already-existing extent at cpos as written for len clusters. 4418 * 4419 * If the existing extent is larger than the request, initiate a 4420 * split. An attempt will be made at merging with adjacent extents. 4421 * 4422 * The caller is responsible for passing down meta_ac if we'll need it. 4423 */ | 4527 if (ret) 4528 mlog_errno(ret); 4529 } 4530 4531out: 4532 brelse(last_eb_bh); 4533 return ret; 4534} 4535 4536/* 4537 * Mark the already-existing extent at cpos as written for len clusters. 4538 * 4539 * If the existing extent is larger than the request, initiate a 4540 * split. An attempt will be made at merging with adjacent extents. 4541 * 4542 * The caller is responsible for passing down meta_ac if we'll need it. 4543 */ |
4424int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *di_bh, | 4544int ocfs2_mark_extent_written(struct inode *inode, struct buffer_head *root_bh, |
4425 handle_t *handle, u32 cpos, u32 len, u32 phys, 4426 struct ocfs2_alloc_context *meta_ac, | 4545 handle_t *handle, u32 cpos, u32 len, u32 phys, 4546 struct ocfs2_alloc_context *meta_ac, |
4427 struct ocfs2_cached_dealloc_ctxt *dealloc) | 4547 struct ocfs2_cached_dealloc_ctxt *dealloc, 4548 enum ocfs2_extent_tree_type et_type) |
4428{ 4429 int ret, index; 4430 u64 start_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys); 4431 struct ocfs2_extent_rec split_rec; 4432 struct ocfs2_path *left_path = NULL; 4433 struct ocfs2_extent_list *el; | 4549{ 4550 int ret, index; 4551 u64 start_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys); 4552 struct ocfs2_extent_rec split_rec; 4553 struct ocfs2_path *left_path = NULL; 4554 struct ocfs2_extent_list *el; |
4555 struct ocfs2_extent_tree *et = NULL; |
|
4434 4435 mlog(0, "Inode %lu cpos %u, len %u, phys %u (%llu)\n", 4436 inode->i_ino, cpos, len, phys, (unsigned long long)start_blkno); 4437 4438 if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { 4439 ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " 4440 "that are being written to, but the feature bit " 4441 "is not set in the super block.", 4442 (unsigned long long)OCFS2_I(inode)->ip_blkno); 4443 ret = -EROFS; 4444 goto out; 4445 } 4446 | 4556 4557 mlog(0, "Inode %lu cpos %u, len %u, phys %u (%llu)\n", 4558 inode->i_ino, cpos, len, phys, (unsigned long long)start_blkno); 4559 4560 if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { 4561 ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " 4562 "that are being written to, but the feature bit " 4563 "is not set in the super block.", 4564 (unsigned long long)OCFS2_I(inode)->ip_blkno); 4565 ret = -EROFS; 4566 goto out; 4567 } 4568 |
4569 et = ocfs2_new_extent_tree(root_bh, et_type); 4570 if (!et) { 4571 ret = -ENOMEM; 4572 mlog_errno(ret); 4573 goto out; 4574 } 4575 |
|
4447 /* 4448 * XXX: This should be fixed up so that we just re-insert the 4449 * next extent records. 4450 */ | 4576 /* 4577 * XXX: This should be fixed up so that we just re-insert the 4578 * next extent records. 4579 */ |
4451 ocfs2_extent_map_trunc(inode, 0); | 4580 if (et_type == OCFS2_DINODE_EXTENT) 4581 ocfs2_extent_map_trunc(inode, 0); |
4452 | 4582 |
4453 left_path = ocfs2_new_inode_path(di_bh); | 4583 left_path = ocfs2_new_path(et->root_bh, et->root_el); |
4454 if (!left_path) { 4455 ret = -ENOMEM; 4456 mlog_errno(ret); 4457 goto out; 4458 } 4459 4460 ret = ocfs2_find_path(inode, left_path, cpos); 4461 if (ret) { --- 14 unchanged lines hidden (view full) --- 4476 4477 memset(&split_rec, 0, sizeof(struct ocfs2_extent_rec)); 4478 split_rec.e_cpos = cpu_to_le32(cpos); 4479 split_rec.e_leaf_clusters = cpu_to_le16(len); 4480 split_rec.e_blkno = cpu_to_le64(start_blkno); 4481 split_rec.e_flags = path_leaf_el(left_path)->l_recs[index].e_flags; 4482 split_rec.e_flags &= ~OCFS2_EXT_UNWRITTEN; 4483 | 4584 if (!left_path) { 4585 ret = -ENOMEM; 4586 mlog_errno(ret); 4587 goto out; 4588 } 4589 4590 ret = ocfs2_find_path(inode, left_path, cpos); 4591 if (ret) { --- 14 unchanged lines hidden (view full) --- 4606 4607 memset(&split_rec, 0, sizeof(struct ocfs2_extent_rec)); 4608 split_rec.e_cpos = cpu_to_le32(cpos); 4609 split_rec.e_leaf_clusters = cpu_to_le16(len); 4610 split_rec.e_blkno = cpu_to_le64(start_blkno); 4611 split_rec.e_flags = path_leaf_el(left_path)->l_recs[index].e_flags; 4612 split_rec.e_flags &= ~OCFS2_EXT_UNWRITTEN; 4613 |
4484 ret = __ocfs2_mark_extent_written(inode, di_bh, handle, left_path, 4485 index, &split_rec, meta_ac, dealloc); | 4614 ret = __ocfs2_mark_extent_written(inode, et, handle, left_path, 4615 index, &split_rec, meta_ac, 4616 dealloc); |
4486 if (ret) 4487 mlog_errno(ret); 4488 4489out: 4490 ocfs2_free_path(left_path); | 4617 if (ret) 4618 mlog_errno(ret); 4619 4620out: 4621 ocfs2_free_path(left_path); |
4622 if (et) 4623 ocfs2_free_extent_tree(et); |
|
4491 return ret; 4492} 4493 | 4624 return ret; 4625} 4626 |
4494static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh, | 4627static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et, |
4495 handle_t *handle, struct ocfs2_path *path, 4496 int index, u32 new_range, 4497 struct ocfs2_alloc_context *meta_ac) 4498{ 4499 int ret, depth, credits = handle->h_buffer_credits; | 4628 handle_t *handle, struct ocfs2_path *path, 4629 int index, u32 new_range, 4630 struct ocfs2_alloc_context *meta_ac) 4631{ 4632 int ret, depth, credits = handle->h_buffer_credits; |
4500 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | |
4501 struct buffer_head *last_eb_bh = NULL; 4502 struct ocfs2_extent_block *eb; 4503 struct ocfs2_extent_list *rightmost_el, *el; 4504 struct ocfs2_extent_rec split_rec; 4505 struct ocfs2_extent_rec *rec; 4506 struct ocfs2_insert_type insert; 4507 4508 /* 4509 * Setup the record to split before we grow the tree. 4510 */ 4511 el = path_leaf_el(path); 4512 rec = &el->l_recs[index]; 4513 ocfs2_make_right_split_rec(inode->i_sb, &split_rec, new_range, rec); 4514 4515 depth = path->p_tree_depth; 4516 if (depth > 0) { 4517 ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), | 4633 struct buffer_head *last_eb_bh = NULL; 4634 struct ocfs2_extent_block *eb; 4635 struct ocfs2_extent_list *rightmost_el, *el; 4636 struct ocfs2_extent_rec split_rec; 4637 struct ocfs2_extent_rec *rec; 4638 struct ocfs2_insert_type insert; 4639 4640 /* 4641 * Setup the record to split before we grow the tree. 4642 */ 4643 el = path_leaf_el(path); 4644 rec = &el->l_recs[index]; 4645 ocfs2_make_right_split_rec(inode->i_sb, &split_rec, new_range, rec); 4646 4647 depth = path->p_tree_depth; 4648 if (depth > 0) { 4649 ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), |
4518 le64_to_cpu(di->i_last_eb_blk), | 4650 ocfs2_get_last_eb_blk(et), |
4519 &last_eb_bh, OCFS2_BH_CACHED, inode); 4520 if (ret < 0) { 4521 mlog_errno(ret); 4522 goto out; 4523 } 4524 4525 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; 4526 rightmost_el = &eb->h_list; 4527 } else 4528 rightmost_el = path_leaf_el(path); 4529 4530 credits += path->p_tree_depth + | 4651 &last_eb_bh, OCFS2_BH_CACHED, inode); 4652 if (ret < 0) { 4653 mlog_errno(ret); 4654 goto out; 4655 } 4656 4657 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; 4658 rightmost_el = &eb->h_list; 4659 } else 4660 rightmost_el = path_leaf_el(path); 4661 4662 credits += path->p_tree_depth + |
4531 ocfs2_extend_meta_needed(&di->id2.i_list); | 4663 ocfs2_extend_meta_needed(et->root_el); |
4532 ret = ocfs2_extend_trans(handle, credits); 4533 if (ret) { 4534 mlog_errno(ret); 4535 goto out; 4536 } 4537 4538 if (le16_to_cpu(rightmost_el->l_next_free_rec) == 4539 le16_to_cpu(rightmost_el->l_count)) { | 4664 ret = ocfs2_extend_trans(handle, credits); 4665 if (ret) { 4666 mlog_errno(ret); 4667 goto out; 4668 } 4669 4670 if (le16_to_cpu(rightmost_el->l_next_free_rec) == 4671 le16_to_cpu(rightmost_el->l_count)) { |
4540 ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, &last_eb_bh, | 4672 ret = ocfs2_grow_tree(inode, handle, et, &depth, &last_eb_bh, |
4541 meta_ac); 4542 if (ret) { 4543 mlog_errno(ret); 4544 goto out; 4545 } 4546 } 4547 4548 memset(&insert, 0, sizeof(struct ocfs2_insert_type)); 4549 insert.ins_appending = APPEND_NONE; 4550 insert.ins_contig = CONTIG_NONE; 4551 insert.ins_split = SPLIT_RIGHT; 4552 insert.ins_tree_depth = depth; 4553 | 4673 meta_ac); 4674 if (ret) { 4675 mlog_errno(ret); 4676 goto out; 4677 } 4678 } 4679 4680 memset(&insert, 0, sizeof(struct ocfs2_insert_type)); 4681 insert.ins_appending = APPEND_NONE; 4682 insert.ins_contig = CONTIG_NONE; 4683 insert.ins_split = SPLIT_RIGHT; 4684 insert.ins_tree_depth = depth; 4685 |
4554 ret = ocfs2_do_insert_extent(inode, handle, di_bh, &split_rec, &insert); | 4686 ret = ocfs2_do_insert_extent(inode, handle, et, &split_rec, &insert); |
4555 if (ret) 4556 mlog_errno(ret); 4557 4558out: 4559 brelse(last_eb_bh); 4560 return ret; 4561} 4562 4563static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, 4564 struct ocfs2_path *path, int index, 4565 struct ocfs2_cached_dealloc_ctxt *dealloc, | 4687 if (ret) 4688 mlog_errno(ret); 4689 4690out: 4691 brelse(last_eb_bh); 4692 return ret; 4693} 4694 4695static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, 4696 struct ocfs2_path *path, int index, 4697 struct ocfs2_cached_dealloc_ctxt *dealloc, |
4566 u32 cpos, u32 len) | 4698 u32 cpos, u32 len, 4699 struct ocfs2_extent_tree *et) |
4567{ 4568 int ret; 4569 u32 left_cpos, rec_range, trunc_range; 4570 int wants_rotate = 0, is_rightmost_tree_rec = 0; 4571 struct super_block *sb = inode->i_sb; 4572 struct ocfs2_path *left_path = NULL; 4573 struct ocfs2_extent_list *el = path_leaf_el(path); 4574 struct ocfs2_extent_rec *rec; 4575 struct ocfs2_extent_block *eb; 4576 4577 if (ocfs2_is_empty_extent(&el->l_recs[0]) && index > 0) { | 4700{ 4701 int ret; 4702 u32 left_cpos, rec_range, trunc_range; 4703 int wants_rotate = 0, is_rightmost_tree_rec = 0; 4704 struct super_block *sb = inode->i_sb; 4705 struct ocfs2_path *left_path = NULL; 4706 struct ocfs2_extent_list *el = path_leaf_el(path); 4707 struct ocfs2_extent_rec *rec; 4708 struct ocfs2_extent_block *eb; 4709 4710 if (ocfs2_is_empty_extent(&el->l_recs[0]) && index > 0) { |
4578 ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc); | 4711 ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc, et); |
4579 if (ret) { 4580 mlog_errno(ret); 4581 goto out; 4582 } 4583 4584 index--; 4585 } 4586 --- 114 unchanged lines hidden (view full) --- 4701 4702 subtree_index = ocfs2_find_subtree_root(inode, left_path, path); 4703 ocfs2_complete_edge_insert(inode, handle, left_path, path, 4704 subtree_index); 4705 } 4706 4707 ocfs2_journal_dirty(handle, path_leaf_bh(path)); 4708 | 4712 if (ret) { 4713 mlog_errno(ret); 4714 goto out; 4715 } 4716 4717 index--; 4718 } 4719 --- 114 unchanged lines hidden (view full) --- 4834 4835 subtree_index = ocfs2_find_subtree_root(inode, left_path, path); 4836 ocfs2_complete_edge_insert(inode, handle, left_path, path, 4837 subtree_index); 4838 } 4839 4840 ocfs2_journal_dirty(handle, path_leaf_bh(path)); 4841 |
4709 ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc); | 4842 ret = ocfs2_rotate_tree_left(inode, handle, path, dealloc, et); |
4710 if (ret) { 4711 mlog_errno(ret); 4712 goto out; 4713 } 4714 4715out: 4716 ocfs2_free_path(left_path); 4717 return ret; 4718} 4719 | 4843 if (ret) { 4844 mlog_errno(ret); 4845 goto out; 4846 } 4847 4848out: 4849 ocfs2_free_path(left_path); 4850 return ret; 4851} 4852 |
4720int ocfs2_remove_extent(struct inode *inode, struct buffer_head *di_bh, | 4853int ocfs2_remove_extent(struct inode *inode, struct buffer_head *root_bh, |
4721 u32 cpos, u32 len, handle_t *handle, 4722 struct ocfs2_alloc_context *meta_ac, | 4854 u32 cpos, u32 len, handle_t *handle, 4855 struct ocfs2_alloc_context *meta_ac, |
4723 struct ocfs2_cached_dealloc_ctxt *dealloc) | 4856 struct ocfs2_cached_dealloc_ctxt *dealloc, 4857 enum ocfs2_extent_tree_type et_type) |
4724{ 4725 int ret, index; 4726 u32 rec_range, trunc_range; 4727 struct ocfs2_extent_rec *rec; 4728 struct ocfs2_extent_list *el; | 4858{ 4859 int ret, index; 4860 u32 rec_range, trunc_range; 4861 struct ocfs2_extent_rec *rec; 4862 struct ocfs2_extent_list *el; |
4729 struct ocfs2_path *path; | 4863 struct ocfs2_path *path = NULL; 4864 struct ocfs2_extent_tree *et = NULL; |
4730 | 4865 |
4866 et = ocfs2_new_extent_tree(root_bh, et_type); 4867 if (!et) { 4868 ret = -ENOMEM; 4869 mlog_errno(ret); 4870 goto out; 4871 } 4872 |
|
4731 ocfs2_extent_map_trunc(inode, 0); 4732 | 4873 ocfs2_extent_map_trunc(inode, 0); 4874 |
4733 path = ocfs2_new_inode_path(di_bh); | 4875 path = ocfs2_new_path(et->root_bh, et->root_el); |
4734 if (!path) { 4735 ret = -ENOMEM; 4736 mlog_errno(ret); 4737 goto out; 4738 } 4739 4740 ret = ocfs2_find_path(inode, path, cpos); 4741 if (ret) { --- 36 unchanged lines hidden (view full) --- 4778 4779 mlog(0, "Inode %llu, remove (cpos %u, len %u). Existing index %d " 4780 "(cpos %u, len %u)\n", 4781 (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos, len, index, 4782 le32_to_cpu(rec->e_cpos), ocfs2_rec_clusters(el, rec)); 4783 4784 if (le32_to_cpu(rec->e_cpos) == cpos || rec_range == trunc_range) { 4785 ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, | 4876 if (!path) { 4877 ret = -ENOMEM; 4878 mlog_errno(ret); 4879 goto out; 4880 } 4881 4882 ret = ocfs2_find_path(inode, path, cpos); 4883 if (ret) { --- 36 unchanged lines hidden (view full) --- 4920 4921 mlog(0, "Inode %llu, remove (cpos %u, len %u). Existing index %d " 4922 "(cpos %u, len %u)\n", 4923 (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos, len, index, 4924 le32_to_cpu(rec->e_cpos), ocfs2_rec_clusters(el, rec)); 4925 4926 if (le32_to_cpu(rec->e_cpos) == cpos || rec_range == trunc_range) { 4927 ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, |
4786 cpos, len); | 4928 cpos, len, et); |
4787 if (ret) { 4788 mlog_errno(ret); 4789 goto out; 4790 } 4791 } else { | 4929 if (ret) { 4930 mlog_errno(ret); 4931 goto out; 4932 } 4933 } else { |
4792 ret = ocfs2_split_tree(inode, di_bh, handle, path, index, | 4934 ret = ocfs2_split_tree(inode, et, handle, path, index, |
4793 trunc_range, meta_ac); 4794 if (ret) { 4795 mlog_errno(ret); 4796 goto out; 4797 } 4798 4799 /* 4800 * The split could have manipulated the tree enough to --- 32 unchanged lines hidden (view full) --- 4833 (unsigned long long)OCFS2_I(inode)->ip_blkno, 4834 cpos, len, le32_to_cpu(rec->e_cpos), 4835 ocfs2_rec_clusters(el, rec)); 4836 ret = -EROFS; 4837 goto out; 4838 } 4839 4840 ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, | 4935 trunc_range, meta_ac); 4936 if (ret) { 4937 mlog_errno(ret); 4938 goto out; 4939 } 4940 4941 /* 4942 * The split could have manipulated the tree enough to --- 32 unchanged lines hidden (view full) --- 4975 (unsigned long long)OCFS2_I(inode)->ip_blkno, 4976 cpos, len, le32_to_cpu(rec->e_cpos), 4977 ocfs2_rec_clusters(el, rec)); 4978 ret = -EROFS; 4979 goto out; 4980 } 4981 4982 ret = ocfs2_truncate_rec(inode, handle, path, index, dealloc, |
4841 cpos, len); | 4983 cpos, len, et); |
4842 if (ret) { 4843 mlog_errno(ret); 4844 goto out; 4845 } 4846 } 4847 4848out: 4849 ocfs2_free_path(path); | 4984 if (ret) { 4985 mlog_errno(ret); 4986 goto out; 4987 } 4988 } 4989 4990out: 4991 ocfs2_free_path(path); |
4992 if (et) 4993 ocfs2_free_extent_tree(et); |
|
4850 return ret; 4851} 4852 4853int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) 4854{ 4855 struct buffer_head *tl_bh = osb->osb_tl_bh; 4856 struct ocfs2_dinode *di; 4857 struct ocfs2_truncate_log *tl; --- 1492 unchanged lines hidden (view full) --- 6350 6351 if (has_data) { 6352 /* 6353 * An error at this point should be extremely rare. If 6354 * this proves to be false, we could always re-build 6355 * the in-inode data from our pages. 6356 */ 6357 ret = ocfs2_insert_extent(osb, handle, inode, di_bh, | 4994 return ret; 4995} 4996 4997int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) 4998{ 4999 struct buffer_head *tl_bh = osb->osb_tl_bh; 5000 struct ocfs2_dinode *di; 5001 struct ocfs2_truncate_log *tl; --- 1492 unchanged lines hidden (view full) --- 6494 6495 if (has_data) { 6496 /* 6497 * An error at this point should be extremely rare. If 6498 * this proves to be false, we could always re-build 6499 * the in-inode data from our pages. 6500 */ 6501 ret = ocfs2_insert_extent(osb, handle, inode, di_bh, |
6358 0, block, 1, 0, NULL); | 6502 0, block, 1, 0, 6503 NULL, OCFS2_DINODE_EXTENT); |
6359 if (ret) { 6360 mlog_errno(ret); 6361 goto out_commit; 6362 } 6363 6364 inode->i_blocks = ocfs2_inode_sector_count(inode); 6365 } 6366 --- 25 unchanged lines hidden (view full) --- 6392 struct ocfs2_truncate_context *tc) 6393{ 6394 int status, i, credits, tl_sem = 0; 6395 u32 clusters_to_del, new_highest_cpos, range; 6396 struct ocfs2_extent_list *el; 6397 handle_t *handle = NULL; 6398 struct inode *tl_inode = osb->osb_tl_inode; 6399 struct ocfs2_path *path = NULL; | 6504 if (ret) { 6505 mlog_errno(ret); 6506 goto out_commit; 6507 } 6508 6509 inode->i_blocks = ocfs2_inode_sector_count(inode); 6510 } 6511 --- 25 unchanged lines hidden (view full) --- 6537 struct ocfs2_truncate_context *tc) 6538{ 6539 int status, i, credits, tl_sem = 0; 6540 u32 clusters_to_del, new_highest_cpos, range; 6541 struct ocfs2_extent_list *el; 6542 handle_t *handle = NULL; 6543 struct inode *tl_inode = osb->osb_tl_inode; 6544 struct ocfs2_path *path = NULL; |
6545 struct ocfs2_dinode *di = (struct ocfs2_dinode *)fe_bh->b_data; |
|
6400 6401 mlog_entry_void(); 6402 6403 new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, 6404 i_size_read(inode)); 6405 | 6546 6547 mlog_entry_void(); 6548 6549 new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, 6550 i_size_read(inode)); 6551 |
6406 path = ocfs2_new_inode_path(fe_bh); | 6552 path = ocfs2_new_path(fe_bh, &di->id2.i_list); |
6407 if (!path) { 6408 status = -ENOMEM; 6409 mlog_errno(status); 6410 goto bail; 6411 } 6412 6413 ocfs2_extent_map_trunc(inode, new_highest_cpos); 6414 --- 281 unchanged lines hidden --- | 6553 if (!path) { 6554 status = -ENOMEM; 6555 mlog_errno(status); 6556 goto bail; 6557 } 6558 6559 ocfs2_extent_map_trunc(inode, new_highest_cpos); 6560 --- 281 unchanged lines hidden --- |