@@ -1115,6 +1115,7 @@ ec_destroy_ch(void *io_device, void *ctx_buf)
11151115
11161116static void ec_device_unregister_done (void * io_device );
11171117static void ec_release_dedicated_channels (struct ec_bdev * ec );
1118+ static int ec_open_dedicated_channels (struct ec_bdev * ec );
11181119/* ec_scrub_free_resources declared in bdev_ec_internal.h. */
11191120
11201121/*
@@ -1497,7 +1498,6 @@ ec_bdev_create_async(const char *name, uint32_t strip_size_kb, uint32_t k, uint3
14971498 struct ec_bdev * ec ;
14981499 struct ec_bdev_create_async_ctx * ctx ;
14991500 int rc ;
1500- uint32_t i , j ;
15011501 bool io_device_registered = false;
15021502
15031503 rc = _ec_bdev_create (name , strip_size_kb , k , m , uuid , & ec );
@@ -1535,41 +1535,9 @@ ec_bdev_create_async(const char *name, uint32_t strip_size_kb, uint32_t k, uint3
15351535 goto error_cleanup ;
15361536 }
15371537
1538- /* Open dedicated WIB channels for each parity disk. */
1539- for (j = 0 ; j < ec -> m ; j ++ ) {
1540- uint32_t pslot = ec -> k + j ;
1541-
1542- if (!ec -> descs [pslot ]) {
1543- ec -> wib_chans [j ] = NULL ;
1544- continue ;
1545- }
1546- ec -> wib_chans [j ] = spdk_bdev_get_io_channel (ec -> descs [pslot ]);
1547- if (!ec -> wib_chans [j ]) {
1548- SPDK_ERRLOG ("EC bdev %s: failed to open WIB channel "
1549- "for parity slot %u\n" , name , pslot );
1550- rc = - ENOMEM ;
1551- goto error_cleanup ;
1552- }
1553- }
1554-
1555- /*
1556- * Open dedicated bitmap channels for every disk. The in-band
1557- * unmapped bitmap is raw-replicated to all n disks (unlike the
1558- * WIB which lives only on the m parity disks), so the channel
1559- * array is n entries wide.
1560- */
1561- for (i = 0 ; i < ec -> n ; i ++ ) {
1562- if (!ec -> descs [i ]) {
1563- ec -> bitmap_chans [i ] = NULL ;
1564- continue ;
1565- }
1566- ec -> bitmap_chans [i ] = spdk_bdev_get_io_channel (ec -> descs [i ]);
1567- if (!ec -> bitmap_chans [i ]) {
1568- SPDK_ERRLOG ("EC bdev %s: failed to open bitmap channel "
1569- "for slot %u\n" , name , i );
1570- rc = - ENOMEM ;
1571- goto error_cleanup ;
1572- }
1538+ rc = ec_open_dedicated_channels (ec );
1539+ if (rc != 0 ) {
1540+ goto error_cleanup ;
15731541 }
15741542
15751543 ec -> wib_poller = spdk_poller_register (ec_wib_idle_poller_cb , ec ,
@@ -1639,6 +1607,61 @@ ec_bdev_create_async(const char *name, uint32_t strip_size_kb, uint32_t k, uint3
16391607 return rc ;
16401608}
16411609
1610+ /*
1611+ * Open the long-lived WIB (one per parity slot) and bitmap (one per slot)
1612+ * channels. Must run on the home thread -- channels bind to the calling
1613+ * thread. On failure, releases any partial opens; no channels remain.
1614+ * Inverse of ec_release_dedicated_channels (which also unregisters the WIB
1615+ * idle poller -- registered later in the create sequence, not here).
1616+ */
1617+ static int
1618+ ec_open_dedicated_channels (struct ec_bdev * ec )
1619+ {
1620+ uint32_t i , j ;
1621+
1622+ assert (spdk_get_thread () == ec -> home_thread );
1623+
1624+ /* WIB channels: one per parity slot; the WIB lives only on the m parity disks. */
1625+ for (j = 0 ; j < ec -> m ; j ++ ) {
1626+ uint32_t pslot = ec -> k + j ;
1627+
1628+ if (!ec -> descs [pslot ]) {
1629+ ec -> wib_chans [j ] = NULL ;
1630+ continue ;
1631+ }
1632+ ec -> wib_chans [j ] = spdk_bdev_get_io_channel (ec -> descs [pslot ]);
1633+ if (!ec -> wib_chans [j ]) {
1634+ SPDK_ERRLOG ("EC bdev %s: failed to open WIB channel "
1635+ "for parity slot %u\n" , ec -> bdev .name , pslot );
1636+ goto err ;
1637+ }
1638+ }
1639+
1640+ /*
1641+ * Bitmap channels: one per slot. The in-band unmapped bitmap is
1642+ * raw-replicated to all n disks (unlike the WIB, on the m parity disks
1643+ * only), so the array is n entries wide.
1644+ */
1645+ for (i = 0 ; i < ec -> n ; i ++ ) {
1646+ if (!ec -> descs [i ]) {
1647+ ec -> bitmap_chans [i ] = NULL ;
1648+ continue ;
1649+ }
1650+ ec -> bitmap_chans [i ] = spdk_bdev_get_io_channel (ec -> descs [i ]);
1651+ if (!ec -> bitmap_chans [i ]) {
1652+ SPDK_ERRLOG ("EC bdev %s: failed to open bitmap channel "
1653+ "for slot %u\n" , ec -> bdev .name , i );
1654+ goto err ;
1655+ }
1656+ }
1657+
1658+ return 0 ;
1659+
1660+ err :
1661+ ec_release_dedicated_channels (ec );
1662+ return - ENOMEM ;
1663+ }
1664+
16421665/*
16431666 * Release the dedicated WIB and bitmap I/O channels and stop the WIB idle
16441667 * poller. Each channel is NULL-checked and NULLed, so this is safe on both
0 commit comments