Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit feb18927 authored by Johann Lombardi's avatar Johann Lombardi Committed by Linus Torvalds
Browse files

[PATCH] ext4: fix credit calculation in ext4_ext_calc_credits_for_insert



Fix a nit in ext4_ext_calc_credits_for_insert().  Besides, credits for the
new root are already added in the index split accounting.

Signed-off-by: default avatarJohann Lombardi <johann.lombardi@bull.net>
Signed-off-by: default avatarAlex Tomas <alex@clusterfs.com>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 97d2a805
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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;