Skip to contentSkip to conversation

btrfs: memset cur_trans->delayed_refs to zero

PATCH In review Alexandru Moise 2 participants 3 messages Sep 6, 2015 – Sep 7, 2015 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: memset cur_trans->delayed_refs to zero

Use memset() to null out the btrfs_delayed_ref_root of btrfs_transaction instead of setting all the members to 0 by hand.

---
 fs/btrfs/transaction.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
fs/btrfs/transaction.c +1 -9
index 8f259b3..faccc1b 100644
@@ -224,15 +224,7 @@ loop:
 	cur_trans->start_time = get_seconds();
 	cur_trans->dirty_bg_run = 0;
 
-	cur_trans->delayed_refs.href_root = RB_ROOT;
-	cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
-	atomic_set(&cur_trans->delayed_refs.num_entries, 0);
-	cur_trans->delayed_refs.num_heads_ready = 0;
-	cur_trans->delayed_refs.pending_csums = 0;
-	cur_trans->delayed_refs.num_heads = 0;
-	cur_trans->delayed_refs.flushing = 0;
-	cur_trans->delayed_refs.run_delayed_start = 0;
-	cur_trans->delayed_refs.qgroup_to_skip = 0;
+	memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs));
 
 	/*
 	 * although the tree mod log is per file system and not per transaction,
Signature · 1 line
2.5.1
#1 lore raw
Quoted 13 lines · Alexandru Moise

Use memset() to null out the btrfs_delayed_ref_root of btrfs_transaction instead of setting all the members to 0 by hand.

---
 fs/btrfs/transaction.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
fs/btrfs/transaction.c +0 -0
index 8f259b3..faccc1b 100644

fs/btrfs/transaction.c loop: · line 229

Quoted 6 lines
fs/btrfs/transaction.c +0 -3
@@ -224,15 +224,7 @@ loop:
 	cur_trans->start_time = get_seconds();
 	cur_trans->dirty_bg_run = 0;
 
-	cur_trans->delayed_refs.href_root = RB_ROOT;
-	cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
-	atomic_set(&cur_trans->delayed_refs.num_entries, 0);

Please keep these. Even if it means duplicated setting to 0, it's using the correct constructor, should it ever change (RB_ROOT) or does some extra work (atomic_set).

#2 lore raw
Quoted 17 lines · David Sterba
Quoted 16 lines · Alexandru Moise

Use memset() to null out the btrfs_delayed_ref_root of btrfs_transaction instead of setting all the members to 0 by hand.

---
 fs/btrfs/transaction.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
fs/btrfs/transaction.c +0 -0
index 8f259b3..faccc1b 100644
@@ -224,15 +224,7 @@ loop:
 	cur_trans->start_time = get_seconds();
 	cur_trans->dirty_bg_run = 0;
 
Quoted 7 lines

fs/btrfs/transaction.c loop: · line 229

Quoted 3 lines
fs/btrfs/transaction.c +0 -3
-	cur_trans->delayed_refs.href_root = RB_ROOT;
-	cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
-	atomic_set(&cur_trans->delayed_refs.num_entries, 0);

Please keep these. Even if it means duplicated setting to 0, it's using the correct constructor, should it ever change (RB_ROOT) or does some extra work (atomic_set).

Sure, I'll send off another patch right away.