]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ocfs2: Make transaction extend more efficient.
authorTao Ma <tao.ma@oracle.com>
Tue, 18 Aug 2009 03:44:07 +0000 (11:44 +0800)
committerJoel Becker <joel.becker@oracle.com>
Wed, 23 Sep 2009 03:09:46 +0000 (20:09 -0700)
In ocfs2_extend_rotate_transaction, op_credits is the orignal
credits in the handle and we only want to extend the credits
for the rotation, but the old solution always double it. It
is harmless for some minor operations, but for actions like
reflink we may rotate tree many times and cause the credits
increase dramatically. So this patch try to only increase
the desired credits.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
fs/ocfs2/alloc.c

index 7c879fc7834f26241fcc0b593eb3089af4c3cbfb..38a42f5d59ff70345b7a8f5840000dc850ea6cff 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;
 }