View | Details | Raw Unified | Return to bug 223803 | Differences between
and this patch

Collapse All | Expand All

(-)sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h (-5 / +6 lines)
Lines 223-234 Link Here
223
	ZIO_FLAG_CANFAIL)
223
	ZIO_FLAG_CANFAIL)
224
224
225
enum zio_child {
225
enum zio_child {
226
	ZIO_CHILD_VDEV = 0,
226
	ZIO_CHILD_VDEV		= 1 << 0,
227
	ZIO_CHILD_GANG,
227
	ZIO_CHILD_GANG		= 1 << 1,
228
	ZIO_CHILD_DDT,
228
	ZIO_CHILD_DDT		= 1 << 2,
229
	ZIO_CHILD_LOGICAL,
229
	ZIO_CHILD_LOGICAL	= 1 << 3
230
	ZIO_CHILD_TYPES
231
};
230
};
231
#define	ZIO_CHILD_TYPES		4
232
#define zio_child(x)		(highbit64(x) - 1)
232
233
233
enum zio_wait_type {
234
enum zio_wait_type {
234
	ZIO_WAIT_READY = 0,
235
	ZIO_WAIT_READY = 0,
(-)sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c (-31 / +46 lines)
Lines 465-472 Link Here
465
465
466
	ASSERT(pio->io_state[ZIO_WAIT_DONE] == 0);
466
	ASSERT(pio->io_state[ZIO_WAIT_DONE] == 0);
467
467
468
	for (int w = 0; w < ZIO_WAIT_TYPES; w++)
468
	for (int w = 0; w < ZIO_WAIT_TYPES; w++) {
469
		pio->io_children[cio->io_child_type][w] += !cio->io_state[w];
469
		int child = zio_child(cio->io_child_type);
470
		pio->io_children[child][w] += !cio->io_state[w];
471
	}
470
472
471
	list_insert_head(&pio->io_child_list, zl);
473
	list_insert_head(&pio->io_child_list, zl);
472
	list_insert_head(&cio->io_parent_list, zl);
474
	list_insert_head(&cio->io_parent_list, zl);
Lines 500-517 Link Here
500
}
502
}
501
503
502
static boolean_t
504
static boolean_t
503
zio_wait_for_children(zio_t *zio, enum zio_child child, enum zio_wait_type wait)
505
zio_wait_for_children(zio_t *zio, enum zio_child children, enum zio_wait_type wait)
504
{
506
{
505
	uint64_t *countp = &zio->io_children[child][wait];
506
	boolean_t waiting = B_FALSE;
507
	boolean_t waiting = B_FALSE;
507
508
508
	mutex_enter(&zio->io_lock);
509
	mutex_enter(&zio->io_lock);
509
	ASSERT(zio->io_stall == NULL);
510
	for (int child = 0; child < ZIO_CHILD_TYPES; child++) {
510
	if (*countp != 0) {
511
		if (!(children & (1 << child)))
511
		zio->io_stage >>= 1;
512
			continue;
512
		zio->io_stall = countp;
513
513
		waiting = B_TRUE;
514
		uint64_t *countp = &zio->io_children[child][wait];
514
	}
515
516
		ASSERT(zio->io_stall == NULL);
517
		if (*countp != 0) {
518
			zio->io_stage >>= 1;
519
			ASSERT3U(zio->io_stage, !=, ZIO_STAGE_OPEN);
520
			zio->io_stall = countp;
521
			waiting = B_TRUE;
522
			break;
523
		}
524
 	}
515
	mutex_exit(&zio->io_lock);
525
	mutex_exit(&zio->io_lock);
516
526
517
	return (waiting);
527
	return (waiting);
Lines 520-527 Link Here
520
static void
530
static void
521
zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait)
531
zio_notify_parent(zio_t *pio, zio_t *zio, enum zio_wait_type wait)
522
{
532
{
523
	uint64_t *countp = &pio->io_children[zio->io_child_type][wait];
533
	int child = zio_child(zio->io_child_type);
524
	int *errorp = &pio->io_child_error[zio->io_child_type];
534
	uint64_t *countp =
535
	    &pio->io_children[child][wait];
536
	int *errorp = &pio->io_child_error[child];
525
537
526
	mutex_enter(&pio->io_lock);
538
	mutex_enter(&pio->io_lock);
527
	if (zio->io_error && !(zio->io_flags & ZIO_FLAG_DONT_PROPAGATE))
539
	if (zio->io_error && !(zio->io_flags & ZIO_FLAG_DONT_PROPAGATE))
Lines 543-550 Link Here
543
static void
555
static void
544
zio_inherit_child_errors(zio_t *zio, enum zio_child c)
556
zio_inherit_child_errors(zio_t *zio, enum zio_child c)
545
{
557
{
546
	if (zio->io_child_error[c] != 0 && zio->io_error == 0)
558
	if (zio->io_child_error[zio_child(c)] != 0 && zio->io_error == 0)
547
		zio->io_error = zio->io_child_error[c];
559
		zio->io_error = zio->io_child_error[zio_child(c)];
548
}
560
}
549
561
550
/*
562
/*
Lines 1176-1184 Link Here
1176
	 * If our children haven't all reached the ready stage,
1188
	 * If our children haven't all reached the ready stage,
1177
	 * wait for them and then repeat this pipeline stage.
1189
	 * wait for them and then repeat this pipeline stage.
1178
	 */
1190
	 */
1179
	if (zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_READY) ||
1191
	if (zio_wait_for_children(zio, ZIO_CHILD_GANG | ZIO_CHILD_LOGICAL,
1180
	    zio_wait_for_children(zio, ZIO_CHILD_LOGICAL, ZIO_WAIT_READY))
1192
	    ZIO_WAIT_READY)) {
1181
		return (ZIO_PIPELINE_STOP);
1193
		return (ZIO_PIPELINE_STOP);
1194
	}
1182
1195
1183
	if (!IO_IS_ALLOCATING(zio))
1196
	if (!IO_IS_ALLOCATING(zio))
1184
		return (ZIO_PIPELINE_CONTINUE);
1197
		return (ZIO_PIPELINE_CONTINUE);
Lines 1593-1602 Link Here
1593
	 * cannot be affected by any side effects of reexecuting 'cio'.
1606
	 * cannot be affected by any side effects of reexecuting 'cio'.
1594
	 */
1607
	 */
1595
	for (cio = zio_walk_children(pio); cio != NULL; cio = cio_next) {
1608
	for (cio = zio_walk_children(pio); cio != NULL; cio = cio_next) {
1609
		int child = zio_child(cio->io_child_type);
1596
		cio_next = zio_walk_children(pio);
1610
		cio_next = zio_walk_children(pio);
1597
		mutex_enter(&pio->io_lock);
1611
		mutex_enter(&pio->io_lock);
1598
		for (int w = 0; w < ZIO_WAIT_TYPES; w++)
1612
		for (int w = 0; w < ZIO_WAIT_TYPES; w++)
1599
			pio->io_children[cio->io_child_type][w]++;
1613
			pio->io_children[child][w]++;
1600
		mutex_exit(&pio->io_lock);
1614
		mutex_exit(&pio->io_lock);
1601
		zio_reexecute(cio);
1615
		zio_reexecute(cio);
1602
	}
1616
	}
Lines 1957-1963 Link Here
1957
	ASSERT(BP_IS_GANG(bp) && zio->io_gang_leader == zio);
1971
	ASSERT(BP_IS_GANG(bp) && zio->io_gang_leader == zio);
1958
	ASSERT(zio->io_child_type > ZIO_CHILD_GANG);
1972
	ASSERT(zio->io_child_type > ZIO_CHILD_GANG);
1959
1973
1960
	if (zio->io_child_error[ZIO_CHILD_GANG] == 0)
1974
	if (zio->io_child_error[zio_child(ZIO_CHILD_GANG)] == 0)
1961
		zio_gang_tree_issue(zio, zio->io_gang_tree, bp, zio->io_data);
1975
		zio_gang_tree_issue(zio, zio->io_gang_tree, bp, zio->io_data);
1962
	else
1976
	else
1963
		zio_gang_tree_free(&zio->io_gang_tree);
1977
		zio_gang_tree_free(&zio->io_gang_tree);
Lines 2174-2180 Link Here
2174
	ASSERT(BP_GET_PSIZE(bp) == zio->io_size);
2188
	ASSERT(BP_GET_PSIZE(bp) == zio->io_size);
2175
	ASSERT(zio->io_child_type == ZIO_CHILD_LOGICAL);
2189
	ASSERT(zio->io_child_type == ZIO_CHILD_LOGICAL);
2176
2190
2177
	if (zio->io_child_error[ZIO_CHILD_DDT]) {
2191
	if (zio->io_child_error[zio_child(ZIO_CHILD_DDT)]) {
2178
		ddt_t *ddt = ddt_select(zio->io_spa, bp);
2192
		ddt_t *ddt = ddt_select(zio->io_spa, bp);
2179
		ddt_entry_t *dde = ddt_repair_start(ddt, bp);
2193
		ddt_entry_t *dde = ddt_repair_start(ddt, bp);
2180
		ddt_phys_t *ddp = dde->dde_phys;
2194
		ddt_phys_t *ddp = dde->dde_phys;
Lines 2220-2226 Link Here
2220
	ASSERT(BP_GET_PSIZE(bp) == zio->io_size);
2234
	ASSERT(BP_GET_PSIZE(bp) == zio->io_size);
2221
	ASSERT(zio->io_child_type == ZIO_CHILD_LOGICAL);
2235
	ASSERT(zio->io_child_type == ZIO_CHILD_LOGICAL);
2222
2236
2223
	if (zio->io_child_error[ZIO_CHILD_DDT]) {
2237
	if (zio->io_child_error[zio_child(ZIO_CHILD_DDT)]) {
2224
		ddt_t *ddt = ddt_select(zio->io_spa, bp);
2238
		ddt_t *ddt = ddt_select(zio->io_spa, bp);
2225
		ddt_entry_t *dde = zio->io_vsd;
2239
		ddt_entry_t *dde = zio->io_vsd;
2226
		if (ddt == NULL) {
2240
		if (ddt == NULL) {
Lines 2234-2240 Link Here
2234
		}
2248
		}
2235
		if (dde->dde_repair_data != NULL) {
2249
		if (dde->dde_repair_data != NULL) {
2236
			bcopy(dde->dde_repair_data, zio->io_data, zio->io_size);
2250
			bcopy(dde->dde_repair_data, zio->io_data, zio->io_size);
2237
			zio->io_child_error[ZIO_CHILD_DDT] = 0;
2251
			zio->io_child_error[zio_child(ZIO_CHILD_DDT)] = 0;
2238
		}
2252
		}
2239
		ddt_repair_done(ddt, dde);
2253
		ddt_repair_done(ddt, dde);
2240
		zio->io_vsd = NULL;
2254
		zio->io_vsd = NULL;
Lines 2671-2677 Link Here
2671
	int ret;
2685
	int ret;
2672
2686
2673
	ASSERT(zio->io_error == 0);
2687
	ASSERT(zio->io_error == 0);
2674
	ASSERT(zio->io_child_error[ZIO_CHILD_VDEV] == 0);
2688
	ASSERT(zio->io_child_error[zio_child(ZIO_CHILD_VDEV)] == 0);
2675
2689
2676
	if (vd == NULL) {
2690
	if (vd == NULL) {
2677
		if (!(zio->io_flags & ZIO_FLAG_CONFIG_WRITER))
2691
		if (!(zio->io_flags & ZIO_FLAG_CONFIG_WRITER))
Lines 3109-3123 Link Here
3109
	blkptr_t *bp = zio->io_bp;
3123
	blkptr_t *bp = zio->io_bp;
3110
	zio_t *pio, *pio_next;
3124
	zio_t *pio, *pio_next;
3111
3125
3112
	if (zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_READY) ||
3126
	if (zio_wait_for_children(zio, ZIO_CHILD_GANG | ZIO_CHILD_DDT,
3113
	    zio_wait_for_children(zio, ZIO_CHILD_DDT, ZIO_WAIT_READY))
3127
	    ZIO_WAIT_READY)) {
3114
		return (ZIO_PIPELINE_STOP);
3128
		return (ZIO_PIPELINE_STOP);
3129
	}
3115
3130
3116
	if (zio->io_ready) {
3131
	if (zio->io_ready) {
3117
		ASSERT(IO_IS_ALLOCATING(zio));
3132
		ASSERT(IO_IS_ALLOCATING(zio));
3118
		ASSERT(bp->blk_birth == zio->io_txg || BP_IS_HOLE(bp) ||
3133
		ASSERT(bp->blk_birth == zio->io_txg || BP_IS_HOLE(bp) ||
3119
		    (zio->io_flags & ZIO_FLAG_NOPWRITE));
3134
		    (zio->io_flags & ZIO_FLAG_NOPWRITE));
3120
		ASSERT(zio->io_children[ZIO_CHILD_GANG][ZIO_WAIT_READY] == 0);
3135
		ASSERT0(zio->io_children[zio_child(
3136
		    ZIO_CHILD_GANG)][ZIO_WAIT_READY]);
3121
3137
3122
		zio->io_ready(zio);
3138
		zio->io_ready(zio);
3123
	}
3139
	}
Lines 3175-3189 Link Here
3175
	 * If our children haven't all completed,
3191
	 * If our children haven't all completed,
3176
	 * wait for them and then repeat this pipeline stage.
3192
	 * wait for them and then repeat this pipeline stage.
3177
	 */
3193
	 */
3178
	if (zio_wait_for_children(zio, ZIO_CHILD_VDEV, ZIO_WAIT_DONE) ||
3194
	if (zio_wait_for_children(zio, ZIO_CHILD_VDEV | ZIO_CHILD_GANG |
3179
	    zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_DONE) ||
3195
	    ZIO_CHILD_DDT | ZIO_CHILD_LOGICAL, ZIO_WAIT_DONE)) {
3180
	    zio_wait_for_children(zio, ZIO_CHILD_DDT, ZIO_WAIT_DONE) ||
3181
	    zio_wait_for_children(zio, ZIO_CHILD_LOGICAL, ZIO_WAIT_DONE))
3182
		return (ZIO_PIPELINE_STOP);
3196
		return (ZIO_PIPELINE_STOP);
3197
	}
3183
3198
3184
	for (int c = 0; c < ZIO_CHILD_TYPES; c++)
3199
	for (int child = 0; child < ZIO_CHILD_TYPES; child++)
3185
		for (int w = 0; w < ZIO_WAIT_TYPES; w++)
3200
		for (int w = 0; w < ZIO_WAIT_TYPES; w++)
3186
			ASSERT(zio->io_children[c][w] == 0);
3201
			ASSERT0(zio->io_children[child][w]);
3187
3202
3188
	if (bp != NULL && !BP_IS_EMBEDDED(bp)) {
3203
	if (bp != NULL && !BP_IS_EMBEDDED(bp)) {
3189
		ASSERT(bp->blk_pad[0] == 0);
3204
		ASSERT(bp->blk_pad[0] == 0);

Return to bug 223803