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

Function vdev_add_parent

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

* Add a mirror/replacing vdev above an existing vdev. There is no need to * call .vdev_op_init() since mirror/replacing vdevs do not have private state. */

Source from the content-addressed store, hash-verified

1196 * call .vdev_op_init() since mirror/replacing vdevs do not have private state.
1197 */
1198vdev_t *
1199vdev_add_parent(vdev_t *cvd, vdev_ops_t *ops)
1200{
1201 spa_t *spa = cvd->vdev_spa;
1202 vdev_t *pvd = cvd->vdev_parent;
1203 vdev_t *mvd;
1204
1205 ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
1206
1207 mvd = vdev_alloc_common(spa, cvd->vdev_id, 0, ops);
1208
1209 mvd->vdev_asize = cvd->vdev_asize;
1210 mvd->vdev_min_asize = cvd->vdev_min_asize;
1211 mvd->vdev_max_asize = cvd->vdev_max_asize;
1212 mvd->vdev_psize = cvd->vdev_psize;
1213 mvd->vdev_ashift = cvd->vdev_ashift;
1214 mvd->vdev_logical_ashift = cvd->vdev_logical_ashift;
1215 mvd->vdev_physical_ashift = cvd->vdev_physical_ashift;
1216 mvd->vdev_state = cvd->vdev_state;
1217 mvd->vdev_crtxg = cvd->vdev_crtxg;
1218
1219 vdev_remove_child(pvd, cvd);
1220 vdev_add_child(pvd, mvd);
1221 cvd->vdev_id = mvd->vdev_children;
1222 vdev_add_child(mvd, cvd);
1223 vdev_top_update(cvd->vdev_top, cvd->vdev_top);
1224
1225 if (mvd == mvd->vdev_top)
1226 vdev_top_transfer(cvd, mvd);
1227
1228 return (mvd);
1229}
1230
1231/*
1232 * Remove a 1-way mirror/replacing vdev from the tree.

Callers 2

spa_vdev_attachFunction · 0.85

Calls 6

spa_config_heldFunction · 0.85
vdev_alloc_commonFunction · 0.85
vdev_remove_childFunction · 0.85
vdev_add_childFunction · 0.85
vdev_top_updateFunction · 0.85
vdev_top_transferFunction · 0.85

Tested by

no test coverage detected