btrfs: Clean up delayed inode items on transaction abort
PATCH v2 1/1 btrfs: Clean up delayed inode items on transaction abort
From: Yalagada Pavan Kumar <[email protected]>
When a transaction is aborted, btrfs_commit_inode_delayed_inode() fails because btrfs_join_transaction() returns an error. This makes btrfs_evict_inode() skip btrfs_kill_delayed_inode_items(), leaving pending items in the delayed node.
Clean up delayed inode items when the transaction is aborted, even if btrfs_commit_inode_delayed_inode() returns an error.
---
v2:
- Add a condition to call btrfs_kill_delayed_inode_items() when the transaction is aborted, even if the inode update fails.
v1: https://lore.kernel.org/linux-btrfs/avMkGGHSH2scfa0t@user/T/#t
--- fs/btrfs/inode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/btrfs/inode.c +8 -3
@@ -5623,16 +5623,21 @@ void btrfs_evict_inode(struct inode *inode)* the inode update is released. */ ret =btrfs_commit_inode_delayed_inode (BTRFS_I (inode)); -if (ret) - goto out;/* * This drops any pending insert or delete operations we have for this * inode. We could have a delayed dir index deletion queued up, but * we're removing the inode completely so that'll be taken care of in * the truncate. +* +* We must also clean up delayed inode items when the transaction is +* aborted. */ -btrfs_kill_delayed_inode_items (BTRFS_I (inode)); +if (!ret ||test_bit (BTRFS_FS_STATE_TRANS_ABORTED , &fs_info->fs_state)) +btrfs_kill_delayed_inode_items (BTRFS_I (inode)); + +if (ret) + goto out;btrfs_init_metadata_block_rsv (fs_info, &rsv,BTRFS_BLOCK_RSV_TEMP ); rsv.size =btrfs_calc_metadata_size (fs_info,1 );
Signature · 1 line
2.43.0
Quoted 36 lines · 在 2026/11/15 02:12, [email protected] 写道:
From: Yalagada Pavan Kumar <[email protected]>
When a transaction is aborted,
btrfs_commit_inode_delayed_inode()fails becausebtrfs_join_transaction()returns an error. This makesbtrfs_evict_inode()skipbtrfs_kill_delayed_inode_items(), leaving pending items in the delayed node.Clean up delayed inode items when the transaction is aborted, even if
btrfs_commit_inode_delayed_inode()returns an error.Reported-by [email protected]Fixes 2adc75d61203 ("btrfs: move btrfs_kill_delayed_inode_items into evict")Signed-off-by Yalagada Pavan Kumar <[email protected]>---
v2:
- Add a condition to callbtrfs_kill_delayed_inode_items()when the transaction is aborted, even if the inode update fails.v1: https://lore.kernel.org/linux-btrfs/avMkGGHSH2scfa0t@user/T/#t
--- fs/btrfs/inode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)fs/btrfs/inode.c +0
-2@@ -5623,16 +5623,21 @@ void btrfs_evict_inode(struct inode *inode)* the inode update is released. */ ret =btrfs_commit_inode_delayed_inode (BTRFS_I (inode)); -if (ret) - goto out;/*
fs/btrfs/inode.c void btrfs_evict_inode(struct inode *inode) · line 5636
Quoted 10 lines
fs/btrfs/inode.c +4
-1* This drops any pending insert or delete operations we have for this * inode. We could have a delayed dir index deletion queued up, but * we're removing the inode completely so that'll be taken care of in * the truncate. +* +* We must also clean up delayed inode items when the transaction is +* aborted. */ -btrfs_kill_delayed_inode_items (BTRFS_I (inode)); +if (!ret ||test_bit (BTRFS_FS_STATE_TRANS_ABORTED , &fs_info->fs_state))
Sashiko still found a problem with this method, and it looks valid to me:
https://sashiko.dev/#/patchset/20261114154207.73644-1-pavankumaryalagada%40gmail.com
Thanks,
Qu
Quoted 7 lines
fs/btrfs/inode.c +4
-0+btrfs_kill_delayed_inode_items (BTRFS_I (inode)); + +if (ret) + goto out;btrfs_init_metadata_block_rsv (fs_info, &rsv,BTRFS_BLOCK_RSV_TEMP ); rsv.size =btrfs_calc_metadata_size (fs_info,1 );