From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 07/25] btrfs: export the excluded extents helpers
Date: Thu, 20 Jun 2019 15:37:49 -0400 [thread overview]
Message-ID: <20190620193807.29311-8-josef@toxicpanda.com> (raw)
In-Reply-To: <20190620193807.29311-1-josef@toxicpanda.com>
We'll need this to move the caching stuff around.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 3 +++
fs/btrfs/extent-tree.c | 40 +++++++++++++++++++++-------------------
2 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c4ae6714e3d4..409852f7af9f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2460,6 +2460,9 @@ static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_fs_info *fs_info,
return (u64)fs_info->nodesize * BTRFS_MAX_LEVEL * num_items;
}
+int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,
+ u64 start, u64 num_bytes);
+void btrfs_free_excluded_extents(struct btrfs_block_group_cache *cache);
int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
unsigned long count);
void btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 82451a64f8ee..eea5a15802f1 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -99,8 +99,8 @@ static int btrfs_add_block_group_cache(struct btrfs_fs_info *info,
return 0;
}
-static int add_excluded_extent(struct btrfs_fs_info *fs_info,
- u64 start, u64 num_bytes)
+int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,
+ u64 start, u64 num_bytes)
{
u64 end = start + num_bytes - 1;
set_extent_bits(&fs_info->freed_extents[0],
@@ -110,7 +110,7 @@ static int add_excluded_extent(struct btrfs_fs_info *fs_info,
return 0;
}
-static void free_excluded_extents(struct btrfs_block_group_cache *cache)
+void btrfs_free_excluded_extents(struct btrfs_block_group_cache *cache)
{
struct btrfs_fs_info *fs_info = cache->fs_info;
u64 start, end;
@@ -135,8 +135,8 @@ static int exclude_super_stripes(struct btrfs_block_group_cache *cache)
if (cache->key.objectid < BTRFS_SUPER_INFO_OFFSET) {
stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->key.objectid;
cache->bytes_super += stripe_len;
- ret = add_excluded_extent(fs_info, cache->key.objectid,
- stripe_len);
+ ret = btrfs_add_excluded_extent(fs_info, cache->key.objectid,
+ stripe_len);
if (ret)
return ret;
}
@@ -169,7 +169,7 @@ static int exclude_super_stripes(struct btrfs_block_group_cache *cache)
}
cache->bytes_super += len;
- ret = add_excluded_extent(fs_info, start, len);
+ ret = btrfs_add_excluded_extent(fs_info, start, len);
if (ret) {
kfree(logical);
return ret;
@@ -449,7 +449,7 @@ static noinline void caching_thread(struct btrfs_work *work)
caching_ctl->progress = (u64)-1;
up_read(&fs_info->commit_root_sem);
- free_excluded_extents(block_group);
+ btrfs_free_excluded_extents(block_group);
mutex_unlock(&caching_ctl->mutex);
wake_up(&caching_ctl->wait);
@@ -458,8 +458,8 @@ static noinline void caching_thread(struct btrfs_work *work)
btrfs_put_block_group(block_group);
}
-static int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
- int load_cache_only)
+int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
+ int load_cache_only)
{
DEFINE_WAIT(wait);
struct btrfs_fs_info *fs_info = cache->fs_info;
@@ -557,7 +557,7 @@ static int btrfs_cache_block_group(struct btrfs_block_group_cache *cache,
wake_up(&caching_ctl->wait);
if (ret == 1) {
put_caching_control(caching_ctl);
- free_excluded_extents(cache);
+ btrfs_free_excluded_extents(cache);
return 0;
}
} else {
@@ -4165,7 +4165,8 @@ static int __exclude_logged_extent(struct btrfs_fs_info *fs_info,
mutex_lock(&caching_ctl->mutex);
if (start >= caching_ctl->progress) {
- ret = add_excluded_extent(fs_info, start, num_bytes);
+ ret = btrfs_add_excluded_extent(fs_info, start,
+ num_bytes);
} else if (start + num_bytes <= caching_ctl->progress) {
ret = btrfs_remove_free_space(block_group,
start, num_bytes);
@@ -4179,7 +4180,8 @@ static int __exclude_logged_extent(struct btrfs_fs_info *fs_info,
num_bytes = (start + num_bytes) -
caching_ctl->progress;
start = caching_ctl->progress;
- ret = add_excluded_extent(fs_info, start, num_bytes);
+ ret = btrfs_add_excluded_extent(fs_info, start,
+ num_bytes);
}
out_lock:
mutex_unlock(&caching_ctl->mutex);
@@ -7637,7 +7639,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
*/
if (block_group->cached == BTRFS_CACHE_NO ||
block_group->cached == BTRFS_CACHE_ERROR)
- free_excluded_extents(block_group);
+ btrfs_free_excluded_extents(block_group);
btrfs_remove_free_space_cache(block_group);
ASSERT(block_group->cached != BTRFS_CACHE_STARTED);
@@ -7939,7 +7941,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
* We may have excluded something, so call this just in
* case.
*/
- free_excluded_extents(cache);
+ btrfs_free_excluded_extents(cache);
btrfs_put_block_group(cache);
goto error;
}
@@ -7954,14 +7956,14 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
if (found_key.offset == btrfs_block_group_used(&cache->item)) {
cache->last_byte_to_unpin = (u64)-1;
cache->cached = BTRFS_CACHE_FINISHED;
- free_excluded_extents(cache);
+ btrfs_free_excluded_extents(cache);
} else if (btrfs_block_group_used(&cache->item) == 0) {
cache->last_byte_to_unpin = (u64)-1;
cache->cached = BTRFS_CACHE_FINISHED;
add_new_free_space(cache, found_key.objectid,
found_key.objectid +
found_key.offset);
- free_excluded_extents(cache);
+ btrfs_free_excluded_extents(cache);
}
ret = btrfs_add_block_group_cache(info, cache);
@@ -8087,14 +8089,14 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
* We may have excluded something, so call this just in
* case.
*/
- free_excluded_extents(cache);
+ btrfs_free_excluded_extents(cache);
btrfs_put_block_group(cache);
return ret;
}
add_new_free_space(cache, chunk_offset, chunk_offset + size);
- free_excluded_extents(cache);
+ btrfs_free_excluded_extents(cache);
#ifdef CONFIG_BTRFS_DEBUG
if (btrfs_should_fragment_free_space(cache)) {
@@ -8181,7 +8183,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
* Free the reserved super bytes from this block group before
* remove it.
*/
- free_excluded_extents(block_group);
+ btrfs_free_excluded_extents(block_group);
btrfs_free_ref_tree_range(fs_info, block_group->key.objectid,
block_group->key.offset);
--
2.14.3
next prev parent reply other threads:[~2019-06-20 19:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 19:37 [PATCH 00/25] btrfs: migrate the block group code Josef Bacik
2019-06-20 19:37 ` [PATCH 01/25] btrfs: move btrfs_add_free_space out of a header file Josef Bacik
2019-06-20 19:37 ` [PATCH 02/25] btrfs: move basic block_group definitions to their own header Josef Bacik
2019-06-20 19:37 ` [PATCH 03/25] btrfs: migrate the block group lookup code Josef Bacik
2019-06-20 19:37 ` [PATCH 04/25] btrfs: migrate the block group ref counting stuff Josef Bacik
2019-06-20 19:37 ` [PATCH 05/25] btrfs: migrate nocow and reservation helpers Josef Bacik
2019-06-20 19:37 ` [PATCH 06/25] btrfs: export the block group caching helpers Josef Bacik
2019-06-20 19:37 ` Josef Bacik [this message]
2019-06-20 19:37 ` [PATCH 08/25] btrfs: export the caching control helpers Josef Bacik
2019-06-20 19:37 ` [PATCH 09/25] btrfs: temporarily export fragment_free_space Josef Bacik
2019-06-20 19:37 ` [PATCH 10/25] btrfs: make caching_thread use btrfs_find_next_key Josef Bacik
2019-06-20 19:37 ` [PATCH 11/25] btrfs: migrate the block group caching code Josef Bacik
2019-06-20 19:37 ` [PATCH 12/25] btrfs: temporarily export inc_block_group_ro Josef Bacik
2019-06-20 19:37 ` [PATCH 13/25] btrfs: migrate the block group removal code Josef Bacik
2019-06-20 19:37 ` [PATCH 14/25] btrfs: export get_alloc_profile Josef Bacik
2019-06-20 19:37 ` [PATCH 15/25] btrfs: migrate the block group read/creation code Josef Bacik
2019-06-20 19:37 ` [PATCH 16/25] btrfs: temporarily export btrfs_get_restripe_target Josef Bacik
2019-06-20 19:37 ` [PATCH 17/25] btrfs: migrate inc/dec_block_group_ro code Josef Bacik
2019-06-20 19:38 ` [PATCH 18/25] btrfs: migrate the dirty bg writeout code Josef Bacik
2019-06-20 19:38 ` [PATCH 19/25] btrfs: export block group accounting helpers Josef Bacik
2019-06-20 19:38 ` [PATCH 20/25] btrfs: migrate the block group space " Josef Bacik
2019-06-20 19:38 ` [PATCH 21/25] btrfs: migrate btrfs_can_relocate Josef Bacik
2019-06-20 19:38 ` [PATCH 22/25] btrfs: migrate the chunk allocation code Josef Bacik
2019-06-20 19:38 ` [PATCH 23/25] btrfs: migrate the alloc_profile helpers Josef Bacik
2019-06-20 19:38 ` [PATCH 24/25] btrfs: migrate the block group cleanup code Josef Bacik
2019-06-20 19:38 ` [PATCH 25/25] btrfs: unexport the temporary exported functions Josef Bacik
2019-08-02 13:56 ` [PATCH 00/25] btrfs: migrate the block group code David Sterba
2019-08-02 14:07 ` Josef Bacik
2019-08-02 18:05 ` David Sterba
2019-08-06 16:43 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190620193807.29311-8-josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).