btrfs: rename btrfs_ordered_extent::list to csum_list

That list head records all pending checksums for that ordered
extent. And unlike other lists, we just use the name "list", which can
be very confusing for readers.

Rename it to "csum_list" which follows the remaining lists, showing the
purpose of the list.

And since we're here, remove a comment inside
btrfs_finish_ordered_zoned() where we have
"ASSERT(!list_empty(&ordered->csum_list))" to make sure the OE has
pending csums.

That comment is only here to make sure we do not call list_first_entry()
before checking BTRFS_ORDERED_PREALLOC.
But since we already have that bit checked and even have a dedicated
ASSERT(), there is no need for that comment anymore.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2026-02-10 13:54:29 +10:30 committed by David Sterba
parent 74e505fc89
commit 09664971b3
5 changed files with 13 additions and 14 deletions

View File

@ -3272,8 +3272,8 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
/* Logic error */
ASSERT(list_empty(&ordered_extent->list));
if (unlikely(!list_empty(&ordered_extent->list))) {
ASSERT(list_empty(&ordered_extent->csum_list));
if (unlikely(!list_empty(&ordered_extent->csum_list))) {
ret = -EINVAL;
btrfs_abort_transaction(trans, ret);
goto out;
@ -3322,7 +3322,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
goto out;
}
ret = add_pending_csums(trans, &ordered_extent->list);
ret = add_pending_csums(trans, &ordered_extent->csum_list);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
goto out;

View File

@ -197,7 +197,7 @@ static struct btrfs_ordered_extent *alloc_ordered_extent(
entry->flags = flags;
refcount_set(&entry->refs, 1);
init_waitqueue_head(&entry->wait);
INIT_LIST_HEAD(&entry->list);
INIT_LIST_HEAD(&entry->csum_list);
INIT_LIST_HEAD(&entry->log_list);
INIT_LIST_HEAD(&entry->root_extent_list);
INIT_LIST_HEAD(&entry->work_list);
@ -329,7 +329,7 @@ void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
struct btrfs_inode *inode = entry->inode;
spin_lock(&inode->ordered_tree_lock);
list_add_tail(&sum->list, &entry->list);
list_add_tail(&sum->list, &entry->csum_list);
spin_unlock(&inode->ordered_tree_lock);
}
@ -628,7 +628,7 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
ASSERT(list_empty(&entry->log_list));
ASSERT(RB_EMPTY_NODE(&entry->rb_node));
btrfs_add_delayed_iput(entry->inode);
list_for_each_entry_safe(sum, tmp, &entry->list, list)
list_for_each_entry_safe(sum, tmp, &entry->csum_list, list)
kvfree(sum);
kmem_cache_free(btrfs_ordered_extent_cache, entry);
}
@ -1323,10 +1323,10 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent(
}
}
list_for_each_entry_safe(sum, tmpsum, &ordered->list, list) {
list_for_each_entry_safe(sum, tmpsum, &ordered->csum_list, list) {
if (offset == len)
break;
list_move_tail(&sum->list, &new->list);
list_move_tail(&sum->list, &new->csum_list);
offset += sum->len;
}

View File

@ -134,7 +134,7 @@ struct btrfs_ordered_extent {
struct btrfs_inode *inode;
/* list of checksums for insertion when the extent io is done */
struct list_head list;
struct list_head csum_list;
/* used for fast fsyncs */
struct list_head log_list;

View File

@ -5088,7 +5088,7 @@ static int log_extent_csums(struct btrfs_trans_handle *trans,
if (test_and_set_bit(BTRFS_ORDERED_LOGGED_CSUM, &ordered->flags))
continue;
list_for_each_entry(sums, &ordered->list, list) {
list_for_each_entry(sums, &ordered->csum_list, list) {
ret = log_csums(trans, inode, log_root, sums);
if (ret)
return ret;

View File

@ -2123,9 +2123,8 @@ void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered)
if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags))
return;
ASSERT(!list_empty(&ordered->list));
/* The ordered->list can be empty in the above pre-alloc case. */
sum = list_first_entry(&ordered->list, struct btrfs_ordered_sum, list);
ASSERT(!list_empty(&ordered->csum_list));
sum = list_first_entry(&ordered->csum_list, struct btrfs_ordered_sum, list);
logical = sum->logical;
len = sum->len;
@ -2156,7 +2155,7 @@ void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered)
*/
if ((inode->flags & BTRFS_INODE_NODATASUM) ||
test_bit(BTRFS_FS_STATE_NO_DATA_CSUMS, &fs_info->fs_state)) {
while ((sum = list_first_entry_or_null(&ordered->list,
while ((sum = list_first_entry_or_null(&ordered->csum_list,
typeof(*sum), list))) {
list_del(&sum->list);
kfree(sum);