Skip to content

Commit ab65360

Browse files
pcd1193182behlendorf
authored andcommitted
Don't assert mg_initialized due to device addition race
During device removal stress tests, we noticed that we were tripping the assertion that mg_initialized was true. After investigation, it was determined that the mg in question was the embedded log metaslab group for a newly added vdev; the normal mg had been initialized (by metaslab_sync_reassess, via vdev_sync_done). However, because the spa config alloc lock is not held as writer across both calls to metaslab_sync_reassess, it is possible for an allocation to happen between the two metaslab_groups being initialized. Because the metaslab code doesn't check the group in question, just the vdev's main mg, it is possible to get past the initial check in vdev_allocatable and later fail due to the assertion. We simply remove the assertions. We could also consider locking the ALLOC lock around the reassess calls in vdev_sync_done, but that risks deadlocks. We could check the actual target mg in vdev_allocatable, but that risks racing with a passivation that comes in after that check but before the assertion. We still won't be able to actually allocate from the metaslab group if no metaslabs are ready, so this change shouldn't break anything. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: George Wilson <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #15818
1 parent acc7cd8 commit ab65360

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

module/zfs/metaslab.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5061,7 +5061,6 @@ metaslab_group_alloc(metaslab_group_t *mg, zio_alloc_list_t *zal,
50615061
int allocator, boolean_t try_hard)
50625062
{
50635063
uint64_t offset;
5064-
ASSERT(mg->mg_initialized);
50655064

50665065
offset = metaslab_group_alloc_normal(mg, zal, asize, txg, want_unique,
50675066
dva, d, allocator, try_hard);
@@ -5212,8 +5211,6 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
52125211
goto next;
52135212
}
52145213

5215-
ASSERT(mg->mg_initialized);
5216-
52175214
/*
52185215
* Avoid writing single-copy data to an unhealthy,
52195216
* non-redundant vdev, unless we've already tried all

0 commit comments

Comments
 (0)