Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/isert: Avoid flush_scheduled_work() usage

Flushing system-wide workqueues is dangerous and will be forbidden.
Replace system_wq with local isert_login_wq.

Link: https://lore.kernel.org/r/fbe5e9a8-0110-0c22-b7d6-74d53948d042@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Tetsuo Handa and committed by
Jason Gunthorpe
549f39a5 988d74de

+16 -9
+16 -9
drivers/infiniband/ulp/isert/ib_isert.c
··· 42 42 43 43 static DEFINE_MUTEX(device_list_mutex); 44 44 static LIST_HEAD(device_list); 45 + static struct workqueue_struct *isert_login_wq; 45 46 static struct workqueue_struct *isert_comp_wq; 46 47 static struct workqueue_struct *isert_release_wq; 47 48 ··· 1018 1017 complete(&isert_conn->login_comp); 1019 1018 return; 1020 1019 } 1021 - schedule_delayed_work(&conn->login_work, 0); 1020 + queue_delayed_work(isert_login_wq, &conn->login_work, 0); 1022 1021 } 1023 1022 1024 1023 static struct iscsi_cmd ··· 2349 2348 2350 2349 /* 2351 2350 * For login requests after the first PDU, isert_rx_login_req() will 2352 - * kick schedule_delayed_work(&conn->login_work) as the packet is 2353 - * received, which turns this callback from iscsi_target_do_login_rx() 2354 - * into a NOP. 2351 + * kick queue_delayed_work(isert_login_wq, &conn->login_work) as 2352 + * the packet is received, which turns this callback from 2353 + * iscsi_target_do_login_rx() into a NOP. 2355 2354 */ 2356 2355 if (!login->first_request) 2357 2356 return 0; ··· 2607 2606 2608 2607 static int __init isert_init(void) 2609 2608 { 2610 - int ret; 2609 + isert_login_wq = alloc_workqueue("isert_login_wq", 0, 0); 2610 + if (!isert_login_wq) { 2611 + isert_err("Unable to allocate isert_login_wq\n"); 2612 + return -ENOMEM; 2613 + } 2611 2614 2612 2615 isert_comp_wq = alloc_workqueue("isert_comp_wq", 2613 2616 WQ_UNBOUND | WQ_HIGHPRI, 0); 2614 2617 if (!isert_comp_wq) { 2615 2618 isert_err("Unable to allocate isert_comp_wq\n"); 2616 - return -ENOMEM; 2619 + goto destroy_login_wq; 2617 2620 } 2618 2621 2619 2622 isert_release_wq = alloc_workqueue("isert_release_wq", WQ_UNBOUND, 2620 2623 WQ_UNBOUND_MAX_ACTIVE); 2621 2624 if (!isert_release_wq) { 2622 2625 isert_err("Unable to allocate isert_release_wq\n"); 2623 - ret = -ENOMEM; 2624 2626 goto destroy_comp_wq; 2625 2627 } 2626 2628 ··· 2634 2630 2635 2631 destroy_comp_wq: 2636 2632 destroy_workqueue(isert_comp_wq); 2633 + destroy_login_wq: 2634 + destroy_workqueue(isert_login_wq); 2637 2635 2638 - return ret; 2636 + return -ENOMEM; 2639 2637 } 2640 2638 2641 2639 static void __exit isert_exit(void) 2642 2640 { 2643 - flush_scheduled_work(); 2641 + flush_workqueue(isert_login_wq); 2644 2642 destroy_workqueue(isert_release_wq); 2645 2643 destroy_workqueue(isert_comp_wq); 2646 2644 iscsit_unregister_transport(&iser_target_transport); 2647 2645 isert_info("iSER_TARGET[0] - Released iser_target_transport\n"); 2646 + destroy_workqueue(isert_login_wq); 2648 2647 } 2649 2648 2650 2649 MODULE_DESCRIPTION("iSER-Target for mainline target infrastructure");