diff options
author | Josef Bacik <josef@toxicpanda.com> | 2019-06-20 15:37:50 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-09-09 14:59:04 +0200 |
commit | e3cb339fa5ca57cfa5429bf3da548331dce93038 (patch) | |
tree | 8c9eed80494cd3fd6c8035f80d7cefc276a9aaf2 /fs | |
parent | 6f410d1b3dbf9213ee89c569e8213511319bbd90 (diff) |
btrfs: export the caching control helpers
Man a lot of people use this stuff.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/block-group.h | 3 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 36 |
2 files changed, 21 insertions, 18 deletions
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index 7069bcfc5e8f..3f8b6ffefb8a 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -170,6 +170,9 @@ void 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 2d92f103fa2b..dab8e90237cd 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -182,8 +182,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; @@ -199,7 +199,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); @@ -455,7 +455,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); } @@ -504,7 +504,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); } @@ -557,7 +557,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; } @@ -579,7 +579,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; } @@ -4153,7 +4153,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 */ @@ -4183,7 +4183,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; @@ -4306,7 +4306,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; } @@ -4937,14 +4937,14 @@ void 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) @@ -4952,14 +4952,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; } @@ -7482,7 +7482,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); @@ -8202,7 +8202,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) { @@ -8223,8 +8223,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); } } |