MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vdev_remove_parent

Function vdev_remove_parent

freebsd/contrib/openzfs/module/zfs/vdev.c:1234–1284  ·  view source on GitHub ↗

* Remove a 1-way mirror/replacing vdev from the tree. */

Source from the content-addressed store, hash-verified

1232 * Remove a 1-way mirror/replacing vdev from the tree.
1233 */
1234void
1235vdev_remove_parent(vdev_t *cvd)
1236{
1237 vdev_t *mvd = cvd->vdev_parent;
1238 vdev_t *pvd = mvd->vdev_parent;
1239
1240 ASSERT(spa_config_held(cvd->vdev_spa, SCL_ALL, RW_WRITER) == SCL_ALL);
1241
1242 ASSERT(mvd->vdev_children == 1);
1243 ASSERT(mvd->vdev_ops == &vdev_mirror_ops ||
1244 mvd->vdev_ops == &vdev_replacing_ops ||
1245 mvd->vdev_ops == &vdev_spare_ops);
1246 cvd->vdev_ashift = mvd->vdev_ashift;
1247 cvd->vdev_logical_ashift = mvd->vdev_logical_ashift;
1248 cvd->vdev_physical_ashift = mvd->vdev_physical_ashift;
1249 vdev_remove_child(mvd, cvd);
1250 vdev_remove_child(pvd, mvd);
1251
1252 /*
1253 * If cvd will replace mvd as a top-level vdev, preserve mvd's guid.
1254 * Otherwise, we could have detached an offline device, and when we
1255 * go to import the pool we'll think we have two top-level vdevs,
1256 * instead of a different version of the same top-level vdev.
1257 */
1258 if (mvd->vdev_top == mvd) {
1259 uint64_t guid_delta = mvd->vdev_guid - cvd->vdev_guid;
1260 cvd->vdev_orig_guid = cvd->vdev_guid;
1261 cvd->vdev_guid += guid_delta;
1262 cvd->vdev_guid_sum += guid_delta;
1263
1264 /*
1265 * If pool not set for autoexpand, we need to also preserve
1266 * mvd's asize to prevent automatic expansion of cvd.
1267 * Otherwise if we are adjusting the mirror by attaching and
1268 * detaching children of non-uniform sizes, the mirror could
1269 * autoexpand, unexpectedly requiring larger devices to
1270 * re-establish the mirror.
1271 */
1272 if (!cvd->vdev_spa->spa_autoexpand)
1273 cvd->vdev_asize = mvd->vdev_asize;
1274 }
1275 cvd->vdev_id = mvd->vdev_id;
1276 vdev_add_child(pvd, cvd);
1277 vdev_top_update(cvd->vdev_top, cvd->vdev_top);
1278
1279 if (cvd == cvd->vdev_top)
1280 vdev_top_transfer(mvd, cvd);
1281
1282 ASSERT(mvd->vdev_children == 0);
1283 vdev_free(mvd);
1284}
1285
1286static void
1287vdev_metaslab_group_create(vdev_t *vd)

Callers 2

vdev_splitFunction · 0.85
spa_vdev_detachFunction · 0.85

Calls 6

spa_config_heldFunction · 0.85
vdev_remove_childFunction · 0.85
vdev_add_childFunction · 0.85
vdev_top_updateFunction · 0.85
vdev_top_transferFunction · 0.85
vdev_freeFunction · 0.85

Tested by

no test coverage detected