Btrfs: check unused against how much space we actually want
There is a bug that may lead to early ENOSPC in our reservation code. We've
been checking against num_bytes which may be above and beyond what we want to
actually reserve, which could give us a false ENOSPC. Fix this by making sure
the unused space is above how much we want to reserve and not how much we're
trying to flush. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5498bda..fd65f6b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3472,7 +3472,7 @@
*/
if (unused <= space_info->total_bytes) {
unused = space_info->total_bytes - unused;
- if (unused >= num_bytes) {
+ if (unused >= orig_bytes) {
space_info->bytes_may_use += orig_bytes;
ret = 0;
} else {