From bf8ff4b9f0aa3f9e49779c8d3edbdc11caa5cd05 Mon Sep 17 00:00:00 2001 From: Mark Harmstone Date: Wed, 7 Jan 2026 14:09:06 +0000 Subject: [PATCH] btrfs: rename struct btrfs_block_group field commit_used to last_used Rename the field commit_used in struct btrfs_block_group to last_used, for clarity and consistency with the similar fields we're about to add. It's not obvious that commit_flags means "flags as of the last commit" rather than "flags related to a commit". Signed-off-by: Mark Harmstone Signed-off-by: David Sterba --- fs/btrfs/block-group.c | 24 ++++++++++++------------ fs/btrfs/block-group.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index a2f95ac5a8d0a..5709acc842970 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2387,7 +2387,7 @@ static int read_one_block_group(struct btrfs_fs_info *info, cache->length = key->offset; cache->used = btrfs_stack_block_group_used(bgi); - cache->commit_used = cache->used; + cache->last_used = cache->used; cache->flags = btrfs_stack_block_group_flags(bgi); cache->global_root_id = btrfs_stack_block_group_chunk_objectid(bgi); cache->space_info = btrfs_find_space_info(info, cache->flags); @@ -2666,7 +2666,7 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans, struct btrfs_block_group_item bgi; struct btrfs_root *root = btrfs_block_group_root(fs_info); struct btrfs_key key; - u64 old_commit_used; + u64 old_last_used; int ret; spin_lock(&block_group->lock); @@ -2674,8 +2674,8 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans, btrfs_set_stack_block_group_chunk_objectid(&bgi, block_group->global_root_id); btrfs_set_stack_block_group_flags(&bgi, block_group->flags); - old_commit_used = block_group->commit_used; - block_group->commit_used = block_group->used; + old_last_used = block_group->last_used; + block_group->last_used = block_group->used; key.objectid = block_group->start; key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; key.offset = block_group->length; @@ -2684,7 +2684,7 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans, ret = btrfs_insert_item(trans, root, &key, &bgi, sizeof(bgi)); if (ret < 0) { spin_lock(&block_group->lock); - block_group->commit_used = old_commit_used; + block_group->last_used = old_last_used; spin_unlock(&block_group->lock); } @@ -3134,7 +3134,7 @@ static int update_block_group_item(struct btrfs_trans_handle *trans, struct extent_buffer *leaf; struct btrfs_block_group_item bgi; struct btrfs_key key; - u64 old_commit_used; + u64 old_last_used; u64 used; /* @@ -3144,14 +3144,14 @@ static int update_block_group_item(struct btrfs_trans_handle *trans, * may be changed. */ spin_lock(&cache->lock); - old_commit_used = cache->commit_used; + old_last_used = cache->last_used; used = cache->used; /* No change in used bytes, can safely skip it. */ - if (cache->commit_used == used) { + if (cache->last_used == used) { spin_unlock(&cache->lock); return 0; } - cache->commit_used = used; + cache->last_used = used; spin_unlock(&cache->lock); key.objectid = cache->start; @@ -3175,17 +3175,17 @@ static int update_block_group_item(struct btrfs_trans_handle *trans, fail: btrfs_release_path(path); /* - * We didn't update the block group item, need to revert commit_used + * We didn't update the block group item, need to revert last_used * unless the block group item didn't exist yet - this is to prevent a * race with a concurrent insertion of the block group item, with * insert_block_group_item(), that happened just after we attempted to - * update. In that case we would reset commit_used to 0 just after the + * update. In that case we would reset last_used to 0 just after the * insertion set it to a value greater than 0 - if the block group later * becomes with 0 used bytes, we would incorrectly skip its update. */ if (ret < 0 && ret != -ENOENT) { spin_lock(&cache->lock); - cache->commit_used = old_commit_used; + cache->last_used = old_last_used; spin_unlock(&cache->lock); } return ret; diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index cd2d53d5b3157..b0fb85a36d97d 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -132,10 +132,10 @@ struct btrfs_block_group { /* * The last committed used bytes of this block group, if the above @used - * is still the same as @commit_used, we don't need to update block + * is still the same as @last_used, we don't need to update block * group item of this block group. */ - u64 commit_used; + u64 last_used; /* * If the free space extent count exceeds this number, convert the block * group to bitmaps. -- 2.47.3