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

Function vdev_mirror_map_init

freebsd/contrib/openzfs/module/zfs/vdev_mirror.c:263–385  ·  view source on GitHub ↗

* Avoid inlining the function to keep vdev_mirror_io_start(), which * is this functions only caller, as small as possible on the stack. */

Source from the content-addressed store, hash-verified

261 * is this functions only caller, as small as possible on the stack.
262 */
263noinline static mirror_map_t *
264vdev_mirror_map_init(zio_t *zio)
265{
266 mirror_map_t *mm = NULL;
267 mirror_child_t *mc;
268 vdev_t *vd = zio->io_vd;
269 int c;
270
271 if (vd == NULL) {
272 dva_t *dva = zio->io_bp->blk_dva;
273 spa_t *spa = zio->io_spa;
274 dsl_scan_t *scn = spa->spa_dsl_pool->dp_scan;
275 dva_t dva_copy[SPA_DVAS_PER_BP];
276
277 /*
278 * The sequential scrub code sorts and issues all DVAs
279 * of a bp separately. Each of these IOs includes all
280 * original DVA copies so that repairs can be performed
281 * in the event of an error, but we only actually want
282 * to check the first DVA since the others will be
283 * checked by their respective sorted IOs. Only if we
284 * hit an error will we try all DVAs upon retrying.
285 *
286 * Note: This check is safe even if the user switches
287 * from a legacy scrub to a sequential one in the middle
288 * of processing, since scn_is_sorted isn't updated until
289 * all outstanding IOs from the previous scrub pass
290 * complete.
291 */
292 if ((zio->io_flags & ZIO_FLAG_SCRUB) &&
293 !(zio->io_flags & ZIO_FLAG_IO_RETRY) &&
294 dsl_scan_scrubbing(spa->spa_dsl_pool) &&
295 scn->scn_is_sorted) {
296 c = 1;
297 } else {
298 c = BP_GET_NDVAS(zio->io_bp);
299 }
300
301 /*
302 * If the pool cannot be written to, then infer that some
303 * DVAs might be invalid or point to vdevs that do not exist.
304 * We skip them.
305 */
306 if (!spa_writeable(spa)) {
307 ASSERT3U(zio->io_type, ==, ZIO_TYPE_READ);
308 int j = 0;
309 for (int i = 0; i < c; i++) {
310 if (zfs_dva_valid(spa, &dva[i], zio->io_bp))
311 dva_copy[j++] = dva[i];
312 }
313 if (j == 0) {
314 zio->io_vsd = NULL;
315 zio->io_error = ENXIO;
316 return (NULL);
317 }
318 if (j < c) {
319 dva = dva_copy;
320 c = j;

Callers 1

vdev_mirror_io_startFunction · 0.85

Calls 10

dsl_scan_scrubbingFunction · 0.85
spa_writeableFunction · 0.85
zfs_dva_validFunction · 0.85
vdev_mirror_map_allocFunction · 0.85
vdev_lookup_topFunction · 0.85
vdev_mirror_map_sizeFunction · 0.85
spa_load_stateFunction · 0.85
dsl_scan_resilveringFunction · 0.85
vdev_mirror_rebuildingFunction · 0.85
kmem_freeFunction · 0.50

Tested by

no test coverage detected