[PATCH] ext4: fix credit calculation in ext4_ext_calc_credits_for_insert
[linux-2.6-block.git] / fs / ext4 / extents.c
index 1442ccbaea7998f2c15c95b3fa3dd6bf82ab87a9..994a6e450e0693bb2418d7b3159f75c800735468 100644 (file)
@@ -1531,16 +1531,17 @@ int inline ext4_ext_calc_credits_for_insert(struct inode *inode,
 
        /*
         * tree can be full, so it would need to grow in depth:
-        * allocation + old root + new root
+        * we need one credit to modify old root, credits for
+        * new root will be added in split accounting
         */
-       needed += 2 + 1 + 1;
+       needed += 1;
 
        /*
         * Index split can happen, we would need:
         *    allocate intermediate indexes (bitmap + group)
         *  + change two blocks at each level, but root (already included)
         */
-       needed = (depth * 2) + (depth * 2);
+       needed += (depth * 2) + (depth * 2);
 
        /* any allocation modifies superblock */
        needed += 1;