* [PATCH 01/17] btrfs: Make btrfs_init_dummy_trans initialize trans' fs_info field
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 02/17] btrfs: Remove fs_info argument from add_block_group_free_space Nikolay Borisov
` (16 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This will be necessary for future cleanups which remove the fs_info
argument from some freespace tree functions.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/tests/btrfs-tests.c | 4 +++-
fs/btrfs/tests/btrfs-tests.h | 3 ++-
fs/btrfs/tests/free-space-tree-tests.c | 2 +-
fs/btrfs/tests/qgroup-tests.c | 12 ++++++------
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 30ed438da2a9..db72b3b6209e 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -219,11 +219,13 @@ void btrfs_free_dummy_block_group(struct btrfs_block_group_cache *cache)
kfree(cache);
}
-void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans)
+void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info)
{
memset(trans, 0, sizeof(*trans));
trans->transid = 1;
trans->type = __TRANS_DUMMY;
+ trans->fs_info = fs_info;
}
int btrfs_run_sanity_tests(void)
diff --git a/fs/btrfs/tests/btrfs-tests.h b/fs/btrfs/tests/btrfs-tests.h
index a5a0b9500d3e..4c11cffb377c 100644
--- a/fs/btrfs/tests/btrfs-tests.h
+++ b/fs/btrfs/tests/btrfs-tests.h
@@ -28,7 +28,8 @@ void btrfs_free_dummy_root(struct btrfs_root *root);
struct btrfs_block_group_cache *
btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info, unsigned long length);
void btrfs_free_dummy_block_group(struct btrfs_block_group_cache *cache);
-void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans);
+void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info);
#else
static inline int btrfs_run_sanity_tests(void)
{
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index e1f9666c4974..a24ead6ceb2b 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -482,7 +482,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
cache->needs_free_space = 1;
cache->fs_info = root->fs_info;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, root->fs_info);
path = btrfs_alloc_path();
if (!path) {
diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
index 39b95783f736..df4bcce20ba5 100644
--- a/fs/btrfs/tests/qgroup-tests.c
+++ b/fs/btrfs/tests/qgroup-tests.c
@@ -24,7 +24,7 @@ static int insert_normal_tree_ref(struct btrfs_root *root, u64 bytenr,
u32 size = sizeof(*item) + sizeof(*iref) + sizeof(*block_info);
int ret;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, NULL);
ins.objectid = bytenr;
ins.type = BTRFS_EXTENT_ITEM_KEY;
@@ -74,7 +74,7 @@ static int add_tree_ref(struct btrfs_root *root, u64 bytenr, u64 num_bytes,
u64 refs;
int ret;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, NULL);
key.objectid = bytenr;
key.type = BTRFS_EXTENT_ITEM_KEY;
@@ -124,7 +124,7 @@ static int remove_extent_item(struct btrfs_root *root, u64 bytenr,
struct btrfs_path *path;
int ret;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, NULL);
key.objectid = bytenr;
key.type = BTRFS_EXTENT_ITEM_KEY;
@@ -158,7 +158,7 @@ static int remove_extent_ref(struct btrfs_root *root, u64 bytenr,
u64 refs;
int ret;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, NULL);
key.objectid = bytenr;
key.type = BTRFS_EXTENT_ITEM_KEY;
@@ -213,7 +213,7 @@ static int test_no_shared_qgroup(struct btrfs_root *root,
struct ulist *new_roots = NULL;
int ret;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, fs_info);
test_msg("Qgroup basic add\n");
ret = btrfs_create_qgroup(NULL, fs_info, BTRFS_FS_TREE_OBJECTID);
@@ -314,7 +314,7 @@ static int test_multiple_refs(struct btrfs_root *root,
struct ulist *new_roots = NULL;
int ret;
- btrfs_init_dummy_trans(&trans);
+ btrfs_init_dummy_trans(&trans, fs_info);
test_msg("Qgroup multiple refs test\n");
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/17] btrfs: Remove fs_info argument from add_block_group_free_space
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
2018-05-10 12:44 ` [PATCH 01/17] btrfs: Make btrfs_init_dummy_trans initialize trans' fs_info field Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 03/17] btrfs: Remove fs_info argument from __add_block_group_free_space Nikolay Borisov
` (15 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We also pass in a transaction handle which has a reference to the
fs_info. Just remove the extraneous argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/free-space-tree.c | 2 +-
fs/btrfs/free-space-tree.h | 1 -
fs/btrfs/tests/free-space-tree-tests.c | 2 +-
4 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 2d359b912e1d..1d3140ce34f0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -10258,7 +10258,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
key.offset);
if (ret)
btrfs_abort_transaction(trans, ret);
- add_block_group_free_space(trans, fs_info, block_group);
+ add_block_group_free_space(trans, block_group);
/* already aborted the transaction if it failed. */
next:
list_del_init(&block_group->bg_list);
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 7019afe6e727..0d4a719c8820 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -1292,9 +1292,9 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
}
int add_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_path *path = NULL;
int ret = 0;
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index 874b4feecad2..e0abc265dc59 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -19,7 +19,6 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info);
int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info);
int load_free_space_tree(struct btrfs_caching_control *caching_ctl);
int add_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group);
int remove_block_group_free_space(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index a24ead6ceb2b..f3dfd9fc762f 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -491,7 +491,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
goto out;
}
- ret = add_block_group_free_space(&trans, root->fs_info, cache);
+ ret = add_block_group_free_space(&trans, cache);
if (ret) {
test_msg("Could not add block group free space\n");
goto out;
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/17] btrfs: Remove fs_info argument from __add_block_group_free_space
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
2018-05-10 12:44 ` [PATCH 01/17] btrfs: Make btrfs_init_dummy_trans initialize trans' fs_info field Nikolay Borisov
2018-05-10 12:44 ` [PATCH 02/17] btrfs: Remove fs_info argument from add_block_group_free_space Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 04/17] btrfs: Remove fs_info argument from __add_to_free_space_tree Nikolay Borisov
` (14 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function already takes a transaction handle which has a reference
to the fs_info.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 0d4a719c8820..a1ff604456b7 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -12,7 +12,6 @@
#include "transaction.h"
static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path);
@@ -791,8 +790,7 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
int ret;
if (block_group->needs_free_space) {
- ret = __add_block_group_free_space(trans, fs_info, block_group,
- path);
+ ret = __add_block_group_free_space(trans, block_group, path);
if (ret)
return ret;
}
@@ -987,8 +985,7 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
int ret;
if (block_group->needs_free_space) {
- ret = __add_block_group_free_space(trans, fs_info, block_group,
- path);
+ ret = __add_block_group_free_space(trans, block_group, path);
if (ret)
return ret;
}
@@ -1274,7 +1271,6 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
}
static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path)
{
@@ -1282,11 +1278,12 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
block_group->needs_free_space = 0;
- ret = add_new_free_space_info(trans, fs_info, block_group, path);
+ ret = add_new_free_space_info(trans, trans->fs_info, block_group, path);
if (ret)
return ret;
- return __add_to_free_space_tree(trans, fs_info, block_group, path,
+ return __add_to_free_space_tree(trans, trans->fs_info, block_group,
+ path,
block_group->key.objectid,
block_group->key.offset);
}
@@ -1311,7 +1308,7 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
goto out;
}
- ret = __add_block_group_free_space(trans, fs_info, block_group, path);
+ ret = __add_block_group_free_space(trans, block_group, path);
out:
btrfs_free_path(path);
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/17] btrfs: Remove fs_info argument from __add_to_free_space_tree
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (2 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 03/17] btrfs: Remove fs_info argument from __add_block_group_free_space Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 05/17] btrfs: Remove fs_info parameter from add_new_free_space_info Nikolay Borisov
` (13 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function already takes a transaction handle which contains a
reference to fs_info.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 14 ++++++--------
fs/btrfs/free-space-tree.h | 1 -
fs/btrfs/tests/free-space-tree-tests.c | 26 +++++++++++++-------------
3 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index a1ff604456b7..501769b941a8 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -976,10 +976,10 @@ static int add_free_space_extent(struct btrfs_trans_handle *trans,
}
int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_free_space_info *info;
u32 flags;
int ret;
@@ -1030,8 +1030,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
}
mutex_lock(&block_group->free_space_lock);
- ret = __add_to_free_space_tree(trans, fs_info, block_group, path, start,
- size);
+ ret = __add_to_free_space_tree(trans, block_group, path, start, size);
mutex_unlock(&block_group->free_space_lock);
btrfs_put_block_group(block_group);
@@ -1101,7 +1100,7 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
break;
if (start < key.objectid) {
- ret = __add_to_free_space_tree(trans, fs_info,
+ ret = __add_to_free_space_tree(trans,
block_group,
path2, start,
key.objectid -
@@ -1126,8 +1125,8 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
break;
}
if (start < end) {
- ret = __add_to_free_space_tree(trans, fs_info, block_group,
- path2, start, end - start);
+ ret = __add_to_free_space_tree(trans, block_group, path2,
+ start, end - start);
if (ret)
goto out_locked;
}
@@ -1282,8 +1281,7 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
if (ret)
return ret;
- return __add_to_free_space_tree(trans, trans->fs_info, block_group,
- path,
+ return __add_to_free_space_tree(trans, block_group, path,
block_group->key.objectid,
block_group->key.offset);
}
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index e0abc265dc59..7555f64d6731 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -37,7 +37,6 @@ search_free_space_info(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, int cow);
int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size);
int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index f3dfd9fc762f..6d2b8f736020 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -274,14 +274,14 @@ static int test_merge_left(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
- cache->key.objectid, alignment);
+ ret = __add_to_free_space_tree(trans, cache, path, cache->key.objectid,
+ alignment);
if (ret) {
test_msg("Could not add free space\n");
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + alignment,
alignment);
if (ret) {
@@ -312,7 +312,7 @@ static int test_merge_right(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + 2 * alignment,
alignment);
if (ret) {
@@ -320,7 +320,7 @@ static int test_merge_right(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + alignment,
alignment);
if (ret) {
@@ -351,14 +351,14 @@ static int test_merge_both(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
- cache->key.objectid, alignment);
+ ret = __add_to_free_space_tree(trans, cache, path, cache->key.objectid,
+ alignment);
if (ret) {
test_msg("Could not add free space\n");
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + 2 * alignment,
alignment);
if (ret) {
@@ -366,7 +366,7 @@ static int test_merge_both(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + alignment,
alignment);
if (ret) {
@@ -399,14 +399,14 @@ static int test_merge_none(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
- cache->key.objectid, alignment);
+ ret = __add_to_free_space_tree(trans, cache, path, cache->key.objectid,
+ alignment);
if (ret) {
test_msg("Could not add free space\n");
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + 4 * alignment,
alignment);
if (ret) {
@@ -414,7 +414,7 @@ static int test_merge_none(struct btrfs_trans_handle *trans,
return ret;
}
- ret = __add_to_free_space_tree(trans, fs_info, cache, path,
+ ret = __add_to_free_space_tree(trans, cache, path,
cache->key.objectid + 2 * alignment,
alignment);
if (ret) {
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/17] btrfs: Remove fs_info parameter from add_new_free_space_info
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (3 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 04/17] btrfs: Remove fs_info argument from __add_to_free_space_tree Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 06/17] btrfs: Remove fs_info argument from add_new_free_space Nikolay Borisov
` (12 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function already takes trans handle from where fs_info can be
referenced. Remove the redundant parameter.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 501769b941a8..4b687e2f97aa 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -44,11 +44,10 @@ void set_free_space_tree_thresholds(struct btrfs_block_group_cache *cache)
}
static int add_new_free_space_info(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path)
{
- struct btrfs_root *root = fs_info->free_space_root;
+ struct btrfs_root *root = trans->fs_info->free_space_root;
struct btrfs_free_space_info *info;
struct btrfs_key key;
struct extent_buffer *leaf;
@@ -1067,7 +1066,7 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
return -ENOMEM;
}
- ret = add_new_free_space_info(trans, fs_info, block_group, path2);
+ ret = add_new_free_space_info(trans, block_group, path2);
if (ret)
goto out;
@@ -1277,7 +1276,7 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
block_group->needs_free_space = 0;
- ret = add_new_free_space_info(trans, trans->fs_info, block_group, path);
+ ret = add_new_free_space_info(trans, block_group, path);
if (ret)
return ret;
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/17] btrfs: Remove fs_info argument from add_new_free_space
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (4 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 05/17] btrfs: Remove fs_info parameter from add_new_free_space_info Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 07/17] btrfs: Remove fs_info parameter from remove_block_group_free_space Nikolay Borisov
` (11 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function also takes a btrfs_block_group_cache which contains a
referene to the fs_info. So use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 2 +-
fs/btrfs/extent-tree.c | 13 ++++++-------
fs/btrfs/free-space-tree.c | 8 +++-----
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 5b7080d2fbff..55e56b368216 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2832,7 +2832,7 @@ void btrfs_wait_for_snapshot_creation(struct btrfs_root *root);
void check_system_chunk(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, const u64 type);
u64 add_new_free_space(struct btrfs_block_group_cache *block_group,
- struct btrfs_fs_info *info, u64 start, u64 end);
+ u64 start, u64 end);
/* ctree.c */
int btrfs_bin_search(struct extent_buffer *eb, const struct btrfs_key *key,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1d3140ce34f0..02948c81ebe0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -343,8 +343,9 @@ static void fragment_free_space(struct btrfs_block_group_cache *block_group)
* since their free space will be released as soon as the transaction commits.
*/
u64 add_new_free_space(struct btrfs_block_group_cache *block_group,
- struct btrfs_fs_info *info, u64 start, u64 end)
+ u64 start, u64 end)
{
+ struct btrfs_fs_info *info = block_group->fs_info;
u64 extent_start, extent_end, size, total_added = 0;
int ret;
@@ -489,8 +490,7 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
if (key.type == BTRFS_EXTENT_ITEM_KEY ||
key.type == BTRFS_METADATA_ITEM_KEY) {
- total_found += add_new_free_space(block_group,
- fs_info, last,
+ total_found += add_new_free_space(block_group, last,
key.objectid);
if (key.type == BTRFS_METADATA_ITEM_KEY)
last = key.objectid +
@@ -508,7 +508,7 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
}
ret = 0;
- total_found += add_new_free_space(block_group, fs_info, last,
+ total_found += add_new_free_space(block_group, last,
block_group->key.objectid +
block_group->key.offset);
caching_ctl->progress = (u64)-1;
@@ -10161,8 +10161,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
} 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, info,
- found_key.objectid,
+ add_new_free_space(cache, found_key.objectid,
found_key.objectid +
found_key.offset);
free_excluded_extents(info, cache);
@@ -10299,7 +10298,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
return ret;
}
- add_new_free_space(cache, fs_info, chunk_offset, chunk_offset + size);
+ add_new_free_space(cache, chunk_offset, chunk_offset + size);
free_excluded_extents(fs_info, cache);
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 4b687e2f97aa..ecf07fdcf2d8 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -1438,7 +1438,6 @@ static int load_free_space_bitmaps(struct btrfs_caching_control *caching_ctl,
extent_start = offset;
} else if (prev_bit == 1 && bit == 0) {
total_found += add_new_free_space(block_group,
- fs_info,
extent_start,
offset);
if (total_found > CACHING_CTL_WAKE_UP) {
@@ -1452,8 +1451,8 @@ static int load_free_space_bitmaps(struct btrfs_caching_control *caching_ctl,
}
}
if (prev_bit == 1) {
- total_found += add_new_free_space(block_group, fs_info,
- extent_start, end);
+ total_found += add_new_free_space(block_group, extent_start,
+ end);
extent_count++;
}
@@ -1510,8 +1509,7 @@ static int load_free_space_extents(struct btrfs_caching_control *caching_ctl,
caching_ctl->progress = key.objectid;
- total_found += add_new_free_space(block_group, fs_info,
- key.objectid,
+ total_found += add_new_free_space(block_group, key.objectid,
key.objectid + key.offset);
if (total_found > CACHING_CTL_WAKE_UP) {
total_found = 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/17] btrfs: Remove fs_info parameter from remove_block_group_free_space
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (5 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 06/17] btrfs: Remove fs_info argument from add_new_free_space Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 08/17] btrfs: Remove fs_info argument from convert_free_space_to_bitmaps Nikolay Borisov
` (10 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function always takes a trans handle which contains a reference to
the fs_info. Use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/free-space-tree.c | 5 ++---
fs/btrfs/free-space-tree.h | 1 -
fs/btrfs/tests/free-space-tree-tests.c | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 02948c81ebe0..7bccd8a8bee1 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -10637,7 +10637,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
mutex_unlock(&fs_info->chunk_mutex);
- ret = remove_block_group_free_space(trans, fs_info, block_group);
+ ret = remove_block_group_free_space(trans, block_group);
if (ret)
goto out;
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index ecf07fdcf2d8..4a7bef5b8de3 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -1316,10 +1316,9 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
}
int remove_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group)
{
- struct btrfs_root *root = fs_info->free_space_root;
+ struct btrfs_root *root = trans->fs_info->free_space_root;
struct btrfs_path *path;
struct btrfs_key key, found_key;
struct extent_buffer *leaf;
@@ -1327,7 +1326,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
int done = 0, nr;
int ret;
- if (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
+ if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE))
return 0;
if (block_group->needs_free_space) {
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index 7555f64d6731..c4adfd05f34f 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -21,7 +21,6 @@ int load_free_space_tree(struct btrfs_caching_control *caching_ctl);
int add_block_group_free_space(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group);
int remove_block_group_free_space(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group);
int add_to_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index 6d2b8f736020..86955cf8c9be 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -510,7 +510,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
if (ret)
goto out;
- ret = remove_block_group_free_space(&trans, root->fs_info, cache);
+ ret = remove_block_group_free_space(&trans, cache);
if (ret) {
test_msg("Could not remove block group free space\n");
goto out;
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/17] btrfs: Remove fs_info argument from convert_free_space_to_bitmaps
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (6 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 07/17] btrfs: Remove fs_info parameter from remove_block_group_free_space Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 09/17] btrfs: Remove fs_info parameter from convert_free_space_to_extents Nikolay Borisov
` (9 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function already takes a transaction handle which contains a
reference to fs_info. So use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 5 ++---
fs/btrfs/free-space-tree.h | 1 -
fs/btrfs/tests/free-space-tree-tests.c | 5 ++---
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 4a7bef5b8de3..1dea35ac7139 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -177,10 +177,10 @@ static void le_bitmap_set(unsigned long *map, unsigned int start, int len)
}
int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *root = fs_info->free_space_root;
struct btrfs_free_space_info *info;
struct btrfs_key key, found_key;
@@ -477,8 +477,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
if (!(flags & BTRFS_FREE_SPACE_USING_BITMAPS) &&
extent_count > block_group->bitmap_high_thresh) {
- ret = convert_free_space_to_bitmaps(trans, fs_info, block_group,
- path);
+ ret = convert_free_space_to_bitmaps(trans, block_group, path);
} else if ((flags & BTRFS_FREE_SPACE_USING_BITMAPS) &&
extent_count < block_group->bitmap_low_thresh) {
ret = convert_free_space_to_extents(trans, fs_info, block_group,
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index c4adfd05f34f..72ff743611ff 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -43,7 +43,6 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size);
int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path);
int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index 86955cf8c9be..d3983ae6173a 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -137,7 +137,7 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans,
return ret;
}
} else {
- ret = convert_free_space_to_bitmaps(trans, fs_info, cache, path);
+ ret = convert_free_space_to_bitmaps(trans, cache, path);
if (ret) {
test_msg("Could not convert to bitmaps\n");
return ret;
@@ -498,8 +498,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
}
if (bitmaps) {
- ret = convert_free_space_to_bitmaps(&trans, root->fs_info,
- cache, path);
+ ret = convert_free_space_to_bitmaps(&trans, cache, path);
if (ret) {
test_msg("Could not convert block group to bitmaps\n");
goto out;
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/17] btrfs: Remove fs_info parameter from convert_free_space_to_extents
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (7 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 08/17] btrfs: Remove fs_info argument from convert_free_space_to_bitmaps Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 10/17] btrfs: Remove fs_info argument from update_free_space_extent_count Nikolay Borisov
` (8 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function always takes a transaction handle which contains a
reference to fs_info. So use that and kill the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 5 ++---
fs/btrfs/free-space-tree.h | 1 -
fs/btrfs/tests/free-space-tree-tests.c | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 1dea35ac7139..3937a3baf2f5 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -316,10 +316,10 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
}
int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *root = fs_info->free_space_root;
struct btrfs_free_space_info *info;
struct btrfs_key key, found_key;
@@ -480,8 +480,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
ret = convert_free_space_to_bitmaps(trans, block_group, path);
} else if ((flags & BTRFS_FREE_SPACE_USING_BITMAPS) &&
extent_count < block_group->bitmap_low_thresh) {
- ret = convert_free_space_to_extents(trans, fs_info, block_group,
- path);
+ ret = convert_free_space_to_extents(trans, block_group, path);
}
out:
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index 72ff743611ff..7624f2a1f8e7 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -46,7 +46,6 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path);
int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path);
int free_space_test_bit(struct btrfs_block_group_cache *block_group,
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index d3983ae6173a..176ee997319c 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -131,7 +131,7 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans,
/* Flip it to the other format and check that for good measure. */
if (flags & BTRFS_FREE_SPACE_USING_BITMAPS) {
- ret = convert_free_space_to_extents(trans, fs_info, cache, path);
+ ret = convert_free_space_to_extents(trans, cache, path);
if (ret) {
test_msg("Could not convert to extents\n");
return ret;
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/17] btrfs: Remove fs_info argument from update_free_space_extent_count
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (8 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 09/17] btrfs: Remove fs_info parameter from convert_free_space_to_extents Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 11/17] btrfs: Remove fs_info argument from modify_free_space_bitmap Nikolay Borisov
` (7 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function already takes a transaction handle which has a reference
to the fs_info. So use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 3937a3baf2f5..4f36016b2476 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -449,7 +449,6 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
}
static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path,
int new_extents)
@@ -462,7 +461,8 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
if (new_extents == 0)
return 0;
- info = search_free_space_info(trans, fs_info, block_group, path, 1);
+ info = search_free_space_info(trans, trans->fs_info, block_group, path,
+ 1);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
goto out;
@@ -683,7 +683,7 @@ static int modify_free_space_bitmap(struct btrfs_trans_handle *trans,
}
btrfs_release_path(path);
- ret = update_free_space_extent_count(trans, fs_info, block_group, path,
+ ret = update_free_space_extent_count(trans, block_group, path,
new_extents);
out:
@@ -770,7 +770,7 @@ static int remove_free_space_extent(struct btrfs_trans_handle *trans,
}
btrfs_release_path(path);
- ret = update_free_space_extent_count(trans, fs_info, block_group, path,
+ ret = update_free_space_extent_count(trans, block_group, path,
new_extents);
out:
@@ -965,7 +965,7 @@ static int add_free_space_extent(struct btrfs_trans_handle *trans,
goto out;
btrfs_release_path(path);
- ret = update_free_space_extent_count(trans, fs_info, block_group, path,
+ ret = update_free_space_extent_count(trans, block_group, path,
new_extents);
out:
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/17] btrfs: Remove fs_info argument from modify_free_space_bitmap
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (9 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 10/17] btrfs: Remove fs_info argument from update_free_space_extent_count Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 12/17] btrfs: Remove fs_info argument from add_free_space_extent Nikolay Borisov
` (6 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function already takes a transaction which has a reference to the
fs_info. So use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 4f36016b2476..e314daeb5072 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -577,12 +577,11 @@ static int free_space_next_bitmap(struct btrfs_trans_handle *trans,
* the bitmap.
*/
static int modify_free_space_bitmap(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path,
u64 start, u64 size, int remove)
{
- struct btrfs_root *root = fs_info->free_space_root;
+ struct btrfs_root *root = block_group->fs_info->free_space_root;
struct btrfs_key key;
u64 end = start + size;
u64 cur_start, cur_size;
@@ -799,8 +798,8 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
btrfs_release_path(path);
if (flags & BTRFS_FREE_SPACE_USING_BITMAPS) {
- return modify_free_space_bitmap(trans, fs_info, block_group,
- path, start, size, 1);
+ return modify_free_space_bitmap(trans, block_group, path,
+ start, size, 1);
} else {
return remove_free_space_extent(trans, fs_info, block_group,
path, start, size);
@@ -994,8 +993,8 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
btrfs_release_path(path);
if (flags & BTRFS_FREE_SPACE_USING_BITMAPS) {
- return modify_free_space_bitmap(trans, fs_info, block_group,
- path, start, size, 0);
+ return modify_free_space_bitmap(trans, block_group, path,
+ start, size, 0);
} else {
return add_free_space_extent(trans, fs_info, block_group, path,
start, size);
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/17] btrfs: Remove fs_info argument from add_free_space_extent
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (10 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 11/17] btrfs: Remove fs_info argument from modify_free_space_bitmap Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 13/17] btrfs: Remove fs_info argument from remove_free_space_extent Nikolay Borisov
` (5 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function always takes a transaction handle which references the
fs_info structure. So use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index e314daeb5072..4d6f8cbb77d7 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -844,12 +844,11 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
}
static int add_free_space_extent(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path,
u64 start, u64 size)
{
- struct btrfs_root *root = fs_info->free_space_root;
+ struct btrfs_root *root = trans->fs_info->free_space_root;
struct btrfs_key key, new_key;
u64 found_start, found_end;
u64 end = start + size;
@@ -996,8 +995,8 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
return modify_free_space_bitmap(trans, block_group, path,
start, size, 0);
} else {
- return add_free_space_extent(trans, fs_info, block_group, path,
- start, size);
+ return add_free_space_extent(trans, block_group, path, start,
+ size);
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 13/17] btrfs: Remove fs_info argument from remove_free_space_extent
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (11 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 12/17] btrfs: Remove fs_info argument from add_free_space_extent Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 14/17] btrfs: Remove fs_info argument from __remove_from_free_space_tree Nikolay Borisov
` (4 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function takes a transaction handle which already has a reference
to the fs_info. Use it and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 4d6f8cbb77d7..f0260cfcf7eb 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -690,12 +690,11 @@ static int modify_free_space_bitmap(struct btrfs_trans_handle *trans,
}
static int remove_free_space_extent(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path,
u64 start, u64 size)
{
- struct btrfs_root *root = fs_info->free_space_root;
+ struct btrfs_root *root = trans->fs_info->free_space_root;
struct btrfs_key key;
u64 found_start, found_end;
u64 end = start + size;
@@ -801,8 +800,8 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
return modify_free_space_bitmap(trans, block_group, path,
start, size, 1);
} else {
- return remove_free_space_extent(trans, fs_info, block_group,
- path, start, size);
+ return remove_free_space_extent(trans, block_group, path,
+ start, size);
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 14/17] btrfs: Remove fs_info argument from __remove_from_free_space_tree
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (12 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 13/17] btrfs: Remove fs_info argument from remove_free_space_extent Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 15/17] btrfs: Remove fs_info argument from remove_from_free_space_tree Nikolay Borisov
` (3 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function takes a transaction handle which holds a reference to
fs_info. So use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 8 ++++----
fs/btrfs/free-space-tree.h | 1 -
fs/btrfs/tests/free-space-tree-tests.c | 16 ++++++++--------
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index f0260cfcf7eb..d9d464f0c724 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -776,7 +776,6 @@ static int remove_free_space_extent(struct btrfs_trans_handle *trans,
}
int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size)
{
@@ -790,7 +789,8 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
return ret;
}
- info = search_free_space_info(NULL, fs_info, block_group, path, 0);
+ info = search_free_space_info(NULL, trans->fs_info, block_group, path,
+ 0);
if (IS_ERR(info))
return PTR_ERR(info);
flags = btrfs_free_space_flags(path->nodes[0], info);
@@ -830,8 +830,8 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
}
mutex_lock(&block_group->free_space_lock);
- ret = __remove_from_free_space_tree(trans, fs_info, block_group, path,
- start, size);
+ ret = __remove_from_free_space_tree(trans, block_group, path, start,
+ size);
mutex_unlock(&block_group->free_space_lock);
btrfs_put_block_group(block_group);
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index 7624f2a1f8e7..ca3ad610a8d0 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -39,7 +39,6 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size);
int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size);
int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index 176ee997319c..cb92868eec15 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -170,7 +170,7 @@ static int test_remove_all(struct btrfs_trans_handle *trans,
const struct free_space_extent extents[] = {};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid,
cache->key.offset);
if (ret) {
@@ -194,7 +194,7 @@ static int test_remove_beginning(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid, alignment);
if (ret) {
test_msg("Could not remove free space\n");
@@ -217,7 +217,7 @@ static int test_remove_end(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid +
cache->key.offset - alignment,
alignment);
@@ -243,7 +243,7 @@ static int test_remove_middle(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid + alignment,
alignment);
if (ret) {
@@ -266,7 +266,7 @@ static int test_merge_left(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid,
cache->key.offset);
if (ret) {
@@ -304,7 +304,7 @@ static int test_merge_right(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid,
cache->key.offset);
if (ret) {
@@ -343,7 +343,7 @@ static int test_merge_both(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid,
cache->key.offset);
if (ret) {
@@ -391,7 +391,7 @@ static int test_merge_none(struct btrfs_trans_handle *trans,
};
int ret;
- ret = __remove_from_free_space_tree(trans, fs_info, cache, path,
+ ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid,
cache->key.offset);
if (ret) {
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 15/17] btrfs: Remove fs_info argument from remove_from_free_space_tree
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (13 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 14/17] btrfs: Remove fs_info argument from __remove_from_free_space_tree Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 16/17] btrfs: Remove fs_info argument from add_to_free_space_tree Nikolay Borisov
` (2 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function alreay takes a transaction handle which holds a reference
to the fs_info. Use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/extent-tree.c | 6 ++----
fs/btrfs/free-space-tree.c | 5 ++---
fs/btrfs/free-space-tree.h | 1 -
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 7bccd8a8bee1..6a1641597d6e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8172,8 +8172,7 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(path->nodes[0]);
btrfs_free_path(path);
- ret = remove_from_free_space_tree(trans, fs_info, ins->objectid,
- ins->offset);
+ ret = remove_from_free_space_tree(trans, ins->objectid, ins->offset);
if (ret)
return ret;
@@ -8255,8 +8254,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(leaf);
btrfs_free_path(path);
- ret = remove_from_free_space_tree(trans, fs_info, ins->objectid,
- num_bytes);
+ ret = remove_from_free_space_tree(trans, ins->objectid, num_bytes);
if (ret)
return ret;
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index d9d464f0c724..36da2c3a28f6 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -806,14 +806,13 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
}
int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
u64 start, u64 size)
{
struct btrfs_block_group_cache *block_group;
struct btrfs_path *path;
int ret;
- if (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
+ if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE))
return 0;
path = btrfs_alloc_path();
@@ -822,7 +821,7 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
goto out;
}
- block_group = btrfs_lookup_block_group(fs_info, start);
+ block_group = btrfs_lookup_block_group(trans->fs_info, start);
if (!block_group) {
ASSERT(0);
ret = -ENOENT;
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index ca3ad610a8d0..95916320abec 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -26,7 +26,6 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info,
u64 start, u64 size);
int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
u64 start, u64 size);
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 16/17] btrfs: Remove fs_info argument from add_to_free_space_tree
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (14 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 15/17] btrfs: Remove fs_info argument from remove_from_free_space_tree Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-10 12:44 ` [PATCH 17/17] btrfs: Remove fs_info argument from populate_free_space_tree Nikolay Borisov
2018-05-11 12:12 ` [PATCH 00/17] Freespace tree big fs_info cleanup David Sterba
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function takes a transaction handle which already contains a
reference to the fs_info. So use it and remove the extra function
argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/free-space-tree.c | 5 ++---
fs/btrfs/free-space-tree.h | 1 -
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6a1641597d6e..bf06a81412f4 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7126,7 +7126,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
}
}
- ret = add_to_free_space_tree(trans, info, bytenr, num_bytes);
+ ret = add_to_free_space_tree(trans, bytenr, num_bytes);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto out;
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 36da2c3a28f6..494ff0815988 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -999,14 +999,13 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
}
int add_to_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
u64 start, u64 size)
{
struct btrfs_block_group_cache *block_group;
struct btrfs_path *path;
int ret;
- if (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
+ if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE))
return 0;
path = btrfs_alloc_path();
@@ -1015,7 +1014,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
goto out;
}
- block_group = btrfs_lookup_block_group(fs_info, start);
+ block_group = btrfs_lookup_block_group(trans->fs_info, start);
if (!block_group) {
ASSERT(0);
ret = -ENOENT;
diff --git a/fs/btrfs/free-space-tree.h b/fs/btrfs/free-space-tree.h
index 95916320abec..3133651d7d70 100644
--- a/fs/btrfs/free-space-tree.h
+++ b/fs/btrfs/free-space-tree.h
@@ -23,7 +23,6 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
int remove_block_group_free_space(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group);
int add_to_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
u64 start, u64 size);
int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
u64 start, u64 size);
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 17/17] btrfs: Remove fs_info argument from populate_free_space_tree
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (15 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 16/17] btrfs: Remove fs_info argument from add_to_free_space_tree Nikolay Borisov
@ 2018-05-10 12:44 ` Nikolay Borisov
2018-05-11 12:12 ` [PATCH 00/17] Freespace tree big fs_info cleanup David Sterba
17 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2018-05-10 12:44 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function always takes a transaction handle which contains a
reference to the fs_info. Use that and remove the extra argument.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-tree.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 494ff0815988..b5950aacd697 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -1039,10 +1039,9 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
* through the normal add/remove hooks.
*/
static int populate_free_space_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group)
{
- struct btrfs_root *extent_root = fs_info->extent_root;
+ struct btrfs_root *extent_root = trans->fs_info->extent_root;
struct btrfs_path *path, *path2;
struct btrfs_key key;
u64 start, end;
@@ -1102,7 +1101,7 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
}
start = key.objectid;
if (key.type == BTRFS_METADATA_ITEM_KEY)
- start += fs_info->nodesize;
+ start += trans->fs_info->nodesize;
else
start += key.offset;
} else if (key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) {
@@ -1158,7 +1157,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
while (node) {
block_group = rb_entry(node, struct btrfs_block_group_cache,
cache_node);
- ret = populate_free_space_tree(trans, fs_info, block_group);
+ ret = populate_free_space_tree(trans, block_group);
if (ret)
goto abort;
node = rb_next(node);
--
2.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 00/17] Freespace tree big fs_info cleanup
2018-05-10 12:44 [PATCH 00/17] Freespace tree big fs_info cleanup Nikolay Borisov
` (16 preceding siblings ...)
2018-05-10 12:44 ` [PATCH 17/17] btrfs: Remove fs_info argument from populate_free_space_tree Nikolay Borisov
@ 2018-05-11 12:12 ` David Sterba
17 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2018-05-11 12:12 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Thu, May 10, 2018 at 03:44:39PM +0300, Nikolay Borisov wrote:
> Here is a series which cleans _all_ freespace tree functions from a redundant
> fs_info argument since they already take either a transaction or a
> block_group_cache structure. Both of those structures contain a reference to
> fs info and can be used instead of an additional parameter. This is needed
> since I will be pulling some of the freespace tree code into btrfs-progs in
> implementing check/rebuild functionality for the freespace tree. So better have
> this sooner rather than later.
>
> This series should bring no functional changes but just in case it passed the
> btrfs' selftests as well as a full xfstest run.
>
> Nikolay Borisov (17):
> btrfs: Make btrfs_init_dummy_trans initialize trans' fs_info field
> btrfs: Remove fs_info argument from add_block_group_free_space
> btrfs: Remove fs_info argument from __add_block_group_free_space
> btrfs: Remove fs_info argument from __add_to_free_space_tree
> btrfs: Remove fs_info parameter from add_new_free_space_info
> btrfs: Remove fs_info argument from add_new_free_space
> btrfs: Remove fs_info parameter from remove_block_group_free_space
> btrfs: Remove fs_info argument from convert_free_space_to_bitmaps
> btrfs: Remove fs_info parameter from convert_free_space_to_extents
> btrfs: Remove fs_info argument from update_free_space_extent_count
> btrfs: Remove fs_info argument from modify_free_space_bitmap
> btrfs: Remove fs_info argument from add_free_space_extent
> btrfs: Remove fs_info argument from remove_free_space_extent
> btrfs: Remove fs_info argument from __remove_from_free_space_tree
> btrfs: Remove fs_info argument from remove_from_free_space_tree
> btrfs: Remove fs_info argument from add_to_free_space_tree
> btrfs: Remove fs_info argument from populate_free_space_tree
All
Reviewed-by: David Sterba <dsterba@suse.com>
and added to misc-next, thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread