@@ -2941,20 +2941,26 @@ again:
goto out;
}
if (IS_ERR(inode)) {
BUG_ON(retries);
retries++;
if (block_group->ro)
goto out_free;
+ /* with nospace_cache avoid creating the free-space inode */
+ if (!btrfs_test_opt(root, SPACE_CACHE)) {
+ dcs = BTRFS_DC_WRITTEN;
+ goto out_free;
+ }
+
ret = create_free_space_inode(root, trans, block_group, path);
if (ret)
goto out_free;
goto again;
}
/* We've already setup this transaction, go ahead and exit */
if (block_group->cache_generation == trans->transid &&
i_size_read(inode)) {
dcs = BTRFS_DC_SETUP;