@@ -1000,8 +1000,8 @@ zio_create(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
1000
1000
if (bp != NULL ) {
1001
1001
if (type != ZIO_TYPE_WRITE ||
1002
1002
zio -> io_child_type == ZIO_CHILD_DDT ) {
1003
- zio -> io_bp_copy = * bp ;
1004
- zio -> io_bp = & zio -> io_bp_copy ; /* so caller can free */
1003
+ /* so caller can free */
1004
+ zio -> io_bp = zio -> io_bp_copy = zio_dup_bp ( bp );
1005
1005
} else {
1006
1006
zio -> io_bp = (blkptr_t * )bp ;
1007
1007
}
@@ -1062,9 +1062,28 @@ zio_destroy(zio_t *zio)
1062
1062
list_destroy (& zio -> io_child_list );
1063
1063
mutex_destroy (& zio -> io_lock );
1064
1064
cv_destroy (& zio -> io_cv );
1065
+ if (zio -> io_bp_copy != NULL )
1066
+ kmem_cache_free (zio_bp_cache , zio -> io_bp_copy );
1065
1067
kmem_cache_free (zio_cache , zio );
1066
1068
}
1067
1069
1070
+ /*
1071
+ * Forcibly set the block pointer in a completed ZIO. This is only used from
1072
+ * l2arc_read_done() to set the original BP on the L2ARC read ZIO so that it
1073
+ * looks sensible when sent back to arc_read_done(). Shouldn't be used anywhere
1074
+ * else. If that changes, that is, you do something about the "XXX fix in L2ARC
1075
+ * 2.0" comment in arc.c that has existed since prehistory, please rewrite this
1076
+ * comment too.
1077
+ */
1078
+ void
1079
+ zio_force_bp (zio_t * zio , const blkptr_t * bp )
1080
+ {
1081
+ ASSERT3U (zio -> io_type , = = , ZIO_TYPE_READ );
1082
+ ASSERT3U (zio -> io_stage , = = , ZIO_STAGE_DONE );
1083
+ ASSERT0P (zio -> io_bp_copy );
1084
+ zio -> io_bp = zio -> io_bp_copy = zio_dup_bp (bp );
1085
+ }
1086
+
1068
1087
/*
1069
1088
* ZIO intended to be between others. Provides synchronization at READY
1070
1089
* and DONE pipeline stages and calls the respective callbacks.
@@ -1822,7 +1841,7 @@ zio_read_bp_init(zio_t *zio)
1822
1841
uint64_t psize =
1823
1842
BP_IS_EMBEDDED (bp ) ? BPE_GET_PSIZE (bp ) : BP_GET_PSIZE (bp );
1824
1843
1825
- ASSERT3P (zio -> io_bp , = = , & zio -> io_bp_copy );
1844
+ ASSERT3P (zio -> io_bp , = = , zio -> io_bp_copy );
1826
1845
1827
1846
if (BP_GET_COMPRESS (bp ) != ZIO_COMPRESS_OFF &&
1828
1847
zio -> io_child_type == ZIO_CHILD_LOGICAL &&
@@ -2150,7 +2169,7 @@ zio_free_bp_init(zio_t *zio)
2150
2169
zio -> io_pipeline = ZIO_DDT_FREE_PIPELINE ;
2151
2170
}
2152
2171
2153
- ASSERT3P (zio -> io_bp , = = , & zio -> io_bp_copy );
2172
+ ASSERT3P (zio -> io_bp , = = , zio -> io_bp_copy );
2154
2173
2155
2174
return (zio );
2156
2175
}
@@ -5327,8 +5346,12 @@ zio_ready(zio_t *zio)
5327
5346
}
5328
5347
5329
5348
#ifdef ZFS_DEBUG
5330
- if (bp != NULL && bp != & zio -> io_bp_copy )
5331
- zio -> io_bp_copy = * bp ;
5349
+ if (bp != NULL && bp != zio -> io_bp_copy ) {
5350
+ if (zio -> io_bp_copy == NULL )
5351
+ zio -> io_bp_copy = zio_dup_bp (bp );
5352
+ else
5353
+ * zio -> io_bp_copy = * bp ;
5354
+ }
5332
5355
#endif
5333
5356
5334
5357
if (zio -> io_error != 0 ) {
@@ -5474,9 +5497,11 @@ zio_done(zio_t *zio)
5474
5497
ASSERT0 (zio -> io_children [c ][w ]);
5475
5498
5476
5499
if (zio -> io_bp != NULL && !BP_IS_EMBEDDED (zio -> io_bp )) {
5477
- ASSERT (memcmp (zio -> io_bp , & zio -> io_bp_copy ,
5478
- sizeof (blkptr_t )) == 0 ||
5479
- (zio -> io_bp == zio_unique_parent (zio )-> io_bp ));
5500
+ if (zio -> io_bp_copy ) {
5501
+ ASSERT (memcmp (zio -> io_bp , zio -> io_bp_copy ,
5502
+ sizeof (blkptr_t )) == 0 ||
5503
+ (zio -> io_bp == zio_unique_parent (zio )-> io_bp ));
5504
+ }
5480
5505
if (zio -> io_type == ZIO_TYPE_WRITE && !BP_IS_HOLE (zio -> io_bp ) &&
5481
5506
zio -> io_bp_override == NULL &&
5482
5507
!(zio -> io_flags & ZIO_FLAG_IO_REPAIR )) {
0 commit comments