@@ -2569,10 +2569,6 @@ static int prepare_for_merge_items(struct btrfs_trans_handle *trans,
int i;
int ret;
- /* There are no relative items of the inode in log. */
- if (BTRFS_I(inode)->logged_trans < trans->transaction->transid)
- return 0;
-
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
@@ -2622,6 +2618,11 @@ static int prepare_for_merge_items(struct btrfs_trans_handle *trans,
if (ret > 0) {
btrfs_release_path(log, path);
+
+ /* There are no relative items of the inode in log. */
+ if (key.type == BTRFS_INODE_ITEM_KEY)
+ break;
+
continue;
}