mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: use correct region_id when cleaning up a failed filemap
If we fail to create a region during dm_stats_create_regions_from_fd(), we must remove all regions that were created to do this to date. This needs to loop over the table of region_id values that were populated by _stats_create_file_regions() before the error. The code for this failure case in the out_remove branch incorrectly uses the table index as the region_id: for (--i; i != DM_STATS_REGION_NOT_PRESENT; i--) { if (!dm_stats_delete_region(dms, i)) log_error("Could not delete region " FMTu64 ".", i); } This causes the cleanup code to delete a completely unrelated set of regions (since the index here will always be nr_regions..0). Fix it to pass the actual region_id stored in regions[i] instead.
This commit is contained in:
parent
7fd2fa22dd
commit
30ad254d84
@ -4382,10 +4382,9 @@ static uint64_t *_stats_create_file_regions(struct dm_stats *dms, int fd,
|
||||
|
||||
out_remove:
|
||||
/* clean up regions after create failure */
|
||||
for (--i; i != DM_STATS_REGION_NOT_PRESENT; i--) {
|
||||
if (!dm_stats_delete_region(dms, i))
|
||||
for (--i; i != DM_STATS_REGION_NOT_PRESENT; i--)
|
||||
if (!dm_stats_delete_region(dms, regions[i]))
|
||||
log_error("Could not delete region " FMTu64 ".", i);
|
||||
}
|
||||
|
||||
out:
|
||||
dm_pool_free(dms->mem, extents);
|
||||
|
Loading…
Reference in New Issue
Block a user