#include "buffer_head_io.h"
 
 #define NOT_ALLOC_NEW_GROUP            0
-#define ALLOC_NEW_GROUP                        1
+#define ALLOC_NEW_GROUP                        0x1
+#define ALLOC_GROUPS_FROM_GLOBAL       0x2
 
 #define OCFS2_MAX_INODES_TO_STEAL      1024
 
 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
                                   struct inode *alloc_inode,
                                   struct buffer_head *bh,
-                                  u64 max_block);
+                                  u64 max_block,
+                                  int flags);
 
 static int ocfs2_cluster_group_search(struct inode *inode,
                                      struct buffer_head *group_bh,
                                                u16 *bg_bit_off);
 static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
                                             u32 bits_wanted, u64 max_block,
+                                            int flags,
                                             struct ocfs2_alloc_context **ac);
 
 void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac)
 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
                                   struct inode *alloc_inode,
                                   struct buffer_head *bh,
-                                  u64 max_block)
+                                  u64 max_block,
+                                  int flags)
 {
        int status, credits;
        struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
        cl = &fe->id2.i_chain;
        status = ocfs2_reserve_clusters_with_limit(osb,
                                                   le16_to_cpu(cl->cl_cpg),
-                                                  max_block, &ac);
+                                                  max_block, flags, &ac);
        if (status < 0) {
                if (status != -ENOSPC)
                        mlog_errno(status);
                                       struct ocfs2_alloc_context *ac,
                                       int type,
                                       u32 slot,
-                                      int alloc_new_group)
+                                      int flags)
 {
        int status;
        u32 bits_wanted = ac->ac_bits_wanted;
                        goto bail;
                }
 
-               if (alloc_new_group != ALLOC_NEW_GROUP) {
+               if (!(flags & ALLOC_NEW_GROUP)) {
                        mlog(0, "Alloc File %u Full: wanted=%u, free_bits=%u, "
                             "and we don't alloc a new group for it.\n",
                             slot, bits_wanted, free_bits);
                }
 
                status = ocfs2_block_group_alloc(osb, alloc_inode, bh,
-                                                ac->ac_max_block);
+                                                ac->ac_max_block, flags);
                if (status < 0) {
                        if (status != -ENOSPC)
                                mlog_errno(status);
        atomic_set(&osb->s_num_inodes_stolen, 0);
        status = ocfs2_reserve_suballoc_bits(osb, *ac,
                                             INODE_ALLOC_SYSTEM_INODE,
-                                            osb->slot_num, ALLOC_NEW_GROUP);
+                                            osb->slot_num,
+                                            ALLOC_NEW_GROUP |
+                                            ALLOC_GROUPS_FROM_GLOBAL);
        if (status >= 0) {
                status = 0;
 
  * things a bit. */
 static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
                                             u32 bits_wanted, u64 max_block,
+                                            int flags,
                                             struct ocfs2_alloc_context **ac)
 {
        int status;
        (*ac)->ac_max_block = max_block;
 
        status = -ENOSPC;
-       if (ocfs2_alloc_should_use_local(osb, bits_wanted)) {
+       if (!(flags & ALLOC_GROUPS_FROM_GLOBAL) &&
+           ocfs2_alloc_should_use_local(osb, bits_wanted)) {
                status = ocfs2_reserve_local_alloc_bits(osb,
                                                        bits_wanted,
                                                        *ac);
                           u32 bits_wanted,
                           struct ocfs2_alloc_context **ac)
 {
-       return ocfs2_reserve_clusters_with_limit(osb, bits_wanted, 0, ac);
+       return ocfs2_reserve_clusters_with_limit(osb, bits_wanted, 0,
+                                                ALLOC_NEW_GROUP, ac);
 }
 
 /*