diff mbox series

[27/31] btrfs: get rid of ->dirty_bytes

Message ID 9e5e464b37fbc7973534375ff18b0fae9bf0365e.1662149276.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: move extent_io_tree code and cleanups | expand

Commit Message

Josef Bacik Sept. 2, 2022, 8:16 p.m. UTC
This was used as an optimization for count_range_bits(EXTENT_DIRTY), but
we no longer do that, thus nothing actually uses the ->dirty_bytes
counter in the extent_io_tree.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent-io-tree.c | 17 +----------------
 fs/btrfs/extent-io-tree.h |  1 -
 2 files changed, 1 insertion(+), 17 deletions(-)

Comments

David Sterba Sept. 7, 2022, 6:48 p.m. UTC | #1
On Fri, Sep 02, 2022 at 04:16:32PM -0400, Josef Bacik wrote:
> This was used as an optimization for count_range_bits(EXTENT_DIRTY), but
> we no longer do that, thus nothing actually uses the ->dirty_bytes
> counter in the extent_io_tree.

Same comment as for 26/31
diff mbox series

Patch

diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 4fd0cac6564a..b4e70d4f243b 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -91,7 +91,6 @@  void extent_io_tree_init(struct btrfs_fs_info *fs_info,
 {
 	tree->fs_info = fs_info;
 	tree->state = RB_ROOT;
-	tree->dirty_bytes = 0;
 	spin_lock_init(&tree->lock);
 	tree->private_data = private_data;
 	tree->owner = owner;
@@ -486,12 +485,6 @@  static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 	u32 bits_to_clear = bits & ~EXTENT_CTLBITS;
 	int ret;
 
-	if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) {
-		u64 range = state->end - state->start + 1;
-		WARN_ON(range > tree->dirty_bytes);
-		tree->dirty_bytes -= range;
-	}
-
 	if (tree->private_data && is_data_inode(tree->private_data))
 		btrfs_clear_delalloc_extent(tree->private_data, state, bits);
 
@@ -756,10 +749,6 @@  static void set_state_bits(struct extent_io_tree *tree,
 	if (tree->private_data && is_data_inode(tree->private_data))
 		btrfs_set_delalloc_extent(tree->private_data, state, bits);
 
-	if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
-		u64 range = state->end - state->start + 1;
-		tree->dirty_bytes += range;
-	}
 	ret = add_extent_changeset(state, bits_to_set, changeset, 1);
 	BUG_ON(ret < 0);
 	state->state |= bits_to_set;
@@ -1538,10 +1527,7 @@  u64 count_range_bits(struct extent_io_tree *tree,
 		return 0;
 
 	spin_lock(&tree->lock);
-	if (cur_start == 0 && bits == EXTENT_DIRTY) {
-		total_bytes = tree->dirty_bytes;
-		goto out;
-	}
+
 	/*
 	 * this search will find all the extents that end after
 	 * our range starts.
@@ -1567,7 +1553,6 @@  u64 count_range_bits(struct extent_io_tree *tree,
 		}
 		state = next_state(state);
 	}
-out:
 	spin_unlock(&tree->lock);
 	return total_bytes;
 }
diff --git a/fs/btrfs/extent-io-tree.h b/fs/btrfs/extent-io-tree.h
index 37543fb713bd..94574062eabe 100644
--- a/fs/btrfs/extent-io-tree.h
+++ b/fs/btrfs/extent-io-tree.h
@@ -69,7 +69,6 @@  struct extent_io_tree {
 	struct rb_root state;
 	struct btrfs_fs_info *fs_info;
 	void *private_data;
-	u64 dirty_bytes;
 
 	/* Who owns this io tree, should be one of IO_TREE_* */
 	u8 owner;