drivers/scsi/libiscsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libiscsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libiscsi.c- Extension
.c- Size
- 107614 bytes
- Lines
- 3938
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/kfifo.hlinux/delay.hlinux/log2.hlinux/slab.hlinux/sched/signal.hlinux/module.hlinux/unaligned.hnet/tcp.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_eh.hscsi/scsi_tcq.hscsi/scsi_host.hscsi/scsi.hscsi/iscsi_proto.hscsi/scsi_transport.hscsi/scsi_transport_iscsi.hscsi/libiscsi.htrace/events/iscsi.h
Detected Declarations
function iscsi_conn_queue_xmitfunction iscsi_conn_queue_recvfunction __iscsi_update_cmdsnfunction iscsi_update_cmdsnfunction iscsi_prep_data_out_pdufunction iscsi_add_hdrfunction iscsi_prep_ecdb_ahsfunction iscsi_check_tmf_restrictionsfunction iscsi_prep_scsi_cmd_pdufunction iscsi_free_taskfunction iscsi_get_taskfunction __iscsi_put_taskfunction iscsi_put_taskfunction iscsi_complete_taskfunction iscsi_complete_scsi_taskfunction cleanup_queued_taskfunction __fail_scsi_taskfunction fail_scsi_taskfunction iscsi_prep_mgmt_taskfunction iscsi_alloc_mgmt_taskfunction iscsi_send_mgmt_taskfunction __iscsi_conn_send_pdufunction iscsi_conn_send_pdufunction iscsi_scsi_cmd_rspfunction iscsi_data_in_rspfunction iscsi_tmf_rspfunction iscsi_send_nopoutfunction iscsi_nop_out_rspfunction iscsi_handle_rejectfunction __iscsi_complete_pdufunction iscsi_complete_pdufunction iscsi_verify_ittfunction iscsi_session_failurefunction iscsi_set_conn_failedfunction iscsi_conn_failurefunction iscsi_check_cmdsn_window_closedfunction iscsi_xmit_taskfunction iscsi_requeue_taskfunction iscsi_data_xmitfunction iscsi_xmitworkerfunction iscsi_queuecommandfunction iscsi_target_allocfunction iscsi_tmf_timedoutfunction iscsi_exec_task_mgmt_fnfunction fail_scsi_tasksfunction iscsi_suspend_queuefunction iscsi_suspend_txfunction iscsi_start_tx
Annotated Snippet
if (opcode != ISCSI_OP_SCSI_DATA_OUT) {
iscsi_session_printk(KERN_INFO, session,
"task [op %x itt 0x%x/0x%x] rejected.\n",
opcode, task->itt, task->hdr_itt);
return -EACCES;
}
/*
* And also all data-out PDUs in response to R2T
* if fast_abort is set.
*/
if (session->fast_abort) {
iscsi_session_printk(KERN_INFO, session,
"task [op %x itt 0x%x/0x%x] fast abort.\n",
opcode, task->itt, task->hdr_itt);
return -EACCES;
}
break;
case ISCSI_TM_FUNC_ABORT_TASK:
/*
* the caller has already checked if the task
* they want to abort was in the pending queue so if
* we are here the cmd pdu has gone out already, and
* we will only hit this for data-outs
*/
if (opcode == ISCSI_OP_SCSI_DATA_OUT &&
task->hdr_itt == tmf->rtt) {
ISCSI_DBG_SESSION(session,
"Preventing task %x/%x from sending "
"data-out due to abort task in "
"progress\n", task->itt,
task->hdr_itt);
return -EACCES;
}
break;
}
return 0;
}
/**
* iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu
* @task: iscsi task
*
* Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set
* fields like dlength or final based on how much data it sends
*/
static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
{
struct iscsi_conn *conn = task->conn;
struct iscsi_session *session = conn->session;
struct scsi_cmnd *sc = task->sc;
struct iscsi_scsi_req *hdr;
unsigned hdrlength, cmd_len, transfer_length;
itt_t itt;
int rc;
rc = iscsi_check_tmf_restrictions(task, ISCSI_OP_SCSI_CMD);
if (rc)
return rc;
if (conn->session->tt->alloc_pdu) {
rc = conn->session->tt->alloc_pdu(task, ISCSI_OP_SCSI_CMD);
if (rc)
return rc;
}
hdr = (struct iscsi_scsi_req *)task->hdr;
itt = hdr->itt;
memset(hdr, 0, sizeof(*hdr));
if (session->tt->parse_pdu_itt)
hdr->itt = task->hdr_itt = itt;
else
hdr->itt = task->hdr_itt = build_itt(task->itt,
task->conn->session->age);
task->hdr_len = 0;
rc = iscsi_add_hdr(task, sizeof(*hdr));
if (rc)
return rc;
hdr->opcode = ISCSI_OP_SCSI_CMD;
hdr->flags = ISCSI_ATTR_SIMPLE;
int_to_scsilun(sc->device->lun, &hdr->lun);
task->lun = hdr->lun;
hdr->exp_statsn = cpu_to_be32(conn->exp_statsn);
cmd_len = sc->cmd_len;
if (cmd_len < ISCSI_CDB_SIZE)
memset(&hdr->cdb[cmd_len], 0, ISCSI_CDB_SIZE - cmd_len);
else if (cmd_len > ISCSI_CDB_SIZE) {
rc = iscsi_prep_ecdb_ahs(task);
if (rc)
return rc;
Annotation
- Immediate include surface: `linux/types.h`, `linux/kfifo.h`, `linux/delay.h`, `linux/log2.h`, `linux/slab.h`, `linux/sched/signal.h`, `linux/module.h`, `linux/unaligned.h`.
- Detected declarations: `function iscsi_conn_queue_xmit`, `function iscsi_conn_queue_recv`, `function __iscsi_update_cmdsn`, `function iscsi_update_cmdsn`, `function iscsi_prep_data_out_pdu`, `function iscsi_add_hdr`, `function iscsi_prep_ecdb_ahs`, `function iscsi_check_tmf_restrictions`, `function iscsi_prep_scsi_cmd_pdu`, `function iscsi_free_task`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.