[08/25] btrfs: export the caching control helpers
diff mbox series

Message ID 20190620193807.29311-9-josef@toxicpanda.com
State New
Headers show
Series
  • btrfs: migrate the block group code
Related show

Commit Message

Josef Bacik June 20, 2019, 7:37 p.m. UTC
Man a lot of people use this stuff.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/block-group.h |  3 +++
 fs/btrfs/extent-tree.c | 36 ++++++++++++++++++------------------
 2 files changed, 21 insertions(+), 18 deletions(-)

Patch
diff mbox series

diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
index c8a63ccd6b58..8cac9c5f1711 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -173,6 +173,9 @@  btrfs_wait_block_group_cache_progress(struct btrfs_block_group_cache *cache,
 int btrfs_wait_block_group_cache_done(struct btrfs_block_group_cache *cache);
 int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
 			    int load_cache_only);
+void btrfs_put_caching_control(struct btrfs_caching_control *ctl);
+struct btrfs_caching_control *
+btrfs_get_caching_control(struct btrfs_block_group_cache *cache);
 
 static inline int
 btrfs_block_group_cache_done(struct btrfs_block_group_cache *cache)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index eea5a15802f1..9b5853e5dd14 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -181,8 +181,8 @@  static int exclude_super_stripes(struct btrfs_block_group_cache *cache)
 	return 0;
 }
 
-static struct btrfs_caching_control *
-get_caching_control(struct btrfs_block_group_cache *cache)
+struct btrfs_caching_control *
+btrfs_get_caching_control(struct btrfs_block_group_cache *cache)
 {
 	struct btrfs_caching_control *ctl;
 
@@ -198,7 +198,7 @@  get_caching_control(struct btrfs_block_group_cache *cache)
 	return ctl;
 }
 
-static void put_caching_control(struct btrfs_caching_control *ctl)
+void btrfs_put_caching_control(struct btrfs_caching_control *ctl)
 {
 	if (refcount_dec_and_test(&ctl->count))
 		kfree(ctl);
@@ -454,7 +454,7 @@  static noinline void caching_thread(struct btrfs_work *work)
 
 	wake_up(&caching_ctl->wait);
 
-	put_caching_control(caching_ctl);
+	btrfs_put_caching_control(caching_ctl);
 	btrfs_put_block_group(block_group);
 }
 
@@ -503,7 +503,7 @@  int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
 		schedule();
 
 		finish_wait(&ctl->wait, &wait);
-		put_caching_control(ctl);
+		btrfs_put_caching_control(ctl);
 		spin_lock(&cache->lock);
 	}
 
@@ -556,7 +556,7 @@  int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
 
 		wake_up(&caching_ctl->wait);
 		if (ret == 1) {
-			put_caching_control(caching_ctl);
+			btrfs_put_caching_control(caching_ctl);
 			btrfs_free_excluded_extents(cache);
 			return 0;
 		}
@@ -578,7 +578,7 @@  int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
 	}
 
 	if (load_cache_only) {
-		put_caching_control(caching_ctl);
+		btrfs_put_caching_control(caching_ctl);
 		return 0;
 	}
 
@@ -4155,7 +4155,7 @@  static int __exclude_logged_extent(struct btrfs_fs_info *fs_info,
 		return -EINVAL;
 
 	btrfs_cache_block_group(block_group, 0);
-	caching_ctl = get_caching_control(block_group);
+	caching_ctl = btrfs_get_caching_control(block_group);
 
 	if (!caching_ctl) {
 		/* Logic error */
@@ -4185,7 +4185,7 @@  static int __exclude_logged_extent(struct btrfs_fs_info *fs_info,
 		}
 out_lock:
 		mutex_unlock(&caching_ctl->mutex);
-		put_caching_control(caching_ctl);
+		btrfs_put_caching_control(caching_ctl);
 	}
 	btrfs_put_block_group(block_group);
 	return ret;
@@ -4308,7 +4308,7 @@  void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info)
 		if (btrfs_block_group_cache_done(cache)) {
 			cache->last_byte_to_unpin = (u64)-1;
 			list_del_init(&caching_ctl->list);
-			put_caching_control(caching_ctl);
+			btrfs_put_caching_control(caching_ctl);
 		} else {
 			cache->last_byte_to_unpin = caching_ctl->progress;
 		}
@@ -4943,14 +4943,14 @@  btrfs_wait_block_group_cache_progress(struct btrfs_block_group_cache *cache,
 {
 	struct btrfs_caching_control *caching_ctl;
 
-	caching_ctl = get_caching_control(cache);
+	caching_ctl = btrfs_get_caching_control(cache);
 	if (!caching_ctl)
 		return;
 
 	wait_event(caching_ctl->wait, btrfs_block_group_cache_done(cache) ||
 		   (cache->free_space_ctl->free_space >= num_bytes));
 
-	put_caching_control(caching_ctl);
+	btrfs_put_caching_control(caching_ctl);
 }
 
 int btrfs_wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
@@ -4958,14 +4958,14 @@  int btrfs_wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
 	struct btrfs_caching_control *caching_ctl;
 	int ret = 0;
 
-	caching_ctl = get_caching_control(cache);
+	caching_ctl = btrfs_get_caching_control(cache);
 	if (!caching_ctl)
 		return (cache->cached == BTRFS_CACHE_ERROR) ? -EIO : 0;
 
 	wait_event(caching_ctl->wait, btrfs_block_group_cache_done(cache));
 	if (cache->cached == BTRFS_CACHE_ERROR)
 		ret = -EIO;
-	put_caching_control(caching_ctl);
+	btrfs_put_caching_control(caching_ctl);
 	return ret;
 }
 
@@ -7606,7 +7606,7 @@  int btrfs_free_block_groups(struct btrfs_fs_info *info)
 		caching_ctl = list_entry(info->caching_block_groups.next,
 					 struct btrfs_caching_control, list);
 		list_del(&caching_ctl->list);
-		put_caching_control(caching_ctl);
+		btrfs_put_caching_control(caching_ctl);
 	}
 	up_write(&info->commit_root_sem);
 
@@ -8307,7 +8307,7 @@  int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
 	}
 
 	if (block_group->has_caching_ctl)
-		caching_ctl = get_caching_control(block_group);
+		caching_ctl = btrfs_get_caching_control(block_group);
 	if (block_group->cached == BTRFS_CACHE_STARTED)
 		btrfs_wait_block_group_cache_done(block_group);
 	if (block_group->has_caching_ctl) {
@@ -8328,8 +8328,8 @@  int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
 		up_write(&fs_info->commit_root_sem);
 		if (caching_ctl) {
 			/* Once for the caching bgs list and once for us. */
-			put_caching_control(caching_ctl);
-			put_caching_control(caching_ctl);
+			btrfs_put_caching_control(caching_ctl);
+			btrfs_put_caching_control(caching_ctl);
 		}
 	}