@@ -744,8 +744,8 @@ zio_unique_parent(zio_t *cio)
744
744
return (pio );
745
745
}
746
746
747
- void
748
- zio_add_child (zio_t * pio , zio_t * cio )
747
+ static void
748
+ zio_add_child_impl (zio_t * pio , zio_t * cio , boolean_t first )
749
749
{
750
750
/*
751
751
* Logical I/Os can have logical, gang, or vdev children.
@@ -765,7 +765,11 @@ zio_add_child(zio_t *pio, zio_t *cio)
765
765
zl -> zl_child = cio ;
766
766
767
767
mutex_enter (& pio -> io_lock );
768
- mutex_enter (& cio -> io_lock );
768
+
769
+ if (first )
770
+ ASSERT (list_is_empty (& cio -> io_parent_list ));
771
+ else
772
+ mutex_enter (& cio -> io_lock );
769
773
770
774
ASSERT (pio -> io_state [ZIO_WAIT_DONE ] == 0 );
771
775
@@ -776,44 +780,22 @@ zio_add_child(zio_t *pio, zio_t *cio)
776
780
list_insert_head (& pio -> io_child_list , zl );
777
781
list_insert_head (& cio -> io_parent_list , zl );
778
782
779
- mutex_exit (& cio -> io_lock );
783
+ if (!first )
784
+ mutex_exit (& cio -> io_lock );
785
+
780
786
mutex_exit (& pio -> io_lock );
781
787
}
782
788
783
789
void
784
- zio_add_child_first (zio_t * pio , zio_t * cio )
790
+ zio_add_child (zio_t * pio , zio_t * cio )
785
791
{
786
- /*
787
- * Logical I/Os can have logical, gang, or vdev children.
788
- * Gang I/Os can have gang or vdev children.
789
- * Vdev I/Os can only have vdev children.
790
- * The following ASSERT captures all of these constraints.
791
- */
792
- ASSERT3S (cio -> io_child_type , <=, pio -> io_child_type );
793
-
794
- /* Parent should not have READY stage if child doesn't have it. */
795
- IMPLY ((cio -> io_pipeline & ZIO_STAGE_READY ) == 0 &&
796
- (cio -> io_child_type != ZIO_CHILD_VDEV ),
797
- (pio -> io_pipeline & ZIO_STAGE_READY ) == 0 );
798
-
799
- zio_link_t * zl = kmem_cache_alloc (zio_link_cache , KM_SLEEP );
800
- zl -> zl_parent = pio ;
801
- zl -> zl_child = cio ;
802
-
803
- ASSERT (list_is_empty (& cio -> io_parent_list ));
804
- list_insert_head (& cio -> io_parent_list , zl );
805
-
806
- mutex_enter (& pio -> io_lock );
807
-
808
- ASSERT (pio -> io_state [ZIO_WAIT_DONE ] == 0 );
809
-
810
- uint64_t * countp = pio -> io_children [cio -> io_child_type ];
811
- for (int w = 0 ; w < ZIO_WAIT_TYPES ; w ++ )
812
- countp [w ] += !cio -> io_state [w ];
813
-
814
- list_insert_head (& pio -> io_child_list , zl );
792
+ zio_add_child_impl (pio , cio , B_FALSE );
793
+ }
815
794
816
- mutex_exit (& pio -> io_lock );
795
+ static void
796
+ zio_add_child_first (zio_t * pio , zio_t * cio )
797
+ {
798
+ zio_add_child_impl (pio , cio , B_TRUE );
817
799
}
818
800
819
801
static void
0 commit comments