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 <liubo2...@cn.fujitsu.com> --- fs/btrfs/inode.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a1f9155..10375fc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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); -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html