Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/kernel/linux-arm64.git] / fs / ocfs2 / alloc.c
index b8fc95d..38a42f5 100644 (file)
@@ -2326,10 +2326,18 @@ static int ocfs2_extend_rotate_transaction(handle_t *handle, int subtree_depth,
                                           int op_credits,
                                           struct ocfs2_path *path)
 {
+       int ret;
        int credits = (path->p_tree_depth - subtree_depth) * 2 + 1 + op_credits;
 
-       if (handle->h_buffer_credits < credits)
-               return ocfs2_extend_trans(handle, credits);
+       if (handle->h_buffer_credits < credits) {
+               ret = ocfs2_extend_trans(handle,
+                                        credits - handle->h_buffer_credits);
+               if (ret)
+                       return ret;
+
+               if (unlikely(handle->h_buffer_credits < credits))
+                       return ocfs2_extend_trans(handle, credits);
+       }
 
        return 0;
 }
@@ -6974,7 +6982,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
                                        ocfs2_blocks_to_clusters(osb->sb,
                                                                 delete_blk),
                                        clusters_to_del, meta_ac,
-                                       &tc->tc_dealloc);
+                                       &tc->tc_dealloc, 1);
                else
                        status = ocfs2_truncate_log_append(osb, handle,
                                                           delete_blk,