]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/ocfs2/alloc.c
ARM: dts: imx6ul: add support for Ka-Ro electronics TXUL mainboard
[karo-tx-linux.git] / fs / ocfs2 / alloc.c
index d002579c6f2b03a62209110a1ce84e7605d2651a..70907d638b6078548045c511081367f93c14126e 100644 (file)
@@ -2516,21 +2516,6 @@ static int ocfs2_update_edge_lengths(handle_t *handle,
        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, subtree_index);
-       if (ret) {
-               mlog_errno(ret);
-               goto out;
-       }
-
        ret = ocfs2_journal_access_path(et->et_ci, handle, path);
        if (ret) {
                mlog_errno(ret);
@@ -2956,7 +2941,7 @@ static int __ocfs2_rotate_tree_left(handle_t *handle,
                     right_path->p_node[subtree_root].bh->b_blocknr,
                     right_path->p_tree_depth);
 
-               ret = ocfs2_extend_rotate_transaction(handle, subtree_root,
+               ret = ocfs2_extend_rotate_transaction(handle, 0,
                                                      orig_credits, left_path);
                if (ret) {
                        mlog_errno(ret);
@@ -3029,21 +3014,9 @@ static int ocfs2_remove_rightmost_path(handle_t *handle,
        struct ocfs2_extent_block *eb;
        struct ocfs2_extent_list *el;
 
-
        ret = ocfs2_et_sanity_check(et);
        if (ret)
                goto out;
-       /*
-        * There's two ways we handle this depending on
-        * whether path is the only existing one.
-        */
-       ret = ocfs2_extend_rotate_transaction(handle, 0,
-                                             handle->h_buffer_credits,
-                                             path);
-       if (ret) {
-               mlog_errno(ret);
-               goto out;
-       }
 
        ret = ocfs2_journal_access_path(et->et_ci, handle, path);
        if (ret) {
@@ -3641,6 +3614,14 @@ static int ocfs2_merge_rec_left(struct ocfs2_path *right_path,
                 */
                if (le16_to_cpu(right_rec->e_leaf_clusters) == 0 &&
                    le16_to_cpu(el->l_next_free_rec) == 1) {
+                       /* extend credit for ocfs2_remove_rightmost_path */
+                       ret = ocfs2_extend_rotate_transaction(handle, 0,
+                                       handle->h_buffer_credits,
+                                       right_path);
+                       if (ret) {
+                               mlog_errno(ret);
+                               goto out;
+                       }
 
                        ret = ocfs2_remove_rightmost_path(handle, et,
                                                          right_path,
@@ -3679,6 +3660,14 @@ static int ocfs2_try_to_merge_extent(handle_t *handle,
        BUG_ON(ctxt->c_contig_type == CONTIG_NONE);
 
        if (ctxt->c_split_covers_rec && ctxt->c_has_empty_extent) {
+               /* extend credit for ocfs2_remove_rightmost_path */
+               ret = ocfs2_extend_rotate_transaction(handle, 0,
+                               handle->h_buffer_credits,
+                               path);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
                /*
                 * The merge code will need to create an empty
                 * extent to take the place of the newly
@@ -3727,6 +3716,15 @@ static int ocfs2_try_to_merge_extent(handle_t *handle,
                 */
                BUG_ON(!ocfs2_is_empty_extent(&el->l_recs[0]));
 
+               /* extend credit for ocfs2_remove_rightmost_path */
+               ret = ocfs2_extend_rotate_transaction(handle, 0,
+                                       handle->h_buffer_credits,
+                                       path);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
+
                /* The merge left us with an empty extent, remove it. */
                ret = ocfs2_rotate_tree_left(handle, et, path, dealloc);
                if (ret) {
@@ -3748,6 +3746,15 @@ static int ocfs2_try_to_merge_extent(handle_t *handle,
                        goto out;
                }
 
+               /* extend credit for ocfs2_remove_rightmost_path */
+               ret = ocfs2_extend_rotate_transaction(handle, 0,
+                               handle->h_buffer_credits,
+                               path);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
+
                ret = ocfs2_rotate_tree_left(handle, et, path, dealloc);
                /*
                 * Error from this last rotate is not critical, so
@@ -3783,6 +3790,16 @@ static int ocfs2_try_to_merge_extent(handle_t *handle,
                }
 
                if (ctxt->c_split_covers_rec) {
+                       /* extend credit for ocfs2_remove_rightmost_path */
+                       ret = ocfs2_extend_rotate_transaction(handle, 0,
+                                       handle->h_buffer_credits,
+                                       path);
+                       if (ret) {
+                               mlog_errno(ret);
+                               ret = 0;
+                               goto out;
+                       }
+
                        /*
                         * The merge may have left an empty extent in
                         * our leaf. Try to rotate it away.
@@ -5342,6 +5359,15 @@ static int ocfs2_truncate_rec(handle_t *handle,
        struct ocfs2_extent_block *eb;
 
        if (ocfs2_is_empty_extent(&el->l_recs[0]) && index > 0) {
+               /* extend credit for ocfs2_remove_rightmost_path */
+               ret = ocfs2_extend_rotate_transaction(handle, 0,
+                               handle->h_buffer_credits,
+                               path);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
+
                ret = ocfs2_rotate_tree_left(handle, et, path, dealloc);
                if (ret) {
                        mlog_errno(ret);
@@ -5928,16 +5954,6 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
 
                ocfs2_journal_dirty(handle, tl_bh);
 
-               /* TODO: Perhaps we can calculate the bulk of the
-                * credits up front rather than extending like
-                * this. */
-               status = ocfs2_extend_trans(handle,
-                                           OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC);
-               if (status < 0) {
-                       mlog_errno(status);
-                       goto bail;
-               }
-
                rec = tl->tl_recs[i];
                start_blk = ocfs2_clusters_to_blocks(data_alloc_inode->i_sb,
                                                    le32_to_cpu(rec.t_start));
@@ -5958,6 +5974,13 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
                                goto bail;
                        }
                }
+
+               status = ocfs2_extend_trans(handle,
+                               OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC);
+               if (status < 0) {
+                       mlog_errno(status);
+                       goto bail;
+               }
                i--;
        }
 
@@ -6016,7 +6039,7 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
                goto out_mutex;
        }
 
-       handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
+       handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC);
        if (IS_ERR(handle)) {
                status = PTR_ERR(handle);
                mlog_errno(status);
@@ -6079,7 +6102,7 @@ void ocfs2_schedule_truncate_log_flush(struct ocfs2_super *osb,
                if (cancel)
                        cancel_delayed_work(&osb->osb_truncate_log_wq);
 
-               queue_delayed_work(ocfs2_wq, &osb->osb_truncate_log_wq,
+               queue_delayed_work(osb->ocfs2_wq, &osb->osb_truncate_log_wq,
                                   OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL);
        }
 }
@@ -6253,7 +6276,7 @@ void ocfs2_truncate_log_shutdown(struct ocfs2_super *osb)
 
        if (tl_inode) {
                cancel_delayed_work(&osb->osb_truncate_log_wq);
-               flush_workqueue(ocfs2_wq);
+               flush_workqueue(osb->ocfs2_wq);
 
                status = ocfs2_flush_truncate_log(osb);
                if (status < 0)