Skip to content

Commit d887f03

Browse files
fdmananakdave
authored andcommitted
btrfs: simplify getting and extracting previous transaction during commit
Instead of detecting if there is a previous transaction by comparing the current transaction's list prev member to the head of the transaction list (fs_info->trans_list), use the list_is_first() helper which contains that logic and the naming makes sense since a new transaction is always added to the end of the list fs_info->trans_list with list_add_tail(). And instead of extracting the previous transaction with the more generic list_entry() helper against the current transaction's list prev member, use the more specific list_prev_entry() helper, which makes it clear what we are doing and is shorter. Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 8c4cfa9 commit d887f03

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/btrfs/transaction.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,14 +2271,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
22712271
wake_up(&fs_info->transaction_blocked_wait);
22722272
btrfs_trans_state_lockdep_release(fs_info, BTRFS_LOCKDEP_TRANS_COMMIT_PREP);
22732273

2274-
if (cur_trans->list.prev != &fs_info->trans_list) {
2274+
if (!list_is_first(&cur_trans->list, &fs_info->trans_list)) {
22752275
enum btrfs_trans_state want_state = TRANS_STATE_COMPLETED;
22762276

22772277
if (trans->in_fsync)
22782278
want_state = TRANS_STATE_SUPER_COMMITTED;
22792279

2280-
prev_trans = list_entry(cur_trans->list.prev,
2281-
struct btrfs_transaction, list);
2280+
prev_trans = list_prev_entry(cur_trans, list);
22822281
if (prev_trans->state < want_state) {
22832282
refcount_inc(&prev_trans->use_count);
22842283
spin_unlock(&fs_info->trans_lock);

0 commit comments

Comments
 (0)