} else {
/* ...and that group is out of reach for everyone else */
supply -= min(supply, dedicated);
+ /*
+ * Every outstanding data extent holds a whole-stripe
+ * margin (bytes_stripe_margin) as collateral against
+ * the commit that closes its open run and traps the
+ * tail. btrfs_space_info_used() charges that margin
+ * against total_bytes, but what an admitted write
+ * actually draws on is the whole-stripe supply: left
+ * out of this bound, the stripes behind bytes admitted
+ * earlier are lost at the next commit, and a write
+ * that passed admission finds no stripe at writeback
+ * (ENOSPC despite reservation margin, data dropped).
+ */
+ bytes += space_info->bytes_stripe_margin;
}
return space_info->bytes_may_use + bytes <= supply;
}