@@ -6821,8 +6821,15 @@ int btrfs_drop_inode(struct inode *inode)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
- if (btrfs_root_refs(&root->root_item) == 0 &&
- !btrfs_is_free_space_inode(root, inode))
+ /*
+ * If the inode has been in the log tree and the transaction is not
+ * committed yet, then we need to keep this inode in cache.
+ */
+ if (BTRFS_I(inode)->last_trans >= root->fs_info->generation &&
+ BTRFS_I(inode)->logged_trans >= BTRFS_I(inode)->last_trans)
+ return 0;
+ else if (btrfs_root_refs(&root->root_item) == 0 &&
+ !btrfs_is_free_space_inode(root, inode))
return 1;
else
return generic_drop_inode(inode);
We maintain the inode's logged_trans to avoid reloging it, but if we iput the inode and reread it, we'll get logged_trans to zero. So when an inode is still in log tree, and transaction is not committed yet, we do not iput the inode. Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com> --- fs/btrfs/inode.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)