@@ -471,21 +471,24 @@ int finish_file_extents(struct extent_iterate_data *priv)
return ret;
}
*priv->inode_nbytes += priv->size;
- return btrfs_insert_inline_extent(priv->trans, priv->root,
- priv->objectid,
- priv->file_off, priv->data,
- priv->size);
- }
-
- ret = commit_file_extents(priv);
- if (ret)
- return ret;
-
- if (priv->total_size > priv->last_file_off) {
- ret = commit_disk_extent(priv, priv->last_file_off, 0,
- priv->total_size - priv->last_file_off);
+ ret = btrfs_insert_inline_extent(priv->trans, priv->root,
+ priv->objectid,
+ priv->file_off, priv->data,
+ priv->size);
if (ret)
return ret;
+ } else {
+ ret = commit_file_extents(priv);
+ if (ret)
+ return ret;
+
+ if (priv->total_size > priv->last_file_off) {
+ ret = commit_disk_extent(priv, priv->last_file_off, 0,
+ priv->total_size -
+ priv->last_file_off);
+ if (ret)
+ return ret;
+ }
}
free(priv->data);
return 0;