ocfs2: budget for extent tree splits when adding refcount flag
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 9 Nov 2016 22:13:11 +0000 (14:13 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Sat, 10 Dec 2016 20:39:45 +0000 (12:39 -0800)
When we're adding the refcount flag to an extent, we have to budget
enough space to handle a full extent btree split in addition to
whatever modifications have to be made to the refcount btree.  We
don't currently do this, with the result that generic/186 crashes
when we need an extent split but not a refcount split because meta_ac
never gets allocated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/ocfs2/refcounttree.c

index 3410eb105b0dc74742e9c9c6a367dea58fec7bca..6c98d567ba0129f92deaee8366937f0f9c20bad9 100644 (file)
@@ -3692,6 +3692,9 @@ int ocfs2_add_refcount_flag(struct inode *inode,
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct ocfs2_alloc_context *meta_ac = NULL;
 
+       /* We need to be able to handle at least an extent tree split. */
+       ref_blocks = ocfs2_extend_meta_needed(data_et->et_root_el);
+
        ret = ocfs2_calc_refcount_meta_credits(inode->i_sb,
                                               ref_ci, ref_root_bh,
                                               p_cluster, num_clusters,