u64 used;
int ret = -ENOSPC;
bool pending_tickets;
- const bool reloc = (READ_ONCE(fs_info->reloc_task) == current);
+ /*
+ * Who may draw on the stripe_meta reserve (bytes_stripe_reserve):
+ * the relocation task, which is what the reserve is for, and the
+ * transaction machinery's own bounded reservations -- NO_FLUSH from
+ * btrfs_use_block_rsv() when a handle's reserve runs dry mid-COW,
+ * FLUSH_LIMIT for delayed refs and delayed inodes, EMERGENCY -- which
+ * a committing transaction cannot fail without aborting. User
+ * operations (FLUSH_ALL, ALL_STEAL, EVICT, DATA) stay behind it.
+ */
+ const bool reloc = (READ_ONCE(fs_info->reloc_task) == current) ||
+ flush == BTRFS_RESERVE_NO_FLUSH ||
+ flush == BTRFS_RESERVE_FLUSH_LIMIT ||
+ flush == BTRFS_RESERVE_FLUSH_EMERGENCY;
ASSERT(orig_bytes, "orig_bytes=%llu", orig_bytes);
/*