Skip to contentSkip to conversation

btrfs: Remove unnecessary call to btrfs_mark_buffer_dirty()

PATCH New Zhen Ni 1 participant 1 message Nov 12, 2025 Btrfs file system

lore
Share & tools
lore

Zhen Ni

author
#0 lore raw

PATCH 1/1 btrfs: Remove unnecessary call to btrfs_mark_buffer_dirty()

When btrfs_insert_empty_item() succeeds, the leaf has already been marked dirty automatically through two mechanisms:

1) COW operations: btrfs_search_slot(cow=1)

2) setup_items_for_insert() → btrfs_mark_buffer_dirty(trans, leaf)

Therefore the explicit call in btrfs_insert_item() is redundant and can be safely removed. This removes unnecessary code verbosity, reduces overhead, and aligns with the cleanup done in commit 1ca4e15f41f2e ("btrfs: volumes: remove unnecessary calls to btrfs_mark_buffer_dirty()").

---
 fs/btrfs/ctree.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/ctree.c +0 -1
index 561658aca018..719eb5127f3a 100644
@@ -4324,7 +4324,6 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 		leaf = path->nodes[0];
 		ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
 		write_extent_buffer(leaf, data, ptr, data_size);
-		btrfs_mark_buffer_dirty(trans, leaf);
 	}
 	return ret;
 }
Signature · 1 line
2.20.1