From 8b06bc592ebc5a31e8d0b9c2ab17c6e78dde1f86 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Fri, 26 Mar 2010 10:09:29 +0800 Subject: ocfs2: Grow discontig block groups in one transaction. Rather than extending the transaction every time we add an extent to a discontiguous block group, we grab enough credits to fill the extent list up front. This means we can free the bits in the same transaction if we end up not getting enough space. Signed-off-by: Joel Becker --- fs/ocfs2/journal.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'fs/ocfs2/journal.h') diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index 7dc56561c9ae..b5baaa8e710f 100644 --- a/fs/ocfs2/journal.h +++ b/fs/ocfs2/journal.h @@ -561,6 +561,18 @@ static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, return blocks; } +/* + * Allocating a discontiguous block group requires the credits from + * ocfs2_calc_group_alloc_credits() as well as enough credits to fill + * the group descriptor's extent list. The caller already has started + * the transaction with ocfs2_calc_group_alloc_credits(). They extend + * it with these credits. + */ +static inline int ocfs2_calc_bg_discontig_credits(struct super_block *sb) +{ + return ocfs2_extent_recs_per_gd(sb); +} + static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, unsigned int clusters_to_del, struct ocfs2_dinode *fe, -- cgit v1.2.3-70-g09d2