* [PATCH 01/14] btrfs: Make btrfs_trans_release_metadata private to transaction.c
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 02/14] btrfs: Open code btrfs_write_and_wait_marked_extents Nikolay Borisov
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
This function is only ever used in __btrfs_end_transaction and
btrfs_commit_transaction so there is no need to export it via header.
Let's move it closer to where it's used, make it static and remove it
from the header. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 2 --
fs/btrfs/extent-tree.c | 18 ------------------
fs/btrfs/transaction.c | 19 +++++++++++++++++++
3 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index aee4365e82ba..1cc77c4bf3c3 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2748,8 +2748,6 @@ void btrfs_delalloc_release_space(struct inode *inode,
struct extent_changeset *reserved, u64 start, u64 len);
void btrfs_free_reserved_data_space_noquota(struct inode *inode, u64 start,
u64 len);
-void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info);
void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans);
int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index cc08e6af3542..b079ebc1f842 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5893,24 +5893,6 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info)
WARN_ON(fs_info->delayed_block_rsv.reserved > 0);
}
-void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
-{
- if (!trans->block_rsv) {
- ASSERT(!trans->bytes_reserved);
- return;
- }
-
- if (!trans->bytes_reserved)
- return;
-
- ASSERT(trans->block_rsv == &fs_info->trans_block_rsv);
- trace_btrfs_space_reservation(fs_info, "transaction",
- trans->transid, trans->bytes_reserved, 0);
- btrfs_block_rsv_release(fs_info, trans->block_rsv,
- trans->bytes_reserved);
- trans->bytes_reserved = 0;
-}
/*
* To be called after all the new block groups attached to the transaction
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 2141587195d4..beca25635787 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -818,6 +818,25 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans)
return should_end_transaction(trans);
}
+static void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info)
+{
+ if (!trans->block_rsv) {
+ ASSERT(!trans->bytes_reserved);
+ return;
+ }
+
+ if (!trans->bytes_reserved)
+ return;
+
+ ASSERT(trans->block_rsv == &fs_info->trans_block_rsv);
+ trace_btrfs_space_reservation(fs_info, "transaction",
+ trans->transid, trans->bytes_reserved, 0);
+ btrfs_block_rsv_release(fs_info, trans->block_rsv,
+ trans->bytes_reserved);
+ trans->bytes_reserved = 0;
+}
+
static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
int throttle)
{
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 02/14] btrfs: Open code btrfs_write_and_wait_marked_extents
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
2018-02-07 15:55 ` [PATCH 01/14] btrfs: Make btrfs_trans_release_metadata private to transaction.c Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 03/14] btrfs: Remove fs_info argument from btrfs_trans_release_metadata Nikolay Borisov
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
btrfs_write_and_wait_transaction is essentially a wrapper of
btrfs_write_and_wait_marked_extents with the addition of calling
clear_btree_io_tree. Having the code split doesn't really bring any
benefit. Open code the later into the former and add proper
documentation header.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 40 ++++++++++++++++------------------------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index beca25635787..5ca4302c136c 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1082,41 +1082,33 @@ int btrfs_wait_tree_log_extents(struct btrfs_root *log_root, int mark)
return err;
}
-/*
- * when btree blocks are allocated, they have some corresponding bits set for
- * them in one of two extent_io trees. This is used to make sure all of
- * those extents are on disk for transaction or log commit
+
+/* btrfs_write_and_wait_transaction - When btree blocks are allocated the
+ * corresponding extents are marked dirty. This function ensures such extents
+ * are persisted on disk for * transaction or log commit.
+ *
+ * @trans: transaction whose dirty pages we'd like to write
*/
-static int btrfs_write_and_wait_marked_extents(struct btrfs_fs_info *fs_info,
- struct extent_io_tree *dirty_pages, int mark)
+static int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info)
{
- int ret;
- int ret2;
+ struct extent_io_tree *dirty_pages = &trans->transaction->dirty_pages;
struct blk_plug plug;
+ int ret, ret2;
blk_start_plug(&plug);
- ret = btrfs_write_marked_extents(fs_info, dirty_pages, mark);
+ ret = btrfs_write_marked_extents(fs_info, dirty_pages, EXTENT_DIRTY);
blk_finish_plug(&plug);
ret2 = btrfs_wait_extents(fs_info, dirty_pages);
+ clear_btree_io_tree(&trans->transaction->dirty_pages);
+
if (ret)
return ret;
- if (ret2)
+ else if (ret2)
return ret2;
- return 0;
-}
-
-static int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
-{
- int ret;
-
- ret = btrfs_write_and_wait_marked_extents(fs_info,
- &trans->transaction->dirty_pages,
- EXTENT_DIRTY);
- clear_btree_io_tree(&trans->transaction->dirty_pages);
-
- return ret;
+ else
+ return 0;
}
/*
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 03/14] btrfs: Remove fs_info argument from btrfs_trans_release_metadata
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
2018-02-07 15:55 ` [PATCH 01/14] btrfs: Make btrfs_trans_release_metadata private to transaction.c Nikolay Borisov
2018-02-07 15:55 ` [PATCH 02/14] btrfs: Open code btrfs_write_and_wait_marked_extents Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 04/14] btrfs: Remove fs_info argument from btrfs_create_pending_block_groups Nikolay Borisov
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
All current callers of this function just get a reference to the
trans->fs_info member and pass it as the second argument. Collapse this
into the function itself. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5ca4302c136c..3c3ed6e3d484 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -818,9 +818,11 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans)
return should_end_transaction(trans);
}
-static void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+static void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans)
+
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
+
if (!trans->block_rsv) {
ASSERT(!trans->bytes_reserved);
return;
@@ -854,7 +856,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
return 0;
}
- btrfs_trans_release_metadata(trans, info);
+ btrfs_trans_release_metadata(trans);
trans->block_rsv = NULL;
if (!list_empty(&trans->new_bgs))
@@ -875,7 +877,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
must_run_delayed_refs = 2;
}
- btrfs_trans_release_metadata(trans, info);
+ btrfs_trans_release_metadata(trans);
trans->block_rsv = NULL;
if (!list_empty(&trans->new_bgs))
@@ -1968,7 +1970,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
return ret;
}
- btrfs_trans_release_metadata(trans, fs_info);
+ btrfs_trans_release_metadata(trans);
trans->block_rsv = NULL;
cur_trans = trans->transaction;
@@ -2322,7 +2324,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
scrub_continue:
btrfs_scrub_continue(fs_info);
cleanup_transaction:
- btrfs_trans_release_metadata(trans, fs_info);
+ btrfs_trans_release_metadata(trans);
btrfs_trans_release_chunk_metadata(trans);
trans->block_rsv = NULL;
btrfs_warn(fs_info, "Skipping commit of aborted transaction.");
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 04/14] btrfs: Remove fs_info argument from btrfs_create_pending_block_groups
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (2 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 03/14] btrfs: Remove fs_info argument from btrfs_trans_release_metadata Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 05/14] btrfs: Don't pass fs_info arg to btrfs_start_dirty_block_groups Nikolay Borisov
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
It can be referenced from the passed transaciton so no point in
passing it as function argument. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 3 +--
fs/btrfs/extent-tree.c | 10 +++++-----
fs/btrfs/transaction.c | 6 +++---
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1cc77c4bf3c3..9963b6caadeb 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2712,8 +2712,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info);
void btrfs_get_block_group_trimming(struct btrfs_block_group_cache *cache);
void btrfs_put_block_group_trimming(struct btrfs_block_group_cache *cache);
-void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info);
+void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans);
u64 btrfs_data_alloc_profile(struct btrfs_fs_info *fs_info);
u64 btrfs_metadata_alloc_profile(struct btrfs_fs_info *fs_info);
u64 btrfs_system_alloc_profile(struct btrfs_fs_info *fs_info);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index b079ebc1f842..99bfc628ab89 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3086,7 +3086,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
if (run_all) {
if (!list_empty(&trans->new_bgs))
- btrfs_create_pending_block_groups(trans, fs_info);
+ btrfs_create_pending_block_groups(trans);
spin_lock(&delayed_refs->lock);
node = rb_first(&delayed_refs->href_root);
@@ -3686,7 +3686,7 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
* make sure all the block groups on our dirty list actually
* exist
*/
- btrfs_create_pending_block_groups(trans, fs_info);
+ btrfs_create_pending_block_groups(trans);
if (!path) {
path = btrfs_alloc_path();
@@ -4706,7 +4706,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
*/
if (trans->can_flush_pending_bgs &&
trans->chunk_bytes_reserved >= (u64)SZ_2M) {
- btrfs_create_pending_block_groups(trans, fs_info);
+ btrfs_create_pending_block_groups(trans);
btrfs_trans_release_chunk_metadata(trans);
}
return ret;
@@ -10130,9 +10130,9 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
return ret;
}
-void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_block_group_cache *block_group, *tmp;
struct btrfs_root *extent_root = fs_info->extent_root;
struct btrfs_block_group_item item;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 3c3ed6e3d484..82b7e5855119 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -860,7 +860,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
trans->block_rsv = NULL;
if (!list_empty(&trans->new_bgs))
- btrfs_create_pending_block_groups(trans, info);
+ btrfs_create_pending_block_groups(trans);
trans->delayed_ref_updates = 0;
if (!trans->sync) {
@@ -881,7 +881,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
trans->block_rsv = NULL;
if (!list_empty(&trans->new_bgs))
- btrfs_create_pending_block_groups(trans, info);
+ btrfs_create_pending_block_groups(trans);
btrfs_trans_release_chunk_metadata(trans);
@@ -1983,7 +1983,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
smp_wmb();
if (!list_empty(&trans->new_bgs))
- btrfs_create_pending_block_groups(trans, fs_info);
+ btrfs_create_pending_block_groups(trans);
ret = btrfs_run_delayed_refs(trans, fs_info, 0);
if (ret) {
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 05/14] btrfs: Don't pass fs_info arg to btrfs_start_dirty_block_groups
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (3 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 04/14] btrfs: Remove fs_info argument from btrfs_create_pending_block_groups Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 06/14] btrfs: Don't pass fs_info to __btrfs_run_delayed_items Nikolay Borisov
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
It can be referenced from the passed transaction so no point in passing
it as a function argument. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 3 +--
fs/btrfs/extent-tree.c | 4 ++--
fs/btrfs/transaction.c | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9963b6caadeb..f929685b80e2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2690,8 +2690,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
u64 bytenr, u64 num_bytes, u64 parent,
u64 root_objectid, u64 owner, u64 offset);
-int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info);
+int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans);
int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info);
int btrfs_setup_space_cache(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 99bfc628ab89..47c27fc403b9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3660,9 +3660,9 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans,
* the commit latency by getting rid of the easy block groups while
* we're still allowing others to join the commit.
*/
-int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_block_group_cache *cache;
struct btrfs_transaction *cur_trans = trans->transaction;
int ret = 0;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 82b7e5855119..aef311531ab2 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2014,7 +2014,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
mutex_unlock(&fs_info->ro_block_group_mutex);
if (run_it)
- ret = btrfs_start_dirty_block_groups(trans, fs_info);
+ ret = btrfs_start_dirty_block_groups(trans);
}
if (ret) {
btrfs_end_transaction(trans);
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 06/14] btrfs: Don't pass fs_info to __btrfs_run_delayed_items
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (4 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 05/14] btrfs: Don't pass fs_info arg to btrfs_start_dirty_block_groups Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 07/14] btrfs: Don't pass fs_info to btrfs_run_delayed_items/_nr Nikolay Borisov
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass the transactino handle, which contains a refrence to
the fs_info so grab it from there. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/delayed-inode.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 1c0bab4080a0..1305872bbff8 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1114,9 +1114,9 @@ __btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
* Returns < 0 on error and returns with an aborted transaction with any
* outstanding delayed items cleaned up.
*/
-static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info, int nr)
+static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans, int nr)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_delayed_root *delayed_root;
struct btrfs_delayed_node *curr_node, *prev_node;
struct btrfs_path *path;
@@ -1164,13 +1164,13 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
int btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info)
{
- return __btrfs_run_delayed_items(trans, fs_info, -1);
+ return __btrfs_run_delayed_items(trans, -1);
}
int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, int nr)
{
- return __btrfs_run_delayed_items(trans, fs_info, nr);
+ return __btrfs_run_delayed_items(trans, nr);
}
int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 07/14] btrfs: Don't pass fs_info to btrfs_run_delayed_items/_nr
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (5 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 06/14] btrfs: Don't pass fs_info to __btrfs_run_delayed_items Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 08/14] btrfs: Don't pass fs_info to commit_fs_roots Nikolay Borisov
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass the transaction which has a reference to the fs_info,
so use that. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/delayed-inode.c | 6 ++----
fs/btrfs/delayed-inode.h | 6 ++----
fs/btrfs/extent-tree.c | 2 +-
fs/btrfs/transaction.c | 8 ++++----
fs/btrfs/tree-log.c | 12 ++++--------
5 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 1305872bbff8..86cc0f5b0435 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1161,14 +1161,12 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans, int nr)
return ret;
}
-int btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+int btrfs_run_delayed_items(struct btrfs_trans_handle *trans)
{
return __btrfs_run_delayed_items(trans, -1);
}
-int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info, int nr)
+int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans, int nr)
{
return __btrfs_run_delayed_items(trans, nr);
}
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index c4189d495934..ae893d85224f 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -111,10 +111,8 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
int btrfs_inode_delayed_dir_index_count(struct btrfs_inode *inode);
-int btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info);
-int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info, int nr);
+int btrfs_run_delayed_items(struct btrfs_trans_handle *trans);
+int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans, int nr);
void btrfs_balance_delayed_items(struct btrfs_fs_info *fs_info);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 47c27fc403b9..52cb4eb12318 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4994,7 +4994,7 @@ static void flush_space(struct btrfs_fs_info *fs_info,
ret = PTR_ERR(trans);
break;
}
- ret = btrfs_run_delayed_items_nr(trans, fs_info, nr);
+ ret = btrfs_run_delayed_items_nr(trans, nr);
btrfs_end_transaction(trans);
break;
case FLUSH_DELALLOC:
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index aef311531ab2..f24f05fb508e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1529,7 +1529,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
* otherwise we corrupt the FS during
* snapshot
*/
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
if (ret) { /* Transaction aborted */
btrfs_abort_transaction(trans, ret);
goto fail;
@@ -2066,7 +2066,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
if (ret)
goto cleanup_transaction;
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
if (ret)
goto cleanup_transaction;
@@ -2074,7 +2074,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
extwriter_counter_read(cur_trans) == 0);
/* some pending stuffs might be added after the previous flush. */
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
if (ret)
goto cleanup_transaction;
@@ -2127,7 +2127,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
* because all the tree which are snapshoted will be forced to COW
* the nodes and leaves.
*/
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
if (ret) {
mutex_unlock(&fs_info->reloc_mutex);
goto scrub_continue;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index df8e76d01dbe..2fbe49a04933 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -852,7 +852,6 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
struct btrfs_inode *dir,
struct btrfs_dir_item *di)
{
- struct btrfs_fs_info *fs_info = root->fs_info;
struct inode *inode;
char *name;
int name_len;
@@ -886,7 +885,7 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
if (ret)
goto out;
else
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
out:
kfree(name);
iput(inode);
@@ -1004,7 +1003,6 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
u64 ref_index, char *name, int namelen,
int *search_done)
{
- struct btrfs_fs_info *fs_info = root->fs_info;
int ret;
char *victim_name;
int victim_name_len;
@@ -1062,7 +1060,7 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
kfree(victim_name);
if (ret)
return ret;
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
if (ret)
return ret;
*search_done = 1;
@@ -1133,8 +1131,7 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
victim_name_len);
if (!ret)
ret = btrfs_run_delayed_items(
- trans,
- fs_info);
+ trans);
}
iput(victim_parent);
kfree(victim_name);
@@ -1991,7 +1988,6 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
struct inode *dir,
struct btrfs_key *dir_key)
{
- struct btrfs_fs_info *fs_info = root->fs_info;
int ret;
struct extent_buffer *eb;
int slot;
@@ -2055,7 +2051,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
BTRFS_I(inode), name, name_len);
if (!ret)
- ret = btrfs_run_delayed_items(trans, fs_info);
+ ret = btrfs_run_delayed_items(trans);
kfree(name);
iput(inode);
if (ret)
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 08/14] btrfs: Don't pass fs_info to commit_fs_roots
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (6 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 07/14] btrfs: Don't pass fs_info to btrfs_run_delayed_items/_nr Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 09/14] btrfs: Don't pass fs_info to commit_cowonly_roots Nikolay Borisov
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass the transaction handle which has a reference to the
fs_info. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index f24f05fb508e..d58c4cf461f3 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1256,9 +1256,9 @@ void btrfs_add_dead_root(struct btrfs_root *root)
/*
* update all the cowonly tree roots on disk
*/
-static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+static noinline int commit_fs_roots(struct btrfs_trans_handle *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *gang[8];
int i;
int ret;
@@ -1376,7 +1376,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
*/
mutex_lock(&fs_info->tree_log_mutex);
- ret = commit_fs_roots(trans, fs_info);
+ ret = commit_fs_roots(trans);
if (ret)
goto out;
ret = btrfs_qgroup_account_extents(trans, fs_info);
@@ -2162,7 +2162,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
*/
mutex_lock(&fs_info->tree_log_mutex);
- ret = commit_fs_roots(trans, fs_info);
+ ret = commit_fs_roots(trans);
if (ret) {
mutex_unlock(&fs_info->tree_log_mutex);
mutex_unlock(&fs_info->reloc_mutex);
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 09/14] btrfs: Don't pass fs_info to commit_cowonly_roots
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (7 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 08/14] btrfs: Don't pass fs_info to commit_fs_roots Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 10/14] btrfs: Remove root argument of cleanup_transaction Nikolay Borisov
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass a transaction handle which refrences the fs_info so
we can grab it from there. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d58c4cf461f3..354143e6d440 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1160,9 +1160,9 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
* failures will cause the file system to go offline. We still need
* to clean up the delayed refs.
*/
-static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct list_head *dirty_bgs = &trans->transaction->dirty_bgs;
struct list_head *io_bgs = &trans->transaction->io_bgs;
struct list_head *next;
@@ -1402,7 +1402,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
* like chunk and root tree, as they won't affect qgroup.
* And we don't write super to avoid half committed status.
*/
- ret = commit_cowonly_roots(trans, fs_info);
+ ret = commit_cowonly_roots(trans);
if (ret)
goto out;
switch_commit_roots(trans->transaction, fs_info);
@@ -2202,7 +2202,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
goto scrub_continue;
}
- ret = commit_cowonly_roots(trans, fs_info);
+ ret = commit_cowonly_roots(trans);
if (ret) {
mutex_unlock(&fs_info->tree_log_mutex);
mutex_unlock(&fs_info->reloc_mutex);
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 10/14] btrfs: Remove root argument of cleanup_transaction
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (8 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 09/14] btrfs: Don't pass fs_info to commit_cowonly_roots Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 11/14] btrfs: Remove fs_info argument from switch_commit_roots Nikolay Borisov
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
The only thing the passed root is used for is:
1. get a reference to the fs_info and to
2. call trace_btrfs_transaction_commit.
We can achieve 1) by simply referring to the fs_info from passed trans
object. As far as 2) is concerned cleanup_transaction is called from
only one place and the 'root' argument passed is the one from the trans
handle. No functional changes.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 354143e6d440..b8fd9fe8a9c1 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1866,10 +1866,9 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
}
-static void cleanup_transaction(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, int err)
+static void cleanup_transaction(struct btrfs_trans_handle *trans, int err)
{
- struct btrfs_fs_info *fs_info = root->fs_info;
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_transaction *cur_trans = trans->transaction;
DEFINE_WAIT(wait);
@@ -1909,7 +1908,7 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
btrfs_put_transaction(cur_trans);
btrfs_put_transaction(cur_trans);
- trace_btrfs_transaction_commit(root);
+ trace_btrfs_transaction_commit(trans->root);
if (current->journal_info == trans)
current->journal_info = NULL;
@@ -2330,7 +2329,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
btrfs_warn(fs_info, "Skipping commit of aborted transaction.");
if (current->journal_info == trans)
current->journal_info = NULL;
- cleanup_transaction(trans, trans->root, ret);
+ cleanup_transaction(trans, ret);
return ret;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 11/14] btrfs: Remove fs_info argument from switch_commit_roots
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (9 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 10/14] btrfs: Remove root argument of cleanup_transaction Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 12/14] btrfs: Remove fs_info argument from create_pending_snapshots/create_pending_snapshot Nikolay Borisov
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already have the fs_info from the passed transaction so use it
directly. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index b8fd9fe8a9c1..81143ac1d88d 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -126,9 +126,9 @@ static void clear_btree_io_tree(struct extent_io_tree *tree)
spin_unlock(&tree->lock);
}
-static noinline void switch_commit_roots(struct btrfs_transaction *trans,
- struct btrfs_fs_info *fs_info)
+static noinline void switch_commit_roots(struct btrfs_transaction *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_root *root, *tmp;
down_write(&fs_info->commit_root_sem);
@@ -1405,7 +1405,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
ret = commit_cowonly_roots(trans);
if (ret)
goto out;
- switch_commit_roots(trans->transaction, fs_info);
+ switch_commit_roots(trans->transaction);
ret = btrfs_write_and_wait_transaction(trans, fs_info);
if (ret)
btrfs_handle_fs_error(fs_info, ret,
@@ -2233,7 +2233,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
list_add_tail(&fs_info->chunk_root->dirty_list,
&cur_trans->switch_commits);
- switch_commit_roots(cur_trans, fs_info);
+ switch_commit_roots(cur_trans);
ASSERT(list_empty(&cur_trans->dirty_bgs));
ASSERT(list_empty(&cur_trans->io_bgs));
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 12/14] btrfs: Remove fs_info argument from create_pending_snapshots/create_pending_snapshot
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (10 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 11/14] btrfs: Remove fs_info argument from switch_commit_roots Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 13/14] btrfs: Remove fs_info argument from btrfs_update_commit_device_bytes_used Nikolay Borisov
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass the trans handle which has a reference to fs_info to
create_pending_snapshot so we can refer to it directly. Doing this
obviates the need to pass the fs_info to create_pending_snapshots as
well. No functional changes.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 81143ac1d88d..abee26b269a1 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1435,9 +1435,10 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
* the creation of the pending snapshots, just return 0.
*/
static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
struct btrfs_pending_snapshot *pending)
{
+
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_key key;
struct btrfs_root_item *new_root_item;
struct btrfs_root *tree_root = fs_info->tree_root;
@@ -1704,8 +1705,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
/*
* create all the snapshots we've scheduled for creation
*/
-static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans)
{
struct btrfs_pending_snapshot *pending, *next;
struct list_head *head = &trans->transaction->pending_snapshots;
@@ -1713,7 +1713,7 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
list_for_each_entry_safe(pending, next, head, list) {
list_del(&pending->list);
- ret = create_pending_snapshot(trans, fs_info, pending);
+ ret = create_pending_snapshot(trans, pending);
if (ret)
break;
}
@@ -2110,7 +2110,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
* deal with them in create_pending_snapshot(), which is the
* core function of the snapshot creation.
*/
- ret = create_pending_snapshots(trans, fs_info);
+ ret = create_pending_snapshots(trans);
if (ret) {
mutex_unlock(&fs_info->reloc_mutex);
goto scrub_continue;
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 13/14] btrfs: Remove fs_info argument from btrfs_update_commit_device_bytes_used
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (11 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 12/14] btrfs: Remove fs_info argument from create_pending_snapshots/create_pending_snapshot Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-07 15:55 ` [PATCH 14/14] btrfs: Remove fs_info argument of btrfs_write_and_wait_transaction Nikolay Borisov
2018-02-12 17:58 ` [PATCH 00/14] Misc transaction cleanups David Sterba
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass the btrfs_transaction which references fs_info so no
need to pass the later as an argument. Also use the opportunity to
shorten transaction->trans. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 2 +-
fs/btrfs/volumes.c | 10 +++++-----
fs/btrfs/volumes.h | 3 +--
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index abee26b269a1..b8dbe4e88631 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2245,7 +2245,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
sizeof(*fs_info->super_copy));
btrfs_update_commit_device_size(fs_info);
- btrfs_update_commit_device_bytes_used(fs_info, cur_trans);
+ btrfs_update_commit_device_bytes_used(cur_trans);
clear_bit(BTRFS_FS_LOG1_ERR, &fs_info->flags);
clear_bit(BTRFS_FS_LOG2_ERR, &fs_info->flags);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 71f9abd44f21..c61fef86538d 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5229,7 +5229,7 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
/*
* There could be two corrupted data stripes, we need
* to loop retry in order to rebuild the correct data.
- *
+ *
* Fail a stripe at a time on every retry except the
* stripe under reconstruction.
*/
@@ -7387,20 +7387,20 @@ void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info)
}
/* Must be invoked during the transaction commit */
-void btrfs_update_commit_device_bytes_used(struct btrfs_fs_info *fs_info,
- struct btrfs_transaction *transaction)
+void btrfs_update_commit_device_bytes_used(struct btrfs_transaction *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct extent_map *em;
struct map_lookup *map;
struct btrfs_device *dev;
int i;
- if (list_empty(&transaction->pending_chunks))
+ if (list_empty(&trans->pending_chunks))
return;
/* In order to kick the device replace finish process */
mutex_lock(&fs_info->chunk_mutex);
- list_for_each_entry(em, &transaction->pending_chunks, list) {
+ list_for_each_entry(em, &trans->pending_chunks, list) {
map = em->map_lookup;
for (i = 0; i < map->num_stripes; i++) {
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index ca6640445a88..8692b40036d6 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -569,8 +569,7 @@ static inline enum btrfs_raid_types btrfs_bg_flags_to_raid_index(u64 flags)
}
void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info);
-void btrfs_update_commit_device_bytes_used(struct btrfs_fs_info *fs_info,
- struct btrfs_transaction *transaction);
+void btrfs_update_commit_device_bytes_used(struct btrfs_transaction *trans);
struct list_head *btrfs_get_fs_uuids(void);
void btrfs_set_fs_info_ptr(struct btrfs_fs_info *fs_info);
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 14/14] btrfs: Remove fs_info argument of btrfs_write_and_wait_transaction
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (12 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 13/14] btrfs: Remove fs_info argument from btrfs_update_commit_device_bytes_used Nikolay Borisov
@ 2018-02-07 15:55 ` Nikolay Borisov
2018-02-12 17:58 ` [PATCH 00/14] Misc transaction cleanups David Sterba
14 siblings, 0 replies; 16+ messages in thread
From: Nikolay Borisov @ 2018-02-07 15:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
We already pass btrfs_trans_handle which contains a reference to the
fs_info so use that. No functional changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/transaction.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index b8dbe4e88631..a57065f022ff 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1091,10 +1091,10 @@ int btrfs_wait_tree_log_extents(struct btrfs_root *log_root, int mark)
*
* @trans: transaction whose dirty pages we'd like to write
*/
-static int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info)
+static int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans)
{
struct extent_io_tree *dirty_pages = &trans->transaction->dirty_pages;
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct blk_plug plug;
int ret, ret2;
@@ -1406,7 +1406,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
if (ret)
goto out;
switch_commit_roots(trans->transaction);
- ret = btrfs_write_and_wait_transaction(trans, fs_info);
+ ret = btrfs_write_and_wait_transaction(trans);
if (ret)
btrfs_handle_fs_error(fs_info, ret,
"Error while writing out transaction for qgroup");
@@ -2260,7 +2260,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
wake_up(&fs_info->transaction_wait);
- ret = btrfs_write_and_wait_transaction(trans, fs_info);
+ ret = btrfs_write_and_wait_transaction(trans);
if (ret) {
btrfs_handle_fs_error(fs_info, ret,
"Error while writing out transaction");
--
2.7.4
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 00/14] Misc transaction cleanups
2018-02-07 15:55 [PATCH 00/14] Misc transaction cleanups Nikolay Borisov
` (13 preceding siblings ...)
2018-02-07 15:55 ` [PATCH 14/14] btrfs: Remove fs_info argument of btrfs_write_and_wait_transaction Nikolay Borisov
@ 2018-02-12 17:58 ` David Sterba
14 siblings, 0 replies; 16+ messages in thread
From: David Sterba @ 2018-02-12 17:58 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Wed, Feb 07, 2018 at 05:55:36PM +0200, Nikolay Borisov wrote:
> Here are a bunch of transaction-related cleanups all of them present no
> functional changes. The first 2 patches could be more interesting - the first
> one moves trans_release_metadata to transaction.c and makes it static and the
> second one opencodes btrfs_write_and_wait_marked_extents in its sole caller
> to make the chall chain shorter. The rest of the patches just kill the
> extraneous fs_info argument since they also take either a btrfs_trans_handle or
> btrfs_transaction pointer which already contain fs_info.
>
> The modified functions are all called from btrfs_commit_transaction. With this
> series applied the only function which remain that still take fs_info and
> some type of transaction reference are:
>
> btrfs_finish_extent_commit
> btrfs_qgroup_account_extents
> btrfs_run_delayed_refs
>
>
> The reason I haven't touched them is that David expressed some reservation
> about mass cleaning of functions which are more or less public interface. And
> the above 3 are such functions. David if you don't objec to converting those 3
> I will keep them in mind when doing further cleanups in the transaction area.
I think all 3 functions don't need the explicit fs_info parameter, the
main object for the functions is the transaction. I don't have a good
example for the API function that should keep both parameters, nothing
in transaction.h and nothing after a few quick greps. For functions like
add_delayed_ref_head, removing the fs_info would be a welcome change as
the number of parameters is high already (more than 10).
The patchset has been added to misc-next, briefly checking the effects
on stack consumption, there are several -8 deltas. Which is good.
^ permalink raw reply [flat|nested] 16+ messages in thread