@@ -132,23 +132,25 @@ ds_cont_csummer_init(struct ds_cont_child *cont)
132132 bool dedup_only = false;
133133
134134 D_ASSERT (cont != NULL );
135- cont_props = & cont -> sc_props ;
135+ while (cont -> sc_csummer_initing ) {
136+ ABT_mutex_lock (cont -> sc_mutex );
137+ ABT_cond_wait (cont -> sc_init_cond , cont -> sc_mutex );
138+ ABT_mutex_unlock (cont -> sc_mutex );
139+ }
136140
137- if (cont -> sc_props_fetched )
141+ if (cont -> sc_csummer_inited )
138142 return 0 ;
139143
144+ D_ASSERT (cont -> sc_csummer == NULL );
145+ cont -> sc_csummer_initing = 1 ;
140146 /** Get the container csum related properties
141147 * Need the pool for the IV namespace
142148 */
143- D_ASSERT ( cont -> sc_csummer == NULL ) ;
149+ cont_props = & cont -> sc_props ;
144150 rc = ds_cont_get_props (cont_props , cont -> sc_pool_uuid , cont -> sc_uuid );
145151 if (rc != 0 )
146152 goto done ;
147153
148- /* Check again since IV fetch yield */
149- if (cont -> sc_props_fetched )
150- goto done ;
151-
152154 csum_val = cont_props -> dcp_csum_type ;
153155 if (!daos_cont_csum_prop_is_enabled (csum_val )) {
154156 dedup_only = true;
@@ -178,9 +180,13 @@ ds_cont_csummer_init(struct ds_cont_child *cont)
178180 DP_UUID (cont -> sc_uuid ), DP_RC (rc ));
179181 rc = 0 ;
180182 }
181- cont -> sc_props_fetched = 1 ;
182-
183+ D_ASSERT (! cont -> sc_csummer_inited ); /* nobody else can do this except me */
184+ cont -> sc_csummer_inited = 1 ;
183185done :
186+ if (cont -> sc_csummer_initing ) {
187+ cont -> sc_csummer_initing = 0 ;
188+ ABT_cond_broadcast (cont -> sc_init_cond );
189+ }
184190 return rc ;
185191}
186192
@@ -218,7 +224,7 @@ cont_aggregate_runnable(struct ds_cont_child *cont, struct sched_request *req,
218224 DP_CONT (cont -> sc_pool -> spc_uuid , cont -> sc_uuid ));
219225 }
220226
221- if (!cont -> sc_props_fetched )
227+ if (!cont -> sc_csummer_inited )
222228 ds_cont_csummer_init (cont );
223229
224230 if (cont -> sc_props .dcp_dedup_enabled ||
@@ -655,6 +661,25 @@ cont_child_obj(struct daos_llink *llink)
655661 return container_of (llink , struct ds_cont_child , sc_list );
656662}
657663
664+ static void
665+ cont_child_fini_abt (struct ds_cont_child * cont )
666+ {
667+ if (cont -> sc_dtx_resync_cond )
668+ ABT_cond_free (& cont -> sc_dtx_resync_cond );
669+ if (cont -> sc_scrub_cond )
670+ ABT_cond_free (& cont -> sc_scrub_cond );
671+ if (cont -> sc_rebuild_cond )
672+ ABT_cond_free (& cont -> sc_rebuild_cond );
673+ if (cont -> sc_init_cond )
674+ ABT_cond_free (& cont -> sc_init_cond );
675+ if (cont -> sc_fini_cond )
676+ ABT_cond_free (& cont -> sc_fini_cond );
677+ if (cont -> sc_mutex )
678+ ABT_mutex_free (& cont -> sc_mutex );
679+ if (cont -> sc_open_mutex )
680+ ABT_mutex_free (& cont -> sc_open_mutex );
681+ }
682+
658683static int
659684cont_child_alloc_ref (void * co_uuid , unsigned int ksize , void * po_uuid ,
660685 struct daos_llink * * link )
@@ -678,34 +703,39 @@ cont_child_alloc_ref(void *co_uuid, unsigned int ksize, void *po_uuid,
678703 rc = ABT_mutex_create (& cont -> sc_mutex );
679704 if (rc != ABT_SUCCESS ) {
680705 rc = dss_abterr2der (rc );
681- goto out_open_mutex ;
706+ goto out_abt ;
682707 }
683708
684709 rc = ABT_cond_create (& cont -> sc_dtx_resync_cond );
685710 if (rc != ABT_SUCCESS ) {
686711 rc = dss_abterr2der (rc );
687- goto out_mutex ;
712+ goto out_abt ;
688713 }
689714 rc = ABT_cond_create (& cont -> sc_scrub_cond );
690715 if (rc != ABT_SUCCESS ) {
691716 rc = dss_abterr2der (rc );
692- goto out_resync_cond ;
717+ goto out_abt ;
693718 }
694719 rc = ABT_cond_create (& cont -> sc_rebuild_cond );
695720 if (rc != ABT_SUCCESS ) {
696721 rc = dss_abterr2der (rc );
697- goto out_scrub_cond ;
722+ goto out_abt ;
723+ }
724+ rc = ABT_cond_create (& cont -> sc_init_cond );
725+ if (rc != ABT_SUCCESS ) {
726+ rc = dss_abterr2der (rc );
727+ goto out_abt ;
698728 }
699729 rc = ABT_cond_create (& cont -> sc_fini_cond );
700730 if (rc != ABT_SUCCESS ) {
701731 rc = dss_abterr2der (rc );
702- goto out_rebuild_cond ;
732+ goto out_abt ;
703733 }
704734
705735 cont -> sc_pool = ds_pool_child_lookup (po_uuid );
706736 if (cont -> sc_pool == NULL ) {
707737 rc = - DER_NO_HDL ;
708- goto out_finish_cond ;
738+ goto out_abt ;
709739 }
710740
711741 rc = vos_cont_open (cont -> sc_pool -> spc_hdl , co_uuid , & cont -> sc_hdl );
@@ -745,18 +775,8 @@ cont_child_alloc_ref(void *co_uuid, unsigned int ksize, void *po_uuid,
745775 vos_cont_close (cont -> sc_hdl );
746776out_pool :
747777 ds_pool_child_put (cont -> sc_pool );
748- out_finish_cond :
749- ABT_cond_free (& cont -> sc_fini_cond );
750- out_rebuild_cond :
751- ABT_cond_free (& cont -> sc_rebuild_cond );
752- out_scrub_cond :
753- ABT_cond_free (& cont -> sc_scrub_cond );
754- out_resync_cond :
755- ABT_cond_free (& cont -> sc_dtx_resync_cond );
756- out_mutex :
757- ABT_mutex_free (& cont -> sc_mutex );
758- out_open_mutex :
759- ABT_mutex_free (& cont -> sc_open_mutex );
778+ out_abt :
779+ cont_child_fini_abt (cont );
760780out :
761781 D_FREE (cont );
762782 return rc ;
@@ -777,14 +797,10 @@ cont_child_free_ref(struct daos_llink *llink)
777797 cont_tgt_track_eph_fini (cont );
778798 vos_cont_close (cont -> sc_hdl );
779799 ds_pool_child_put (cont -> sc_pool );
780- daos_csummer_destroy (& cont -> sc_csummer );
800+ if (cont -> sc_csummer )
801+ daos_csummer_destroy (& cont -> sc_csummer );
781802 D_FREE (cont -> sc_snapshots );
782- ABT_cond_free (& cont -> sc_dtx_resync_cond );
783- ABT_cond_free (& cont -> sc_scrub_cond );
784- ABT_cond_free (& cont -> sc_rebuild_cond );
785- ABT_cond_free (& cont -> sc_fini_cond );
786- ABT_mutex_free (& cont -> sc_mutex );
787- ABT_mutex_free (& cont -> sc_open_mutex );
803+ cont_child_fini_abt (cont );
788804 D_FREE (cont );
789805}
790806
0 commit comments