@@ -992,8 +992,10 @@ zio_create(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
992
992
if (bp != NULL ) {
993
993
if (type != ZIO_TYPE_WRITE ||
994
994
zio -> io_child_type == ZIO_CHILD_DDT ) {
995
- zio -> io_bp_copy = * bp ;
996
- zio -> io_bp = & zio -> io_bp_copy ; /* so caller can free */
995
+ zio -> io_bp_copy =
996
+ kmem_cache_alloc (zio_bp_cache , KM_SLEEP );
997
+ * zio -> io_bp_copy = * bp ;
998
+ zio -> io_bp = zio -> io_bp_copy ; /* so caller can free */
997
999
} else {
998
1000
zio -> io_bp = (blkptr_t * )bp ;
999
1001
}
@@ -1054,9 +1056,30 @@ zio_destroy(zio_t *zio)
1054
1056
list_destroy (& zio -> io_child_list );
1055
1057
mutex_destroy (& zio -> io_lock );
1056
1058
cv_destroy (& zio -> io_cv );
1059
+ if (zio -> io_bp_copy != NULL )
1060
+ kmem_cache_free (zio_bp_cache , zio -> io_bp_copy );
1057
1061
kmem_cache_free (zio_cache , zio );
1058
1062
}
1059
1063
1064
+ /*
1065
+ * Forcibly set the block pointer in a completed ZIO. This is only used from
1066
+ * l2arc_read_done() to set the original BP on the L2ARC read ZIO so that it
1067
+ * looks sensible when sent back to arc_read_done(). Shouldn't be used anywhere
1068
+ * else. If that changes,
1069
+ * that is, you do something about the "XXX fix in L2ARC 2.0" comment in arc.c
1070
+ * that has existed since prehistory, please rewrite this comment too.
1071
+ */
1072
+ void
1073
+ zio_force_bp (zio_t * zio , const blkptr_t * bp )
1074
+ {
1075
+ ASSERT3U (zio -> io_type , = = , ZIO_TYPE_READ );
1076
+ ASSERT3U (zio -> io_stage , = = , ZIO_STAGE_DONE );
1077
+ ASSERT0P (zio -> io_bp_copy );
1078
+ zio -> io_bp_copy = kmem_cache_alloc (zio_bp_cache , KM_SLEEP );
1079
+ * zio -> io_bp_copy = * bp ;
1080
+ zio -> io_bp = zio -> io_bp_copy ;
1081
+ }
1082
+
1060
1083
/*
1061
1084
* ZIO intended to be between others. Provides synchronization at READY
1062
1085
* and DONE pipeline stages and calls the respective callbacks.
@@ -1814,7 +1837,7 @@ zio_read_bp_init(zio_t *zio)
1814
1837
uint64_t psize =
1815
1838
BP_IS_EMBEDDED (bp ) ? BPE_GET_PSIZE (bp ) : BP_GET_PSIZE (bp );
1816
1839
1817
- ASSERT3P (zio -> io_bp , = = , & zio -> io_bp_copy );
1840
+ ASSERT3P (zio -> io_bp , = = , zio -> io_bp_copy );
1818
1841
1819
1842
if (BP_GET_COMPRESS (bp ) != ZIO_COMPRESS_OFF &&
1820
1843
zio -> io_child_type == ZIO_CHILD_LOGICAL &&
@@ -2142,7 +2165,7 @@ zio_free_bp_init(zio_t *zio)
2142
2165
zio -> io_pipeline = ZIO_DDT_FREE_PIPELINE ;
2143
2166
}
2144
2167
2145
- ASSERT3P (zio -> io_bp , = = , & zio -> io_bp_copy );
2168
+ ASSERT3P (zio -> io_bp , = = , zio -> io_bp_copy );
2146
2169
2147
2170
return (zio );
2148
2171
}
@@ -5308,8 +5331,12 @@ zio_ready(zio_t *zio)
5308
5331
}
5309
5332
5310
5333
#ifdef ZFS_DEBUG
5311
- if (bp != NULL && bp != & zio -> io_bp_copy )
5312
- zio -> io_bp_copy = * bp ;
5334
+ if (bp != NULL && bp != zio -> io_bp_copy ) {
5335
+ if (zio -> io_bp_copy == NULL )
5336
+ zio -> io_bp_copy =
5337
+ kmem_cache_alloc (zio_bp_cache , KM_SLEEP );
5338
+ * zio -> io_bp_copy = * bp ;
5339
+ }
5313
5340
#endif
5314
5341
5315
5342
if (zio -> io_error != 0 ) {
@@ -5455,9 +5482,11 @@ zio_done(zio_t *zio)
5455
5482
ASSERT0 (zio -> io_children [c ][w ]);
5456
5483
5457
5484
if (zio -> io_bp != NULL && !BP_IS_EMBEDDED (zio -> io_bp )) {
5458
- ASSERT (memcmp (zio -> io_bp , & zio -> io_bp_copy ,
5459
- sizeof (blkptr_t )) == 0 ||
5460
- (zio -> io_bp == zio_unique_parent (zio )-> io_bp ));
5485
+ if (zio -> io_bp_copy ) {
5486
+ ASSERT (memcmp (zio -> io_bp , zio -> io_bp_copy ,
5487
+ sizeof (blkptr_t )) == 0 ||
5488
+ (zio -> io_bp == zio_unique_parent (zio )-> io_bp ));
5489
+ }
5461
5490
if (zio -> io_type == ZIO_TYPE_WRITE && !BP_IS_HOLE (zio -> io_bp ) &&
5462
5491
zio -> io_bp_override == NULL &&
5463
5492
!(zio -> io_flags & ZIO_FLAG_IO_REPAIR )) {
0 commit comments