You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(19) |
Nov
(18) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(14) |
Feb
(14) |
Mar
(3) |
Apr
(10) |
May
(10) |
Jun
(17) |
Jul
(15) |
Aug
(24) |
Sep
(24) |
Oct
(11) |
Nov
(13) |
Dec
(15) |
2008 |
Jan
(10) |
Feb
(46) |
Mar
(20) |
Apr
(42) |
May
(44) |
Jun
(22) |
Jul
(59) |
Aug
(8) |
Sep
(15) |
Oct
(52) |
Nov
(30) |
Dec
(38) |
2009 |
Jan
(27) |
Feb
(27) |
Mar
(47) |
Apr
(85) |
May
(74) |
Jun
(41) |
Jul
(70) |
Aug
(64) |
Sep
(97) |
Oct
(147) |
Nov
(67) |
Dec
(48) |
2010 |
Jan
(68) |
Feb
(33) |
Mar
(53) |
Apr
(98) |
May
(55) |
Jun
(71) |
Jul
(99) |
Aug
(132) |
Sep
(291) |
Oct
(220) |
Nov
(344) |
Dec
(300) |
2011 |
Jan
(57) |
Feb
(25) |
Mar
(59) |
Apr
(104) |
May
(60) |
Jun
(155) |
Jul
(143) |
Aug
(43) |
Sep
(53) |
Oct
(20) |
Nov
(35) |
Dec
(103) |
2012 |
Jan
(62) |
Feb
(43) |
Mar
(29) |
Apr
(80) |
May
(75) |
Jun
(61) |
Jul
(52) |
Aug
(58) |
Sep
(33) |
Oct
(32) |
Nov
(69) |
Dec
(37) |
2013 |
Jan
(77) |
Feb
(28) |
Mar
(52) |
Apr
(18) |
May
(37) |
Jun
(21) |
Jul
(22) |
Aug
(55) |
Sep
(29) |
Oct
(74) |
Nov
(50) |
Dec
(44) |
2014 |
Jan
(77) |
Feb
(62) |
Mar
(81) |
Apr
(99) |
May
(59) |
Jun
(95) |
Jul
(55) |
Aug
(34) |
Sep
(78) |
Oct
(33) |
Nov
(48) |
Dec
(51) |
2015 |
Jan
(56) |
Feb
(120) |
Mar
(37) |
Apr
(15) |
May
(22) |
Jun
(196) |
Jul
(54) |
Aug
(33) |
Sep
(32) |
Oct
(42) |
Nov
(149) |
Dec
(61) |
2016 |
Jan
(15) |
Feb
(26) |
Mar
(37) |
Apr
(27) |
May
(14) |
Jun
(11) |
Jul
(13) |
Aug
(64) |
Sep
(2) |
Oct
(36) |
Nov
(18) |
Dec
(46) |
2017 |
Jan
(6) |
Feb
(1) |
Mar
(2) |
Apr
(50) |
May
(42) |
Jun
(11) |
Jul
(4) |
Aug
(12) |
Sep
(11) |
Oct
(21) |
Nov
(15) |
Dec
(42) |
2018 |
Jan
(33) |
Feb
(27) |
Mar
(20) |
Apr
(5) |
May
(4) |
Jun
(1) |
Jul
(42) |
Aug
(29) |
Sep
(11) |
Oct
(40) |
Nov
(312) |
Dec
(18) |
2019 |
Jan
(44) |
Feb
(98) |
Mar
(125) |
Apr
(160) |
May
(123) |
Jun
(33) |
Jul
(56) |
Aug
(81) |
Sep
(24) |
Oct
(23) |
Nov
(52) |
Dec
(86) |
2020 |
Jan
(6) |
Feb
(17) |
Mar
(62) |
Apr
(21) |
May
(118) |
Jun
(42) |
Jul
(52) |
Aug
(62) |
Sep
(20) |
Oct
(5) |
Nov
(23) |
Dec
(111) |
2021 |
Jan
(31) |
Feb
(8) |
Mar
(26) |
Apr
(13) |
May
(54) |
Jun
(31) |
Jul
(17) |
Aug
(10) |
Sep
(83) |
Oct
(8) |
Nov
(21) |
Dec
(33) |
2022 |
Jan
(67) |
Feb
(11) |
Mar
(4) |
Apr
(46) |
May
(12) |
Jun
(17) |
Jul
(19) |
Aug
(7) |
Sep
(53) |
Oct
(14) |
Nov
(29) |
Dec
(22) |
2023 |
Jan
(20) |
Feb
(4) |
Mar
(37) |
Apr
(25) |
May
(15) |
Jun
(20) |
Jul
(38) |
Aug
(1) |
Sep
(1) |
Oct
(34) |
Nov
|
Dec
(8) |
2024 |
Jan
(15) |
Feb
(10) |
Mar
|
Apr
(4) |
May
(23) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Gleb C. <lna...@ya...> - 2023-07-19 08:38:27
|
Commit: d26ab07 GitHub URL: https://github.com/SCST-project/scst/commit/d26ab07ae97c9a877fefb3badb5a2dba03bb15cd Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Fix end of loop test This loop will exit successfully when "found" is false or in the failure case it times out with "wait_iter" set to -1. The test for timeouts is impossible as is. Fixes: b843adde8d49 ("scsi: qla2xxx: Fix mem access after free") Signed-off-by: Dan Carpenter <dan...@li...> Link: https://lore.kernel.org/r/cea...@ki...untain Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 339020091e24 upstrema ] Modified Paths: -------------- qla2x00t-32gbit/qla_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index e08ddac..7bd76e8 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -1450,7 +1450,7 @@ __qla2x00_eh_wait_for_pending_commands(struct qla_qpair *qpair, unsigned int t, break; } - if (!wait_iter && found) + if (wait_iter == -1) status = QLA_FUNCTION_FAILED; return status; |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:38:12
|
Commit: ffd578e GitHub URL: https://github.com/SCST-project/scst/commit/ffd578e720b725d6967d4087c4324a982b4fd7b3 Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Update version to 10.02.08.300-k Update version to 10.02.08.300-k. Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or...> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit eb91eb809c8d upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_version.h b/qla2x00t-32gbit/qla_version.h index 42d69d8..4d6f06f 100644 --- a/qla2x00t-32gbit/qla_version.h +++ b/qla2x00t-32gbit/qla_version.h @@ -6,9 +6,9 @@ /* * Driver version */ -#define QLA2XXX_VERSION "10.02.08.200-k" +#define QLA2XXX_VERSION "10.02.08.300-k" #define QLA_DRIVER_MAJOR_VER 10 #define QLA_DRIVER_MINOR_VER 2 #define QLA_DRIVER_PATCH_VER 8 -#define QLA_DRIVER_BETA_VER 200 +#define QLA_DRIVER_BETA_VER 300 |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:38:00
|
Commit: e8a1a2f GitHub URL: https://github.com/SCST-project/scst/commit/e8a1a2f15ab1f2dce00d35accb3d5cc0b44f8e48 Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Wait for io return on terminate rport System crash due to use after free. Current code allows terminate_rport_io to exit before making sure all IOs has returned. For FCP-2 device, IO's can hang on in HW because driver has not tear down the session in FW at first sign of cable pull. When dev_loss_tmo timer pops, terminate_rport_io is called and upper layer is about to free various resources. Terminate_rport_io trigger qla to do the final cleanup, but the cleanup might not be fast enough where it leave qla still holding on to the same resource. Wait for IO's to return to upper layer before resources are freed. Cc: st...@vg... Signed-off-by: Quinn Tran <qu...@ma...> Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or...> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit fc0cba0c7be8 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_attr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) =================================================================== diff --git a/qla2x00t-32gbit/qla_attr.c b/qla2x00t-32gbit/qla_attr.c index 16b6b5c..c9fc1d7 100644 --- a/qla2x00t-32gbit/qla_attr.c +++ b/qla2x00t-32gbit/qla_attr.c @@ -2821,6 +2821,7 @@ static void qla2x00_terminate_rport_io(struct fc_rport *rport) { fc_port_t *fcport = *(fc_port_t **)rport->dd_data; + scsi_qla_host_t *vha; if (!fcport) return; @@ -2830,9 +2831,12 @@ qla2x00_terminate_rport_io(struct fc_rport *rport) if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags)) return; + vha = fcport->vha; if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) { qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16); + qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, + 0, WAIT_TARGET); return; } /* @@ -2857,6 +2861,15 @@ qla2x00_terminate_rport_io(struct fc_rport *rport) qla2x00_port_logout(fcport->vha, fcport); } } + + /* check for any straggling io left behind */ + if (qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, 0, WAIT_TARGET)) { + ql_log(ql_log_warn, vha, 0x300b, + "IO not return. Resetting. \n"); + set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + qla2x00_wait_for_chip_reset(vha); + } } static int |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:37:49
|
Commit: 284f444 GitHub URL: https://github.com/SCST-project/scst/commit/284f4446e18600e59dc93aefbe948b74dd85eac4 Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Fix mem access after free System crash, where driver is accessing scsi layer's memory (scsi_cmnd->device->host) to search for a well known internal pointer (vha). The scsi_cmnd was released back to upper layer which could be freed, but the driver is still accessing it. 7 [ffffa8e8d2c3f8d0] page_fault at ffffffff86c010fe [exception RIP: __qla2x00_eh_wait_for_pending_commands+240] RIP: ffffffffc0642350 RSP: ffffa8e8d2c3f988 RFLAGS: 00010286 RAX: 0000000000000165 RBX: 0000000000000002 RCX: 00000000000036d8 RDX: 0000000000000000 RSI: ffff9c5c56535188 RDI: 0000000000000286 RBP: ffff9c5bf7aa4a58 R8: ffff9c589aecdb70 R9: 00000000000003d1 R10: 0000000000000001 R11: 0000000000380000 R12: ffff9c5c5392bc78 R13: ffff9c57044ff5c0 R14: ffff9c56b5a3aa00 R15: 00000000000006db ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 8 [ffffa8e8d2c3f9c8] qla2x00_eh_wait_for_pending_commands at ffffffffc0646dd5 [qla2xxx] 9 [ffffa8e8d2c3fa00] __qla2x00_async_tm_cmd at ffffffffc0658094 [qla2xxx] Remove access of freed memory. Currently the driver was checking to see if scsi_done was called by seeing if the sp->type has changed. Instead, check to see if the command has left the oustanding_cmds[] array as sign of scsi_done was called. Cc: st...@vg... Signed-off-by: Quinn Tran <qu...@ma...> Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or...> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit b843adde8d49 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_isr.c | 38 ++++- qla2x00t-32gbit/qla_os.c | 130 +++++++-------- 2 files changed, 95 insertions(+), 73 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index 70a8edd..a238f3f 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -1874,9 +1874,9 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha, } } -srb_t * -qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, - struct req_que *req, void *iocb) +static srb_t * +qla_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, + struct req_que *req, void *iocb, u16 *ret_index) { struct qla_hw_data *ha = vha->hw; sts_entry_t *pkt = iocb; @@ -1911,12 +1911,25 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, return NULL; } - req->outstanding_cmds[index] = NULL; - + *ret_index = index; qla_put_fw_resources(sp->qpair, &sp->iores); return sp; } +srb_t * +qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, + struct req_que *req, void *iocb) +{ + uint16_t index; + srb_t *sp; + + sp = qla_get_sp_from_handle(vha, func, req, iocb, &index); + if (sp) + req->outstanding_cmds[index] = NULL; + + return sp; +} + static void qla2x00_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, struct mbx_entry *mbx) @@ -3260,13 +3273,13 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) return; } - req->outstanding_cmds[handle] = NULL; cp = GET_CMD_SP(sp); if (cp == NULL) { ql_dbg(ql_dbg_io, vha, 0x3018, "Command already returned (0x%x/%p).\n", sts->handle, sp); + req->outstanding_cmds[handle] = NULL; return; } @@ -3537,6 +3550,9 @@ out: if (rsp->status_srb == NULL) sp->done(sp, res); + + /* for io's, clearing of outstanding_cmds[handle] means scsi_done was called */ + req->outstanding_cmds[handle] = NULL; } /** @@ -3613,6 +3629,7 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt) uint16_t que = MSW(pkt->handle); struct req_que *req = NULL; int res = DID_ERROR << 16; + u16 index; ql_dbg(ql_dbg_async, vha, 0x502a, "iocb type %xh with error status %xh, handle %xh, rspq id %d\n", @@ -3631,7 +3648,6 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt) switch (pkt->entry_type) { case NOTIFY_ACK_TYPE: - case STATUS_TYPE: case STATUS_CONT_TYPE: case LOGINOUT_PORT_IOCB_TYPE: case CT_IOCB_TYPE: @@ -3651,6 +3667,14 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt) case CTIO_TYPE7: case CTIO_CRC2: return 1; + case STATUS_TYPE: + sp = qla_get_sp_from_handle(vha, func, req, pkt, &index); + if (sp) { + sp->done(sp, res); + req->outstanding_cmds[index] = NULL; + return 0; + } + break; } fatal: ql_log(ql_log_warn, vha, 0x5030, diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 490568e..e08ddac 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -1119,43 +1119,6 @@ qc24_fail_command: return 0; } -/* - * qla2x00_eh_wait_on_command - * Waits for the command to be returned by the Firmware for some - * max time. - * - * Input: - * cmd = Scsi Command to wait on. - * - * Return: - * Completed in time : QLA_SUCCESS - * Did not complete in time : QLA_FUNCTION_FAILED - */ -static int -qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) -{ -#define ABORT_POLLING_PERIOD 1000 -#define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) - unsigned long wait_iter = ABORT_WAIT_ITER; - scsi_qla_host_t *vha = shost_priv(cmd->device->host); - struct qla_hw_data *ha = vha->hw; - srb_t *sp = scsi_cmd_priv(cmd); - int ret = QLA_SUCCESS; - - if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { - ql_dbg(ql_dbg_taskm, vha, 0x8005, - "Return:eh_wait.\n"); - return ret; - } - - while (sp->type && wait_iter--) - msleep(ABORT_POLLING_PERIOD); - if (sp->type) - ret = QLA_FUNCTION_FAILED; - - return ret; -} - /* * qla2x00_wait_for_hba_online * Wait till the HBA is online after going through @@ -1406,6 +1369,9 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) return ret; } +#define ABORT_POLLING_PERIOD 1000 +#define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) + /* * Returns: QLA_SUCCESS or QLA_FUNCTION_FAILED. */ @@ -1419,41 +1385,73 @@ __qla2x00_eh_wait_for_pending_commands(struct qla_qpair *qpair, unsigned int t, struct req_que *req = qpair->req; srb_t *sp; struct scsi_cmnd *cmd; + unsigned long wait_iter = ABORT_WAIT_ITER; + bool found; + struct qla_hw_data *ha = vha->hw; status = QLA_SUCCESS; - spin_lock_irqsave(qpair->qp_lock_ptr, flags); - for (cnt = 1; status == QLA_SUCCESS && - cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; - if (!sp) - continue; - if (sp->type != SRB_SCSI_CMD) - continue; - if (vha->vp_idx != sp->vha->vp_idx) - continue; - match = 0; - cmd = GET_CMD_SP(sp); - switch (type) { - case WAIT_HOST: - match = 1; - break; - case WAIT_TARGET: - match = cmd->device->id == t; - break; - case WAIT_LUN: - match = (cmd->device->id == t && - cmd->device->lun == l); - break; - } - if (!match) - continue; + while (wait_iter--) { + found = false; - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - status = qla2x00_eh_wait_on_command(cmd); spin_lock_irqsave(qpair->qp_lock_ptr, flags); + for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { + sp = req->outstanding_cmds[cnt]; + if (!sp) + continue; + if (sp->type != SRB_SCSI_CMD) + continue; + if (vha->vp_idx != sp->vha->vp_idx) + continue; + match = 0; + cmd = GET_CMD_SP(sp); + switch (type) { + case WAIT_HOST: + match = 1; + break; + case WAIT_TARGET: + if (sp->fcport) + match = sp->fcport->d_id.b24 == t; + else + match = 0; + break; + case WAIT_LUN: + if (sp->fcport) + match = (sp->fcport->d_id.b24 == t && + cmd->device->lun == l); + else + match = 0; + break; + } + if (!match) + continue; + + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + + if (unlikely(pci_channel_offline(ha->pdev)) || + ha->flags.eeh_busy) { + ql_dbg(ql_dbg_taskm, vha, 0x8005, + "Return:eh_wait.\n"); + return status; + } + + /* + * SRB_SCSI_CMD is still in the outstanding_cmds array. + * it means scsi_done has not called. Wait for it to + * clear from outstanding_cmds. + */ + msleep(ABORT_POLLING_PERIOD); + spin_lock_irqsave(qpair->qp_lock_ptr, flags); + found = true; + } + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + + if (!found) + break; } - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + + if (!wait_iter && found) + status = QLA_FUNCTION_FAILED; return status; } |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:37:33
|
Commit: 7db9f41 GitHub URL: https://github.com/SCST-project/scst/commit/7db9f41baecd437c169cb0c81b299e1bc23146a7 Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Fix hang in task management Task management command hangs where a side band chip reset failed to nudge the TMF from it's current send path. Add additional error check to block TMF from entering during chip reset and along the TMF path to cause it to bail out, skip over abort of marker. Cc: st...@vg... Signed-off-by: Quinn Tran <qu...@ma...> Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or...> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 9ae615c5bfd3 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_def.h | 4 + qla2x00t-32gbit/qla_init.c | 60 ++++++++++++++- 2 files changed, 61 insertions(+), 3 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_def.h b/qla2x00t-32gbit/qla_def.h index 01c84e2..433d9a8 100644 --- a/qla2x00t-32gbit/qla_def.h +++ b/qla2x00t-32gbit/qla_def.h @@ -5568,4 +5568,8 @@ struct ql_vnd_tgt_stats_resp { _fp->disc_state, _fp->scan_state, _fp->loop_id, _fp->deleted, \ _fp->flags +#define TMF_NOT_READY(_fcport) \ + (!_fcport || IS_SESSION_DELETED(_fcport) || atomic_read(&_fcport->state) != FCS_ONLINE || \ + !_fcport->vha->hw->flags.fw_started) + #endif diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index dc17acd..69719b6 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -1996,6 +1996,11 @@ qla2x00_tmf_iocb_timeout(void *data) int rc, h; unsigned long flags; + if (sp->type == SRB_MARKER) { + complete(&tmf->u.tmf.comp); + return; + } + rc = qla24xx_async_abort_cmd(sp, false); if (rc) { spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); @@ -2023,6 +2028,7 @@ static void qla_marker_sp_done(srb_t *sp, int res) sp->handle, sp->fcport->d_id.b24, sp->u.iocb_cmd.u.tmf.flags, sp->u.iocb_cmd.u.tmf.lun, sp->qpair->id); + sp->u.iocb_cmd.u.tmf.data = res; complete(&tmf->u.tmf.comp); } @@ -2039,6 +2045,11 @@ static void qla_marker_sp_done(srb_t *sp, int res) } while (cnt); \ } +/** + * qla26xx_marker: send marker IOCB and wait for the completion of it. + * @arg: pointer to argument list. + * It is assume caller will provide an fcport pointer and modifier + */ static int qla26xx_marker(struct tmf_arg *arg) { @@ -2048,6 +2059,14 @@ qla26xx_marker(struct tmf_arg *arg) int rval = QLA_FUNCTION_FAILED; fc_port_t *fcport = arg->fcport; + if (TMF_NOT_READY(arg->fcport)) { + ql_dbg(ql_dbg_taskm, vha, 0x8039, + "FC port not ready for marker loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d.\n", + fcport->loop_id, fcport->d_id.b24, + arg->modifier, arg->lun, arg->qpair->id); + return QLA_SUSPENDED; + } + /* ref: INIT */ sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL); if (!sp) @@ -2074,11 +2093,19 @@ qla26xx_marker(struct tmf_arg *arg) if (rval != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x8031, - "Marker IOCB failed (%x).\n", rval); + "Marker IOCB send failure (%x).\n", rval); goto done_free_sp; } wait_for_completion(&tm_iocb->u.tmf.comp); + rval = tm_iocb->u.tmf.data; + + if (rval != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x8019, + "Marker failed hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n", + sp->handle, fcport->loop_id, fcport->d_id.b24, + arg->modifier, arg->lun, sp->qpair->id, rval); + } done_free_sp: /* ref: INIT */ @@ -2091,6 +2118,8 @@ static void qla2x00_tmf_sp_done(srb_t *sp, int res) { struct srb_iocb *tmf = &sp->u.iocb_cmd; + if (res) + tmf->u.tmf.data = res; complete(&tmf->u.tmf.comp); } @@ -2104,6 +2133,14 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg) fc_port_t *fcport = arg->fcport; + if (TMF_NOT_READY(arg->fcport)) { + ql_dbg(ql_dbg_taskm, vha, 0x8032, + "FC port not ready for TM command loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d.\n", + fcport->loop_id, fcport->d_id.b24, + arg->modifier, arg->lun, arg->qpair->id); + return QLA_SUSPENDED; + } + /* ref: INIT */ sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL); if (!sp) @@ -2178,7 +2215,9 @@ int qla_get_tmf(fc_port_t *fcport) msleep(1); spin_lock_irqsave(&ha->tgt.sess_lock, flags); - if (fcport->deleted) { + if (TMF_NOT_READY(fcport)) { + ql_log(ql_log_warn, vha, 0x802c, + "Unable to acquire TM resource due to disruption.\n"); rc = EIO; break; } @@ -2204,7 +2243,10 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, struct scsi_qla_host *vha = fcport->vha; struct qla_qpair *qpair; struct tmf_arg a; - int i, rval; + int i, rval = QLA_SUCCESS; + + if (TMF_NOT_READY(fcport)) + return QLA_SUSPENDED; a.vha = fcport->vha; a.fcport = fcport; @@ -2223,6 +2265,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, qpair = vha->hw->queue_pair_map[i]; if (!qpair) continue; + + if (TMF_NOT_READY(fcport)) { + ql_log(ql_log_warn, vha, 0x8026, + "Unable to send TM due to disruption.\n"); + rval = QLA_SUSPENDED; + break; + } + a.qpair = qpair; a.flags = flags|TCF_NOTMCMD_TO_TARGET; rval = __qla2x00_async_tm_cmd(&a); @@ -2231,10 +2281,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, } } + if (rval) + goto bailout; + a.qpair = vha->hw->base_qpair; a.flags = flags; rval = __qla2x00_async_tm_cmd(&a); +bailout: if (a.modifier == MK_SYNC_ID_LUN) qla_put_tmf(fcport); |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:37:19
|
Commit: 7a1d0dd GitHub URL: https://github.com/SCST-project/scst/commit/7a1d0ddaf53e3b7d709c17140302e1e139185f2c Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Backport to older kernel versions Unbreak the build for the previous commit against kernel versions before v5.1. Modified Paths: -------------- scst/include/backport.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) =================================================================== diff --git a/scst/include/backport.h b/scst/include/backport.h index 80683bc..4e693ae 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -687,6 +687,19 @@ static inline bool list_entry_in_list(const struct list_head *entry) return !list_empty(entry); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) && \ + (!defined(RHEL_RELEASE_CODE) || \ + RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(8, 1)) +/* + * See also commit 70b44595eafe ("mm, compaction: use free lists to quickly + * locate a migration source") # v5.1. + */ +static inline int list_is_first(const struct list_head *list, const struct list_head *head) +{ + return list->prev == head; +} +#endif + /* <linux/lockdep.h> */ /* |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:37:06
|
Commit: 4b813bf GitHub URL: https://github.com/SCST-project/scst/commit/4b813bf125242b6da4e67620fc871e3a449cd8b2 Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Fix task management cmd fail due to unavailable resource Task management command failed with status 2Ch which is a result of too many task management commands sent to the same target. Hence limit task management commands to 8 per target. Reported-by: kernel test robot <lk...@in...> Link: https://lore.kernel.org/oe-kbuild-all/202...@in.../ Cc: st...@vg... Signed-off-by: Quinn Tran <qu...@ma...> Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or...> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 6a87679626b5 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_def.h | 3 + qla2x00t-32gbit/qla_init.c | 63 +++++++++++++-- 2 files changed, 61 insertions(+), 5 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_def.h b/qla2x00t-32gbit/qla_def.h index 2717f6f..01c84e2 100644 --- a/qla2x00t-32gbit/qla_def.h +++ b/qla2x00t-32gbit/qla_def.h @@ -2593,6 +2593,7 @@ enum rscn_addr_format { typedef struct fc_port { struct list_head list; struct scsi_qla_host *vha; + struct list_head tmf_pending; unsigned int conf_compl_supported:1; unsigned int deleted:2; @@ -2613,6 +2614,8 @@ typedef struct fc_port { unsigned int do_prli_nvme:1; uint8_t nvme_flag; + uint8_t active_tmf; +#define MAX_ACTIVE_TMF 8 uint8_t node_name[WWN_SIZE]; uint8_t port_name[WWN_SIZE]; diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 1339077..dc17acd 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -2149,6 +2149,54 @@ done: return rval; } +static void qla_put_tmf(fc_port_t *fcport) +{ + struct scsi_qla_host *vha = fcport->vha; + struct qla_hw_data *ha = vha->hw; + unsigned long flags; + + spin_lock_irqsave(&ha->tgt.sess_lock, flags); + fcport->active_tmf--; + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); +} + +static +int qla_get_tmf(fc_port_t *fcport) +{ + struct scsi_qla_host *vha = fcport->vha; + struct qla_hw_data *ha = vha->hw; + unsigned long flags; + int rc = 0; + LIST_HEAD(tmf_elem); + + spin_lock_irqsave(&ha->tgt.sess_lock, flags); + list_add_tail(&tmf_elem, &fcport->tmf_pending); + + while (fcport->active_tmf >= MAX_ACTIVE_TMF) { + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); + + msleep(1); + + spin_lock_irqsave(&ha->tgt.sess_lock, flags); + if (fcport->deleted) { + rc = EIO; + break; + } + if (fcport->active_tmf < MAX_ACTIVE_TMF && + list_is_first(&tmf_elem, &fcport->tmf_pending)) + break; + } + + list_del(&tmf_elem); + + if (!rc) + fcport->active_tmf++; + + spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); + + return rc; +} + int qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, uint32_t tag) @@ -2156,18 +2204,19 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, struct scsi_qla_host *vha = fcport->vha; struct qla_qpair *qpair; struct tmf_arg a; - struct completion comp; int i, rval; - init_completion(&comp); a.vha = fcport->vha; a.fcport = fcport; a.lun = lun; - - if (flags & (TCF_LUN_RESET|TCF_ABORT_TASK_SET|TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) + if (flags & (TCF_LUN_RESET|TCF_ABORT_TASK_SET|TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) { a.modifier = MK_SYNC_ID_LUN; - else + + if (qla_get_tmf(fcport)) + return QLA_FUNCTION_FAILED; + } else { a.modifier = MK_SYNC_ID; + } if (vha->hw->mqenable) { for (i = 0; i < vha->hw->num_qpairs; i++) { @@ -2186,6 +2235,9 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, a.flags = flags; rval = __qla2x00_async_tm_cmd(&a); + if (a.modifier == MK_SYNC_ID_LUN) + qla_put_tmf(fcport); + return rval; } @@ -5403,6 +5455,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) INIT_WORK(&fcport->reg_work, qla_register_fcport_fn); INIT_LIST_HEAD(&fcport->gnl_entry); INIT_LIST_HEAD(&fcport->list); + INIT_LIST_HEAD(&fcport->tmf_pending); INIT_LIST_HEAD(&fcport->sess_cmd_list); spin_lock_init(&fcport->sess_cmd_lock); |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:36:46
|
Commit: 3f90ea1 GitHub URL: https://github.com/SCST-project/scst/commit/3f90ea13219c67a75bed48abafa22ddf9d51cf5b Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Fix task management cmd failure Task management cmd failed with status 30h which means FW is not able to finish processing one task management before another task management for the same lun. Hence add wait for completion of marker to space it out. Reported-by: kernel test robot <lk...@in...> Link: https://lore.kernel.org/oe-kbuild-all/202...@in.../ Cc: st...@vg... Signed-off-by: Quinn Tran <qu...@ma...> Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or... <mailto:him...@or...>> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit 9803fb5d2759 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_def.h | 6 + qla2x00t-32gbit/qla_init.c | 102 ++++++++++++--- qla2x00t-32gbit/qla_iocb.c | 28 +++- qla2x00t-32gbit/qla_isr.c | 26 +++- 4 files changed, 139 insertions(+), 23 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_def.h b/qla2x00t-32gbit/qla_def.h index 9e21fbe..2717f6f 100644 --- a/qla2x00t-32gbit/qla_def.h +++ b/qla2x00t-32gbit/qla_def.h @@ -514,6 +514,7 @@ struct tmf_arg { struct scsi_qla_host *vha; u64 lun; u32 flags; + uint8_t modifier; }; struct els_logo_payload { @@ -595,6 +596,10 @@ struct srb_iocb { uint32_t data; struct completion comp; __le16 comp_status; + + uint8_t modifier; + uint8_t vp_index; + uint16_t loop_id; } tmf; struct { #define SRB_FXDISC_REQ_DMA_VALID BIT_0 @@ -698,6 +703,7 @@ struct srb_iocb { #define SRB_SA_UPDATE 25 #define SRB_ELS_CMD_HST_NOLOGIN 26 #define SRB_SA_REPLACE 27 +#define SRB_MARKER 28 struct qla_els_pt_arg { u8 els_opcode; diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 7b9af55..1339077 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -2013,6 +2013,80 @@ qla2x00_tmf_iocb_timeout(void *data) } } +static void qla_marker_sp_done(srb_t *sp, int res) +{ + struct srb_iocb *tmf = &sp->u.iocb_cmd; + + if (res != QLA_SUCCESS) + ql_dbg(ql_dbg_taskm, sp->vha, 0x8004, + "Async-marker fail hdl=%x portid=%06x ctrl=%x lun=%lld qp=%d.\n", + sp->handle, sp->fcport->d_id.b24, sp->u.iocb_cmd.u.tmf.flags, + sp->u.iocb_cmd.u.tmf.lun, sp->qpair->id); + + complete(&tmf->u.tmf.comp); +} + +#define START_SP_W_RETRIES(_sp, _rval) \ +{\ + int cnt = 5; \ + do { \ + _rval = qla2x00_start_sp(_sp); \ + if (_rval == EAGAIN) \ + msleep(1); \ + else \ + break; \ + cnt--; \ + } while (cnt); \ +} + +static int +qla26xx_marker(struct tmf_arg *arg) +{ + struct scsi_qla_host *vha = arg->vha; + struct srb_iocb *tm_iocb; + srb_t *sp; + int rval = QLA_FUNCTION_FAILED; + fc_port_t *fcport = arg->fcport; + + /* ref: INIT */ + sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL); + if (!sp) + goto done; + + sp->type = SRB_MARKER; + sp->name = "marker"; + qla2x00_init_async_sp(sp, qla2x00_get_async_timeout(vha), qla_marker_sp_done); + sp->u.iocb_cmd.timeout = qla2x00_tmf_iocb_timeout; + + tm_iocb = &sp->u.iocb_cmd; + init_completion(&tm_iocb->u.tmf.comp); + tm_iocb->u.tmf.modifier = arg->modifier; + tm_iocb->u.tmf.lun = arg->lun; + tm_iocb->u.tmf.loop_id = fcport->loop_id; + tm_iocb->u.tmf.vp_index = vha->vp_idx; + + START_SP_W_RETRIES(sp, rval); + + ql_dbg(ql_dbg_taskm, vha, 0x8006, + "Async-marker hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n", + sp->handle, fcport->loop_id, fcport->d_id.b24, + arg->modifier, arg->lun, sp->qpair->id, rval); + + if (rval != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x8031, + "Marker IOCB failed (%x).\n", rval); + goto done_free_sp; + } + + wait_for_completion(&tm_iocb->u.tmf.comp); + +done_free_sp: + /* ref: INIT */ + kref_put(&sp->cmd_kref, qla2x00_sp_release); +done: + return rval; +} + static void qla2x00_tmf_sp_done(srb_t *sp, int res) { struct srb_iocb *tmf = &sp->u.iocb_cmd; @@ -2026,7 +2100,6 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg) struct scsi_qla_host *vha = arg->vha; struct srb_iocb *tm_iocb; srb_t *sp; - unsigned long flags; int rval = QLA_FUNCTION_FAILED; fc_port_t *fcport = arg->fcport; @@ -2048,11 +2121,12 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg) tm_iocb->u.tmf.flags = arg->flags; tm_iocb->u.tmf.lun = arg->lun; - rval = qla2x00_start_sp(sp); + START_SP_W_RETRIES(sp, rval); + ql_dbg(ql_dbg_taskm, vha, 0x802f, - "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x ctrl=%x.\n", - sp->handle, fcport->loop_id, fcport->d_id.b.domain, - fcport->d_id.b.area, fcport->d_id.b.al_pa, arg->flags); + "Async-tmf hdl=%x loop-id=%x portid=%06x ctrl=%x lun=%lld qp=%d rval=%x.\n", + sp->handle, fcport->loop_id, fcport->d_id.b24, + arg->flags, arg->lun, sp->qpair->id, rval); if (rval != QLA_SUCCESS) goto done_free_sp; @@ -2065,17 +2139,8 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg) "TM IOCB failed (%x).\n", rval); } - if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) { - flags = tm_iocb->u.tmf.flags; - if (flags & (TCF_LUN_RESET|TCF_ABORT_TASK_SET| - TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) - flags = MK_SYNC_ID_LUN; - else - flags = MK_SYNC_ID; - - qla2x00_marker(vha, sp->qpair, - sp->fcport->loop_id, arg->lun, flags); - } + if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) + rval = qla26xx_marker(arg); done_free_sp: /* ref: INIT */ @@ -2099,6 +2164,11 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, a.fcport = fcport; a.lun = lun; + if (flags & (TCF_LUN_RESET|TCF_ABORT_TASK_SET|TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) + a.modifier = MK_SYNC_ID_LUN; + else + a.modifier = MK_SYNC_ID; + if (vha->hw->mqenable) { for (i = 0; i < vha->hw->num_qpairs; i++) { qpair = vha->hw->queue_pair_map[i]; diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index 68b724d..2742d37 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -528,21 +528,25 @@ __qla2x00_marker(struct scsi_qla_host *vha, struct qla_qpair *qpair, return (QLA_FUNCTION_FAILED); } + mrk24 = (struct mrk_entry_24xx *)mrk; + mrk->entry_type = MARKER_TYPE; mrk->modifier = type; if (type != MK_SYNC_ALL) { if (IS_FWI2_CAPABLE(ha)) { - mrk24 = (struct mrk_entry_24xx *) mrk; mrk24->nport_handle = cpu_to_le16(loop_id); int_to_scsilun(lun, (struct scsi_lun *)&mrk24->lun); host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun)); mrk24->vp_index = vha->vp_idx; - mrk24->handle = make_handle(req->id, mrk24->handle); } else { SET_TARGET_ID(ha, mrk->target, loop_id); mrk->lun = cpu_to_le16((uint16_t)lun); } } + + if (IS_FWI2_CAPABLE(ha)) + mrk24->handle = QLA_SKIP_HANDLE; + wmb(); qla2x00_start_iocbs(vha, req); @@ -3869,9 +3873,9 @@ static int qla_get_iocbs_resource(struct srb *sp) case SRB_NACK_LOGO: case SRB_LOGOUT_CMD: case SRB_CTRL_VP: - push_it_through = true; - fallthrough; + case SRB_MARKER: default: + push_it_through = true; get_exch = false; } @@ -3887,6 +3891,19 @@ static int qla_get_iocbs_resource(struct srb *sp) return qla_get_fw_resources(sp->qpair, &sp->iores); } +static void +qla_marker_iocb(srb_t *sp, struct mrk_entry_24xx *mrk) +{ + mrk->entry_type = MARKER_TYPE; + mrk->modifier = sp->u.iocb_cmd.u.tmf.modifier; + if (sp->u.iocb_cmd.u.tmf.modifier != MK_SYNC_ALL) { + mrk->nport_handle = cpu_to_le16(sp->u.iocb_cmd.u.tmf.loop_id); + int_to_scsilun(sp->u.iocb_cmd.u.tmf.lun, (struct scsi_lun *)&mrk->lun); + host_to_fcp_swap(mrk->lun, sizeof(mrk->lun)); + mrk->vp_index = sp->u.iocb_cmd.u.tmf.vp_index; + } +} + int qla2x00_start_sp(srb_t *sp) { @@ -3990,6 +4007,9 @@ qla2x00_start_sp(srb_t *sp) case SRB_SA_REPLACE: qla24xx_sa_replace_iocb(sp, pkt); break; + case SRB_MARKER: + qla_marker_iocb(sp, pkt); + break; default: break; } diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index 646a4eb..70a8edd 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3773,6 +3773,28 @@ static int qla_chk_cont_iocb_avail(struct scsi_qla_host *vha, return rc; } +static void qla_marker_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, + struct mrk_entry_24xx *pkt) +{ + const char func[] = "MRK-IOCB"; + srb_t *sp; + int res = QLA_SUCCESS; + + if (!IS_FWI2_CAPABLE(vha->hw)) + return; + + sp = qla2x00_get_sp_from_handle(vha, func, req, pkt); + if (!sp) + return; + + if (pkt->entry_status) { + ql_dbg(ql_dbg_taskm, vha, 0x8025, "marker failure.\n"); + res = QLA_COMMAND_ERROR; + } + sp->u.iocb_cmd.u.tmf.data = res; + sp->done(sp, res); +} + /** * qla24xx_process_response_queue() - Process response queue entries. * @vha: SCSI driver HA context @@ -3889,9 +3911,7 @@ process_err: (struct nack_to_isp *)pkt); break; case MARKER_TYPE: - /* Do nothing in this case, this check is to prevent it - * from falling into default case - */ + qla_marker_iocb_entry(vha, rsp->req, (struct mrk_entry_24xx *)pkt); break; case ABORT_IOCB_TYPE: qla24xx_abort_iocb_entry(vha, rsp->req, |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:36:32
|
Commit: 9ff415d GitHub URL: https://github.com/SCST-project/scst/commit/9ff415d4077be8702367441cc634c8977610404b Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- qla2x00t-32gbit: Multi-que support for TMF Add queue flush for task management command, before placing it on the wire. Do IO flush for all Request Q's. Reported-by: kernel test robot <lk...@in...> Link: https://lore.kernel.org/oe-kbuild-all/202...@in.../ Cc: st...@vg... Signed-off-by: Quinn Tran <qu...@ma...> Signed-off-by: Nilesh Javali <nj...@ma...> Link: https://lore.kernel.org/r/202...@ma... Reviewed-by: Himanshu Madhani <him...@or... <mailto:him...@or...>> Signed-off-by: Martin K. Petersen <mar...@or...> [ commit d90171dd0da5 upstream ] Modified Paths: -------------- qla2x00t-32gbit/qla_def.h | 8 ++ qla2x00t-32gbit/qla_gbl.h | 2 +- qla2x00t-32gbit/qla_init.c | 69 +++++++++++---- qla2x00t-32gbit/qla_iocb.c | 5 +- 4 files changed, 66 insertions(+), 18 deletions(-) =================================================================== diff --git a/qla2x00t-32gbit/qla_def.h b/qla2x00t-32gbit/qla_def.h index d4f7c4d..9e21fbe 100644 --- a/qla2x00t-32gbit/qla_def.h +++ b/qla2x00t-32gbit/qla_def.h @@ -508,6 +508,14 @@ static inline be_id_t port_id_to_be_id(port_id_t port_id) return res; } +struct tmf_arg { + struct qla_qpair *qpair; + struct fc_port *fcport; + struct scsi_qla_host *vha; + u64 lun; + u32 flags; +}; + struct els_logo_payload { uint8_t opcode; uint8_t rsvd[3]; diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index 82701c4..d397c98 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -69,7 +69,7 @@ extern int qla2x00_async_logout(struct scsi_qla_host *, fc_port_t *); extern int qla2x00_async_prlo(struct scsi_qla_host *, fc_port_t *); extern int qla2x00_async_adisc(struct scsi_qla_host *, fc_port_t *, uint16_t *); -extern int qla2x00_async_tm_cmd(fc_port_t *, uint32_t, uint32_t, uint32_t); +extern int qla2x00_async_tm_cmd(fc_port_t *, uint32_t, uint64_t, uint32_t); struct qla_work_evt *qla2x00_alloc_work(struct scsi_qla_host *, enum qla_work_type); extern int qla24xx_async_gnl(struct scsi_qla_host *, fc_port_t *); diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index 6e1ea1f..7b9af55 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -2020,17 +2020,19 @@ static void qla2x00_tmf_sp_done(srb_t *sp, int res) complete(&tmf->u.tmf.comp); } -int -qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun, - uint32_t tag) +static int +__qla2x00_async_tm_cmd(struct tmf_arg *arg) { - struct scsi_qla_host *vha = fcport->vha; + struct scsi_qla_host *vha = arg->vha; struct srb_iocb *tm_iocb; srb_t *sp; + unsigned long flags; int rval = QLA_FUNCTION_FAILED; + fc_port_t *fcport = arg->fcport; + /* ref: INIT */ - sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); + sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL); if (!sp) goto done; @@ -2043,15 +2045,15 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun, tm_iocb = &sp->u.iocb_cmd; init_completion(&tm_iocb->u.tmf.comp); - tm_iocb->u.tmf.flags = flags; - tm_iocb->u.tmf.lun = lun; + tm_iocb->u.tmf.flags = arg->flags; + tm_iocb->u.tmf.lun = arg->lun; + rval = qla2x00_start_sp(sp); ql_dbg(ql_dbg_taskm, vha, 0x802f, - "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x.\n", + "Async-tmf hdl=%x loop-id=%x portid=%02x%02x%02x ctrl=%x.\n", sp->handle, fcport->loop_id, fcport->d_id.b.domain, - fcport->d_id.b.area, fcport->d_id.b.al_pa); + fcport->d_id.b.area, fcport->d_id.b.al_pa, arg->flags); - rval = qla2x00_start_sp(sp); if (rval != QLA_SUCCESS) goto done_free_sp; wait_for_completion(&tm_iocb->u.tmf.comp); @@ -2065,12 +2067,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun, if (!test_bit(UNLOADING, &vha->dpc_flags) && !IS_QLAFX00(vha->hw)) { flags = tm_iocb->u.tmf.flags; - lun = (uint16_t)tm_iocb->u.tmf.lun; + if (flags & (TCF_LUN_RESET|TCF_ABORT_TASK_SET| + TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) + flags = MK_SYNC_ID_LUN; + else + flags = MK_SYNC_ID; - /* Issue Marker IOCB */ - qla2x00_marker(vha, vha->hw->base_qpair, - fcport->loop_id, lun, - flags == TCF_LUN_RESET ? MK_SYNC_ID_LUN : MK_SYNC_ID); + qla2x00_marker(vha, sp->qpair, + sp->fcport->loop_id, arg->lun, flags); } done_free_sp: @@ -2080,6 +2084,41 @@ done: return rval; } +int +qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun, + uint32_t tag) +{ + struct scsi_qla_host *vha = fcport->vha; + struct qla_qpair *qpair; + struct tmf_arg a; + struct completion comp; + int i, rval; + + init_completion(&comp); + a.vha = fcport->vha; + a.fcport = fcport; + a.lun = lun; + + if (vha->hw->mqenable) { + for (i = 0; i < vha->hw->num_qpairs; i++) { + qpair = vha->hw->queue_pair_map[i]; + if (!qpair) + continue; + a.qpair = qpair; + a.flags = flags|TCF_NOTMCMD_TO_TARGET; + rval = __qla2x00_async_tm_cmd(&a); + if (rval) + break; + } + } + + a.qpair = vha->hw->base_qpair; + a.flags = flags; + rval = __qla2x00_async_tm_cmd(&a); + + return rval; +} + int qla24xx_async_abort_command(srb_t *sp) { diff --git a/qla2x00t-32gbit/qla_iocb.c b/qla2x00t-32gbit/qla_iocb.c index b007ba4..68b724d 100644 --- a/qla2x00t-32gbit/qla_iocb.c +++ b/qla2x00t-32gbit/qla_iocb.c @@ -2557,7 +2557,7 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk) scsi_qla_host_t *vha = fcport->vha; struct qla_hw_data *ha = vha->hw; struct srb_iocb *iocb = &sp->u.iocb_cmd; - struct req_que *req = vha->req; + struct req_que *req = sp->qpair->req; flags = iocb->u.tmf.flags; lun = iocb->u.tmf.lun; @@ -2573,7 +2573,8 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk) tsk->port_id[2] = fcport->d_id.b.domain; tsk->vp_index = fcport->vha->vp_idx; - if (flags == TCF_LUN_RESET) { + if (flags & (TCF_LUN_RESET | TCF_ABORT_TASK_SET| + TCF_CLEAR_TASK_SET|TCF_CLEAR_ACA)) { int_to_scsilun(lun, &tsk->lun); host_to_fcp_swap((uint8_t *)&tsk->lun, sizeof(tsk->lun)); |
From: Gleb C. <lna...@ya...> - 2023-07-19 08:36:23
|
Commit: 606430b GitHub URL: https://github.com/SCST-project/scst/commit/606430be2967e8b4024d0062a62ce76a898222c5 Author: Gleb Chesnokov Date: 2023-07-19T11:35:51+03:00 Log Message: ----------- scst/include/backport.h: Improve the RHEL 9.2 backport This was detected by smatch. Modified Paths: -------------- scst/include/backport.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) =================================================================== diff --git a/scst/include/backport.h b/scst/include/backport.h index 619ef70..80683bc 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -177,7 +177,9 @@ enum { }; #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0) && \ + (!defined(RHEL_RELEASE_CODE) || \ + RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(9, 2)) /* * See also commit 342a72a33407 ("block: Introduce the type blk_opf_t") # v6.0 */ |
From: Gleb C. <lna...@ya...> - 2023-07-19 07:55:06
|
Commit: bc9ec6f GitHub URL: https://github.com/SCST-project/scst/commit/bc9ec6f9e7bcb9697cc1ddc1b3cbd92c42d0d645 Author: Gleb Chesnokov Date: 2023-07-19T10:54:35+03:00 Log Message: ----------- scst: Replace all strlcpy() with strscpy() strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NULL-terminated [1]. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy Modified Paths: -------------- iscsi-scst/kernel/target.c | 2 +- qla2x00t-32gbit/qla_init.c | 8 ++--- qla2x00t-32gbit/qla_mr.c | 20 +++++------ qla2x00t/qla_gs.c | 8 ++--- qla2x00t/qla_init.c | 10 +++--- qla2x00t/qla_nx.c | 2 +- qla2x00t/qla_os.c | 2 +- scst/include/backport.h | 23 +++++++++++++ scst/src/dev_handlers/scst_user.c | 6 ++-- scst/src/dev_handlers/scst_vdisk.c | 2 +- scst/src/scst_debug.c | 2 +- scst/src/scst_event.c | 22 ++++++------ scst/src/scst_main.c | 6 ++-- scst/src/scst_mem.c | 2 +- scst/src/scst_tg.c | 26 +++++++-------- srpt/src/ib_srpt.c | 6 ++-- 16 files changed, 84 insertions(+), 63 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index 8840d34..a74ef48 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -89,7 +89,7 @@ static int iscsi_target_create(struct iscsi_kern_target_info *info, u32 tid, target->tid = info->tid = tid; - strlcpy(target->name, name, sizeof(target->name)); + strscpy(target->name, name, sizeof(target->name)); mutex_init(&target->target_mutex); INIT_LIST_HEAD(&target->session_list); diff --git a/qla2x00t-32gbit/qla_init.c b/qla2x00t-32gbit/qla_init.c index b86f9af..6e1ea1f 100644 --- a/qla2x00t-32gbit/qla_init.c +++ b/qla2x00t-32gbit/qla_init.c @@ -4864,7 +4864,7 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, if (use_tbl && ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && index < QLA_MODEL_NAMES) - strlcpy(ha->model_desc, + strscpy(ha->model_desc, qla2x00_model_name[index * 2 + 1], sizeof(ha->model_desc)); } else { @@ -4872,14 +4872,14 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, if (use_tbl && ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && index < QLA_MODEL_NAMES) { - strlcpy(ha->model_number, + strscpy(ha->model_number, qla2x00_model_name[index * 2], sizeof(ha->model_number)); - strlcpy(ha->model_desc, + strscpy(ha->model_desc, qla2x00_model_name[index * 2 + 1], sizeof(ha->model_desc)); } else { - strlcpy(ha->model_number, def, + strscpy(ha->model_number, def, sizeof(ha->model_number)); } } diff --git a/qla2x00t-32gbit/qla_mr.c b/qla2x00t-32gbit/qla_mr.c index 84c129f..ba12fdc 100644 --- a/qla2x00t-32gbit/qla_mr.c +++ b/qla2x00t-32gbit/qla_mr.c @@ -691,7 +691,7 @@ qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len) struct qla_hw_data *ha = vha->hw; if (pci_is_pcie(ha->pdev)) - strlcpy(str, "PCIe iSA", str_len); + strscpy(str, "PCIe iSA", str_len); return str; } @@ -1860,21 +1860,21 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) phost_info = &preg_hsi->hsi; memset(preg_hsi, 0, sizeof(struct register_host_info)); phost_info->os_type = OS_TYPE_LINUX; - strlcpy(phost_info->sysname, p_sysid->sysname, + strscpy(phost_info->sysname, p_sysid->sysname, sizeof(phost_info->sysname)); - strlcpy(phost_info->nodename, p_sysid->nodename, + strscpy(phost_info->nodename, p_sysid->nodename, sizeof(phost_info->nodename)); if (!strcmp(phost_info->nodename, "(none)")) ha->mr.host_info_resend = true; - strlcpy(phost_info->release, p_sysid->release, + strscpy(phost_info->release, p_sysid->release, sizeof(phost_info->release)); - strlcpy(phost_info->version, p_sysid->version, + strscpy(phost_info->version, p_sysid->version, sizeof(phost_info->version)); - strlcpy(phost_info->machine, p_sysid->machine, + strscpy(phost_info->machine, p_sysid->machine, sizeof(phost_info->machine)); - strlcpy(phost_info->domainname, p_sysid->domainname, + strscpy(phost_info->domainname, p_sysid->domainname, sizeof(phost_info->domainname)); - strlcpy(phost_info->hostdriver, QLA2XXX_VERSION, + strscpy(phost_info->hostdriver, QLA2XXX_VERSION, sizeof(phost_info->hostdriver)); preg_hsi->utc = (uint64_t)ktime_get_real_seconds(); ql_dbg(ql_dbg_init, vha, 0x0149, @@ -1919,9 +1919,9 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) if (fx_type == FXDISC_GET_CONFIG_INFO) { struct config_info_data *pinfo = (struct config_info_data *) fdisc->u.fxiocb.rsp_addr; - strlcpy(vha->hw->model_number, pinfo->model_num, + strscpy(vha->hw->model_number, pinfo->model_num, ARRAY_SIZE(vha->hw->model_number)); - strlcpy(vha->hw->model_desc, pinfo->model_description, + strscpy(vha->hw->model_desc, pinfo->model_description, ARRAY_SIZE(vha->hw->model_desc)); memcpy(&vha->hw->mr.symbolic_name, pinfo->symbolic_name, sizeof(vha->hw->mr.symbolic_name)); diff --git a/qla2x00t/qla_gs.c b/qla2x00t/qla_gs.c index ec76353..119949f 100644 --- a/qla2x00t/qla_gs.c +++ b/qla2x00t/qla_gs.c @@ -1353,7 +1353,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Model name. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_HBA_MODEL); - strlcpy(eiter->a.model, ha->model_number, sizeof(eiter->a.model)); + strscpy(eiter->a.model, ha->model_number, sizeof(eiter->a.model)); alen = strlen(eiter->a.model); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); @@ -1365,7 +1365,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); - strlcpy(eiter->a.model_desc, ha->model_desc, + strscpy(eiter->a.model_desc, ha->model_desc, sizeof(eiter->a.model_desc)); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; @@ -1378,7 +1378,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Hardware version. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_HBA_HARDWARE_VERSION); - strlcpy(eiter->a.hw_version, ha->adapter_id, + strscpy(eiter->a.hw_version, ha->adapter_id, sizeof(eiter->a.hw_version)); alen = strlen(eiter->a.hw_version); alen += (alen & 3) ? (4 - (alen & 3)) : 4; @@ -1654,7 +1654,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha) ct_req->req.rpa.attrs.count = cpu_to_be32(FDMI_PORT_ATTR_COUNT); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_PORT_HOST_NAME); - strlcpy(eiter->a.host_name, fc_host_system_hostname(vha->host), + strscpy(eiter->a.host_name, fc_host_system_hostname(vha->host), sizeof(eiter->a.host_name)); alen = strlen(eiter->a.host_name); alen += (alen & 3) ? (4 - (alen & 3)) : 4; diff --git a/qla2x00t/qla_init.c b/qla2x00t/qla_init.c index 8b50a71..bf91a31 100644 --- a/qla2x00t/qla_init.c +++ b/qla2x00t/qla_init.c @@ -2162,7 +2162,7 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, !IS_CNA_CAPABLE(ha) && !IS_QLA2031(ha); if (memcmp(model, BINZERO, len) != 0) { - strncpy(ha->model_number, model, len); + memcpy(ha->model_number, model, len); st = en = ha->model_number; en += len - 1; while (en > st) { @@ -2175,7 +2175,7 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, if (use_tbl && ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && index < QLA_MODEL_NAMES) - strlcpy(ha->model_desc, + strscpy(ha->model_desc, qla2x00_model_name[index * 2 + 1], sizeof(ha->model_desc)); } else { @@ -2183,14 +2183,14 @@ qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, if (use_tbl && ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC && index < QLA_MODEL_NAMES) { - strlcpy(ha->model_number, + strscpy(ha->model_number, qla2x00_model_name[index * 2], sizeof(ha->model_number)); - strlcpy(ha->model_desc, + strscpy(ha->model_desc, qla2x00_model_name[index * 2 + 1], sizeof(ha->model_desc)); } else { - strlcpy(ha->model_number, def, + strscpy(ha->model_number, def, sizeof(ha->model_number)); } } diff --git a/qla2x00t/qla_nx.c b/qla2x00t/qla_nx.c index 780377f..4c3d90c 100644 --- a/qla2x00t/qla_nx.c +++ b/qla2x00t/qla_nx.c @@ -1599,7 +1599,7 @@ qla82xx_pci_info_str(struct scsi_qla_host *vha, char *str, int str_len) pci_read_config_word(ha->pdev, pcie_reg + PCI_EXP_LNKSTA, &lnk); ha->link_width = (lnk >> 4) & 0x3f; - strlcpy(str, "PCIe (", str_len); + strscpy(str, "PCIe (", str_len); strncat(str, "2.5Gb/s ", str_len - (strlen(str)+1)); snprintf(lwstr, sizeof(lwstr), "x%d)", ha->link_width); strncat(str, lwstr, str_len - (strlen(str)+1)); diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index 4ffa2f6..0c3c70a 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -494,7 +494,7 @@ qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str, int str_len) }; uint16_t pci_bus; - strlcpy(str, "PCI", str_len); + strscpy(str, "PCI", str_len); pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; if (pci_bus) { strncat(str, "-X (", str_len - (strlen(str)+1)); diff --git a/scst/include/backport.h b/scst/include/backport.h index 709a88f..619ef70 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1322,6 +1322,29 @@ static inline void *memdup_user_nul(const void __user *src, size_t len) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) && \ + (LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(3, 16, 0) >> 8 || \ + LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 60)) && \ + (LINUX_VERSION_CODE >> 8 != KERNEL_VERSION(3, 18, 0) >> 8 || \ + LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 64)) && \ + (!defined(RHEL_RELEASE_CODE) || \ + RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(7, 7)) +/* + * See also commit 30035e45753b ("string: provide strscpy()") # v4.3, v3.16.60, v3.18.64. + */ +static inline ssize_t strscpy(char *dest, const char *src, size_t count) +{ + size_t ret; + + if (count == 0) + return -E2BIG; + + ret = strlcpy(dest, src, count); + + return ret >= count ? -E2BIG : ret; +} +#endif + /* <linux/sysfs.h> */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) && \ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 10ace41..6f579b8 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -3119,10 +3119,10 @@ static int dev_user_attach_tgt(struct scst_tgt_dev *tgt_dev) if (tgtt->get_scsi_transport_version != NULL) ucmd->user_cmd.sess.scsi_transport_version = tgtt->get_scsi_transport_version(tgt); - strlcpy(ucmd->user_cmd.sess.initiator_name, + strscpy(ucmd->user_cmd.sess.initiator_name, tgt_dev->sess->initiator_name, sizeof(ucmd->user_cmd.sess.initiator_name)-1); - strlcpy(ucmd->user_cmd.sess.target_name, + strscpy(ucmd->user_cmd.sess.target_name, tgt_dev->sess->tgt->tgt_name, sizeof(ucmd->user_cmd.sess.target_name)-1); @@ -3369,7 +3369,7 @@ static int dev_user_register_dev(struct file *file, scst_init_threads(&dev->udev_cmd_threads); - strlcpy(dev->name, dev_desc->name, sizeof(dev->name)-1); + strscpy(dev->name, dev_desc->name, sizeof(dev->name)-1); scst_init_mem_lim(&dev->udev_mem_lim); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index cf6907c..262e9c1 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -9366,7 +9366,7 @@ static ssize_t vdev_sysfs_bind_alua_state_store(struct kobject *kobj, dev = container_of(kobj, struct scst_device, dev_kobj); virt_dev = dev->dh_priv; - strlcpy(ch, buf, 16); + strscpy(ch, buf, 16); res = kstrtoul(ch, 0, &bind_alua_state); if (res < 0) goto out; diff --git a/scst/src/scst_debug.c b/scst/src/scst_debug.c index d211eb8..a76a1bb 100644 --- a/scst/src/scst_debug.c +++ b/scst/src/scst_debug.c @@ -67,7 +67,7 @@ int debug_print_with_prefix(unsigned long trace_flag, const char *severity, spin_lock_irqsave(&trace_buf_lock, flags); - strlcpy(trace_buf, severity, TRACE_BUF_SIZE); + strscpy(trace_buf, severity, TRACE_BUF_SIZE); i = strlen(trace_buf); if (trace_flag & TRACE_PID) diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 593548e..7221008 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -278,7 +278,7 @@ void scst_event_queue(uint32_t event_code, const char *issuer_name, TRACE_DBG("Scheduling event entry %p", e); e->event.event_code = event_code; - strlcpy(e->event.issuer_name, issuer_name, sizeof(e->event.issuer_name)); + strscpy(e->event.issuer_name, issuer_name, sizeof(e->event.issuer_name)); queue_work(scst_event_wq, &e->scst_event_queue_work); @@ -317,9 +317,9 @@ int scst_event_queue_lun_not_found(const struct scst_cmd *cmd) payload = (struct scst_event_lun_not_found_payload *)event->payload; payload->lun = cmd->lun; - strlcpy(payload->initiator_name, cmd->sess->initiator_name, + strscpy(payload->initiator_name, cmd->sess->initiator_name, sizeof(payload->initiator_name)); - strlcpy(payload->target_name, cmd->tgt->tgt_name, + strscpy(payload->target_name, cmd->tgt->tgt_name, sizeof(payload->target_name)); scst_event_queue(SCST_EVENT_LUN_NOT_FOUND, @@ -358,9 +358,9 @@ int scst_event_queue_negative_luns_inquiry(const struct scst_tgt *tgt, event->payload_len = sizeof(*payload); payload = (struct scst_event_negative_luns_inquiry_payload *)event->payload; - strlcpy(payload->initiator_name, initiator_name, + strscpy(payload->initiator_name, initiator_name, sizeof(payload->initiator_name)); - strlcpy(payload->target_name, tgt->tgt_name, + strscpy(payload->target_name, tgt->tgt_name, sizeof(payload->target_name)); scst_event_queue(SCST_EVENT_NEGATIVE_LUNS_INQUIRY, @@ -399,7 +399,7 @@ int scst_event_queue_ext_blocking_done(struct scst_device *dev, void *data, int event->payload_len = sizeof(*payload) + len; payload = (struct scst_event_ext_blocking_done_payload *)event->payload; - strlcpy(payload->device_name, dev->virt_name, sizeof(payload->device_name)); + strscpy(payload->device_name, dev->virt_name, sizeof(payload->device_name)); if (len > 0) memcpy(payload->data, data, len); @@ -442,13 +442,13 @@ int scst_event_queue_tm_fn_received(struct scst_mgmt_cmd *mcmd) payload->fn = mcmd->fn; payload->lun = mcmd->lun; if (mcmd->mcmd_tgt_dev != NULL) - strlcpy(payload->device_name, mcmd->mcmd_tgt_dev->dev->virt_name, + strscpy(payload->device_name, mcmd->mcmd_tgt_dev->dev->virt_name, sizeof(payload->device_name)); - strlcpy(payload->initiator_name, mcmd->sess->initiator_name, + strscpy(payload->initiator_name, mcmd->sess->initiator_name, sizeof(payload->initiator_name)); - strlcpy(payload->target_name, mcmd->sess->tgt->tgt_name, + strscpy(payload->target_name, mcmd->sess->tgt->tgt_name, sizeof(payload->target_name)); - strlcpy(payload->session_sysfs_name, mcmd->sess->sess_name, + strscpy(payload->session_sysfs_name, mcmd->sess->sess_name, sizeof(payload->session_sysfs_name)); if (mcmd->cmd_to_abort != NULL) { payload->cmd_to_abort_tag = mcmd->cmd_to_abort->tag; @@ -493,7 +493,7 @@ int scst_event_queue_reg_vdev(const char *dev_name) event->payload_len = sizeof(*payload); payload = (struct scst_event_reg_vdev_payload *)event->payload; - strlcpy(payload->device_name, dev_name, + strscpy(payload->device_name, dev_name, sizeof(payload->device_name)); scst_event_queue(SCST_EVENT_REG_VIRT_DEV, diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 3462a37..5ca545f 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -625,7 +625,7 @@ char *scst_get_cmd_state_name(char *name, int len, unsigned int state) { if (state < ARRAY_SIZE(scst_cmd_state_name) && scst_cmd_state_name[state]) - strlcpy(name, scst_cmd_state_name[state], len); + strscpy(name, scst_cmd_state_name[state], len); else snprintf(name, len, "%d", state); return name; @@ -703,7 +703,7 @@ static const char *const scst_tm_fn_name[] = { char *scst_get_tm_fn_name(char *name, int len, unsigned int fn) { if (fn < ARRAY_SIZE(scst_tm_fn_name) && scst_tm_fn_name[fn]) - strlcpy(name, scst_tm_fn_name[fn], len); + strscpy(name, scst_tm_fn_name[fn], len); else snprintf(name, len, "%d", fn); return name; @@ -723,7 +723,7 @@ char *scst_get_mcmd_state_name(char *name, int len, unsigned int state) { if (state < ARRAY_SIZE(scst_mcmd_state_name) && scst_mcmd_state_name[state]) - strlcpy(name, scst_mcmd_state_name[state], len); + strscpy(name, scst_mcmd_state_name[state], len); else snprintf(name, len, "%d", state); return name; diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index fb438b5..af5cd48 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1412,7 +1412,7 @@ static int sgv_pool_init(struct sgv_pool *pool, const char *name, name, sizeof(struct sgv_pool_obj), clustering_type, single_alloc_pages, pool->max_caches, pool->max_cached_pages); - strlcpy(pool->name, name, sizeof(pool->name)-1); + strscpy(pool->name, name, sizeof(pool->name)-1); pool->owner_mm = current->mm; diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index d03dda1..0b8c72b 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -1739,9 +1739,8 @@ static int scst_emit_stpg_event(struct scst_cmd *cmd, struct scst_dev_group *dg, res = 1; - if (strlcpy(payload->device_name, dev->virt_name, - sizeof(payload->device_name)) >= - sizeof(payload->device_name)) { + if (strscpy(payload->device_name, dev->virt_name, + sizeof(payload->device_name)) < 0) { PRINT_ERROR("Device name %s too long", dev->virt_name); goto out_too_long; } @@ -1752,19 +1751,18 @@ static int scst_emit_stpg_event(struct scst_cmd *cmd, struct scst_dev_group *dg, if (osi[j].prev_state == osi[j].new_state) continue; - if (strlcpy(descr->prev_state, + if (strscpy(descr->prev_state, scst_alua_state_name(osi[j].prev_state), - sizeof(descr->prev_state)) >= - sizeof(descr->prev_state) || - strlcpy(descr->new_state, + sizeof(descr->prev_state)) < 0 || + strscpy(descr->new_state, scst_alua_state_name(osi[j].new_state), - sizeof(descr->new_state)) >= - sizeof(descr->new_state) || - strlcpy(descr->dg_name, dg->name, sizeof(descr->dg_name)) - >= sizeof(descr->dg_name) || - strlcpy(descr->tg_name, osi[j].tg->name, - sizeof(descr->tg_name)) >= - sizeof(descr->tg_name)) + sizeof(descr->new_state)) < 0 || + strscpy(descr->dg_name, + dg->name, + sizeof(descr->dg_name)) < 0 || + strscpy(descr->tg_name, + osi[j].tg->name, + sizeof(descr->tg_name)) < 0) goto out_too_long; descr->group_id = osi[j].group_id; diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 8cfac94..751b7f6 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -451,7 +451,7 @@ static void srpt_get_ioc(struct srpt_port *sport, u32 slot, memset(iocp, 0, sizeof(*iocp)); mutex_lock(&sport->mutex); - strlcpy(iocp->id_string, sport->port_id, sizeof(iocp->id_string)); + strscpy(iocp->id_string, sport->port_id, sizeof(iocp->id_string)); mutex_unlock(&sport->mutex); iocp->guid = cpu_to_be64(srpt_service_guid); iocp->vendor_id = cpu_to_be32(sdev->dev_attr.vendor_id); @@ -2707,7 +2707,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev, goto free_recv_ring; } - strlcpy(ch->sess_name, src_addr, sizeof(ch->sess_name)); + strscpy(ch->sess_name, src_addr, sizeof(ch->sess_name)); pr_debug("registering session %s\n", ch->sess_name); BUG_ON(!sport->scst_tgt); @@ -4258,7 +4258,7 @@ static void srpt_init_sport(struct srpt_port *sport, struct ib_device *ib_dev) INIT_LIST_HEAD(&sport->nexus_list); init_waitqueue_head(&sport->ch_releaseQ); mutex_init(&sport->mutex); - strlcpy(sport->port_id, DEFAULT_SRPT_ID_STRING, + strscpy(sport->port_id, DEFAULT_SRPT_ID_STRING, sizeof(sport->port_id)); for (i = 0; i < ib_dev->num_comp_vectors; i++) cpumask_set_cpu(i, &sport->comp_v_mask); |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:36:59
|
Commit: 16a17c2 GitHub URL: https://github.com/SCST-project/scst/commit/16a17c259bc6c349871c6c60fe5e254301efd72e Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- iscsi-scst: Port to Linux kernel v6.5 Use sendmsg() conditionally with MSG_SPLICE_PAGES in write_data() rather than calling sendpage(). Support for the following net layer changes in the Linux kernel v6.5: - dc97391e6610 ("sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)") Modified Paths: -------------- iscsi-scst/kernel/conn.c | 9 +++-- iscsi-scst/kernel/nthread.c | 26 ++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index 031e6c3..487cf65 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -741,7 +741,6 @@ int conn_activate(struct iscsi_conn *conn) static int conn_setup_sock(struct iscsi_conn *conn) { - int res = 0; int opt = 1; mm_segment_t oldfs; struct iscsi_session *session = conn->session; @@ -750,12 +749,13 @@ static int conn_setup_sock(struct iscsi_conn *conn) conn->sock = SOCKET_I(file_inode(conn->file)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) if (conn->sock->ops->sendpage == NULL) { PRINT_ERROR("Socket for sid %llx doesn't support sendpage()", (unsigned long long)session->sid); - res = -EINVAL; - goto out; + return -EINVAL; } +#endif #if 0 conn->sock->sk->sk_allocation = GFP_NOIO; @@ -768,8 +768,7 @@ static int conn_setup_sock(struct iscsi_conn *conn) KERNEL_SOCKPTR(&opt), sizeof(opt)); set_fs(oldfs); -out: - return res; + return 0; } void iscsi_tcp_conn_free(struct iscsi_conn *conn) diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index d335340..09a2330 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1096,8 +1096,13 @@ out: static int write_data(struct iscsi_conn *conn) { struct socket *sock; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) ssize_t (*sock_sendpage)(struct socket *sock, struct page *page, int offset, size_t size, int flags); +#else + struct msghdr msg = {}; + struct bio_vec bvec; +#endif struct iscsi_cmnd *write_cmnd, *parent_req; struct iscsi_cmnd *ref_cmd; struct page *page; @@ -1190,9 +1195,13 @@ static int write_data(struct iscsi_conn *conn) if (sg != write_cmnd->rsp_sg && (!parent_req->scst_cmd || parent_req->scst_state == ISCSI_CMD_STATE_AEN || !scst_cmd_get_dh_data_buff_alloced(parent_req->scst_cmd))) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) + flags |= MSG_SPLICE_PAGES; +#else sock_sendpage = sock->ops->sendpage; else sock_sendpage = sock_no_sendpage; +#endif sg_size = size; @@ -1236,14 +1245,21 @@ static int write_data(struct iscsi_conn *conn) flags |= MSG_MORE; while (sendsize) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) res = sock_sendpage(sock, page, offset, sendsize, flags); +#else + memset(&msg, 0, sizeof(struct msghdr)); + msg.msg_flags = flags; + + bvec_set_page(&bvec, page, sendsize, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, sendsize); + res = sock_sendmsg(sock, &msg); +#endif TRACE_WRITE( - "%s sid %#Lx, cid %u, res %d (page index %lu, offset %u, sendsize %lu, size %lu, cmd %p, page %p)", - (sock_sendpage != sock_no_sendpage) ? - "sendpage" : "sock_no_sendpage", + "sid %#Lx cid %u: res %d (page[%p] index %lu, offset %u, sendsize %lu, size %lu, cmd %p)", (unsigned long long)conn->session->sid, conn->cid, - res, page->index, offset, sendsize, size, - write_cmnd, page); + res, page, page->index, offset, sendsize, size, + write_cmnd); if (unlikely(res <= 0)) { if (res == -EINTR) |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:36:48
|
Commit: 324bf62 GitHub URL: https://github.com/SCST-project/scst/commit/324bf62e28189cd52abfcd6a05047452d04dd846 Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- iscsi-scst: Refactor sendpage functionality in write_data() This patch carries out a refactoring of the sendpage functionality in the write_data() function: 1. Reorganize the logic used to select the sock_sendpage function. 2. Streamline the data sending loop by reducing conditional branches and eliminating labels. 3. Adjust the error handling for -EINTR and -EAGAIN to make the code cleaner and easier to follow. This patch doesn't change any functionality. Modified Paths: -------------- iscsi-scst/kernel/nthread.c | 98 ++++++--------- 1 file changed, 36 insertions(+), 62 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 2806142..d335340 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1185,15 +1185,15 @@ static int write_data(struct iscsi_conn *conn) } sock = conn->sock; + flags = MSG_DONTWAIT; - if (parent_req->scst_cmd && - parent_req->scst_state != ISCSI_CMD_STATE_AEN && - scst_cmd_get_dh_data_buff_alloced(parent_req->scst_cmd)) - sock_sendpage = sock_no_sendpage; - else + if (sg != write_cmnd->rsp_sg && + (!parent_req->scst_cmd || parent_req->scst_state == ISCSI_CMD_STATE_AEN || + !scst_cmd_get_dh_data_buff_alloced(parent_req->scst_cmd))) sock_sendpage = sock->ops->sendpage; + else + sock_sendpage = sock_no_sendpage; - flags = MSG_DONTWAIT; sg_size = size; if (sg != write_cmnd->rsp_sg) { @@ -1222,7 +1222,6 @@ static int write_data(struct iscsi_conn *conn) } length = sg[idx].length - offset; offset += sg[idx].offset; - sock_sendpage = sock_no_sendpage; TRACE_WRITE("rsp_sg: write_offset %d, sg_size %lu, idx %d, offset %d, length %lu", conn->write_offset, sg_size, idx, offset, length); } @@ -1230,84 +1229,59 @@ static int write_data(struct iscsi_conn *conn) while (true) { sendsize = min_t(size_t, size, length); - if (size <= sendsize) { -retry2: - res = sock_sendpage(sock, page, offset, size, flags); + + if (sendsize == size) + flags &= ~MSG_MORE; + else + flags |= MSG_MORE; + + while (sendsize) { + res = sock_sendpage(sock, page, offset, sendsize, flags); TRACE_WRITE( - "Final %s sid %#Lx, cid %u, res %d (page index %lu, offset %u, size %lu, cmd %p, page %p)", + "%s sid %#Lx, cid %u, res %d (page index %lu, offset %u, sendsize %lu, size %lu, cmd %p, page %p)", (sock_sendpage != sock_no_sendpage) ? "sendpage" : "sock_no_sendpage", - (unsigned long long)conn->session->sid, - conn->cid, res, page->index, - offset, size, write_cmnd, page); + (unsigned long long)conn->session->sid, conn->cid, + res, page->index, offset, sendsize, size, + write_cmnd, page); + if (unlikely(res <= 0)) { if (res == -EINTR) - goto retry2; - else - goto out_res; - } + continue; + + if (res == -EAGAIN) { + conn->write_offset += sg_size - size; + goto out_iov; + } - if (res == size) { - conn->write_size = 0; - res = saved_size; - goto out; + goto out_err; } offset += res; + sendsize -= res; size -= res; - goto retry2; - } - -retry1: - res = sock_sendpage(sock, page, offset, sendsize, flags | MSG_MORE); - TRACE_WRITE( - "%s sid %#Lx, cid %u, res %d (page index %lu, offset %u, sendsize %lu, size %lu, cmd %p, page %p)", - (sock_sendpage != sock_no_sendpage) ? - "sendpage" : "sock_no_sendpage", - (unsigned long long)conn->session->sid, conn->cid, - res, page->index, offset, sendsize, size, - write_cmnd, page); - if (unlikely(res <= 0)) { - if (res == -EINTR) - goto retry1; - else - goto out_res; } - size -= res; + if (size == 0) + goto out_iov; - if (res == sendsize) { - idx++; - EXTRACHECKS_BUG_ON(idx >= ref_cmd->sg_cnt); - page = sg_page(&sg[idx]); - length = sg[idx].length; - offset = sg[idx].offset; - } else { - offset += res; - sendsize -= res; - goto retry1; - } + idx++; + EXTRACHECKS_BUG_ON(idx >= ref_cmd->sg_cnt); + page = sg_page(&sg[idx]); + length = sg[idx].length; + offset = sg[idx].offset; } -out_off: - conn->write_offset += sg_size - size; - out_iov: conn->write_size = size; - if ((saved_size == size) && res == -EAGAIN) - goto out; - res = saved_size - size; + if (res != -EAGAIN || saved_size != size) + res = saved_size - size; out: TRACE_EXIT_RES(res); return res; -out_res: - if (res == -EAGAIN) - goto out_off; - /* else go through */ - out_err: #ifndef CONFIG_SCST_DEBUG if (!conn->closing) { |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:36:43
|
Commit: c1f7510 GitHub URL: https://github.com/SCST-project/scst/commit/c1f7510d80ae39992510589a31430ddd7b9f83ac Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- iscsi-scst: Improve 'write iop loop' in write_data() This patch introduces several improvements to the 'write iop loop' in the write_data() function: 1. Move iop-related variables under the scope of the 'write iop loop'. 2. Eliminate the 'retry' label, use 'continue' instead for simplicity. 3. Remove the redundant 'rest' variable, use just 'res' instead. This patch doesn't change any functionality. Modified Paths: -------------- iscsi-scst/kernel/nthread.c | 43 ++++++++------- 1 file changed, 23 insertions(+), 20 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index f011072..2806142 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1095,8 +1095,6 @@ out: static int write_data(struct iscsi_conn *conn) { - struct file *file; - struct kvec *iop; struct socket *sock; ssize_t (*sock_sendpage)(struct socket *sock, struct page *page, int offset, size_t size, int flags); @@ -1106,7 +1104,7 @@ static int write_data(struct iscsi_conn *conn) struct scatterlist *sg; size_t saved_size, size, sg_size; size_t sendsize, length; - int offset, idx, flags, res = 0, count; + int offset, idx, flags, res = 0; bool ref_cmd_to_parent; TRACE_ENTRY(); @@ -1126,40 +1124,45 @@ static int write_data(struct iscsi_conn *conn) req_add_to_write_timeout_list(parent_req); - file = conn->file; - size = conn->write_size; - saved_size = size; - iop = conn->write_iop; - count = conn->write_iop_used; + saved_size = size = conn->write_size; + + if (conn->write_iop) { + struct file *file = conn->file; + struct kvec *iop = conn->write_iop; + int count = conn->write_iop_used; + loff_t off; + + sBUG_ON(count > ARRAY_SIZE(conn->write_iov)); - if (iop) { while (true) { - loff_t off = 0; - int rest; + off = 0; - sBUG_ON(count > ARRAY_SIZE(conn->write_iov)); -retry: res = scst_writev(file, iop, count, &off); TRACE_WRITE("sid %#Lx, cid %u, res %d, iov_len %zd", (unsigned long long)conn->session->sid, conn->cid, res, iop->iov_len); + if (unlikely(res <= 0)) { + if (res == -EINTR) + continue; + if (res == -EAGAIN) { conn->write_iop = iop; conn->write_iop_used = count; goto out_iov; - } else if (res == -EINTR) - goto retry; + } + goto out_err; } - rest = res; size -= res; - while ((typeof(rest))iop->iov_len <= rest && rest) { - rest -= iop->iov_len; + + while ((typeof(res))iop->iov_len <= res && res) { + res -= iop->iov_len; iop++; count--; } + if (count == 0) { conn->write_iop = NULL; conn->write_iop_used = 0; @@ -1169,8 +1172,8 @@ retry: } sBUG_ON(iop > conn->write_iov + ARRAY_SIZE(conn->write_iov)); - iop->iov_base += rest; - iop->iov_len -= rest; + iop->iov_base += res; + iop->iov_len -= res; } } |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:36:26
|
Commit: b5294cb GitHub URL: https://github.com/SCST-project/scst/commit/b5294cbf38caef207f5646a6c7db93a8a9153d4c Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- iscsi-scst: Improve write_data() This patch introduces several improvements to the write_data() function: 1. Remove the redundant 'sendpage' function pointer variable. 2. Update variables related to size to use the size_t type for better type correctness and safety. 3. Introduce a new variable, 'parent_req', to store the 'write_cmnd->parent_req' pointer and reduce redundant accesses. 4. Fix several checkpatch warnings. This patch doesn't change any functionality. Modified Paths: -------------- iscsi-scst/kernel/nthread.c | 73 ++++++++------- 1 file changed, 37 insertions(+), 36 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 593d7ee..f011072 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -1098,31 +1098,33 @@ static int write_data(struct iscsi_conn *conn) struct file *file; struct kvec *iop; struct socket *sock; - ssize_t (*sock_sendpage)(struct socket *, struct page *, int, size_t, - int); - ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); - struct iscsi_cmnd *write_cmnd = conn->write_cmnd; + ssize_t (*sock_sendpage)(struct socket *sock, struct page *page, + int offset, size_t size, int flags); + struct iscsi_cmnd *write_cmnd, *parent_req; struct iscsi_cmnd *ref_cmd; struct page *page; struct scatterlist *sg; - int saved_size, size, sendsize; - int length, offset, idx; - int flags, res, count, sg_size; + size_t saved_size, size, sg_size; + size_t sendsize, length; + int offset, idx, flags, res = 0, count; bool ref_cmd_to_parent; TRACE_ENTRY(); + write_cmnd = conn->write_cmnd; + parent_req = write_cmnd->parent_req; + iscsi_extracheck_is_wr_thread(conn); if (!write_cmnd->own_sg) { - ref_cmd = write_cmnd->parent_req; + ref_cmd = parent_req; ref_cmd_to_parent = true; } else { ref_cmd = write_cmnd; ref_cmd_to_parent = false; } - req_add_to_write_timeout_list(write_cmnd->parent_req); + req_add_to_write_timeout_list(parent_req); file = conn->file; size = conn->write_size; @@ -1131,7 +1133,7 @@ static int write_data(struct iscsi_conn *conn) count = conn->write_iop_used; if (iop) { - while (1) { + while (true) { loff_t off = 0; int rest; @@ -1181,9 +1183,9 @@ retry: sock = conn->sock; - if (write_cmnd->parent_req->scst_cmd && - write_cmnd->parent_req->scst_state != ISCSI_CMD_STATE_AEN && - scst_cmd_get_dh_data_buff_alloced(write_cmnd->parent_req->scst_cmd)) + if (parent_req->scst_cmd && + parent_req->scst_state != ISCSI_CMD_STATE_AEN && + scst_cmd_get_dh_data_buff_alloced(parent_req->scst_cmd)) sock_sendpage = sock_no_sendpage; else sock_sendpage = sock->ops->sendpage; @@ -1201,8 +1203,8 @@ retry: offset = conn->write_offset + sg[0].offset; idx = offset >> PAGE_SHIFT; offset &= ~PAGE_MASK; - length = min(size, (int)PAGE_SIZE - offset); - TRACE_WRITE("write_offset %d, sg_size %d, idx %d, offset %d, length %d", + length = min_t(size_t, size, PAGE_SIZE - offset); + TRACE_WRITE("write_offset %d, sg_size %lu, idx %d, offset %d, length %lu", conn->write_offset, sg_size, idx, offset, length); } else { /* @@ -1218,25 +1220,23 @@ retry: length = sg[idx].length - offset; offset += sg[idx].offset; sock_sendpage = sock_no_sendpage; - TRACE_WRITE("rsp_sg: write_offset %d, sg_size %d, idx %d, " - "offset %d, length %d", conn->write_offset, sg_size, - idx, offset, length); + TRACE_WRITE("rsp_sg: write_offset %d, sg_size %lu, idx %d, offset %d, length %lu", + conn->write_offset, sg_size, idx, offset, length); } page = sg_page(&sg[idx]); - while (1) { - sendpage = sock_sendpage; - - sendsize = min(size, length); + while (true) { + sendsize = min_t(size_t, size, length); if (size <= sendsize) { retry2: - res = sendpage(sock, page, offset, size, flags); - TRACE_WRITE("Final %s sid %#Lx, cid %u, res %d (page index %lu, offset %u, size %u, cmd %p, page %p)", - (sendpage != sock_no_sendpage) ? - "sendpage" : "sock_no_sendpage", - (unsigned long long)conn->session->sid, - conn->cid, res, page->index, - offset, size, write_cmnd, page); + res = sock_sendpage(sock, page, offset, size, flags); + TRACE_WRITE( + "Final %s sid %#Lx, cid %u, res %d (page index %lu, offset %u, size %lu, cmd %p, page %p)", + (sock_sendpage != sock_no_sendpage) ? + "sendpage" : "sock_no_sendpage", + (unsigned long long)conn->session->sid, + conn->cid, res, page->index, + offset, size, write_cmnd, page); if (unlikely(res <= 0)) { if (res == -EINTR) goto retry2; @@ -1256,13 +1256,14 @@ retry2: } retry1: - res = sendpage(sock, page, offset, sendsize, flags | MSG_MORE); - TRACE_WRITE("%s sid %#Lx, cid %u, res %d (page index %lu, offset %u, sendsize %u, size %u, cmd %p, page %p)", - (sendpage != sock_no_sendpage) ? "sendpage" : - "sock_no_sendpage", - (unsigned long long)conn->session->sid, conn->cid, - res, page->index, offset, sendsize, size, - write_cmnd, page); + res = sock_sendpage(sock, page, offset, sendsize, flags | MSG_MORE); + TRACE_WRITE( + "%s sid %#Lx, cid %u, res %d (page index %lu, offset %u, sendsize %lu, size %lu, cmd %p, page %p)", + (sock_sendpage != sock_no_sendpage) ? + "sendpage" : "sock_no_sendpage", + (unsigned long long)conn->session->sid, conn->cid, + res, page->index, offset, sendsize, size, + write_cmnd, page); if (unlikely(res <= 0)) { if (res == -EINTR) goto retry1; |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:36:13
|
Commit: a62b094 GitHub URL: https://github.com/SCST-project/scst/commit/a62b094f4fea3006497c025927575ed35d1e2829 Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- scst_user: Port to Linux kernel v6.5 Support for the following mm layer changes in the Linux kernel v6.5: - 54d020692b34 ("mm/gup: remove unused vmas parameter from get_user_pages()") Modified Paths: -------------- scst/include/backport.h | 73 ++++++--------- scst/src/dev_handlers/scst_user.c | 4 +- 2 files changed, 33 insertions(+), 44 deletions(-) =================================================================== diff --git a/scst/include/backport.h b/scst/include/backport.h index dd784cf..709a88f 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -572,60 +572,49 @@ static inline u32 int_sqrt64(u64 x) } #endif -#if LINUX_VERSION_CODE >> 8 == KERNEL_VERSION(4, 4, 0) >> 8 && \ - LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168) -/* - * See also commit 8e50b8b07f46 ("mm: replace get_user_pages() write/force - * parameters with gup_flags") # v4.4.168. - */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) static inline long get_user_pages_backport(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, - struct page **pages, - struct vm_area_struct **vmas) + struct page **pages) { +#if LINUX_VERSION_CODE >> 8 == KERNEL_VERSION(4, 4, 0) >> 8 && \ + LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168) + /* + * See also commit 8e50b8b07f46 ("mm: replace get_user_pages() write/force + * parameters with gup_flags") # v4.4.168. + */ return get_user_pages(current, current->mm, start, nr_pages, gup_flags, - pages, vmas); -} -#define get_user_pages get_user_pages_backport -#elif !defined(CONFIG_SUSE_KERNEL) && \ - LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) -/* - * See also commit cde70140fed8 ("mm/gup: Overload get_user_pages() functions") - * # v4.6. - */ -static inline long get_user_pages_backport(unsigned long start, - unsigned long nr_pages, - unsigned int gup_flags, - struct page **pages, - struct vm_area_struct **vmas) -{ - const bool write = gup_flags & FOLL_WRITE; - const bool force = 0; - - WARN_ON_ONCE(gup_flags & ~FOLL_WRITE); - return get_user_pages(current, current->mm, start, nr_pages, write, - force, pages, vmas); -} -#define get_user_pages get_user_pages_backport + pages, NULL); #elif (!defined(CONFIG_SUSE_KERNEL) && \ LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) || \ LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) -/* - * See also commit 768ae309a961 ("mm: replace get_user_pages() write/force - * parameters with gup_flags") # v4.9. - */ -static inline long get_user_pages_backport(unsigned long start, - unsigned long nr_pages, - unsigned int gup_flags, - struct page **pages, - struct vm_area_struct **vmas) -{ const bool write = gup_flags & FOLL_WRITE; const bool force = 0; WARN_ON_ONCE(gup_flags & ~FOLL_WRITE); - return get_user_pages(start, nr_pages, write, force, pages, vmas); +#if !defined(CONFIG_SUSE_KERNEL) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) + /* + * See also commit cde70140fed8 ("mm/gup: Overload get_user_pages() functions") + * # v4.6. + */ + return get_user_pages(current, current->mm, start, nr_pages, write, + force, pages, NULL); +#else + /* + * See also commit 768ae309a961 ("mm: replace get_user_pages() write/force + * parameters with gup_flags") # v4.9. + */ + return get_user_pages(start, nr_pages, write, force, pages, NULL); +#endif +#else + /* + * See also commit 54d020692b34 ("mm/gup: remove unused vmas parameter from + * get_user_pages()") # v6.5. + */ + return get_user_pages(start, nr_pages, gup_flags, pages, NULL); +#endif } #define get_user_pages get_user_pages_backport #endif diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index e66a410..10ace41 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -1261,12 +1261,12 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff, #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) down_read(&tsk->mm->mmap_sem); rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE, - ucmd->data_pages, NULL); + ucmd->data_pages); up_read(&tsk->mm->mmap_sem); #else mmap_read_lock(tsk->mm); rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE, - ucmd->data_pages, NULL); + ucmd->data_pages); mmap_read_unlock(tsk->mm); #endif |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:36:04
|
Commit: 7a1ea23 GitHub URL: https://github.com/SCST-project/scst/commit/7a1ea234e7e9428c85e0c8a5d66158e369b8e81a Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- scst_tape: Port to Linux kernel v6.5 Support for the following scsi core changes in the Linux kernel v6.5: - a6cdc35fab0d ("scsi: core: Support retrieving sub-pages of mode pages") Modified Paths: -------------- scst/src/dev_handlers/scst_tape.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) =================================================================== diff --git a/scst/src/dev_handlers/scst_tape.c b/scst/src/dev_handlers/scst_tape.c index 1bb0301..845b98e 100644 --- a/scst/src/dev_handlers/scst_tape.c +++ b/scst/src/dev_handlers/scst_tape.c @@ -171,12 +171,15 @@ static int tape_attach(struct scst_device *dev) TRACE_DBG("%s", "Doing MODE_SENSE"); rc = scsi_mode_sense(dev->scsi_dev, - ((dev->scsi_dev->scsi_level <= SCSI_2) ? - ((dev->scsi_dev->lun << 5) & 0xe0) : 0), - 0 /* Mode Page 0 */, - buffer, buffer_size, - SCST_GENERIC_TAPE_SMALL_TIMEOUT, TAPE_RETRIES, - &data, NULL); + ((dev->scsi_dev->scsi_level <= SCSI_2) ? + ((dev->scsi_dev->lun << 5) & 0xe0) : 0), + 0 /* Mode Page 0 */, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) + 0 /* Sub Page */, +#endif + buffer, buffer_size, + SCST_GENERIC_TAPE_SMALL_TIMEOUT, TAPE_RETRIES, + &data, NULL); TRACE_DBG("MODE_SENSE done: %x", rc); if (rc == 0) { |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:35:42
|
Commit: 76750f3 GitHub URL: https://github.com/SCST-project/scst/commit/76750f3352d095e6a544d02a10d84b15147bcb0a Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- scst: Port to Linux kernel v6.5 Support for the following block layer changes in the Linux kernel v6.5: - 05bdb9965305 ("block: replace fmode_t with a block-specific type for block open flags") - 0718afd47f70 ("block: introduce holder ops") - 2736e8eeb0cc ("block: use the holder as indication for exclusive opens") Modified Paths: -------------- .github/workflows/checkpatch_pull.yml | 1 + .github/workflows/checkpatch_push.yml | 1 + scst/include/backport.h | 53 ++++++++++++++- scst/src/dev_handlers/scst_vdisk.c | 24 +++---- scst/src/scst_lib.c | 4 +- 5 files changed, 66 insertions(+), 17 deletions(-) =================================================================== diff --git a/.github/workflows/checkpatch_pull.yml b/.github/workflows/checkpatch_pull.yml index dfee81f..a9ced98 100644 --- a/.github/workflows/checkpatch_pull.yml +++ b/.github/workflows/checkpatch_pull.yml @@ -35,6 +35,7 @@ jobs: SPDX_LICENSE_TAG LINUX_VERSION_CODE CONSTANT_COMPARISON + NEW_TYPEDEFS SPACING ) ignore_str=${ignore[*]} diff --git a/.github/workflows/checkpatch_push.yml b/.github/workflows/checkpatch_push.yml index e517ccc..28acad5 100644 --- a/.github/workflows/checkpatch_push.yml +++ b/.github/workflows/checkpatch_push.yml @@ -40,6 +40,7 @@ jobs: SPDX_LICENSE_TAG LINUX_VERSION_CODE CONSTANT_COMPARISON + NEW_TYPEDEFS SPACING ) ignore_str=${ignore[*]} diff --git a/scst/include/backport.h b/scst/include/backport.h index d8e873a..dd784cf 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -228,6 +228,55 @@ void blk_execute_rq_nowait_backport(struct request *rq, bool at_head) /* <linux/blkdev.h> */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) +/* + * See also commit 05bdb9965305 ("block: replace fmode_t with a block-specific + * type for block open flags") # v6.5. + */ +typedef fmode_t blk_mode_t; + +#define BLK_OPEN_READ ((__force blk_mode_t)FMODE_READ) +#define BLK_OPEN_WRITE ((__force blk_mode_t)FMODE_WRITE) +#define BLK_OPEN_EXCL ((__force blk_mode_t)FMODE_EXCL) + +/* + * See also commit 0718afd47f70 ("block: introduce holder ops") # v6.5. + */ +struct blk_holder_ops { + /* empty dummy */ +}; + +static inline struct block_device * +blkdev_get_by_path_backport(const char *path, blk_mode_t mode, + void *holder, const struct blk_holder_ops *hops) +{ + WARN_ON_ONCE(hops); + + /* + * See also commit 2736e8eeb0cc ("block: use the holder as + * indication for exclusive opens") # v6.5. + */ + if (holder) + mode |= BLK_OPEN_EXCL; + + return blkdev_get_by_path(path, mode, holder); +} + +#define blkdev_get_by_path blkdev_get_by_path_backport + +/* + * See also commit 2736e8eeb0cc ("block: use the holder as indication for + * exclusive opens") # v6.5. + */ +static inline void blkdev_put_backport(struct block_device *bdev, void *holder) +{ + blkdev_put(bdev, holder ? BLK_OPEN_EXCL : 0); +} + +#define blkdev_put blkdev_put_backport + +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) && \ (!defined(RHEL_RELEASE_CODE) || \ RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(9, 1)) @@ -235,8 +284,8 @@ void blk_execute_rq_nowait_backport(struct request *rq, bool at_head) * See also commit 44abff2c0b97 ("block: decouple REQ_OP_SECURE_ERASE * from REQ_OP_DISCARD") # v5.19. */ -static inline -int blkdev_issue_discard_backport(struct block_device *bdev, sector_t sector, +static inline int +blkdev_issue_discard_backport(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask) { return blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, 0); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index eaa61c5..cf6907c 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -191,7 +191,6 @@ struct scst_vdisk_dev { struct file *fd; struct file *dif_fd; struct block_device *bdev; - fmode_t bdev_mode; struct bio_set *vdisk_bioset; #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) struct bio_set vdisk_bioset_struct; @@ -503,7 +502,7 @@ static void vdisk_blockio_check_flush_support(struct scst_vdisk_dev *virt_dev) virt_dev->wt_flag || !virt_dev->dev_active) goto out; - bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, NULL); + bdev = blkdev_get_by_path(virt_dev->filename, BLK_OPEN_READ, NULL, NULL); if (IS_ERR(bdev)) { if (PTR_ERR(bdev) == -EMEDIUMTYPE) TRACE(TRACE_MINOR, @@ -522,7 +521,7 @@ static void vdisk_blockio_check_flush_support(struct scst_vdisk_dev *virt_dev) virt_dev->nv_cache = 1; } - blkdev_put(bdev, FMODE_READ); + blkdev_put(bdev, NULL); out: TRACE_EXIT(); @@ -544,7 +543,7 @@ static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev) goto check; if (virt_dev->blockio) { - bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, NULL); + bdev = blkdev_get_by_path(virt_dev->filename, BLK_OPEN_READ, NULL, NULL); res = PTR_ERR_OR_ZERO(bdev); } else { fd = filp_open(virt_dev->filename, O_LARGEFILE, 0600); @@ -640,7 +639,7 @@ check: if (fd_open) { if (virt_dev->blockio) - blkdev_put(bdev, FMODE_READ); + blkdev_put(bdev, NULL); else filp_close(fd, NULL); } @@ -965,7 +964,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) TRACE_ENTRY(); - bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, NULL); + bdev = blkdev_get_by_path(virt_dev->filename, BLK_OPEN_READ, NULL, NULL); if (IS_ERR(bdev)) { res = PTR_ERR(bdev); goto out; @@ -1043,7 +1042,7 @@ out_no_bi: res = 0; out_close: - blkdev_put(bdev, FMODE_READ); + blkdev_put(bdev, NULL); out: TRACE_EXIT_RES(res); @@ -1307,13 +1306,12 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only) virt_dev->dev->virt_name); res = -EMEDIUMTYPE; } else if (virt_dev->blockio) { - virt_dev->bdev_mode = FMODE_READ | FMODE_EXCL; + blk_mode_t bdev_mode = BLK_OPEN_READ; if (!read_only) - virt_dev->bdev_mode |= FMODE_WRITE; + bdev_mode |= BLK_OPEN_WRITE; - virt_dev->bdev = blkdev_get_by_path(virt_dev->filename, - virt_dev->bdev_mode, virt_dev); + virt_dev->bdev = blkdev_get_by_path(virt_dev->filename, bdev_mode, virt_dev, NULL); res = PTR_ERR_OR_ZERO(virt_dev->bdev); } else { virt_dev->fd = vdev_open_fd(virt_dev, virt_dev->filename, @@ -1352,7 +1350,7 @@ out: out_close_fd: if (virt_dev->blockio) { - blkdev_put(virt_dev->bdev, virt_dev->bdev_mode); + blkdev_put(virt_dev->bdev, virt_dev); virt_dev->bdev = NULL; } else { filp_close(virt_dev->fd, NULL); @@ -1367,7 +1365,7 @@ static void vdisk_close_fd(struct scst_vdisk_dev *virt_dev) virt_dev->fd, virt_dev->bdev, virt_dev->dif_fd); if (virt_dev->bdev) { - blkdev_put(virt_dev->bdev, virt_dev->bdev_mode); + blkdev_put(virt_dev->bdev, virt_dev); virt_dev->bdev = NULL; } else if (virt_dev->fd) { filp_close(virt_dev->fd, NULL); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index bdb45c4..283a28b 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5983,11 +5983,11 @@ loff_t scst_bdev_size(const char *path) struct block_device *bdev; loff_t res; - bdev = blkdev_get_by_path(path, FMODE_READ, NULL); + bdev = blkdev_get_by_path(path, BLK_OPEN_READ, NULL, NULL); if (IS_ERR(bdev)) return PTR_ERR(bdev); res = i_size_read(bdev->bd_inode); - blkdev_put(bdev, FMODE_READ); + blkdev_put(bdev, NULL); return res; } EXPORT_SYMBOL(scst_bdev_size); |
From: Gleb C. <lna...@ya...> - 2023-07-10 07:35:33
|
Commit: 5c14b16 GitHub URL: https://github.com/SCST-project/scst/commit/5c14b16fb773a0ed72c32619179d3ad6a4a22be0 Author: Gleb Chesnokov Date: 2023-07-10T10:34:57+03:00 Log Message: ----------- scst_vdisk: Open block devices exclusively Enable exclusive opening of block devices to prevent concurrent usage. Additionally, remove the redundant 'holder' argument for 'blkdev_get_by_path()' where exclusive opening isn't utilized. Modified Paths: -------------- scst/src/dev_handlers/scst_vdisk.c | 26 +++++++-------- scst/src/scst_lib.c | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) =================================================================== diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 95a3bf4..eaa61c5 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -503,12 +503,12 @@ static void vdisk_blockio_check_flush_support(struct scst_vdisk_dev *virt_dev) virt_dev->wt_flag || !virt_dev->dev_active) goto out; - bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, - (void *)__func__); + bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, NULL); if (IS_ERR(bdev)) { if (PTR_ERR(bdev) == -EMEDIUMTYPE) - TRACE(TRACE_MINOR, "Unable to open %s with EMEDIUMTYPE, " - "DRBD passive?", virt_dev->filename); + TRACE(TRACE_MINOR, + "Unable to open %s with EMEDIUMTYPE, DRBD passive?", + virt_dev->filename); else PRINT_ERROR("blkdev_get_by_path(%s) failed: %ld", virt_dev->filename, PTR_ERR(bdev)); @@ -516,9 +516,9 @@ static void vdisk_blockio_check_flush_support(struct scst_vdisk_dev *virt_dev) } if (vdisk_blockio_flush(bdev, GFP_KERNEL, false, NULL, false) != 0) { - PRINT_WARNING("Device %s doesn't support barriers, switching " - "to NV_CACHE mode. Read README for more details.", - virt_dev->filename); + PRINT_WARNING( +"Device %s doesn't support barriers, switching to NV_CACHE mode. Read README for more details.", + virt_dev->filename); virt_dev->nv_cache = 1; } @@ -544,8 +544,7 @@ static void vdisk_check_tp_support(struct scst_vdisk_dev *virt_dev) goto check; if (virt_dev->blockio) { - bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, - (void *)__func__); + bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, NULL); res = PTR_ERR_OR_ZERO(bdev); } else { fd = filp_open(virt_dev->filename, O_LARGEFILE, 0600); @@ -966,8 +965,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev) TRACE_ENTRY(); - bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, - (void *)__func__); + bdev = blkdev_get_by_path(virt_dev->filename, FMODE_READ, NULL); if (IS_ERR(bdev)) { res = PTR_ERR(bdev); goto out; @@ -1309,11 +1307,13 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only) virt_dev->dev->virt_name); res = -EMEDIUMTYPE; } else if (virt_dev->blockio) { - virt_dev->bdev_mode = FMODE_READ; + virt_dev->bdev_mode = FMODE_READ | FMODE_EXCL; + if (!read_only) virt_dev->bdev_mode |= FMODE_WRITE; + virt_dev->bdev = blkdev_get_by_path(virt_dev->filename, - virt_dev->bdev_mode, (void *)__func__); + virt_dev->bdev_mode, virt_dev); res = PTR_ERR_OR_ZERO(virt_dev->bdev); } else { virt_dev->fd = vdev_open_fd(virt_dev, virt_dev->filename, diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 23149b6..bdb45c4 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5983,7 +5983,7 @@ loff_t scst_bdev_size(const char *path) struct block_device *bdev; loff_t res; - bdev = blkdev_get_by_path(path, FMODE_READ, (void *)__func__); + bdev = blkdev_get_by_path(path, FMODE_READ, NULL); if (IS_ERR(bdev)) return PTR_ERR(bdev); res = i_size_read(bdev->bd_inode); |
From: Gleb C. <lna...@ya...> - 2023-06-30 07:56:55
|
Commit: 86d5b21 GitHub URL: https://github.com/SCST-project/scst/commit/86d5b218e4cbf98da04db81b8e320e490fbbe472 Author: Gleb Chesnokov Date: 2023-06-30T10:56:09+03:00 Log Message: ----------- scst_targ: Check prepare_to_wait_exclusive_head() return value The prepare_to_wait_exclusive_head() function was modified in commit d8894cbd1157 ("scst.h: Refactor wait_event_locked() to enhance usability and clarity"). It now returns an error if the current interruptible thread has pending signals. This patch introduces the scst_wait_for_cmd() helper function for the scst_cmd_thread(). This new function handles the return value of the prepare_to_wait_exclusive_head() appropriately. This patch fixes the following Coverity complaint: CID 321410 (#1 of 1): Unchecked return value (CHECKED_RETURN) check_return: Calling prepare_to_wait_exclusive_head without checking return value. Modified Paths: -------------- scst/src/scst_targ.c | 51 ++++++++++----- 1 file changed, 34 insertions(+), 17 deletions(-) =================================================================== diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 70e212e..4b4eac7 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4800,6 +4800,39 @@ static inline int test_cmd_threads(struct scst_cmd_thread_t *thr) return res; } +static inline int +scst_wait_for_cmd(struct scst_cmd_threads *p_cmd_threads, struct scst_cmd_thread_t *thr) +{ + DEFINE_WAIT(wq_entry); + int ret = 0; + + if (test_cmd_threads(thr)) + return 0; + + for (;;) { + long __int = prepare_to_wait_exclusive_head(&p_cmd_threads->cmd_list_waitQ, + &wq_entry, TASK_INTERRUPTIBLE); + + if (test_cmd_threads(thr)) + break; + + if (__int) { + ret = __int; + goto out; + } + + spin_unlock(&thr->thr_cmd_list_lock); + spin_unlock_irq(&p_cmd_threads->cmd_list_lock); + schedule(); + spin_lock_irq(&p_cmd_threads->cmd_list_lock); + spin_lock(&thr->thr_cmd_list_lock); + } + finish_wait(&p_cmd_threads->cmd_list_waitQ, &wq_entry); + +out: + return ret; +} + int scst_cmd_thread(void *arg) { struct scst_cmd_thread_t *thr = arg; @@ -4822,23 +4855,7 @@ int scst_cmd_thread(void *arg) spin_lock_irq(&p_cmd_threads->cmd_list_lock); spin_lock(&thr->thr_cmd_list_lock); while (!kthread_should_stop()) { - if (!test_cmd_threads(thr)) { - DEFINE_WAIT(wait); - - do { - prepare_to_wait_exclusive_head( - &p_cmd_threads->cmd_list_waitQ, - &wait, TASK_INTERRUPTIBLE); - if (test_cmd_threads(thr)) - break; - spin_unlock(&thr->thr_cmd_list_lock); - spin_unlock_irq(&p_cmd_threads->cmd_list_lock); - schedule(); - spin_lock_irq(&p_cmd_threads->cmd_list_lock); - spin_lock(&thr->thr_cmd_list_lock); - } while (!test_cmd_threads(thr)); - finish_wait(&p_cmd_threads->cmd_list_waitQ, &wait); - } + scst_wait_for_cmd(p_cmd_threads, thr); if (tm_dbg_is_release()) { spin_unlock_irq(&p_cmd_threads->cmd_list_lock); |
From: Gleb C. <lna...@ya...> - 2023-06-30 07:56:38
|
Commit: 057224f GitHub URL: https://github.com/SCST-project/scst/commit/057224f6691b8ee7fedb677e1c69844d051423b1 Author: Gleb Chesnokov Date: 2023-06-30T10:56:09+03:00 Log Message: ----------- scst_user: Simplify signal pending check The scst_wait_event_interruptible_lock_irq() function now implicitly checks for pending signals. Therefore, there is no need to check for these signals explicitly. This patch replaces the explicit check with a simple evaluation of the function's return value. This patch doesn't change any functionality. Modified Paths: -------------- scst/src/dev_handlers/scst_user.c | 21 +++++---------- 1 file changed, 6 insertions(+), 15 deletions(-) =================================================================== diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index fcf2d90..e66a410 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -36,10 +36,6 @@ #endif #include "scst_dev_handler.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) -#include <linux/sched/signal.h> -#endif - #ifndef INSIDE_KERNEL_TREE #if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G) #warning HIGHMEM kernel configurations are not supported by this module, \ @@ -2219,8 +2215,7 @@ static inline int test_cmd_threads(struct scst_user_dev *dev, bool can_block) { int res = !list_empty(&dev->udev_cmd_threads.active_cmd_list) || !list_empty(&dev->ready_cmd_list) || - !can_block || !dev->blocking || dev->cleanup_done || - signal_pending(current); + !can_block || !dev->blocking || dev->cleanup_done; return res; } @@ -2233,9 +2228,11 @@ static int dev_user_get_next_cmd(struct scst_user_dev *dev, TRACE_ENTRY(); while (1) { - scst_wait_event_interruptible_lock_irq(dev->udev_cmd_threads.cmd_list_waitQ, - test_cmd_threads(dev, can_block), - dev->udev_cmd_threads.cmd_list_lock); + res = scst_wait_event_interruptible_lock_irq(dev->udev_cmd_threads.cmd_list_waitQ, + test_cmd_threads(dev, can_block), + dev->udev_cmd_threads.cmd_list_lock); + if (res) + break; dev_user_process_scst_commands(dev); @@ -2248,12 +2245,6 @@ static int dev_user_get_next_cmd(struct scst_user_dev *dev, TRACE_DBG("No ready commands, returning %d", res); break; } - - if (signal_pending(current)) { - res = -EINTR; - TRACE_DBG("Signal pending, returning %d", res); - break; - } } TRACE_EXIT_RES(res); |
From: Gleb C. <lna...@ya...> - 2023-06-28 16:32:18
|
Commit: 6a92549 GitHub URL: https://github.com/SCST-project/scst/commit/6a925490fd5447033aabb847ab3418a20aba4266 Author: Gleb Chesnokov Date: 2023-06-28T19:31:45+03:00 Log Message: ----------- scst: Confirm percpu refs has scheduled and switched to atomic This patch replaces percpu_ref_kill() with percpu_ref_kill_and_confirm() to guarantee safe usage of references in atomic mode immediately afterwards. This change ensures accurate checking of active commands following the initial reference killing. Reported-by: Lev Vainblat <le...@za...> Modified Paths: -------------- .github/workflows/checkpatch_pull.yml | 1 + .github/workflows/checkpatch_push.yml | 1 + scst/include/backport.h | 10 +++- scst/src/scst_main.c | 42 ++++++++++----- scst/src/scst_priv.h | 1 - 5 files changed, 40 insertions(+), 15 deletions(-) =================================================================== diff --git a/.github/workflows/checkpatch_pull.yml b/.github/workflows/checkpatch_pull.yml index c231e64..dfee81f 100644 --- a/.github/workflows/checkpatch_pull.yml +++ b/.github/workflows/checkpatch_pull.yml @@ -30,6 +30,7 @@ jobs: UNKNOWN_COMMIT_ID NO_AUTHOR_SIGN_OFF COMMIT_LOG_USE_LINK + BAD_REPORTED_BY_LINK FILE_PATH_CHANGES SPDX_LICENSE_TAG LINUX_VERSION_CODE diff --git a/.github/workflows/checkpatch_push.yml b/.github/workflows/checkpatch_push.yml index c5071f4..e517ccc 100644 --- a/.github/workflows/checkpatch_push.yml +++ b/.github/workflows/checkpatch_push.yml @@ -35,6 +35,7 @@ jobs: UNKNOWN_COMMIT_ID NO_AUTHOR_SIGN_OFF COMMIT_LOG_USE_LINK + BAD_REPORTED_BY_LINK FILE_PATH_CHANGES SPDX_LICENSE_TAG LINUX_VERSION_CODE diff --git a/scst/include/backport.h b/scst/include/backport.h index 6d0fd87..d8e873a 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1098,13 +1098,21 @@ static inline void percpu_ref_put(struct percpu_ref *ref) ref->release(ref); } -static inline void percpu_ref_kill(struct percpu_ref *ref) +static inline void +percpu_ref_kill_and_confirm(struct percpu_ref *ref, percpu_ref_func_t *confirm_kill) { WARN_ON_ONCE(ref->dead); ref->dead = true; + if (confirm_kill) + confirm_kill(ref); percpu_ref_put(ref); } +static inline void percpu_ref_kill(struct percpu_ref *ref) +{ + percpu_ref_kill_and_confirm(ref, NULL); +} + static inline void percpu_ref_resurrect(struct percpu_ref *ref) { WARN_ON_ONCE(!ref->dead); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 11d26d3..3462a37 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -129,7 +129,8 @@ spinlock_t scst_mgmt_lock; struct list_head scst_sess_init_list; struct list_head scst_sess_shut_list; -wait_queue_head_t scst_dev_cmd_waitQ; +static wait_queue_head_t scst_dev_cmd_waitQ; +static struct completion scst_confirm_done; static struct mutex scst_cmd_threads_mutex; /* protected by scst_cmd_threads_mutex */ @@ -792,7 +793,7 @@ static int scst_susp_wait(unsigned long timeout) t = min(timeout, SCST_SUSP_WAIT_REPORT_TIMEOUT); res = wait_event_interruptible_timeout(scst_dev_cmd_waitQ, - percpu_ref_killed, t); + percpu_ref_killed, t); if (res > 0) { res = 0; goto out; @@ -800,15 +801,16 @@ static int scst_susp_wait(unsigned long timeout) goto out; if (res == 0) { - PRINT_INFO("%d active commands to still not completed. See " - "README for possible reasons.", scst_get_cmd_counter()); + PRINT_INFO( + "%d active commands to still not completed. See README for possible reasons.", + scst_get_cmd_counter()); scst_trace_cmds(scst_to_syslog, &hp); scst_trace_mcmds(scst_to_syslog, &hp); } if (timeout != SCST_SUSPEND_TIMEOUT_UNLIMITED) { res = wait_event_interruptible_timeout(scst_dev_cmd_waitQ, - percpu_ref_killed, timeout - t); + percpu_ref_killed, timeout - t); if (res == 0) res = -EBUSY; else if (res > 0) @@ -826,6 +828,11 @@ out: #undef SCST_SUSP_WAIT_REPORT_TIMEOUT } +static void scst_suspend_counter_confirm(struct percpu_ref *ref) +{ + complete(&scst_confirm_done); +} + /* * scst_suspend_activity() - globally suspend activity * @@ -864,8 +871,12 @@ int scst_suspend_activity(unsigned long timeout) goto out_up; /* Cause scst_get_cmd() to fail. */ + init_completion(&scst_confirm_done); + percpu_ref_killed = false; - percpu_ref_kill(&scst_cmd_count); + percpu_ref_kill_and_confirm(&scst_cmd_count, scst_suspend_counter_confirm); + + wait_for_completion(&scst_confirm_done); /* * See comment in scst_user.c::dev_user_task_mgmt_fn() for more @@ -878,7 +889,7 @@ int scst_suspend_activity(unsigned long timeout) if (scst_get_cmd_counter() != 0) { PRINT_INFO("Waiting for %d active commands to complete...", - scst_get_cmd_counter()); + scst_get_cmd_counter()); rep = true; lock_contended(&scst_suspend_dep_map, _RET_IP_); @@ -887,15 +898,19 @@ int scst_suspend_activity(unsigned long timeout) res = scst_susp_wait(timeout); /* Cause scst_get_mcmd() to fail. */ + init_completion(&scst_confirm_done); + percpu_ref_killed = false; - percpu_ref_kill(&scst_mcmd_count); + percpu_ref_kill_and_confirm(&scst_mcmd_count, scst_suspend_counter_confirm); + + wait_for_completion(&scst_confirm_done); if (res != 0) goto out_resume; if (scst_get_cmd_counter() != 0) - TRACE_MGMT_DBG("Waiting for %d active commands finally to " - "complete", scst_get_cmd_counter()); + TRACE_MGMT_DBG("Waiting for %d active commands finally to complete", + scst_get_cmd_counter()); if (timeout != SCST_SUSPEND_TIMEOUT_UNLIMITED) { wait_time = jiffies - cur_time; @@ -913,7 +928,7 @@ int scst_suspend_activity(unsigned long timeout) goto out_resume; if (rep) - PRINT_INFO("%s", "All active commands completed"); + PRINT_INFO("All active commands completed"); out_up: mutex_unlock(&scst_suspend_mutex); @@ -973,8 +988,9 @@ static void __scst_resume_activity(void) spin_lock_irq(&scst_mcmd_lock); list_for_each_entry(m, &scst_delayed_mgmt_cmd_list, mgmt_cmd_list_entry) { - TRACE_MGMT_DBG("Moving delayed mgmt cmd %p to head of active " - "mgmt cmd list", m); + TRACE_MGMT_DBG( + "Moving delayed mgmt cmd %p to head of active mgmt cmd list", + m); } list_splice_init(&scst_delayed_mgmt_cmd_list, &scst_active_mgmt_cmd_list); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index c9c0d3f..4927630 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -172,7 +172,6 @@ extern struct list_head scst_template_list; extern struct list_head scst_dev_list; extern struct list_head scst_dev_type_list; extern struct list_head scst_virtual_dev_type_list; -extern wait_queue_head_t scst_dev_cmd_waitQ; extern const struct scst_cl_ops scst_no_dlm_cl_ops; extern const struct scst_cl_ops scst_dlm_cl_ops; |
From: Gleb C. <lna...@ya...> - 2023-06-27 14:11:39
|
Commit: bdf867f GitHub URL: https://github.com/SCST-project/scst/commit/bdf867ffd18a8781ccf344f1ef39ebb29c412897 Author: Gleb Chesnokov Date: 2023-06-27T17:11:13+03:00 Log Message: ----------- scst: Use scst_wait_event_...() with INTERRUPTIBLE sleep This patch changes the processing threads to use INTERRUPTIBLE sleep states in the scst_wait_event_...() functions. This aims to avoid warnings from the hung task detection checker and to prevent unnecessary load counting. Fixes: d8894cbd1157 ("scst.h: Refactor wait_event_locked() to enhance usability and clarity") Modified Paths: -------------- iscsi-scst/kernel/nthread.c | 4 +- scst/include/scst.h | 64 ++++++--------- scst/src/dev_handlers/scst_user.c | 10 +-- scst/src/scst_sysfs.c | 4 +- scst/src/scst_targ.c | 16 ++-- 5 files changed, 44 insertions(+), 54 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index fb4e93a..593d7ee 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -960,7 +960,7 @@ int istrd(void *arg) spin_lock_bh(&p->rd_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_bh(p->rd_waitQ, test_rd_list(p), p->rd_lock); + scst_wait_event_interruptible_lock_bh(p->rd_waitQ, test_rd_list(p), p->rd_lock); scst_do_job_rd(p); } spin_unlock_bh(&p->rd_lock); @@ -1612,7 +1612,7 @@ int istwr(void *arg) spin_lock_bh(&p->wr_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_bh(p->wr_waitQ, test_wr_list(p), p->wr_lock); + scst_wait_event_interruptible_lock_bh(p->wr_waitQ, test_wr_list(p), p->wr_lock); scst_do_job_wr(p); } spin_unlock_bh(&p->wr_lock); diff --git a/scst/include/scst.h b/scst/include/scst.h index 91258d1..781aabb 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5485,31 +5485,20 @@ prepare_to_wait_exclusive_head(struct wait_queue_head *wq_head, __out: __ret; \ }) -#define __scst_wait_event_lock(wq_head, condition, lock) \ - (void)___scst_wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, \ - spin_unlock(&lock); \ - schedule(); \ - spin_lock(&lock)) - -#define scst_wait_event_lock(wq_head, condition, lock) \ -do { \ - if (condition) \ - break; \ - __scst_wait_event_lock(wq_head, condition, lock); \ -} while (0) - -#define __scst_wait_event_lock_bh(wq_head, condition, lock) \ - (void)___scst_wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, \ - spin_unlock_bh(&lock); \ - schedule(); \ - spin_lock_bh(&lock)) - -#define scst_wait_event_lock_bh(wq_head, condition, lock) \ -do { \ - if (condition) \ - break; \ - __scst_wait_event_lock_bh(wq_head, condition, lock); \ -} while (0) +#define __scst_wait_event_interruptible_lock(wq_head, condition, lock) \ + ___scst_wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, \ + spin_unlock(&lock); \ + schedule(); \ + spin_lock(&lock)) + +#define scst_wait_event_interruptible_lock(wq_head, condition, lock) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __ret = __scst_wait_event_interruptible_lock(wq_head, \ + condition, lock); \ + __ret; \ +}) #define __scst_wait_event_interruptible_lock_bh(wq_head, condition, lock) \ ___scst_wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, \ @@ -5526,19 +5515,20 @@ do { \ __ret; \ }) +#define __scst_wait_event_interruptible_lock_irq(wq_head, condition, lock) \ + ___scst_wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, \ + spin_unlock_irq(&lock); \ + schedule(); \ + spin_lock_irq(&lock)) -#define __scst_wait_event_lock_irq(wq_head, condition, lock) \ - (void)___scst_wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, \ - spin_unlock_irq(&lock); \ - schedule(); \ - spin_lock_irq(&lock)) - -#define scst_wait_event_lock_irq(wq_head, condition, lock) \ -do { \ - if (condition) \ - break; \ - __scst_wait_event_lock_irq(wq_head, condition, lock); \ -} while (0) +#define scst_wait_event_interruptible_lock_irq(wq_head, condition, lock) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __ret = __scst_wait_event_interruptible_lock_irq(wq_head, \ + condition, lock);\ + __ret; \ +}) #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) const char *scst_get_opcode_name(struct scst_cmd *cmd); diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index e41b3ba..fcf2d90 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -2233,9 +2233,9 @@ static int dev_user_get_next_cmd(struct scst_user_dev *dev, TRACE_ENTRY(); while (1) { - scst_wait_event_lock_irq(dev->udev_cmd_threads.cmd_list_waitQ, - test_cmd_threads(dev, can_block), - dev->udev_cmd_threads.cmd_list_lock); + scst_wait_event_interruptible_lock_irq(dev->udev_cmd_threads.cmd_list_waitQ, + test_cmd_threads(dev, can_block), + dev->udev_cmd_threads.cmd_list_lock); dev_user_process_scst_commands(dev); @@ -4053,8 +4053,8 @@ static int dev_user_cleanup_thread(void *arg) spin_lock(&cleanup_lock); while (!kthread_should_stop()) { - scst_wait_event_lock(cleanup_list_waitQ, test_cleanup_list(), - cleanup_lock); + scst_wait_event_interruptible_lock(cleanup_list_waitQ, test_cleanup_list(), + cleanup_lock); /* * We have to poll devices, because commands can go from SCST diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 1ed7227..f21362d 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -470,8 +470,8 @@ static int sysfs_work_thread_fn(void *arg) while (!kthread_should_stop()) { if (one_time_only && !test_sysfs_work_list()) break; - scst_wait_event_lock(sysfs_work_waitQ, test_sysfs_work_list(), - sysfs_work_lock); + scst_wait_event_interruptible_lock(sysfs_work_waitQ, test_sysfs_work_list(), + sysfs_work_lock); scst_process_sysfs_works(); } spin_unlock(&sysfs_work_lock); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2593cc0..70e212e 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4510,9 +4510,9 @@ int scst_init_thread(void *arg) spin_lock_irq(&scst_init_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_irq(scst_init_cmd_list_waitQ, - test_init_cmd_list(), - scst_init_lock); + scst_wait_event_interruptible_lock_irq(scst_init_cmd_list_waitQ, + test_init_cmd_list(), + scst_init_lock); scst_do_job_init(); } spin_unlock_irq(&scst_init_lock); @@ -6794,9 +6794,9 @@ int scst_tm_thread(void *arg) spin_lock_irq(&scst_mcmd_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_irq(scst_mgmt_cmd_list_waitQ, - test_mgmt_cmd_list(), - scst_mcmd_lock); + scst_wait_event_interruptible_lock_irq(scst_mgmt_cmd_list_waitQ, + test_mgmt_cmd_list(), + scst_mcmd_lock); while (!list_empty(&scst_active_mgmt_cmd_list)) { int rc; @@ -7610,8 +7610,8 @@ int scst_global_mgmt_thread(void *arg) spin_lock_irq(&scst_mgmt_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_irq(scst_mgmt_waitQ, test_mgmt_list(), - scst_mgmt_lock); + scst_wait_event_interruptible_lock_irq(scst_mgmt_waitQ, test_mgmt_list(), + scst_mgmt_lock); while (!list_empty(&scst_sess_init_list)) { sess = list_first_entry(&scst_sess_init_list, |
From: Gleb C. <lna...@ya...> - 2023-06-27 07:32:04
|
Commit: 1d6ab4a GitHub URL: https://github.com/SCST-project/scst/commit/1d6ab4aa72b666c62fc4cd851b6f5581f7d23d11 Author: Gleb Chesnokov Date: 2023-06-27T10:31:33+03:00 Log Message: ----------- nightly build: Update kernel versions Another kernel versions update following the 6.4 release. Modified Paths: -------------- nightly/conf/nightly.conf | 51 ++++++++------- 1 file changed, 27 insertions(+), 24 deletions(-) =================================================================== diff --git a/nightly/conf/nightly.conf b/nightly/conf/nightly.conf index dec3437..5246074 100644 --- a/nightly/conf/nightly.conf +++ b/nightly/conf/nightly.conf @@ -3,37 +3,38 @@ ABT_DETAILS="x86_64" ABT_JOBS=5 ABT_KERNELS=" \ -6.3 \ -6.2.13-nc \ -6.1.26-nc \ +6.4 \ +6.3.9-nc \ +6.2.16-nc \ +6.1.35-nc \ 6.0.19-nc \ 5.19.17-nc \ 5.18.19-nc \ 5.17.15-nc \ 5.16.20-nc \ -5.15.109-nc \ +5.15.118-nc \ 5.14.21-nc \ 5.13.19-nc \ 5.12.19-nc \ 5.11.22-nc \ -5.10.179-nc \ +5.10.185-nc \ 5.9.16-nc \ 5.8.18-nc \ 5.7.19-nc \ 5.6.19-nc \ 5.5.19-nc \ -5.4.242-nc \ +5.4.248-nc \ 5.3.18-nc \ 5.2.21-nc \ 5.1.21-nc \ 5.0.21-nc \ 4.20.17-nc \ -4.19.282-nc \ +4.19.287-nc \ 4.18.20-nc \ 4.17.19-nc \ 4.16.18-nc \ 4.15.18-nc \ -4.14.314-nc \ +4.14.319-nc \ 4.13.16-nc \ 4.12.14-nc \ 4.11.12-nc \ @@ -58,8 +59,10 @@ ABT_KERNELS=" \ 3.12.74-nc \ 3.11.10-nc \ 3.10.108-nc \ +5.14.0-284.11.1.el9_2^AlmaLinux^9.2-nc \ 5.14.0-162.23.1.el9_1^AlmaLinux^9.1-nc \ 5.14.0-70.30.1.el9_0^AlmaLinux^9.0-nc \ +4.18.0-477.13.1.el8_8^AlmaLinux^8.8-nc \ 4.18.0-425.19.2.el8_7^AlmaLinux^8.7-nc \ 4.18.0-372.32.1.el8_6^AlmaLinux^8.6-nc \ 4.18.0-348.2.1.el8_5^CentOS^8.5.2111-nc \ @@ -68,20 +71,20 @@ ABT_KERNELS=" \ 4.18.0-193.28.1.el8_2^CentOS^8.2.2004-nc \ 4.18.0-147.8.1.el8_1^CentOS^8.1.1911-nc \ 4.18.0-80.11.2.el8_0^CentOS^8.0.1905-nc \ -3.10.0-1160.88.1.el7^CentOS^7.9.2009-nc \ -3.10.0-1127.19.1.el7^CentOS^7.8.2003-nc \ -3.10.0-1062.18.1.el7^CentOS^7.7.1908-nc \ -3.10.0-957.27.2.el7^CentOS^7.6.1810-nc \ -3.10.0-862.14.4.el7^CentOS^7.5.1804-nc \ -5.15.0-8.91.4.1.el9uek^UEK^9-nc \ -5.15.0-8.91.4.1.el8uek^UEK^8-nc \ -5.4.17-2136.318.7.1.el8uek^UEK^8-nc \ -5.4.17-2102.206.1.el8uek^UEK^8-nc \ -5.4.17-2036.104.5.el8uek^UEK^8-nc \ -5.4.17-2011.7.4.el8uek^UEK^8-nc \ -5.4.17-2136.318.7.1.el7uek^UEK^7-nc \ -5.4.17-2102.206.1.el7uek^UEK^7-nc \ -5.4.17-2036.104.5.el7uek^UEK^7-nc \ -5.4.17-2011.7.4.el7uek^UEK^7-nc \ -4.1.12-124.48.6.el6uek^UEK^6-nc \ +3.10.0-1160.90.1.el7^CentOS^7.9.2009-nc \ +3.10.0-1127.19.1.el7^CentOS^7.8.2003-nc \ +3.10.0-1062.18.1.el7^CentOS^7.7.1908-nc \ +3.10.0-957.27.2.el7^CentOS^7.6.1810-nc \ +3.10.0-862.14.4.el7^CentOS^7.5.1804-nc \ +5.15.0-102.110.5.1.el9uek^UEK^9-nc \ +5.15.0-102.110.5.1.el8uek^UEK^8-nc \ +5.4.17-2136.320.7.1.el8uek^UEK^8-nc \ +5.4.17-2102.206.1.el8uek^UEK^8-nc \ +5.4.17-2036.104.5.el8uek^UEK^8-nc \ +5.4.17-2011.7.4.el8uek^UEK^8-nc \ +5.4.17-2136.320.7.1.el7uek^UEK^7-nc \ +5.4.17-2102.206.1.el7uek^UEK^7-nc \ +5.4.17-2036.104.5.el7uek^UEK^7-nc \ +5.4.17-2011.7.4.el7uek^UEK^7-nc \ +4.1.12-124.48.6.el6uek^UEK^6-nc \ " |
From: Gleb C. <lna...@ya...> - 2023-06-20 06:55:28
|
Commit: be1574d GitHub URL: https://github.com/SCST-project/scst/commit/be1574d80e0ff51c74bb05f4a1996e1316df78b5 Author: Gleb Chesnokov Date: 2023-06-20T09:53:50+03:00 Log Message: ----------- scst_lib: Make __scst_ext_blocking_done() static Since __scst_ext_blocking_done() is only called from inside scst_lib.c, declare that function static. This patch doesn't change any functionality. Modified Paths: -------------- scst/src/scst_lib.c | 13 ++++++++----- scst/src/scst_priv.h | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) =================================================================== diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 897d526..23149b6 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -14854,14 +14854,18 @@ static inline void scst_ext_blocker_put(struct scst_ext_blocker *b) } /* Must be called under dev_lock and BHs off. Might release it, then reacquire. */ -void __scst_ext_blocking_done(struct scst_device *dev) +static void __scst_ext_blocking_done(struct scst_device *dev) + __releases(&dev->dev_lock) + __acquires(&dev->dev_lock) { bool stop; TRACE_ENTRY(); + lockdep_assert_held(&dev->dev_lock); + TRACE_BLOCK("Notifying ext blockers for dev %s (ext_blocks_cnt %d)", - dev->virt_name, dev->ext_blocks_cnt); + dev->virt_name, dev->ext_blocks_cnt); stop = list_empty(&dev->ext_blockers_list); while (!stop) { @@ -14870,8 +14874,8 @@ void __scst_ext_blocking_done(struct scst_device *dev) b = list_first_entry(&dev->ext_blockers_list, typeof(*b), ext_blockers_list_entry); - TRACE_DBG("Notifying async ext blocker %p (cnt %d)", b, - dev->ext_blocks_cnt); + TRACE_DBG("Notifying async ext blocker %p (cnt %d)", + b, dev->ext_blocks_cnt); list_del(&b->ext_blockers_list_entry); @@ -14890,7 +14894,6 @@ void __scst_ext_blocking_done(struct scst_device *dev) } TRACE_EXIT(); - return; } static void scst_ext_blocking_done_fn(struct work_struct *work) diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 641ae5b..c9c0d3f 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -615,7 +615,6 @@ int scst_sync_ext_block_dev(struct scst_device *dev); int scst_ext_block_dev(struct scst_device *dev, ext_blocker_done_fn_t done_fn, const void *priv, size_t priv_len, bool block_stpg); void scst_ext_unblock_dev(struct scst_device *dev, bool stpg); -void __scst_ext_blocking_done(struct scst_device *dev); void scst_ext_blocking_done(struct scst_device *dev); int scst_get_suspend_count(void); |