linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] Summer argument cleanup
@ 2018-05-28  6:36 Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 01/11] btrfs-progs: check: Remove root argument from delete_extent_records Nikolay Borisov
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Hello, 

Here is yet another series removing a bunch of extraneous argument. The series 
constitutes no functional changes. Some of the function actually have a kernel 
counterpart (btrfs_lookup_extent_info/clean_tree_block). However the former's 
userspace signature differs and the patch in this series makes it identical to 
the kernel one. 

Nikolay Borisov (11):
  btrfs-progs: check: Remove root argument from delete_extent_records
  btrfs-progs: check: Remove root parameter from
    btrfs_fix_block_accounting
  btrfs-progs: check: Remove root parameter from del_pending_extents
  btrfs-progs: check: Remove root argument from finish_current_insert
  btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info
  btrfs-progs: Remove unused argument from clean_tree_block
  btrfs-progs: check: Remove unused root argument from
    btrfs_extent_post_op
  btrfs-progs: Change btrfs_root to btrfs_fs_info argument in
    btrfs_lookup_extent_info
  btrfs-progs: Remove root argument from btrfs_set_block_flags
  btrfs-progs: Remove root argument from write_one_cache_group
  btrfs-progs: Remove fs_info argument from write_ctree_super

 check/main.c        |  31 +++++++-------
 check/mode-lowmem.c |   6 +--
 ctree.c             |  17 ++++----
 ctree.h             |  13 +++---
 disk-io.c           |   9 ++--
 disk-io.h           |   6 +--
 extent-tree.c       | 121 ++++++++++++++++++++++++----------------------------
 free-space-tree.c   |   2 +-
 transaction.c       |   2 +-
 9 files changed, 96 insertions(+), 111 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 01/11] btrfs-progs: check: Remove root argument from delete_extent_records
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 02/11] btrfs-progs: check: Remove root parameter from btrfs_fix_block_accounting Nikolay Borisov
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

This function is always passed the extent_root as "root" parameter. In
turn it uses the root parameter to mostly access fs_info and performs
only a single call to btrfs_update_block_group where it passses the
passed root. This is all redundant since fs_info can be referenced
from the transaction handle and in turn extent_root can be referenced
from the fs_info. So do that to simplify the function's signature.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 check/main.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/check/main.c b/check/main.c
index 68da994f7ae0..4cf243d9b379 100644
--- a/check/main.c
+++ b/check/main.c
@@ -6295,10 +6295,10 @@ static int free_extent_hook(struct btrfs_trans_handle *trans,
 }
 
 static int delete_extent_records(struct btrfs_trans_handle *trans,
-				 struct btrfs_root *root,
 				 struct btrfs_path *path,
 				 u64 bytenr)
 {
+	struct btrfs_fs_info *fs_info = trans->fs_info;
 	struct btrfs_key key;
 	struct btrfs_key found_key;
 	struct extent_buffer *leaf;
@@ -6311,8 +6311,8 @@ static int delete_extent_records(struct btrfs_trans_handle *trans,
 	key.offset = (u64)-1;
 
 	while (1) {
-		ret = btrfs_search_slot(trans, root->fs_info->extent_root,
-					&key, path, 0, 1);
+		ret = btrfs_search_slot(trans, fs_info->extent_root, &key,
+					path, 0, 1);
 		if (ret < 0)
 			break;
 
@@ -6354,7 +6354,7 @@ static int delete_extent_records(struct btrfs_trans_handle *trans,
 			"repair deleting extent record: key [%llu,%u,%llu]\n",
 			found_key.objectid, found_key.type, found_key.offset);
 
-		ret = btrfs_del_item(trans, root->fs_info->extent_root, path);
+		ret = btrfs_del_item(trans, fs_info->extent_root, path);
 		if (ret)
 			break;
 		btrfs_release_path(path);
@@ -6362,10 +6362,10 @@ static int delete_extent_records(struct btrfs_trans_handle *trans,
 		if (found_key.type == BTRFS_EXTENT_ITEM_KEY ||
 		    found_key.type == BTRFS_METADATA_ITEM_KEY) {
 			u64 bytes = (found_key.type == BTRFS_EXTENT_ITEM_KEY) ?
-				found_key.offset : root->fs_info->nodesize;
+				found_key.offset : fs_info->nodesize;
 
-			ret = btrfs_update_block_group(root, bytenr,
-						       bytes, 0, 0);
+			ret = btrfs_update_block_group(fs_info->extent_root,
+						       bytenr, bytes, 0, 0);
 			if (ret)
 				break;
 		}
@@ -7293,8 +7293,7 @@ static int fixup_extent_refs(struct btrfs_fs_info *info,
 	}
 
 	/* step two, delete all the existing records */
-	ret = delete_extent_records(trans, info->extent_root, &path,
-				    rec->start);
+	ret = delete_extent_records(trans, &path, rec->start);
 
 	if (ret < 0)
 		goto out;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 02/11] btrfs-progs: check: Remove root parameter from btrfs_fix_block_accounting
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 01/11] btrfs-progs: check: Remove root argument from delete_extent_records Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 03/11] btrfs-progs: check: Remove root parameter from del_pending_extents Nikolay Borisov
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

It's always set to extent_root and the function already takes a
transaction handle where fs_info could be referenced and in turn
the extent_tree.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 check/main.c        | 2 +-
 check/mode-lowmem.c | 2 +-
 ctree.h             | 3 +--
 extent-tree.c       | 8 +++-----
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/check/main.c b/check/main.c
index 4cf243d9b379..71cc16735443 100644
--- a/check/main.c
+++ b/check/main.c
@@ -7671,7 +7671,7 @@ static int check_extent_refs(struct btrfs_root *root,
 				goto repair_abort;
 			}
 
-			ret = btrfs_fix_block_accounting(trans, root);
+			ret = btrfs_fix_block_accounting(trans);
 			if (ret)
 				goto repair_abort;
 			ret = btrfs_commit_transaction(trans, root);
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 9890180d1d3c..410c5f635d4e 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -556,7 +556,7 @@ static int repair_block_accounting(struct btrfs_fs_info *fs_info)
 		return ret;
 	}
 
-	ret = btrfs_fix_block_accounting(trans, root);
+	ret = btrfs_fix_block_accounting(trans);
 	btrfs_commit_transaction(trans, root);
 	return ret;
 }
diff --git a/ctree.h b/ctree.h
index 697895a9e098..c833ad6998b9 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2500,8 +2500,7 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
 			 u64 num_bytes, u64 empty_size,
 			 u64 hint_byte, u64 search_end,
 			 struct btrfs_key *ins, bool is_data);
-int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
-				 struct btrfs_root *root);
+int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans);
 void btrfs_pin_extent(struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes);
 void btrfs_unpin_extent(struct btrfs_fs_info *fs_info,
 			u64 bytenr, u64 num_bytes);
diff --git a/extent-tree.c b/extent-tree.c
index 1b8a4f8cb1c3..3132ccc8d44f 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -3788,8 +3788,7 @@ int btrfs_free_block_group(struct btrfs_trans_handle *trans,
  * Fixup block accounting. The initial block accounting created by
  * make_block_groups isn't accuracy in this case.
  */
-int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
-			       struct btrfs_root *root)
+int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans)
 {
 	int ret = 0;
 	int slot;
@@ -3799,9 +3798,8 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
 	struct btrfs_key key;
 	struct extent_buffer *leaf;
 	struct btrfs_block_group_cache *cache;
-	struct btrfs_fs_info *fs_info = root->fs_info;
-
-	root = root->fs_info->extent_root;
+	struct btrfs_fs_info *fs_info = trans->fs_info;
+	struct btrfs_root *root = fs_info->extent_root;
 
 	while(extent_root_pending_ops(fs_info)) {
 		ret = finish_current_insert(trans, root);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 03/11] btrfs-progs: check: Remove root parameter from del_pending_extents
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 01/11] btrfs-progs: check: Remove root argument from delete_extent_records Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 02/11] btrfs-progs: check: Remove root parameter from btrfs_fix_block_accounting Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 04/11] btrfs-progs: check: Remove root argument from finish_current_insert Nikolay Borisov
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

This function always operates on the extent root which can be
referenced from trans->fs_info. Do that to simplify function's
signature.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 extent-tree.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/extent-tree.c b/extent-tree.c
index 3132ccc8d44f..e950ba6de3cc 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -56,8 +56,7 @@ static int __free_extent(struct btrfs_trans_handle *trans,
 			 u64 owner_offset, int refs_to_drop);
 static int finish_current_insert(struct btrfs_trans_handle *trans, struct
 				 btrfs_root *extent_root);
-static int del_pending_extents(struct btrfs_trans_handle *trans, struct
-			       btrfs_root *extent_root);
+static int del_pending_extents(struct btrfs_trans_handle *trans);
 static struct btrfs_block_group_cache *
 btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache
 		       *hint, u64 search_start, int data, int owner);
@@ -1423,7 +1422,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
 out:
 	btrfs_free_path(path);
 	finish_current_insert(trans, root->fs_info->extent_root);
-	del_pending_extents(trans, root->fs_info->extent_root);
+	del_pending_extents(trans);
 	BUG_ON(err);
 	return err;
 }
@@ -1432,7 +1431,7 @@ int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
 			 struct btrfs_root *root)
 {
 	finish_current_insert(trans, root->fs_info->extent_root);
-	del_pending_extents(trans, root->fs_info->extent_root);
+	del_pending_extents(trans);
 	return 0;
 }
 
@@ -1612,7 +1611,7 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
 out:
 	btrfs_free_path(path);
 	finish_current_insert(trans, root->fs_info->extent_root);
-	del_pending_extents(trans, root->fs_info->extent_root);
+	del_pending_extents(trans);
 	return ret;
 }
 
@@ -1728,7 +1727,7 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
 	btrfs_release_path(path);
 fail:
 	finish_current_insert(trans, extent_root);
-	pending_ret = del_pending_extents(trans, extent_root);
+	pending_ret = del_pending_extents(trans);
 	if (ret)
 		return ret;
 	if (pending_ret)
@@ -2397,8 +2396,7 @@ static int __free_extent(struct btrfs_trans_handle *trans,
  * find all the blocks marked as pending in the radix tree and remove
  * them from the extent map
  */
-static int del_pending_extents(struct btrfs_trans_handle *trans, struct
-			       btrfs_root *extent_root)
+static int del_pending_extents(struct btrfs_trans_handle *trans)
 {
 	int ret;
 	int err = 0;
@@ -2408,6 +2406,8 @@ static int del_pending_extents(struct btrfs_trans_handle *trans, struct
 	struct extent_io_tree *pending_del;
 	struct extent_io_tree *extent_ins;
 	struct pending_extent_op *extent_op;
+	struct btrfs_fs_info *fs_info = trans->fs_info;
+	struct btrfs_root *extent_root = fs_info->extent_root;
 
 	extent_ins = &extent_root->fs_info->extent_ins;
 	pending_del = &extent_root->fs_info->pending_del;
@@ -2497,7 +2497,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
 	}
 	ret = __free_extent(trans, root, bytenr, num_bytes, parent,
 			    root_objectid, owner, offset, 1);
-	pending_ret = del_pending_extents(trans, root->fs_info->extent_root);
+	pending_ret = del_pending_extents(trans);
 	return ret ? ret : pending_ret;
 }
 
@@ -2790,7 +2790,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
 						generation, flags,
 						key, level, ins);
 		finish_current_insert(trans, root->fs_info->extent_root);
-		del_pending_extents(trans, root->fs_info->extent_root);
+		del_pending_extents(trans);
 	}
 	return ret;
 }
@@ -3318,7 +3318,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
 
 	ret = finish_current_insert(trans, extent_root);
 	BUG_ON(ret);
-	ret = del_pending_extents(trans, extent_root);
+	ret = del_pending_extents(trans);
 	BUG_ON(ret);
 
 	return 0;
@@ -3417,7 +3417,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
 		BUG_ON(ret);
 
 		finish_current_insert(trans, extent_root);
-		ret = del_pending_extents(trans, extent_root);
+		ret = del_pending_extents(trans);
 		BUG_ON(ret);
 
 		cur_start = cache->key.objectid + cache->key.offset;
@@ -3805,7 +3805,7 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans)
 		ret = finish_current_insert(trans, root);
 		if (ret)
 			return ret;
-		ret = del_pending_extents(trans, root);
+		ret = del_pending_extents(trans);
 		if (ret)
 			return ret;
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 04/11] btrfs-progs: check: Remove root argument from finish_current_insert
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (2 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 03/11] btrfs-progs: check: Remove root parameter from del_pending_extents Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 05/11] btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info Nikolay Borisov
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Just reference it directly from trans->fs_info.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 extent-tree.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/extent-tree.c b/extent-tree.c
index e950ba6de3cc..89fed5b73b1f 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -54,8 +54,7 @@ static int __free_extent(struct btrfs_trans_handle *trans,
 			 u64 bytenr, u64 num_bytes, u64 parent,
 			 u64 root_objectid, u64 owner_objectid,
 			 u64 owner_offset, int refs_to_drop);
-static int finish_current_insert(struct btrfs_trans_handle *trans, struct
-				 btrfs_root *extent_root);
+static int finish_current_insert(struct btrfs_trans_handle *trans);
 static int del_pending_extents(struct btrfs_trans_handle *trans);
 static struct btrfs_block_group_cache *
 btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache
@@ -1421,7 +1420,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
 		err = ret;
 out:
 	btrfs_free_path(path);
-	finish_current_insert(trans, root->fs_info->extent_root);
+	finish_current_insert(trans);
 	del_pending_extents(trans);
 	BUG_ON(err);
 	return err;
@@ -1430,7 +1429,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
 int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
 			 struct btrfs_root *root)
 {
-	finish_current_insert(trans, root->fs_info->extent_root);
+	finish_current_insert(trans);
 	del_pending_extents(trans);
 	return 0;
 }
@@ -1610,7 +1609,7 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
 	btrfs_set_extent_flags(l, item, flags);
 out:
 	btrfs_free_path(path);
-	finish_current_insert(trans, root->fs_info->extent_root);
+	finish_current_insert(trans);
 	del_pending_extents(trans);
 	return ret;
 }
@@ -1726,7 +1725,7 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
 	btrfs_mark_buffer_dirty(leaf);
 	btrfs_release_path(path);
 fail:
-	finish_current_insert(trans, extent_root);
+	finish_current_insert(trans);
 	pending_ret = del_pending_extents(trans);
 	if (ret)
 		return ret;
@@ -2056,13 +2055,13 @@ static int extent_root_pending_ops(struct btrfs_fs_info *info)
 	return ret == 0;
 
 }
-static int finish_current_insert(struct btrfs_trans_handle *trans,
-				 struct btrfs_root *extent_root)
+static int finish_current_insert(struct btrfs_trans_handle *trans)
 {
 	u64 start;
 	u64 end;
 	u64 priv;
-	struct btrfs_fs_info *info = extent_root->fs_info;
+	struct btrfs_fs_info *info = trans->fs_info;
+	struct btrfs_root *extent_root = info->extent_root;
 	struct pending_extent_op *extent_op;
 	struct btrfs_key key;
 	int ret;
@@ -2388,7 +2387,7 @@ static int __free_extent(struct btrfs_trans_handle *trans,
 	}
 fail:
 	btrfs_free_path(path);
-	finish_current_insert(trans, extent_root);
+	finish_current_insert(trans);
 	return ret;
 }
 
@@ -2789,7 +2788,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
 		ret = alloc_reserved_tree_block(trans, root, root_objectid,
 						generation, flags,
 						key, level, ins);
-		finish_current_insert(trans, root->fs_info->extent_root);
+		finish_current_insert(trans);
 		del_pending_extents(trans);
 	}
 	return ret;
@@ -3316,7 +3315,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
 				sizeof(cache->item));
 	BUG_ON(ret);
 
-	ret = finish_current_insert(trans, extent_root);
+	ret = finish_current_insert(trans);
 	BUG_ON(ret);
 	ret = del_pending_extents(trans);
 	BUG_ON(ret);
@@ -3416,7 +3415,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
 					sizeof(cache->item));
 		BUG_ON(ret);
 
-		finish_current_insert(trans, extent_root);
+		finish_current_insert(trans);
 		ret = del_pending_extents(trans);
 		BUG_ON(ret);
 
@@ -3802,7 +3801,7 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans)
 	struct btrfs_root *root = fs_info->extent_root;
 
 	while(extent_root_pending_ops(fs_info)) {
-		ret = finish_current_insert(trans, root);
+		ret = finish_current_insert(trans);
 		if (ret)
 			return ret;
 		ret = del_pending_extents(trans);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 05/11] btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (3 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 04/11] btrfs-progs: check: Remove root argument from finish_current_insert Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 06/11] btrfs-progs: Remove unused argument from clean_tree_block Nikolay Borisov
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

This function needs btrfs_fs_info and not a root. So make it directly
take btrfs_fs_info,

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 extent-tree.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/extent-tree.c b/extent-tree.c
index 89fed5b73b1f..8e7f888b5ce5 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -1979,12 +1979,11 @@ static int update_block_group(struct btrfs_root *root,
 	return 0;
 }
 
-static int update_pinned_extents(struct btrfs_root *root,
+static int update_pinned_extents(struct btrfs_fs_info *fs_info,
 				u64 bytenr, u64 num, int pin)
 {
 	u64 len;
 	struct btrfs_block_group_cache *cache;
-	struct btrfs_fs_info *fs_info = root->fs_info;
 
 	if (pin) {
 		set_extent_dirty(&fs_info->pinned_extents,
@@ -2033,7 +2032,8 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
 					    EXTENT_DIRTY);
 		if (ret)
 			break;
-		update_pinned_extents(root, start, end + 1 - start, 0);
+		update_pinned_extents(trans->fs_info, start, end + 1 - start,
+				      0);
 		clear_extent_dirty(unpin, start, end);
 		set_extent_dirty(free_space_cache, start, end);
 	}
@@ -2136,7 +2136,7 @@ static int pin_down_bytes(struct btrfs_trans_handle *trans,
 	}
 	free_extent_buffer(buf);
 pinit:
-	update_pinned_extents(root, bytenr, num_bytes, 1);
+	update_pinned_extents(trans->fs_info, bytenr, num_bytes, 1);
 
 	BUG_ON(err < 0);
 	return 0;
@@ -2145,13 +2145,13 @@ static int pin_down_bytes(struct btrfs_trans_handle *trans,
 void btrfs_pin_extent(struct btrfs_fs_info *fs_info,
 		       u64 bytenr, u64 num_bytes)
 {
-	update_pinned_extents(fs_info->extent_root, bytenr, num_bytes, 1);
+	update_pinned_extents(fs_info, bytenr, num_bytes, 1);
 }
 
 void btrfs_unpin_extent(struct btrfs_fs_info *fs_info,
 			u64 bytenr, u64 num_bytes)
 {
-	update_pinned_extents(fs_info->extent_root, bytenr, num_bytes, 0);
+	update_pinned_extents(fs_info, bytenr, num_bytes, 0);
 }
 
 /*
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 06/11] btrfs-progs: Remove unused argument from clean_tree_block
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (4 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 05/11] btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 07/11] btrfs-progs: check: Remove unused root argument from btrfs_extent_post_op Nikolay Borisov
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

This function actually uses only the extent_buffer arg but takes 3
arguments. Furthermore, it's current interface doesn't even mirror
the kernel counterpart. Just remove the extra arguments.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 ctree.c           | 12 ++++++------
 disk-io.c         |  3 +--
 disk-io.h         |  3 +--
 extent-tree.c     |  2 +-
 free-space-tree.c |  2 +-
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/ctree.c b/ctree.c
index 2c3ba70b000c..e79d7aa32319 100644
--- a/ctree.c
+++ b/ctree.c
@@ -251,7 +251,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 			ret = btrfs_dec_ref(trans, root, buf, 1);
 			BUG_ON(ret);
 		}
-		clean_tree_block(trans, root, buf);
+		clean_tree_block(buf);
 	}
 	return 0;
 }
@@ -717,7 +717,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
 		root->node = child;
 		add_root_to_dirty_list(root);
 		path->nodes[level] = NULL;
-		clean_tree_block(trans, root, mid);
+		clean_tree_block(mid);
 		/* once for the path */
 		free_extent_buffer(mid);
 
@@ -770,7 +770,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
 			u64 bytenr = right->start;
 			u32 blocksize = right->len;
 
-			clean_tree_block(trans, root, right);
+			clean_tree_block(right);
 			free_extent_buffer(right);
 			right = NULL;
 			wret = btrfs_del_ptr(root, path, level + 1, pslot + 1);
@@ -816,7 +816,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
 		/* we've managed to empty the middle node, drop it */
 		u64 bytenr = mid->start;
 		u32 blocksize = mid->len;
-		clean_tree_block(trans, root, mid);
+		clean_tree_block(mid);
 		free_extent_buffer(mid);
 		mid = NULL;
 		wret = btrfs_del_ptr(root, path, level + 1, pslot);
@@ -2739,7 +2739,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 		if (leaf == root->node) {
 			btrfs_set_header_level(leaf, 0);
 		} else {
-			clean_tree_block(trans, root, leaf);
+			clean_tree_block(leaf);
 			wret = btrfs_del_leaf(trans, root, path, leaf);
 			BUG_ON(ret);
 			if (wret)
@@ -2775,7 +2775,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 			}
 
 			if (btrfs_header_nritems(leaf) == 0) {
-				clean_tree_block(trans, root, leaf);
+				clean_tree_block(leaf);
 				path->slots[1] = slot;
 				ret = btrfs_del_leaf(trans, root, path, leaf);
 				BUG_ON(ret);
diff --git a/disk-io.c b/disk-io.c
index 72d44531a1b5..456b354cb727 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1684,8 +1684,7 @@ int close_ctree_fs_info(struct btrfs_fs_info *fs_info)
 	return err;
 }
 
-int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-		     struct extent_buffer *eb)
+int clean_tree_block(struct extent_buffer *eb)
 {
 	return clear_extent_buffer_dirty(eb);
 }
diff --git a/disk-io.h b/disk-io.h
index c4496155771f..36fb68cdb86a 100644
--- a/disk-io.h
+++ b/disk-io.h
@@ -131,8 +131,7 @@ struct extent_buffer* btrfs_find_create_tree_block(
 
 void btrfs_setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
 		      u64 objectid);
-int clean_tree_block(struct btrfs_trans_handle *trans,
-		     struct btrfs_root *root, struct extent_buffer *buf);
+int clean_tree_block(struct extent_buffer *buf);
 
 void btrfs_free_fs_info(struct btrfs_fs_info *fs_info);
 struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr);
diff --git a/extent-tree.c b/extent-tree.c
index 8e7f888b5ce5..e06fe56b5ca8 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2129,7 +2129,7 @@ static int pin_down_bytes(struct btrfs_trans_handle *trans,
 		if (header_owner != BTRFS_TREE_LOG_OBJECTID &&
 		    header_transid == trans->transid &&
 		    !btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
-			clean_tree_block(NULL, root, buf);
+			clean_tree_block(buf);
 			free_extent_buffer(buf);
 			return 1;
 		}
diff --git a/free-space-tree.c b/free-space-tree.c
index 69a4eca8a74f..139a031e8483 100644
--- a/free-space-tree.c
+++ b/free-space-tree.c
@@ -135,7 +135,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
 
 	list_del(&free_space_root->dirty_list);
 
-	ret = clean_tree_block(trans, tree_root, free_space_root->node);
+	ret = clean_tree_block(free_space_root->node);
 	if (ret)
 		goto abort;
 	ret = btrfs_free_tree_block(trans, free_space_root,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 07/11] btrfs-progs: check: Remove unused root argument from btrfs_extent_post_op
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (5 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 06/11] btrfs-progs: Remove unused argument from clean_tree_block Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 08/11] btrfs-progs: Change btrfs_root to btrfs_fs_info argument in btrfs_lookup_extent_info Nikolay Borisov
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

This is no longer used by the callees of that function so remove it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 check/main.c  | 2 +-
 ctree.h       | 3 +--
 extent-tree.c | 5 ++---
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/check/main.c b/check/main.c
index 71cc16735443..9a7e6b6dbde3 100644
--- a/check/main.c
+++ b/check/main.c
@@ -8626,7 +8626,7 @@ static int reinit_extent_tree(struct btrfs_trans_handle *trans,
 			fprintf(stderr, "Error adding block group\n");
 			return ret;
 		}
-		btrfs_extent_post_op(trans, fs_info->extent_root);
+		btrfs_extent_post_op(trans);
 	}
 
 	ret = reset_balance(trans, fs_info);
diff --git a/ctree.h b/ctree.h
index c833ad6998b9..138cd22c6c6e 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2504,8 +2504,7 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans);
 void btrfs_pin_extent(struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes);
 void btrfs_unpin_extent(struct btrfs_fs_info *fs_info,
 			u64 bytenr, u64 num_bytes);
-int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
-			 struct btrfs_root *root);
+int btrfs_extent_post_op(struct btrfs_trans_handle *trans);
 struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
 							 btrfs_fs_info *info,
 							 u64 bytenr);
diff --git a/extent-tree.c b/extent-tree.c
index e06fe56b5ca8..d90eb8139d8b 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -1426,8 +1426,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
 	return err;
 }
 
-int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
-			 struct btrfs_root *root)
+int btrfs_extent_post_op(struct btrfs_trans_handle *trans)
 {
 	finish_current_insert(trans);
 	del_pending_extents(trans);
@@ -4012,7 +4011,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans,
 		} else if (ret != -EEXIST) {
 			goto fail;
 		}
-		btrfs_extent_post_op(trans, extent_root);
+		btrfs_extent_post_op(trans);
 		extent_bytenr = disk_bytenr;
 		extent_num_bytes = num_bytes;
 		extent_offset = 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 08/11] btrfs-progs: Change btrfs_root to btrfs_fs_info argument in btrfs_lookup_extent_info
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (6 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 07/11] btrfs-progs: check: Remove unused root argument from btrfs_extent_post_op Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 09/11] btrfs-progs: Remove root argument from btrfs_set_block_flags Nikolay Borisov
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

That function really wants an fs_info and not a root. Accidentally,
this also makes the kernel/user space signatures to be coherent.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 check/main.c        | 10 +++++-----
 check/mode-lowmem.c |  4 ++--
 ctree.c             |  3 ++-
 ctree.h             |  2 +-
 extent-tree.c       | 14 ++++++--------
 5 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/check/main.c b/check/main.c
index 9a7e6b6dbde3..9e8a83f86ab0 100644
--- a/check/main.c
+++ b/check/main.c
@@ -1622,9 +1622,9 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
 		refs = nrefs->refs[*level];
 		ret = 0;
 	} else {
-		ret = btrfs_lookup_extent_info(NULL, root,
-				       path->nodes[*level]->start,
-				       *level, 1, &refs, NULL);
+		ret = btrfs_lookup_extent_info(NULL, fs_info,
+					       path->nodes[*level]->start,
+					       *level, 1, &refs, NULL);
 		if (ret < 0) {
 			err = ret;
 			goto out;
@@ -1664,7 +1664,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
 		if (bytenr == nrefs->bytenr[*level - 1]) {
 			refs = nrefs->refs[*level - 1];
 		} else {
-			ret = btrfs_lookup_extent_info(NULL, root, bytenr,
+			ret = btrfs_lookup_extent_info(NULL, fs_info, bytenr,
 					*level - 1, 1, &refs, NULL);
 			if (ret < 0) {
 				refs = 0;
@@ -5928,7 +5928,7 @@ static int run_next_block(struct btrfs_root *root,
 
 	flags = 0;
 	if (!init_extent_tree) {
-		ret = btrfs_lookup_extent_info(NULL, root, bytenr,
+		ret = btrfs_lookup_extent_info(NULL, fs_info, bytenr,
 				       btrfs_header_level(buf), 1, NULL,
 				       &flags);
 		if (ret < 0) {
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 410c5f635d4e..989306f03c2a 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -186,8 +186,8 @@ static int update_nodes_refs(struct btrfs_root *root, u64 bytenr,
 
 	if (bytenr != (u64)-1) {
 		/* the return value of this function seems a mistake */
-		ret = btrfs_lookup_extent_info(NULL, root, bytenr,
-				       level, 1, &refs, &flags);
+		ret = btrfs_lookup_extent_info(NULL, root->fs_info, bytenr,
+					       level, 1, &refs, &flags);
 		/* temporary fix */
 		if (ret < 0 && !check_all)
 			return ret;
diff --git a/ctree.c b/ctree.c
index e79d7aa32319..c89fd11fc48b 100644
--- a/ctree.c
+++ b/ctree.c
@@ -192,7 +192,8 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 	 */
 
 	if (btrfs_block_can_be_shared(root, buf)) {
-		ret = btrfs_lookup_extent_info(trans, root, buf->start,
+		ret = btrfs_lookup_extent_info(trans, trans->fs_info,
+					       buf->start,
 					       btrfs_header_level(buf), 1,
 					       &refs, &flags);
 		BUG_ON(ret);
diff --git a/ctree.h b/ctree.h
index 138cd22c6c6e..037e020401d2 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2517,7 +2517,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
 					struct btrfs_disk_key *key, int level,
 					u64 hint, u64 empty_size);
 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
-			     struct btrfs_root *root, u64 bytenr,
+			     struct btrfs_fs_info *fs_info, u64 bytenr,
 			     u64 offset, int metadata, u64 *refs, u64 *flags);
 int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
 			  struct btrfs_root *root,
diff --git a/extent-tree.c b/extent-tree.c
index d90eb8139d8b..2fd4e7a0d9eb 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -1434,7 +1434,7 @@ int btrfs_extent_post_op(struct btrfs_trans_handle *trans)
 }
 
 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
-			     struct btrfs_root *root, u64 bytenr,
+			     struct btrfs_fs_info *fs_info, u64 bytenr,
 			     u64 offset, int metadata, u64 *refs, u64 *flags)
 {
 	struct btrfs_path *path;
@@ -1446,9 +1446,8 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 	u64 num_refs;
 	u64 extent_flags;
 
-	if (metadata &&
-	    !btrfs_fs_incompat(root->fs_info, SKINNY_METADATA)) {
-		offset = root->fs_info->nodesize;
+	if (metadata && !btrfs_fs_incompat(fs_info, SKINNY_METADATA)) {
+		offset = fs_info->nodesize;
 		metadata = 0;
 	}
 
@@ -1465,8 +1464,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 		key.type = BTRFS_EXTENT_ITEM_KEY;
 
 again:
-	ret = btrfs_search_slot(trans, root->fs_info->extent_root, &key, path,
-				0, 0);
+	ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out;
 
@@ -1483,14 +1481,14 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 					      path->slots[0]);
 			if (key.objectid == bytenr &&
 			    key.type == BTRFS_EXTENT_ITEM_KEY &&
-			    key.offset == root->fs_info->nodesize)
+			    key.offset == fs_info->nodesize)
 				ret = 0;
 		}
 
 		if (ret) {
 			btrfs_release_path(path);
 			key.type = BTRFS_EXTENT_ITEM_KEY;
-			key.offset = root->fs_info->nodesize;
+			key.offset = fs_info->nodesize;
 			metadata = 0;
 			goto again;
 		}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 09/11] btrfs-progs: Remove root argument from btrfs_set_block_flags
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (7 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 08/11] btrfs-progs: Change btrfs_root to btrfs_fs_info argument in btrfs_lookup_extent_info Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 10/11] btrfs-progs: Remove root argument from write_one_cache_group Nikolay Borisov
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

It's used only to get a reference to fs_info, which can be obtained from
the transaction handle.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 ctree.c       |  2 +-
 ctree.h       |  5 ++---
 extent-tree.c | 22 ++++++++++------------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/ctree.c b/ctree.c
index c89fd11fc48b..2c51580fec65 100644
--- a/ctree.c
+++ b/ctree.c
@@ -236,7 +236,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
 			BUG_ON(ret);
 		}
 		if (new_flags != 0) {
-			ret = btrfs_set_block_flags(trans, root, buf->start,
+			ret = btrfs_set_block_flags(trans, buf->start,
 						    btrfs_header_level(buf),
 						    new_flags);
 			BUG_ON(ret);
diff --git a/ctree.h b/ctree.h
index 037e020401d2..c1033c86d484 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2519,9 +2519,8 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 			     struct btrfs_fs_info *fs_info, u64 bytenr,
 			     u64 offset, int metadata, u64 *refs, u64 *flags);
-int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
-			  struct btrfs_root *root,
-			  u64 bytenr, int level, u64 flags);
+int btrfs_set_block_flags(struct btrfs_trans_handle *trans, u64 bytenr,
+			  int level, u64 flags);
 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 		  struct extent_buffer *buf, int record_parent);
 int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
diff --git a/extent-tree.c b/extent-tree.c
index 2fd4e7a0d9eb..24fb96492c13 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -1529,18 +1529,17 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 	return ret;
 }
 
-int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
-			  struct btrfs_root *root,
-			  u64 bytenr, int level, u64 flags)
+int btrfs_set_block_flags(struct btrfs_trans_handle *trans, u64 bytenr,
+			  int level, u64 flags)
 {
+	struct btrfs_fs_info *fs_info = trans->fs_info;
 	struct btrfs_path *path;
 	int ret;
 	struct btrfs_key key;
 	struct extent_buffer *l;
 	struct btrfs_extent_item *item;
 	u32 item_size;
-	int skinny_metadata =
-		btrfs_fs_incompat(root->fs_info, SKINNY_METADATA);
+	int skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
 
 	path = btrfs_alloc_path();
 	if (!path)
@@ -1552,13 +1551,12 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
 		key.offset = level;
 		key.type = BTRFS_METADATA_ITEM_KEY;
 	} else {
-		key.offset = root->fs_info->nodesize;
+		key.offset = fs_info->nodesize;
 		key.type = BTRFS_EXTENT_ITEM_KEY;
 	}
 
 again:
-	ret = btrfs_search_slot(trans, root->fs_info->extent_root, &key, path,
-				0, 0);
+	ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out;
 
@@ -1569,13 +1567,13 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
 			btrfs_item_key_to_cpu(path->nodes[0], &key,
 					      path->slots[0]);
 			if (key.objectid == bytenr &&
-			    key.offset == root->fs_info->nodesize &&
+			    key.offset == fs_info->nodesize &&
 			    key.type == BTRFS_EXTENT_ITEM_KEY)
 				ret = 0;
 		}
 		if (ret) {
 			btrfs_release_path(path);
-			key.offset = root->fs_info->nodesize;
+			key.offset = fs_info->nodesize;
 			key.type = BTRFS_EXTENT_ITEM_KEY;
 			goto again;
 		}
@@ -1591,8 +1589,8 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
 	item_size = btrfs_item_size_nr(l, path->slots[0]);
 #ifdef BTRFS_COMPAT_EXTENT_TREE_V0
 	if (item_size < sizeof(*item)) {
-		ret = convert_extent_item_v0(trans, root->fs_info->extent_root,
-					     path, (u64)-1, 0);
+		ret = convert_extent_item_v0(trans, fs_info->extent_root, path,
+					     (u64)-1, 0);
 		if (ret < 0)
 			goto out;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 10/11] btrfs-progs: Remove root argument from write_one_cache_group
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (8 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 09/11] btrfs-progs: Remove root argument from btrfs_set_block_flags Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-28  6:36 ` [PATCH 11/11] btrfs-progs: Remove fs_info argument from write_ctree_super Nikolay Borisov
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

It's not needed since we can acquire a reference to the fs_info from
the transaction handle already passed.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 extent-tree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/extent-tree.c b/extent-tree.c
index 24fb96492c13..1694c479cc2b 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -1699,13 +1699,12 @@ int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 }
 
 static int write_one_cache_group(struct btrfs_trans_handle *trans,
-				 struct btrfs_root *root,
 				 struct btrfs_path *path,
 				 struct btrfs_block_group_cache *cache)
 {
 	int ret;
 	int pending_ret;
-	struct btrfs_root *extent_root = root->fs_info->extent_root;
+	struct btrfs_root *extent_root = trans->fs_info->extent_root;
 	unsigned long bi;
 	struct extent_buffer *leaf;
 
@@ -1765,7 +1764,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
 				  BLOCK_GROUP_DIRTY);
 
 		cache = (struct btrfs_block_group_cache *)(unsigned long)ptr;
-		ret = write_one_cache_group(trans, root, path, cache);
+		ret = write_one_cache_group(trans, path, cache);
 	}
 	btrfs_free_path(path);
 	return 0;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 11/11] btrfs-progs: Remove fs_info argument from write_ctree_super
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (9 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 10/11] btrfs-progs: Remove root argument from write_one_cache_group Nikolay Borisov
@ 2018-05-28  6:36 ` Nikolay Borisov
  2018-05-29  1:06 ` [PATCH 00/11] Summer argument cleanup Lu Fengqi
  2018-05-31 11:34 ` David Sterba
  12 siblings, 0 replies; 14+ messages in thread
From: Nikolay Borisov @ 2018-05-28  6:36 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 to obtain it.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 disk-io.c     | 6 +++---
 disk-io.h     | 3 +--
 transaction.c | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index 456b354cb727..4a609a892be7 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1606,10 +1606,10 @@ int write_all_supers(struct btrfs_fs_info *fs_info)
 	return 0;
 }
 
-int write_ctree_super(struct btrfs_trans_handle *trans,
-		      struct btrfs_fs_info *fs_info)
+int write_ctree_super(struct btrfs_trans_handle *trans)
 {
 	int ret;
+	struct btrfs_fs_info *fs_info = trans->fs_info;
 	struct btrfs_root *tree_root = fs_info->tree_root;
 	struct btrfs_root *chunk_root = fs_info->chunk_root;
 
@@ -1657,7 +1657,7 @@ int close_ctree_fs_info(struct btrfs_fs_info *fs_info)
 		BUG_ON(ret);
 		ret = __commit_transaction(trans, root);
 		BUG_ON(ret);
-		write_ctree_super(trans, fs_info);
+		write_ctree_super(trans);
 		kfree(trans);
 	}
 
diff --git a/disk-io.h b/disk-io.h
index 36fb68cdb86a..fefdb0a75d07 100644
--- a/disk-io.h
+++ b/disk-io.h
@@ -164,8 +164,7 @@ static inline int close_ctree(struct btrfs_root *root)
 }
 
 int write_all_supers(struct btrfs_fs_info *fs_info);
-int write_ctree_super(struct btrfs_trans_handle *trans,
-		      struct btrfs_fs_info *fs_info);
+int write_ctree_super(struct btrfs_trans_handle *trans);
 int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr,
 		unsigned sbflags);
 int btrfs_map_bh_to_logical(struct btrfs_root *root, struct extent_buffer *bh,
diff --git a/transaction.c b/transaction.c
index ad70572838c1..9619265ef6e8 100644
--- a/transaction.c
+++ b/transaction.c
@@ -168,7 +168,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 	BUG_ON(ret);
 	ret = __commit_transaction(trans, root);
 	BUG_ON(ret);
-	write_ctree_super(trans, fs_info);
+	write_ctree_super(trans);
 	btrfs_finish_extent_commit(trans, fs_info->extent_root,
 			           &fs_info->pinned_extents);
 	kfree(trans);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 00/11] Summer argument cleanup
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (10 preceding siblings ...)
  2018-05-28  6:36 ` [PATCH 11/11] btrfs-progs: Remove fs_info argument from write_ctree_super Nikolay Borisov
@ 2018-05-29  1:06 ` Lu Fengqi
  2018-05-31 11:34 ` David Sterba
  12 siblings, 0 replies; 14+ messages in thread
From: Lu Fengqi @ 2018-05-29  1:06 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Mon, May 28, 2018 at 09:36:39AM +0300, Nikolay Borisov wrote:
>Hello, 
>
>Here is yet another series removing a bunch of extraneous argument. The series 
>constitutes no functional changes. Some of the function actually have a kernel 
>counterpart (btrfs_lookup_extent_info/clean_tree_block). However the former's 
>userspace signature differs and the patch in this series makes it identical to 
>the kernel one. 

This series looks good to me.

Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>

-- 
Thanks,
Lu

>
>Nikolay Borisov (11):
>  btrfs-progs: check: Remove root argument from delete_extent_records
>  btrfs-progs: check: Remove root parameter from
>    btrfs_fix_block_accounting
>  btrfs-progs: check: Remove root parameter from del_pending_extents
>  btrfs-progs: check: Remove root argument from finish_current_insert
>  btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info
>  btrfs-progs: Remove unused argument from clean_tree_block
>  btrfs-progs: check: Remove unused root argument from
>    btrfs_extent_post_op
>  btrfs-progs: Change btrfs_root to btrfs_fs_info argument in
>    btrfs_lookup_extent_info
>  btrfs-progs: Remove root argument from btrfs_set_block_flags
>  btrfs-progs: Remove root argument from write_one_cache_group
>  btrfs-progs: Remove fs_info argument from write_ctree_super
>
> check/main.c        |  31 +++++++-------
> check/mode-lowmem.c |   6 +--
> ctree.c             |  17 ++++----
> ctree.h             |  13 +++---
> disk-io.c           |   9 ++--
> disk-io.h           |   6 +--
> extent-tree.c       | 121 ++++++++++++++++++++++++----------------------------
> free-space-tree.c   |   2 +-
> transaction.c       |   2 +-
> 9 files changed, 96 insertions(+), 111 deletions(-)
>
>-- 
>2.7.4
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 00/11] Summer argument cleanup
  2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
                   ` (11 preceding siblings ...)
  2018-05-29  1:06 ` [PATCH 00/11] Summer argument cleanup Lu Fengqi
@ 2018-05-31 11:34 ` David Sterba
  12 siblings, 0 replies; 14+ messages in thread
From: David Sterba @ 2018-05-31 11:34 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Mon, May 28, 2018 at 09:36:39AM +0300, Nikolay Borisov wrote:
> Hello, 
> 
> Here is yet another series removing a bunch of extraneous argument. The series 
> constitutes no functional changes. Some of the function actually have a kernel 
> counterpart (btrfs_lookup_extent_info/clean_tree_block). However the former's 
> userspace signature differs and the patch in this series makes it identical to 
> the kernel one. 
> 
> Nikolay Borisov (11):
>   btrfs-progs: check: Remove root argument from delete_extent_records
>   btrfs-progs: check: Remove root parameter from
>     btrfs_fix_block_accounting
>   btrfs-progs: check: Remove root parameter from del_pending_extents
>   btrfs-progs: check: Remove root argument from finish_current_insert
>   btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info
>   btrfs-progs: Remove unused argument from clean_tree_block
>   btrfs-progs: check: Remove unused root argument from
>     btrfs_extent_post_op
>   btrfs-progs: Change btrfs_root to btrfs_fs_info argument in
>     btrfs_lookup_extent_info
>   btrfs-progs: Remove root argument from btrfs_set_block_flags
>   btrfs-progs: Remove root argument from write_one_cache_group
>   btrfs-progs: Remove fs_info argument from write_ctree_super

Applied, thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-05-31 11:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-28  6:36 [PATCH 00/11] Summer argument cleanup Nikolay Borisov
2018-05-28  6:36 ` [PATCH 01/11] btrfs-progs: check: Remove root argument from delete_extent_records Nikolay Borisov
2018-05-28  6:36 ` [PATCH 02/11] btrfs-progs: check: Remove root parameter from btrfs_fix_block_accounting Nikolay Borisov
2018-05-28  6:36 ` [PATCH 03/11] btrfs-progs: check: Remove root parameter from del_pending_extents Nikolay Borisov
2018-05-28  6:36 ` [PATCH 04/11] btrfs-progs: check: Remove root argument from finish_current_insert Nikolay Borisov
2018-05-28  6:36 ` [PATCH 05/11] btrfs-progs: check: Make update_pinned_extents take btrfs_fs_info Nikolay Borisov
2018-05-28  6:36 ` [PATCH 06/11] btrfs-progs: Remove unused argument from clean_tree_block Nikolay Borisov
2018-05-28  6:36 ` [PATCH 07/11] btrfs-progs: check: Remove unused root argument from btrfs_extent_post_op Nikolay Borisov
2018-05-28  6:36 ` [PATCH 08/11] btrfs-progs: Change btrfs_root to btrfs_fs_info argument in btrfs_lookup_extent_info Nikolay Borisov
2018-05-28  6:36 ` [PATCH 09/11] btrfs-progs: Remove root argument from btrfs_set_block_flags Nikolay Borisov
2018-05-28  6:36 ` [PATCH 10/11] btrfs-progs: Remove root argument from write_one_cache_group Nikolay Borisov
2018-05-28  6:36 ` [PATCH 11/11] btrfs-progs: Remove fs_info argument from write_ctree_super Nikolay Borisov
2018-05-29  1:06 ` [PATCH 00/11] Summer argument cleanup Lu Fengqi
2018-05-31 11:34 ` David Sterba

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).