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

scsi: Expand all create*_workqueue() invocations

The workqueue maintainer wants to remove the create*_workqueue() macros
because these macros always set the WQ_MEM_RECLAIM flag and because these
only support literal workqueue names. Hence this patch that replaces the
create*_workqueue() invocations with the definition of this macro. The
WQ_MEM_RECLAIM flag has been retained because I think that flag is necessary
for workqueues created by storage drivers. This patch has been generated by
running spatch and git clang-format. spatch has been invoked as follows:

spatch --in-place --sp-file expand-create-workqueue.spatch $(git grep -lEw 'create_(freezable_|singlethread_|)workqueue' */scsi */ufs)

The contents of the expand-create-workqueue.spatch file is as follows:

@@
expression name;
@@
-create_workqueue(name)
+alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, name)
@@
expression name;
@@
-create_freezable_workqueue(name)
+alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, 1, name)
@@
expression name;
@@
-create_singlethread_workqueue(name)
+alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)

Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240822195944.654691-2-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
b97c0741 8400291e

+64 -43
+2 -1
drivers/scsi/bfa/bfad_im.c
··· 768 768 bfa_trc(bfad, 0); 769 769 snprintf(im->drv_workq_name, KOBJ_NAME_LEN, "bfad_wq_%d", 770 770 bfad->inst_no); 771 - im->drv_workq = create_singlethread_workqueue(im->drv_workq_name); 771 + im->drv_workq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, 772 + im->drv_workq_name); 772 773 if (!im->drv_workq) 773 774 return BFA_STATUS_FAILED; 774 775
+2 -2
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 2363 2363 interface->vlan_id = vlan_id; 2364 2364 interface->tm_timeout = BNX2FC_TM_TIMEOUT; 2365 2365 2366 - interface->timer_work_queue = 2367 - create_singlethread_workqueue("bnx2fc_timer_wq"); 2366 + interface->timer_work_queue = alloc_ordered_workqueue( 2367 + "%s", WQ_MEM_RECLAIM, "bnx2fc_timer_wq"); 2368 2368 if (!interface->timer_work_queue) { 2369 2369 printk(KERN_ERR PFX "ulp_init could not create timer_wq\n"); 2370 2370 rc = -EINVAL;
+2 -1
drivers/scsi/device_handler/scsi_dh_rdac.c
··· 822 822 /* 823 823 * Create workqueue to handle mode selects for rdac 824 824 */ 825 - kmpath_rdacd = create_singlethread_workqueue("kmpath_rdacd"); 825 + kmpath_rdacd = 826 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "kmpath_rdacd"); 826 827 if (!kmpath_rdacd) { 827 828 scsi_unregister_device_handler(&rdac_dh); 828 829 printk(KERN_ERR "kmpath_rdacd creation failed.\n");
+2 -1
drivers/scsi/elx/efct/efct_lio.c
··· 1114 1114 atomic_set(&efct->tgt_efct.watermark_hit, 0); 1115 1115 atomic_set(&efct->tgt_efct.initiator_count, 0); 1116 1116 1117 - lio_wq = create_singlethread_workqueue("efct_lio_worker"); 1117 + lio_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, 1118 + "efct_lio_worker"); 1118 1119 if (!lio_wq) { 1119 1120 efc_log_err(efct, "workqueue create failed\n"); 1120 1121 return -EIO;
+2 -1
drivers/scsi/esas2r/esas2r_init.c
··· 313 313 esas2r_fw_event_off(a); 314 314 snprintf(a->fw_event_q_name, ESAS2R_KOBJ_NAME_LEN, "esas2r/%d", 315 315 a->index); 316 - a->fw_event_q = create_singlethread_workqueue(a->fw_event_q_name); 316 + a->fw_event_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, 317 + a->fw_event_q_name); 317 318 318 319 init_waitqueue_head(&a->buffered_ioctl_waiter); 319 320 init_waitqueue_head(&a->nvram_waiter);
+4 -4
drivers/scsi/fcoe/fcoe_sysfs.c
··· 799 799 800 800 snprintf(ctlr->work_q_name, sizeof(ctlr->work_q_name), 801 801 "ctlr_wq_%d", ctlr->id); 802 - ctlr->work_q = create_singlethread_workqueue( 803 - ctlr->work_q_name); 802 + ctlr->work_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, 803 + ctlr->work_q_name); 804 804 if (!ctlr->work_q) 805 805 goto out_del; 806 806 807 807 snprintf(ctlr->devloss_work_q_name, 808 808 sizeof(ctlr->devloss_work_q_name), 809 809 "ctlr_dl_wq_%d", ctlr->id); 810 - ctlr->devloss_work_q = create_singlethread_workqueue( 811 - ctlr->devloss_work_q_name); 810 + ctlr->devloss_work_q = alloc_ordered_workqueue( 811 + "%s", WQ_MEM_RECLAIM, ctlr->devloss_work_q_name); 812 812 if (!ctlr->devloss_work_q) 813 813 goto out_del_q; 814 814
+4 -2
drivers/scsi/fnic/fnic_main.c
··· 1161 1161 goto err_create_fnic_ioreq_slab; 1162 1162 } 1163 1163 1164 - fnic_event_queue = create_singlethread_workqueue("fnic_event_wq"); 1164 + fnic_event_queue = 1165 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fnic_event_wq"); 1165 1166 if (!fnic_event_queue) { 1166 1167 printk(KERN_ERR PFX "fnic work queue create failed\n"); 1167 1168 err = -ENOMEM; 1168 1169 goto err_create_fnic_workq; 1169 1170 } 1170 1171 1171 - fnic_fip_queue = create_singlethread_workqueue("fnic_fip_q"); 1172 + fnic_fip_queue = 1173 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fnic_fip_q"); 1172 1174 if (!fnic_fip_queue) { 1173 1175 printk(KERN_ERR PFX "fnic FIP work queue create failed\n"); 1174 1176 err = -ENOMEM;
+2 -1
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 2302 2302 2303 2303 hisi_hba->last_slot_index = 0; 2304 2304 2305 - hisi_hba->wq = create_singlethread_workqueue(dev_name(dev)); 2305 + hisi_hba->wq = 2306 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, dev_name(dev)); 2306 2307 if (!hisi_hba->wq) { 2307 2308 dev_err(dev, "sas_alloc: failed to create workqueue\n"); 2308 2309 goto err_out;
+1 -1
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
··· 3537 3537 init_completion(&vscsi->unconfig); 3538 3538 3539 3539 snprintf(wq_name, 24, "ibmvscsis%s", dev_name(&vdev->dev)); 3540 - vscsi->work_q = create_workqueue(wq_name); 3540 + vscsi->work_q = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name); 3541 3541 if (!vscsi->work_q) { 3542 3542 rc = -ENOMEM; 3543 3543 dev_err(&vscsi->dev, "create_workqueue failed\n");
+2 -1
drivers/scsi/libfc/fc_exch.c
··· 2693 2693 fc_cpu_order = ilog2(roundup_pow_of_two(nr_cpu_ids)); 2694 2694 fc_cpu_mask = (1 << fc_cpu_order) - 1; 2695 2695 2696 - fc_exch_workqueue = create_singlethread_workqueue("fc_exch_workqueue"); 2696 + fc_exch_workqueue = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, 2697 + "fc_exch_workqueue"); 2697 2698 if (!fc_exch_workqueue) 2698 2699 goto err; 2699 2700 return 0;
+2 -1
drivers/scsi/libfc/fc_rport.c
··· 2263 2263 */ 2264 2264 int fc_setup_rport(void) 2265 2265 { 2266 - rport_event_queue = create_singlethread_workqueue("fc_rport_eq"); 2266 + rport_event_queue = 2267 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fc_rport_eq"); 2267 2268 if (!rport_event_queue) 2268 2269 return -ENOMEM; 2269 2270 return 0;
+2 -2
drivers/scsi/libsas/sas_init.c
··· 122 122 123 123 error = -ENOMEM; 124 124 snprintf(name, sizeof(name), "%s_event_q", dev_name(sas_ha->dev)); 125 - sas_ha->event_q = create_singlethread_workqueue(name); 125 + sas_ha->event_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name); 126 126 if (!sas_ha->event_q) 127 127 goto Undo_ports; 128 128 129 129 snprintf(name, sizeof(name), "%s_disco_q", dev_name(sas_ha->dev)); 130 - sas_ha->disco_q = create_singlethread_workqueue(name); 130 + sas_ha->disco_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name); 131 131 if (!sas_ha->disco_q) 132 132 goto Undo_event_q; 133 133
+2 -2
drivers/scsi/megaraid/megaraid_sas_fusion.c
··· 1988 1988 sizeof(instance->fault_handler_work_q_name), 1989 1989 "poll_megasas%d_status", instance->host->host_no); 1990 1990 1991 - instance->fw_fault_work_q = 1992 - create_singlethread_workqueue(instance->fault_handler_work_q_name); 1991 + instance->fw_fault_work_q = alloc_ordered_workqueue( 1992 + "%s", WQ_MEM_RECLAIM, instance->fault_handler_work_q_name); 1993 1993 if (!instance->fw_fault_work_q) { 1994 1994 dev_err(&instance->pdev->dev, "Failed from %s %d\n", 1995 1995 __func__, __LINE__);
+2 -2
drivers/scsi/mpi3mr/mpi3mr_fw.c
··· 2742 2742 snprintf(mrioc->watchdog_work_q_name, 2743 2743 sizeof(mrioc->watchdog_work_q_name), "watchdog_%s%d", mrioc->name, 2744 2744 mrioc->id); 2745 - mrioc->watchdog_work_q = 2746 - create_singlethread_workqueue(mrioc->watchdog_work_q_name); 2745 + mrioc->watchdog_work_q = alloc_ordered_workqueue( 2746 + "%s", WQ_MEM_RECLAIM, mrioc->watchdog_work_q_name); 2747 2747 if (!mrioc->watchdog_work_q) { 2748 2748 ioc_err(mrioc, "%s: failed (line=%d)\n", __func__, __LINE__); 2749 2749 return;
+2 -2
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 846 846 snprintf(ioc->fault_reset_work_q_name, 847 847 sizeof(ioc->fault_reset_work_q_name), "poll_%s%d_status", 848 848 ioc->driver_name, ioc->id); 849 - ioc->fault_reset_work_q = 850 - create_singlethread_workqueue(ioc->fault_reset_work_q_name); 849 + ioc->fault_reset_work_q = alloc_ordered_workqueue( 850 + "%s", WQ_MEM_RECLAIM, ioc->fault_reset_work_q_name); 851 851 if (!ioc->fault_reset_work_q) { 852 852 ioc_err(ioc, "%s: failed (line=%d)\n", __func__, __LINE__); 853 853 return;
+2 -1
drivers/scsi/myrb.c
··· 114 114 115 115 snprintf(cb->work_q_name, sizeof(cb->work_q_name), 116 116 "myrb_wq_%d", cb->host->host_no); 117 - cb->work_q = create_singlethread_workqueue(cb->work_q_name); 117 + cb->work_q = 118 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, cb->work_q_name); 118 119 if (!cb->work_q) { 119 120 dma_pool_destroy(cb->dcdb_pool); 120 121 cb->dcdb_pool = NULL;
+2 -1
drivers/scsi/myrs.c
··· 2208 2208 2209 2209 snprintf(cs->work_q_name, sizeof(cs->work_q_name), 2210 2210 "myrs_wq_%d", shost->host_no); 2211 - cs->work_q = create_singlethread_workqueue(cs->work_q_name); 2211 + cs->work_q = 2212 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, cs->work_q_name); 2212 2213 if (!cs->work_q) { 2213 2214 dma_pool_destroy(cs->dcdb_pool); 2214 2215 cs->dcdb_pool = NULL;
+7 -6
drivers/scsi/qedf/qedf_main.c
··· 3374 3374 3375 3375 sprintf(host_buf, "qedf_%u_link", 3376 3376 qedf->lport->host->host_no); 3377 - qedf->link_update_wq = create_workqueue(host_buf); 3377 + qedf->link_update_wq = 3378 + alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf); 3378 3379 INIT_DELAYED_WORK(&qedf->link_update, qedf_handle_link_update); 3379 3380 INIT_DELAYED_WORK(&qedf->link_recovery, qedf_link_recovery); 3380 3381 INIT_DELAYED_WORK(&qedf->grcdump_work, qedf_wq_grcdump); ··· 3586 3585 3587 3586 /* Start LL2 processing thread */ 3588 3587 snprintf(host_buf, 20, "qedf_%d_ll2", host->host_no); 3589 - qedf->ll2_recv_wq = 3590 - create_workqueue(host_buf); 3588 + qedf->ll2_recv_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf); 3591 3589 if (!qedf->ll2_recv_wq) { 3592 3590 QEDF_ERR(&(qedf->dbg_ctx), "Failed to LL2 workqueue.\n"); 3593 3591 rc = -ENOMEM; ··· 3629 3629 3630 3630 sprintf(host_buf, "qedf_%u_timer", qedf->lport->host->host_no); 3631 3631 qedf->timer_work_queue = 3632 - create_workqueue(host_buf); 3632 + alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf); 3633 3633 if (!qedf->timer_work_queue) { 3634 3634 QEDF_ERR(&(qedf->dbg_ctx), "Failed to start timer " 3635 3635 "workqueue.\n"); ··· 3641 3641 if (mode != QEDF_MODE_RECOVERY) { 3642 3642 sprintf(host_buf, "qedf_%u_dpc", 3643 3643 qedf->lport->host->host_no); 3644 - qedf->dpc_wq = create_workqueue(host_buf); 3644 + qedf->dpc_wq = 3645 + alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf); 3645 3646 } 3646 3647 INIT_DELAYED_WORK(&qedf->recovery_work, qedf_recovery_handler); 3647 3648 ··· 4183 4182 goto err3; 4184 4183 } 4185 4184 4186 - qedf_io_wq = create_workqueue("qedf_io_wq"); 4185 + qedf_io_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, "qedf_io_wq"); 4187 4186 if (!qedf_io_wq) { 4188 4187 QEDF_ERR(NULL, "Could not create qedf_io_wq.\n"); 4189 4188 goto err4;
+4 -2
drivers/scsi/qedi/qedi_main.c
··· 2767 2767 } 2768 2768 2769 2769 sprintf(host_buf, "host_%d", qedi->shost->host_no); 2770 - qedi->tmf_thread = create_singlethread_workqueue(host_buf); 2770 + qedi->tmf_thread = 2771 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, host_buf); 2771 2772 if (!qedi->tmf_thread) { 2772 2773 QEDI_ERR(&qedi->dbg_ctx, 2773 2774 "Unable to start tmf thread!\n"); ··· 2777 2776 } 2778 2777 2779 2778 sprintf(host_buf, "qedi_ofld%d", qedi->shost->host_no); 2780 - qedi->offload_thread = create_workqueue(host_buf); 2779 + qedi->offload_thread = 2780 + alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, host_buf); 2781 2781 if (!qedi->offload_thread) { 2782 2782 QEDI_ERR(&qedi->dbg_ctx, 2783 2783 "Unable to start offload thread!\n");
+4 -2
drivers/scsi/qla2xxx/qla_os.c
··· 3501 3501 3502 3502 if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { 3503 3503 sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); 3504 - ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); 3504 + ha->dpc_lp_wq = 3505 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name); 3505 3506 INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); 3506 3507 3507 3508 sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); 3508 - ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); 3509 + ha->dpc_hp_wq = 3510 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name); 3509 3511 INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); 3510 3512 INIT_WORK(&ha->idc_state_handler, 3511 3513 qla83xx_idc_state_handler_work);
+1 -1
drivers/scsi/qla4xxx/ql4_os.c
··· 8806 8806 DEBUG2(printk("scsi: %s: Starting kernel thread for " 8807 8807 "qla4xxx_dpc\n", __func__)); 8808 8808 sprintf(buf, "qla4xxx_%lu_dpc", ha->host_no); 8809 - ha->dpc_thread = create_singlethread_workqueue(buf); 8809 + ha->dpc_thread = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, buf); 8810 8810 if (!ha->dpc_thread) { 8811 8811 ql4_printk(KERN_WARNING, ha, "Unable to start DPC thread!\n"); 8812 8812 ret = -ENODEV;
+4 -2
drivers/scsi/snic/snic_main.c
··· 302 302 SNIC_BUG_ON(shost->work_q != NULL); 303 303 snprintf(shost->work_q_name, sizeof(shost->work_q_name), "scsi_wq_%d", 304 304 shost->host_no); 305 - shost->work_q = create_singlethread_workqueue(shost->work_q_name); 305 + shost->work_q = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, 306 + shost->work_q_name); 306 307 if (!shost->work_q) { 307 308 SNIC_HOST_ERR(shost, "Failed to Create ScsiHost wq.\n"); 308 309 ··· 885 884 snic_glob->req_cache[SNIC_REQ_TM_CACHE] = cachep; 886 885 887 886 /* snic_event queue */ 888 - snic_glob->event_q = create_singlethread_workqueue("snic_event_wq"); 887 + snic_glob->event_q = 888 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "snic_event_wq"); 889 889 if (!snic_glob->event_q) { 890 890 SNIC_ERR("snic event queue create failed\n"); 891 891 ret = -ENOMEM;
+2 -1
drivers/scsi/stex.c
··· 1797 1797 1798 1798 snprintf(hba->work_q_name, sizeof(hba->work_q_name), 1799 1799 "stex_wq_%d", host->host_no); 1800 - hba->work_q = create_singlethread_workqueue(hba->work_q_name); 1800 + hba->work_q = 1801 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, hba->work_q_name); 1801 1802 if (!hba->work_q) { 1802 1803 printk(KERN_ERR DRV_NAME "(%s): create workqueue failed\n", 1803 1804 pci_name(pdev));
+2 -1
drivers/scsi/vmw_pvscsi.c
··· 1137 1137 snprintf(name, sizeof(name), 1138 1138 "vmw_pvscsi_wq_%u", adapter->host->host_no); 1139 1139 1140 - adapter->workqueue = create_singlethread_workqueue(name); 1140 + adapter->workqueue = 1141 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name); 1141 1142 if (!adapter->workqueue) { 1142 1143 printk(KERN_ERR "vmw_pvscsi: failed to create work queue\n"); 1143 1144 return 0;
+3 -2
drivers/ufs/core/ufshcd.c
··· 1800 1800 1801 1801 snprintf(wq_name, sizeof(wq_name), "ufs_clkscaling_%d", 1802 1802 hba->host->host_no); 1803 - hba->clk_scaling.workq = create_singlethread_workqueue(wq_name); 1803 + hba->clk_scaling.workq = 1804 + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, wq_name); 1804 1805 1805 1806 hba->clk_scaling.is_initialized = true; 1806 1807 } ··· 10445 10444 /* Initialize work queues */ 10446 10445 snprintf(eh_wq_name, sizeof(eh_wq_name), "ufs_eh_wq_%d", 10447 10446 hba->host->host_no); 10448 - hba->eh_wq = create_singlethread_workqueue(eh_wq_name); 10447 + hba->eh_wq = alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, eh_wq_name); 10449 10448 if (!hba->eh_wq) { 10450 10449 dev_err(hba->dev, "%s: failed to create eh workqueue\n", 10451 10450 __func__);