mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-11-16 01:58:49 +03:00
= Motivation
We've noticed several zloop crashes within Delphix generated
due to the following sequence of events:
- A device gets expanded and new metaslabas are allocated for
it. These metaslabs go through `metaslab_init()` but haven't
gone through `metaslab_sync_done()` yet. This meas that the
only range tree that's actually set is the `ms_allocatable`.
All the others are NULL.
- A vdev_initialization is issues and `vdev_initialize_thread`
starts processing one of these new metaslabs of the expanded
vdev.
- As part of `vdev_initialize_calculate_progress()` we call
into `metaslab_load()` and `metaslab_load_impl()` which
in turn tries to dereference the metaslabs trees that
are still NULL and therefore we crash.
The same failure can come up from the `vdev_trim` code paths.
= This Patch
We considered the following solutions to deal with this issue:
[A] Add logic to `vdev_initialize/trim` to skip those new
metaslabs. We decided against this as it would be good
to avoid exposing this lower-level detail to higer-level
operations.
[B] Have `metaslab_load_impl()` return early for new metaslabs
and thus never touch those range_trees that are NULL at
that time. This seemed more of a work-around for the bug
and not a clear-cut solution.
[C] Refactor our logic so all metaslabs have their range_trees
created at the time of their creatin in `metaslab_init()`.
In this patch we decided to go with [C] because:
(1) It doesn't expose more metaslab details to higher level
operations such as vdev initialize and trim.
(2) The current behavior of creating the range trees lazily
in `metaslab_sync_done()` is unnecessarily complicated.
(3) Always initializing the metaslab range_trees makes other
parts of the codebase cleaner. For example, we used to
use `ms_freed` as the reference value for knowing whether
all the range_trees have been initialized. Now we no
longer need to do that check in most places (and in the
few that we do we use the `ms_new` boolean field now
which is more readable).
= Side Changes
Probably due to a mismerge we set `ms_loaded` to `B_TRUE` twice
in `metasloab_load_impl()`. In this patch we remove the extraneous
assignment.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #11737
|
||
|---|---|---|
| .. | ||
| abd.c | ||
| aggsum.c | ||
| arc.c | ||
| blkptr.c | ||
| bplist.c | ||
| bpobj.c | ||
| bptree.c | ||
| bqueue.c | ||
| btree.c | ||
| dataset_kstats.c | ||
| dbuf_stats.c | ||
| dbuf.c | ||
| ddt_zap.c | ||
| ddt.c | ||
| dmu_diff.c | ||
| dmu_object.c | ||
| dmu_objset.c | ||
| dmu_recv.c | ||
| dmu_redact.c | ||
| dmu_send.c | ||
| dmu_traverse.c | ||
| dmu_tx.c | ||
| dmu_zfetch.c | ||
| dmu.c | ||
| dnode_sync.c | ||
| dnode.c | ||
| dsl_bookmark.c | ||
| dsl_crypt.c | ||
| dsl_dataset.c | ||
| dsl_deadlist.c | ||
| dsl_deleg.c | ||
| dsl_destroy.c | ||
| dsl_dir.c | ||
| dsl_pool.c | ||
| dsl_prop.c | ||
| dsl_scan.c | ||
| dsl_synctask.c | ||
| dsl_userhold.c | ||
| edonr_zfs.c | ||
| fm.c | ||
| gzip.c | ||
| hkdf.c | ||
| lz4.c | ||
| lzjb.c | ||
| Makefile.in | ||
| metaslab.c | ||
| mmp.c | ||
| multilist.c | ||
| objlist.c | ||
| pathname.c | ||
| range_tree.c | ||
| refcount.c | ||
| rrwlock.c | ||
| sa.c | ||
| sha256.c | ||
| skein_zfs.c | ||
| spa_boot.c | ||
| spa_checkpoint.c | ||
| spa_config.c | ||
| spa_errlog.c | ||
| spa_history.c | ||
| spa_log_spacemap.c | ||
| spa_misc.c | ||
| spa_stats.c | ||
| spa.c | ||
| space_map.c | ||
| space_reftree.c | ||
| THIRDPARTYLICENSE.cityhash | ||
| THIRDPARTYLICENSE.cityhash.descrip | ||
| txg.c | ||
| uberblock.c | ||
| unique.c | ||
| vdev_cache.c | ||
| vdev_draid_rand.c | ||
| vdev_draid.c | ||
| vdev_indirect_births.c | ||
| vdev_indirect_mapping.c | ||
| vdev_indirect.c | ||
| vdev_initialize.c | ||
| vdev_label.c | ||
| vdev_mirror.c | ||
| vdev_missing.c | ||
| vdev_queue.c | ||
| vdev_raidz_math_aarch64_neon_common.h | ||
| vdev_raidz_math_aarch64_neon.c | ||
| vdev_raidz_math_aarch64_neonx2.c | ||
| vdev_raidz_math_avx2.c | ||
| vdev_raidz_math_avx512bw.c | ||
| vdev_raidz_math_avx512f.c | ||
| vdev_raidz_math_impl.h | ||
| vdev_raidz_math_powerpc_altivec_common.h | ||
| vdev_raidz_math_powerpc_altivec.c | ||
| vdev_raidz_math_scalar.c | ||
| vdev_raidz_math_sse2.c | ||
| vdev_raidz_math_ssse3.c | ||
| vdev_raidz_math.c | ||
| vdev_raidz.c | ||
| vdev_rebuild.c | ||
| vdev_removal.c | ||
| vdev_root.c | ||
| vdev_trim.c | ||
| vdev.c | ||
| zap_leaf.c | ||
| zap_micro.c | ||
| zap.c | ||
| zcp_get.c | ||
| zcp_global.c | ||
| zcp_iter.c | ||
| zcp_set.c | ||
| zcp_synctask.c | ||
| zcp.c | ||
| zfeature.c | ||
| zfs_byteswap.c | ||
| zfs_fm.c | ||
| zfs_fuid.c | ||
| zfs_ioctl.c | ||
| zfs_log.c | ||
| zfs_onexit.c | ||
| zfs_quota.c | ||
| zfs_ratelimit.c | ||
| zfs_replay.c | ||
| zfs_rlock.c | ||
| zfs_sa.c | ||
| zfs_vnops.c | ||
| zil.c | ||
| zio_checksum.c | ||
| zio_compress.c | ||
| zio_inject.c | ||
| zio.c | ||
| zle.c | ||
| zrlock.c | ||
| zthr.c | ||
| zvol.c | ||