@@ -1670,14 +1670,31 @@ struct subsystem_ns_change_ctx_v2 {
1670
1670
struct spdk_nvmf_ctrlr * ctrlr ;
1671
1671
// spdk_nvmf_subsystem_state_change_done cb_fn;
1672
1672
// uint32_t nsid;
1673
+ struct spdk_nvmf_subsystem * subsystem ;
1674
+ bool last_one ;
1675
+ struct spdk_thread * thread ;
1673
1676
};
1674
1677
1675
1678
1679
+ static void
1680
+ nvmf_subsystem_ns_changed_v3 (void * cb_arg )
1681
+ {
1682
+ struct spdk_nvmf_subsystem * subsystem = cb_arg ;
1683
+ SPDK_NOTICELOG ("Running the subsystem.\n" );
1684
+ if (spdk_nvmf_subsystem_resume (subsystem , NULL , NULL ) != 0 ) {
1685
+ SPDK_ERRLOG ("Failed to resume NVME-oF subsystem with id: %u\n" , subsystem -> id );
1686
+ }
1687
+ }
1688
+
1676
1689
static void
1677
1690
nvmf_subsystem_ns_changed_v2 (void * cb_arg )
1678
1691
{
1679
1692
struct subsystem_ns_change_ctx_v2 * ctx = cb_arg ;
1680
1693
nvmf_ctrlr_ns_changed (ctx -> ctrlr , ctx -> nsid );
1694
+ if (ctx -> last_one ) {
1695
+ SPDK_NOTICELOG ("changing the ns list namespace: %d done.\n" , ctx -> nsid );
1696
+ spdk_thread_send_msg (ctx -> thread , nvmf_subsystem_ns_changed_v3 , ctx -> subsystem );
1697
+ }
1681
1698
free (ctx );
1682
1699
}
1683
1700
@@ -1686,14 +1703,31 @@ nvmf_subsystem_ns_changed(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
1686
1703
{
1687
1704
struct spdk_nvmf_ctrlr * ctrlr ;
1688
1705
struct subsystem_ns_change_ctx_v2 * ctx ;
1689
- ctx = calloc (1 , sizeof (struct subsystem_ns_change_ctx_v2 ));
1706
+ int count = 0 ;
1707
+ ctx = calloc (subsystem -> max_cntlid , sizeof (struct subsystem_ns_change_ctx_v2 ));
1708
+ if (!ctx ) {
1709
+ SPDK_ERRLOG ("Cannot allocate memory for chnaging the ns list.\n" );
1710
+ if (spdk_nvmf_subsystem_resume (subsystem , NULL , NULL ) != 0 ) {
1711
+ SPDK_ERRLOG ("Failed to resume NVME-oF subsystem with id: %u\n" , subsystem -> id );
1712
+ }
1713
+ return ;
1714
+ }
1690
1715
TAILQ_FOREACH (ctrlr , & subsystem -> ctrlrs , link ) {
1691
1716
if (nvmf_ctrlr_ns_is_visible (ctrlr , nsid )) {
1692
- ctx -> nsid = nsid ;
1693
- ctx -> ctrlr = ctrlr ;
1694
- spdk_thread_send_msg (ctrlr -> thread , nvmf_subsystem_ns_changed_v2 , ctx );
1717
+ ctx [count ].nsid = nsid ;
1718
+ ctx [count ].ctrlr = ctrlr ;
1719
+ ctx [count ].subsystem = subsystem ;
1720
+ ctx [count ].thread = spdk_get_thread ();
1721
+ count ++ ;
1695
1722
// nvmf_ctrlr_ns_changed(ctrlr, nsid);
1723
+ }
1724
+ }
1725
+
1726
+ for (int i = 0 ; i < count ; i ++ ) {
1727
+ if ( i == count - 1 ) {
1728
+ ctx [i ].last_one = true;
1696
1729
}
1730
+ spdk_thread_send_msg (ctx [i ].ctrlr -> thread , nvmf_subsystem_ns_changed_v2 , & ctx [i ]);
1697
1731
}
1698
1732
}
1699
1733
@@ -1843,13 +1877,9 @@ static void
1843
1877
_nvmf_ns_resize (struct spdk_nvmf_subsystem * subsystem , void * cb_arg , int status )
1844
1878
{
1845
1879
struct subsystem_ns_change_ctx * ctx = cb_arg ;
1846
- SPDK_NOTICELOG ("starting to change the ns list.\n" );
1880
+ SPDK_NOTICELOG ("starting to change the ns list namespace: %d .\n" , ctx -> nsid );
1847
1881
nvmf_subsystem_ns_changed (subsystem , ctx -> nsid );
1848
1882
SPDK_NOTICELOG ("ns list changed and resume the subsystem.\n" );
1849
- if (spdk_nvmf_subsystem_resume (subsystem , NULL , NULL ) != 0 ) {
1850
- SPDK_ERRLOG ("Failed to resume NVME-oF subsystem with id: %u\n" , subsystem -> id );
1851
- }
1852
-
1853
1883
free (ctx );
1854
1884
}
1855
1885
0 commit comments