Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2adcac1a authored by Josef Bacik's avatar Josef Bacik
Browse files

Btrfs: fall back to non-inline if we don't have enough space



If cow_file_range_inline fails with ENOSPC we abort the transaction which
isn't very nice.  This really shouldn't be happening anyways but there's no
sense in making it a horrible error when we can easily just go allocate
normal data space for this stuff.  Thanks,

Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
parent 8a35d95f
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -257,10 +257,13 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans,
	ret = insert_inline_extent(trans, root, inode, start,
	ret = insert_inline_extent(trans, root, inode, start,
				   inline_len, compressed_size,
				   inline_len, compressed_size,
				   compress_type, compressed_pages);
				   compress_type, compressed_pages);
	if (ret) {
	if (ret && ret != -ENOSPC) {
		btrfs_abort_transaction(trans, root, ret);
		btrfs_abort_transaction(trans, root, ret);
		return ret;
		return ret;
	} else if (ret == -ENOSPC) {
		return 1;
	}
	}

	btrfs_delalloc_release_metadata(inode, end + 1 - start);
	btrfs_delalloc_release_metadata(inode, end + 1 - start);
	btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0);
	btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0);
	return 0;
	return 0;