ocfs2: Pass struct ocfs2_caching_info to the journal functions.
[pandora-kernel.git] / fs / ocfs2 / alloc.c
index 9edcde4..616afa9 100644 (file)
@@ -415,11 +415,11 @@ static inline void ocfs2_et_update_clusters(struct inode *inode,
 }
 
 static inline int ocfs2_et_root_journal_access(handle_t *handle,
-                                              struct inode *inode,
+                                              struct ocfs2_caching_info *ci,
                                               struct ocfs2_extent_tree *et,
                                               int type)
 {
-       return et->et_root_journal_access(handle, inode, et->et_root_bh,
+       return et->et_root_journal_access(handle, ci, et->et_root_bh,
                                          type);
 }
 
@@ -633,7 +633,7 @@ static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et)
  * ocfs2_journal_access_path(), but I don't have a better one.
  */
 static int ocfs2_path_bh_journal_access(handle_t *handle,
-                                       struct inode *inode,
+                                       struct ocfs2_caching_info *ci,
                                        struct ocfs2_path *path,
                                        int idx)
 {
@@ -645,14 +645,15 @@ static int ocfs2_path_bh_journal_access(handle_t *handle,
        if (idx)
                access = ocfs2_journal_access_eb;
 
-       return access(handle, inode, path->p_node[idx].bh,
+       return access(handle, ci, path->p_node[idx].bh,
                      OCFS2_JOURNAL_ACCESS_WRITE);
 }
 
 /*
  * Convenience function to journal all components in a path.
  */
-static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle,
+static int ocfs2_journal_access_path(struct ocfs2_caching_info *ci,
+                                    handle_t *handle,
                                     struct ocfs2_path *path)
 {
        int i, ret = 0;
@@ -661,7 +662,7 @@ static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle,
                goto out;
 
        for(i = 0; i < path_num_items(path); i++) {
-               ret = ocfs2_path_bh_journal_access(handle, inode, path, i);
+               ret = ocfs2_path_bh_journal_access(handle, ci, path, i);
                if (ret < 0) {
                        mlog_errno(ret);
                        goto out;
@@ -859,7 +860,7 @@ int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno,
        int rc;
        struct buffer_head *tmp = *bh;
 
-       rc = ocfs2_read_block(inode, eb_blkno, &tmp,
+       rc = ocfs2_read_block(INODE_CACHE(inode), eb_blkno, &tmp,
                              ocfs2_validate_extent_block);
 
        /* If ocfs2_read_block() got us a new bh, pass it up. */
@@ -949,9 +950,10 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
                                mlog_errno(status);
                                goto bail;
                        }
-                       ocfs2_set_new_buffer_uptodate(inode, bhs[i]);
+                       ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode),
+                                                     bhs[i]);
 
-                       status = ocfs2_journal_access_eb(handle, inode, bhs[i],
+                       status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), bhs[i],
                                                         OCFS2_JOURNAL_ACCESS_CREATE);
                        if (status < 0) {
                                mlog_errno(status);
@@ -1050,7 +1052,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle,
                goto out;
        }
 
-       status = ocfs2_journal_access_path(inode, handle, path);
+       status = ocfs2_journal_access_path(INODE_CACHE(inode), handle, path);
        if (status < 0) {
                mlog_errno(status);
                goto out;
@@ -1161,7 +1163,7 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
                BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb));
                eb_el = &eb->h_list;
 
-               status = ocfs2_journal_access_eb(handle, inode, bh,
+               status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), bh,
                                                 OCFS2_JOURNAL_ACCESS_CREATE);
                if (status < 0) {
                        mlog_errno(status);
@@ -1201,20 +1203,20 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
         * journal_dirty erroring as it won't unless we've aborted the
         * handle (in which case we would never be here) so reserving
         * the write with journal_access is all we need to do. */
-       status = ocfs2_journal_access_eb(handle, inode, *last_eb_bh,
+       status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), *last_eb_bh,
                                         OCFS2_JOURNAL_ACCESS_WRITE);
        if (status < 0) {
                mlog_errno(status);
                goto bail;
        }
-       status = ocfs2_et_root_journal_access(handle, inode, et,
+       status = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                              OCFS2_JOURNAL_ACCESS_WRITE);
        if (status < 0) {
                mlog_errno(status);
                goto bail;
        }
        if (eb_bh) {
-               status = ocfs2_journal_access_eb(handle, inode, eb_bh,
+               status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), eb_bh,
                                                 OCFS2_JOURNAL_ACCESS_WRITE);
                if (status < 0) {
                        mlog_errno(status);
@@ -1304,7 +1306,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
        eb_el = &eb->h_list;
        root_el = et->et_root_el;
 
-       status = ocfs2_journal_access_eb(handle, inode, new_eb_bh,
+       status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), new_eb_bh,
                                         OCFS2_JOURNAL_ACCESS_CREATE);
        if (status < 0) {
                mlog_errno(status);
@@ -1323,7 +1325,7 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
                goto bail;
        }
 
-       status = ocfs2_et_root_journal_access(handle, inode, et,
+       status = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                              OCFS2_JOURNAL_ACCESS_WRITE);
        if (status < 0) {
                mlog_errno(status);
@@ -1914,7 +1916,8 @@ static void ocfs2_adjust_adjacent_records(struct ocfs2_extent_rec *left_rec,
         * immediately to their right.
         */
        left_clusters = le32_to_cpu(right_child_el->l_recs[0].e_cpos);
-       if (ocfs2_is_empty_extent(&right_child_el->l_recs[0])) {
+       if (!ocfs2_rec_clusters(right_child_el, &right_child_el->l_recs[0])) {
+               BUG_ON(right_child_el->l_tree_depth);
                BUG_ON(le16_to_cpu(right_child_el->l_next_free_rec) <= 1);
                left_clusters = le32_to_cpu(right_child_el->l_recs[1].e_cpos);
        }
@@ -2093,7 +2096,7 @@ static int ocfs2_rotate_subtree_right(struct inode *inode,
        root_bh = left_path->p_node[subtree_index].bh;
        BUG_ON(root_bh != right_path->p_node[subtree_index].bh);
 
-       ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
+       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), right_path,
                                           subtree_index);
        if (ret) {
                mlog_errno(ret);
@@ -2101,14 +2104,14 @@ static int ocfs2_rotate_subtree_right(struct inode *inode,
        }
 
        for(i = subtree_index + 1; i < path_num_items(right_path); i++) {
-               ret = ocfs2_path_bh_journal_access(handle, inode,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                   right_path, i);
                if (ret) {
                        mlog_errno(ret);
                        goto out;
                }
 
-               ret = ocfs2_path_bh_journal_access(handle, inode,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                   left_path, i);
                if (ret) {
                        mlog_errno(ret);
@@ -2476,15 +2479,37 @@ out_ret_path:
        return ret;
 }
 
-static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
-                                     struct ocfs2_path *path)
+static int ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
+                                    int subtree_index, struct ocfs2_path *path)
 {
-       int i, idx;
+       int i, idx, ret;
        struct ocfs2_extent_rec *rec;
        struct ocfs2_extent_list *el;
        struct ocfs2_extent_block *eb;
        u32 range;
 
+       /*
+        * In normal tree rotation process, we will never touch the
+        * tree branch above subtree_index and ocfs2_extend_rotate_transaction
+        * doesn't reserve the credits for them either.
+        *
+        * But we do have a special case here which will update the rightmost
+        * records for all the bh in the path.
+        * So we have to allocate extra credits and access them.
+        */
+       ret = ocfs2_extend_trans(handle,
+                                handle->h_buffer_credits + subtree_index);
+       if (ret) {
+               mlog_errno(ret);
+               goto out;
+       }
+
+       ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, path);
+       if (ret) {
+               mlog_errno(ret);
+               goto out;
+       }
+
        /* Path should always be rightmost. */
        eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data;
        BUG_ON(eb->h_next_leaf_blk != 0ULL);
@@ -2505,6 +2530,8 @@ static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
 
                ocfs2_journal_dirty(handle, path->p_node[i].bh);
        }
+out:
+       return ret;
 }
 
 static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
@@ -2534,7 +2561,7 @@ static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
                             le16_to_cpu(el->l_next_free_rec));
 
                        ocfs2_journal_dirty(handle, bh);
-                       ocfs2_remove_from_cache(inode, bh);
+                       ocfs2_remove_from_cache(INODE_CACHE(inode), bh);
                        continue;
                }
 
@@ -2547,7 +2574,7 @@ static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
                if (ret)
                        mlog_errno(ret);
 
-               ocfs2_remove_from_cache(inode, bh);
+               ocfs2_remove_from_cache(INODE_CACHE(inode), bh);
        }
 }
 
@@ -2628,7 +2655,7 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
                        return -EAGAIN;
 
                if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) {
-                       ret = ocfs2_journal_access_eb(handle, inode,
+                       ret = ocfs2_journal_access_eb(handle, INODE_CACHE(inode),
                                                      path_leaf_bh(right_path),
                                                      OCFS2_JOURNAL_ACCESS_WRITE);
                        if (ret) {
@@ -2647,7 +2674,7 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
                 * We have to update i_last_eb_blk during the meta
                 * data delete.
                 */
-               ret = ocfs2_et_root_journal_access(handle, inode, et,
+               ret = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                                   OCFS2_JOURNAL_ACCESS_WRITE);
                if (ret) {
                        mlog_errno(ret);
@@ -2663,7 +2690,7 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
         */
        BUG_ON(right_has_empty && !del_right_subtree);
 
-       ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
+       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), right_path,
                                           subtree_index);
        if (ret) {
                mlog_errno(ret);
@@ -2671,14 +2698,14 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
        }
 
        for(i = subtree_index + 1; i < path_num_items(right_path); i++) {
-               ret = ocfs2_path_bh_journal_access(handle, inode,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                   right_path, i);
                if (ret) {
                        mlog_errno(ret);
                        goto out;
                }
 
-               ret = ocfs2_path_bh_journal_access(handle, inode,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                   left_path, i);
                if (ret) {
                        mlog_errno(ret);
@@ -2717,7 +2744,12 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
        if (del_right_subtree) {
                ocfs2_unlink_subtree(inode, handle, left_path, right_path,
                                     subtree_index, dealloc);
-               ocfs2_update_edge_lengths(inode, handle, left_path);
+               ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
+                                               left_path);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
 
                eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
                ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
@@ -2833,7 +2865,7 @@ static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode,
        if (!ocfs2_is_empty_extent(&el->l_recs[0]))
                return 0;
 
-       ret = ocfs2_path_bh_journal_access(handle, inode, path,
+       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), path,
                                           path_num_items(path) - 1);
        if (ret) {
                mlog_errno(ret);
@@ -2916,7 +2948,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
                 * Caller might still want to make changes to the
                 * tree root, so re-add it to the journal here.
                 */
-               ret = ocfs2_path_bh_journal_access(handle, inode,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                   left_path, 0);
                if (ret) {
                        mlog_errno(ret);
@@ -2994,7 +3026,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
                goto out;
        }
 
-       ret = ocfs2_journal_access_path(inode, handle, path);
+       ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, path);
        if (ret) {
                mlog_errno(ret);
                goto out;
@@ -3024,7 +3056,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
                        goto out;
                }
 
-               ret = ocfs2_journal_access_path(inode, handle, left_path);
+               ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, left_path);
                if (ret) {
                        mlog_errno(ret);
                        goto out;
@@ -3034,7 +3066,12 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
 
                ocfs2_unlink_subtree(inode, handle, left_path, path,
                                     subtree_index, dealloc);
-               ocfs2_update_edge_lengths(inode, handle, left_path);
+               ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
+                                               left_path);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
 
                eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
                ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
@@ -3334,7 +3371,7 @@ static int ocfs2_merge_rec_right(struct inode *inode,
                root_bh = left_path->p_node[subtree_index].bh;
                BUG_ON(root_bh != right_path->p_node[subtree_index].bh);
 
-               ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), right_path,
                                                   subtree_index);
                if (ret) {
                        mlog_errno(ret);
@@ -3343,14 +3380,14 @@ static int ocfs2_merge_rec_right(struct inode *inode,
 
                for (i = subtree_index + 1;
                     i < path_num_items(right_path); i++) {
-                       ret = ocfs2_path_bh_journal_access(handle, inode,
+                       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                           right_path, i);
                        if (ret) {
                                mlog_errno(ret);
                                goto out;
                        }
 
-                       ret = ocfs2_path_bh_journal_access(handle, inode,
+                       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                           left_path, i);
                        if (ret) {
                                mlog_errno(ret);
@@ -3363,7 +3400,7 @@ static int ocfs2_merge_rec_right(struct inode *inode,
                right_rec = &el->l_recs[index + 1];
        }
 
-       ret = ocfs2_path_bh_journal_access(handle, inode, left_path,
+       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), left_path,
                                           path_num_items(left_path) - 1);
        if (ret) {
                mlog_errno(ret);
@@ -3503,7 +3540,7 @@ static int ocfs2_merge_rec_left(struct inode *inode,
                root_bh = left_path->p_node[subtree_index].bh;
                BUG_ON(root_bh != right_path->p_node[subtree_index].bh);
 
-               ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
+               ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), right_path,
                                                   subtree_index);
                if (ret) {
                        mlog_errno(ret);
@@ -3512,14 +3549,14 @@ static int ocfs2_merge_rec_left(struct inode *inode,
 
                for (i = subtree_index + 1;
                     i < path_num_items(right_path); i++) {
-                       ret = ocfs2_path_bh_journal_access(handle, inode,
+                       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                           right_path, i);
                        if (ret) {
                                mlog_errno(ret);
                                goto out;
                        }
 
-                       ret = ocfs2_path_bh_journal_access(handle, inode,
+                       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode),
                                                           left_path, i);
                        if (ret) {
                                mlog_errno(ret);
@@ -3532,7 +3569,7 @@ static int ocfs2_merge_rec_left(struct inode *inode,
                        has_empty_extent = 1;
        }
 
-       ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
+       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), right_path,
                                           path_num_items(right_path) - 1);
        if (ret) {
                mlog_errno(ret);
@@ -3970,7 +4007,7 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle,
                }
        }
 
-       ret = ocfs2_journal_access_path(inode, handle, right_path);
+       ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, right_path);
        if (ret) {
                mlog_errno(ret);
                goto out;
@@ -4099,7 +4136,7 @@ static int ocfs2_insert_path(struct inode *inode,
                        goto out;
                }
 
-               ret = ocfs2_journal_access_path(inode, handle, left_path);
+               ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, left_path);
                if (ret < 0) {
                        mlog_errno(ret);
                        goto out;
@@ -4110,7 +4147,7 @@ static int ocfs2_insert_path(struct inode *inode,
         * Pass both paths to the journal. The majority of inserts
         * will be touching all components anyway.
         */
-       ret = ocfs2_journal_access_path(inode, handle, right_path);
+       ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, right_path);
        if (ret < 0) {
                mlog_errno(ret);
                goto out;
@@ -4175,7 +4212,7 @@ static int ocfs2_do_insert_extent(struct inode *inode,
 
        el = et->et_root_el;
 
-       ret = ocfs2_et_root_journal_access(handle, inode, et,
+       ret = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                           OCFS2_JOURNAL_ACCESS_WRITE);
        if (ret) {
                mlog_errno(ret);
@@ -4237,7 +4274,7 @@ static int ocfs2_do_insert_extent(struct inode *inode,
                 * ocfs2_rotate_tree_right() might have extended the
                 * transaction without re-journaling our tree root.
                 */
-               ret = ocfs2_et_root_journal_access(handle, inode, et,
+               ret = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                                   OCFS2_JOURNAL_ACCESS_WRITE);
                if (ret) {
                        mlog_errno(ret);
@@ -4760,7 +4797,7 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb,
        BUG_ON(num_bits > clusters_to_add);
 
        /* reserve our write early -- insert_extent may update the tree root */
-       status = ocfs2_et_root_journal_access(handle, inode, et,
+       status = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                              OCFS2_JOURNAL_ACCESS_WRITE);
        if (status < 0) {
                mlog_errno(status);
@@ -4935,7 +4972,7 @@ static int ocfs2_replace_extent_rec(struct inode *inode,
 {
        int ret;
 
-       ret = ocfs2_path_bh_journal_access(handle, inode, path,
+       ret = ocfs2_path_bh_journal_access(handle, INODE_CACHE(inode), path,
                                           path_num_items(path) - 1);
        if (ret) {
                mlog_errno(ret);
@@ -5297,13 +5334,13 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle,
                goto out;
        }
 
-       ret = ocfs2_journal_access_path(inode, handle, path);
+       ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, path);
        if (ret) {
                mlog_errno(ret);
                goto out;
        }
 
-       ret = ocfs2_journal_access_path(inode, handle, left_path);
+       ret = ocfs2_journal_access_path(INODE_CACHE(inode), handle, left_path);
        if (ret) {
                mlog_errno(ret);
                goto out;
@@ -5538,7 +5575,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
                goto out;
        }
 
-       ret = ocfs2_et_root_journal_access(handle, inode, et,
+       ret = ocfs2_et_root_journal_access(handle, INODE_CACHE(inode), et,
                                           OCFS2_JOURNAL_ACCESS_WRITE);
        if (ret) {
                mlog_errno(ret);
@@ -5655,7 +5692,7 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb,
                goto bail;
        }
 
-       status = ocfs2_journal_access_di(handle, tl_inode, tl_bh,
+       status = ocfs2_journal_access_di(handle, INODE_CACHE(tl_inode), tl_bh,
                                         OCFS2_JOURNAL_ACCESS_WRITE);
        if (status < 0) {
                mlog_errno(status);
@@ -5717,7 +5754,7 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
        while (i >= 0) {
                /* Caller has given us at least enough credits to
                 * update the truncate log dinode */
-               status = ocfs2_journal_access_di(handle, tl_inode, tl_bh,
+               status = ocfs2_journal_access_di(handle, INODE_CACHE(tl_inode), tl_bh,
                                                 OCFS2_JOURNAL_ACCESS_WRITE);
                if (status < 0) {
                        mlog_errno(status);
@@ -5975,7 +6012,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
                tl->tl_used = 0;
 
                ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check);
-               status = ocfs2_write_block(osb, tl_bh, tl_inode);
+               status = ocfs2_write_block(osb, tl_bh, INODE_CACHE(tl_inode));
                if (status < 0) {
                        mlog_errno(status);
                        goto bail;
@@ -6684,7 +6721,7 @@ delete:
 
                        mlog(0, "deleting this extent block.\n");
 
-                       ocfs2_remove_from_cache(inode, bh);
+                       ocfs2_remove_from_cache(INODE_CACHE(inode), bh);
 
                        BUG_ON(ocfs2_rec_clusters(el, &el->l_recs[0]));
                        BUG_ON(le32_to_cpu(el->l_recs[0].e_cpos));
@@ -6734,14 +6771,14 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
         * Each component will be touched, so we might as well journal
         * here to avoid having to handle errors later.
         */
-       status = ocfs2_journal_access_path(inode, handle, path);
+       status = ocfs2_journal_access_path(INODE_CACHE(inode), handle, path);
        if (status < 0) {
                mlog_errno(status);
                goto bail;
        }
 
        if (last_eb_bh) {
-               status = ocfs2_journal_access_eb(handle, inode, last_eb_bh,
+               status = ocfs2_journal_access_eb(handle, INODE_CACHE(inode), last_eb_bh,
                                                 OCFS2_JOURNAL_ACCESS_WRITE);
                if (status < 0) {
                        mlog_errno(status);
@@ -6816,7 +6853,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
        }
        status = 0;
 bail:
-
+       brelse(last_eb_bh);
        mlog_exit(status);
        return status;
 }
@@ -7103,7 +7140,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
                goto out_unlock;
        }
 
-       ret = ocfs2_journal_access_di(handle, inode, di_bh,
+       ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
                                      OCFS2_JOURNAL_ACCESS_WRITE);
        if (ret) {
                mlog_errno(ret);
@@ -7472,7 +7509,7 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
                goto out;
        }
 
-       ret = ocfs2_journal_access_di(handle, inode, di_bh,
+       ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
                                      OCFS2_JOURNAL_ACCESS_WRITE);
        if (ret) {
                mlog_errno(ret);