btrfs: rename do_chunk_alloc to btrfs_chunk_alloc
authorJosef Bacik <josef@toxicpanda.com>
Tue, 18 Jun 2019 20:09:17 +0000 (16:09 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 2 Jul 2019 10:30:51 +0000 (12:30 +0200)
Really we just need the enum, but as we break more things up it'll help
to have this external to extent-tree.c.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c

index 1d6a60f437a62d78e0cf57306aae1bb9b16295d5..8fca40370cf1d5d480b6fac3f2d73bb041971b28 100644 (file)
@@ -2780,6 +2780,28 @@ enum btrfs_flush_state {
        COMMIT_TRANS            =       9,
 };
 
        COMMIT_TRANS            =       9,
 };
 
+/*
+ * control flags for do_chunk_alloc's force field
+ * CHUNK_ALLOC_NO_FORCE means to only allocate a chunk
+ * if we really need one.
+ *
+ * CHUNK_ALLOC_LIMITED means to only try and allocate one
+ * if we have very few chunks already allocated.  This is
+ * used as part of the clustering code to help make sure
+ * we have a good pool of storage to cluster in, without
+ * filling the FS with empty chunks
+ *
+ * CHUNK_ALLOC_FORCE means it must try to allocate one
+ *
+ */
+enum btrfs_chunk_alloc_enum {
+       CHUNK_ALLOC_NO_FORCE,
+       CHUNK_ALLOC_LIMITED,
+       CHUNK_ALLOC_FORCE,
+};
+
+int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
+                     enum btrfs_chunk_alloc_enum force);
 int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
 int btrfs_check_data_free_space(struct inode *inode,
                        struct extent_changeset **reserved, u64 start, u64 len);
 int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
 int btrfs_check_data_free_space(struct inode *inode,
                        struct extent_changeset **reserved, u64 start, u64 len);
index 11ee633b02dc89f17e6484dca42ddbbe2bb8bf1e..16e61acc0179cbfb75528bdbee282c1b512c972f 100644 (file)
 
 #undef SCRAMBLE_DELAYED_REFS
 
 
 #undef SCRAMBLE_DELAYED_REFS
 
-/*
- * control flags for do_chunk_alloc's force field
- * CHUNK_ALLOC_NO_FORCE means to only allocate a chunk
- * if we really need one.
- *
- * CHUNK_ALLOC_LIMITED means to only try and allocate one
- * if we have very few chunks already allocated.  This is
- * used as part of the clustering code to help make sure
- * we have a good pool of storage to cluster in, without
- * filling the FS with empty chunks
- *
- * CHUNK_ALLOC_FORCE means it must try to allocate one
- *
- */
-enum {
-       CHUNK_ALLOC_NO_FORCE,
-       CHUNK_ALLOC_LIMITED,
-       CHUNK_ALLOC_FORCE,
-};
-
 /*
  * Declare a helper function to detect underflow of various space info members
  */
 /*
  * Declare a helper function to detect underflow of various space info members
  */
@@ -88,8 +68,6 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
 static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
                                     struct btrfs_delayed_ref_node *node,
                                     struct btrfs_delayed_extent_op *extent_op);
 static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
                                     struct btrfs_delayed_ref_node *node,
                                     struct btrfs_delayed_extent_op *extent_op);
-static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
-                         int force);
 static int find_next_key(struct btrfs_path *path, int level,
                         struct btrfs_key *key);
 static void dump_space_info(struct btrfs_fs_info *fs_info,
 static int find_next_key(struct btrfs_path *path, int level,
                         struct btrfs_key *key);
 static void dump_space_info(struct btrfs_fs_info *fs_info,
@@ -4143,8 +4121,8 @@ again:
                        if (IS_ERR(trans))
                                return PTR_ERR(trans);
 
                        if (IS_ERR(trans))
                                return PTR_ERR(trans);
 
-                       ret = do_chunk_alloc(trans, alloc_target,
-                                            CHUNK_ALLOC_NO_FORCE);
+                       ret = btrfs_chunk_alloc(trans, alloc_target,
+                                               CHUNK_ALLOC_NO_FORCE);
                        btrfs_end_transaction(trans);
                        if (ret < 0) {
                                if (ret != -ENOSPC)
                        btrfs_end_transaction(trans);
                        if (ret < 0) {
                                if (ret != -ENOSPC)
@@ -4414,8 +4392,8 @@ void check_system_chunk(struct btrfs_trans_handle *trans, u64 type)
  *    - return 1 if it successfully allocates a chunk,
  *    - return errors including -ENOSPC otherwise.
  */
  *    - return 1 if it successfully allocates a chunk,
  *    - return errors including -ENOSPC otherwise.
  */
-static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
-                         int force)
+int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
+                     enum btrfs_chunk_alloc_enum force)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_space_info *space_info;
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_space_info *space_info;
@@ -4877,10 +4855,10 @@ static void flush_space(struct btrfs_fs_info *fs_info,
                        ret = PTR_ERR(trans);
                        break;
                }
                        ret = PTR_ERR(trans);
                        break;
                }
-               ret = do_chunk_alloc(trans,
-                                    btrfs_metadata_alloc_profile(fs_info),
-                                    (state == ALLOC_CHUNK) ?
-                                     CHUNK_ALLOC_NO_FORCE : CHUNK_ALLOC_FORCE);
+               ret = btrfs_chunk_alloc(trans,
+                               btrfs_metadata_alloc_profile(fs_info),
+                               (state == ALLOC_CHUNK) ? CHUNK_ALLOC_NO_FORCE :
+                                       CHUNK_ALLOC_FORCE);
                btrfs_end_transaction(trans);
                if (ret > 0 || ret == -ENOSPC)
                        ret = 0;
                btrfs_end_transaction(trans);
                if (ret > 0 || ret == -ENOSPC)
                        ret = 0;
@@ -7672,8 +7650,8 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
                                return ret;
                        }
 
                                return ret;
                        }
 
-                       ret = do_chunk_alloc(trans, ffe_ctl->flags,
-                                            CHUNK_ALLOC_FORCE);
+                       ret = btrfs_chunk_alloc(trans, ffe_ctl->flags,
+                                               CHUNK_ALLOC_FORCE);
 
                        /*
                         * If we can't allocate a new chunk we've already looped
 
                        /*
                         * If we can't allocate a new chunk we've already looped
@@ -9687,8 +9665,7 @@ again:
         */
        alloc_flags = update_block_group_flags(fs_info, cache->flags);
        if (alloc_flags != cache->flags) {
         */
        alloc_flags = update_block_group_flags(fs_info, cache->flags);
        if (alloc_flags != cache->flags) {
-               ret = do_chunk_alloc(trans, alloc_flags,
-                                    CHUNK_ALLOC_FORCE);
+               ret = btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
                /*
                 * ENOSPC is allowed here, we may have enough space
                 * already allocated at the new raid level to
                /*
                 * ENOSPC is allowed here, we may have enough space
                 * already allocated at the new raid level to
@@ -9704,7 +9681,7 @@ again:
        if (!ret)
                goto out;
        alloc_flags = get_alloc_profile(fs_info, cache->space_info->flags);
        if (!ret)
                goto out;
        alloc_flags = get_alloc_profile(fs_info, cache->space_info->flags);
-       ret = do_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
+       ret = btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
        if (ret < 0)
                goto out;
        ret = inc_block_group_ro(cache, 0);
        if (ret < 0)
                goto out;
        ret = inc_block_group_ro(cache, 0);
@@ -9725,7 +9702,7 @@ int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, u64 type)
 {
        u64 alloc_flags = get_alloc_profile(trans->fs_info, type);
 
 {
        u64 alloc_flags = get_alloc_profile(trans->fs_info, type);
 
-       return do_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
+       return btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
 }
 
 /*
 }
 
 /*