@@ -67,7 +67,7 @@ _core_is_loaded_cache_visitor(ocf_cache_t cache, void *cb_arg)
6767 if (!rc && !ocf_core_get_priv (core )) {
6868 /* Core context is assigned only after manual core add (either right
6969 * away if all devices are present, after corresponding cache start,
70- * or base bdev appearance ).
70+ * or base bdev showing up ).
7171 * If there is no context, it means that this core was just added from
7272 * metadata during cache load and that's what we're looking for here. */
7373
@@ -518,24 +518,35 @@ _core_add_from_waitlist_lock_cb(ocf_cache_t cache, void *cb_arg, int error)
518518 return ;
519519 }
520520
521+ core_ctx -> core_cfg .try_add = vbdev_ocf_core_is_loaded (vbdev_ocf_core_get_name (core_ctx ));
522+
521523 ocf_mngt_cache_add_core (cache , & core_ctx -> core_cfg , _core_add_from_waitlist_add_cb , core_ctx );
522524}
523525
524- void
525- vbdev_ocf_core_add_from_waitlist (ocf_cache_t cache )
526+ static void
527+ _core_add_from_waitlist_read_lock_cb (ocf_cache_t cache , void * cb_arg , int error )
526528{
527529 struct vbdev_ocf_cache * cache_ctx = ocf_cache_get_priv (cache );
528530 struct vbdev_ocf_core * core_ctx ;
529531 uint32_t cache_block_size = spdk_bdev_get_block_size (cache_ctx -> base .bdev );
530532 uint32_t core_block_size ;
531533
534+ SPDK_DEBUGLOG (vbdev_ocf , "OCF cache '%s': looking for its cores in wait list\n" ,
535+ ocf_cache_get_name (cache ));
536+
537+ if (error ) {
538+ SPDK_ERRLOG ("OCF cache '%s': failed to acquire OCF cache lock (OCF error: %d)\n" ,
539+ ocf_cache_get_name (cache ), error );
540+ return ;
541+ }
542+
532543 vbdev_ocf_foreach_core_in_waitlist (core_ctx ) {
533544 if (strcmp (ocf_cache_get_name (cache ), core_ctx -> cache_name ) ||
534545 !vbdev_ocf_core_is_base_attached (core_ctx )) {
535546 continue ;
536547 }
537548
538- SPDK_NOTICELOG ("OCF core '%s': adding from waitlist to cache '%s'\n" ,
549+ SPDK_NOTICELOG ("OCF core '%s': adding from wait list to cache '%s'\n" ,
539550 vbdev_ocf_core_get_name (core_ctx ), ocf_cache_get_name (cache ));
540551
541552 core_block_size = spdk_bdev_get_block_size (core_ctx -> base .bdev );
@@ -546,10 +557,16 @@ vbdev_ocf_core_add_from_waitlist(ocf_cache_t cache)
546557 continue ;
547558 }
548559
549- core_ctx -> core_cfg .try_add = vbdev_ocf_core_is_loaded (vbdev_ocf_core_get_name (core_ctx ));
550-
551560 ocf_mngt_cache_lock (cache , _core_add_from_waitlist_lock_cb , core_ctx );
552561 }
562+
563+ ocf_mngt_cache_read_unlock (cache );
564+ }
565+
566+ void
567+ vbdev_ocf_core_add_from_waitlist (ocf_cache_t cache )
568+ {
569+ ocf_mngt_cache_read_lock (cache , _core_add_from_waitlist_read_lock_cb , NULL );
553570}
554571
555572static void
0 commit comments