If a free is trying to free more blocks than the used counter the file
system is clearly corrupted so shut it down. Keep the debug only assert
to follow the (good?) old XFS tradition of panicing on corruption for
debug builds.
Signed-off-by: Christoph Hellwig <hch@lst.de>
uint64_t *used = xfs_zone_used_counter(rtg);
xfs_assert_ilocked(rtg->rtg_inodes[XFS_RTGI_RMAP], XFS_ILOCK_EXCL);
- ASSERT(len <= *used);
+ if (len > *used) {
+ xfs_err(mp,
+"trying to free more blocks (%lld) than used counter (%lld).",
+ len, *used);
+ ASSERT(len <= *used);
+ xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
+ return -EFSCORRUPTED;
+ }
trace_xfs_zone_free_blocks(rtg, xfs_rtb_to_rgbno(mp, fsbno), len);