Skip to content

Commit

Permalink
handle ITT
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Oct 12, 2024
1 parent 5ea29cd commit 09222b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions iscsi-pdu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,18 @@ std::optional<iscsi_response_set> iscsi_pdu_scsi_cmd::get_response(scsi *const s
DOLOG(logging::ll_debug, "iscsi_pdu_scsi_cmd::get_response", ses->get_endpoint_name(), "sending R2T with %zu sense bytes", scsi_reply.value().sense_data.size());

uint32_t TTT = 0;
if (my_getrandom(&TTT) == false) {
uint32_t ITT = get_Itasktag();
if (ITT != 0xffffffff) {
DOLOG(logging::ll_debug, "iscsi_pdu_scsi_cmd::get_response", ses->get_endpoint_name(), "has an ITT: %08x", ITT);
TTT = ITT;
}
else if (my_getrandom(&TTT) == false) {
DOLOG(logging::ll_debug, "iscsi_pdu_scsi_cmd::get_response", ses->get_endpoint_name(), "my_getrandom failed");
ok = false;
}

ses->init_r2t_session(scsi_reply.value().r2t, this, TTT);
DOLOG(logging::ll_debug, "iscsi_pdu_scsi_cmd::get_response", ses->get_endpoint_name(), "TTT is %08x", TTT);
DOLOG(logging::ll_debug, "iscsi_pdu_scsi_cmd::get_response", ses->get_endpoint_name(), "ITT/TTT is %08x", TTT);

if (temp->set(*this, TTT, scsi_reply.value().r2t.bytes_done, scsi_reply.value().r2t.bytes_left) == false) {
ok = false;
Expand Down
8 changes: 6 additions & 2 deletions scsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,12 @@ std::optional<scsi_response> scsi::send(const uint64_t lun, const uint8_t *const
else {
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE without data");

if (transfer_length)
response.type = ir_r2t; // allow R2T packets to come in
if (transfer_length) {
response.type = ir_r2t; // allow R2T packets to come in
response.r2t.buffer_lba = lba;
response.r2t.bytes_left = transfer_length * backend_block_size;
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "starting R2T with %u bytes left (LBA: %" PRIu64 ")", response.r2t.bytes_left, response.r2t.buffer_lba);
}
else {
response.type = ir_empty_sense;
DOLOG(logging::ll_debug, "scsi::send", lun_identifier, "WRITE with 0 transfer_length");
Expand Down

0 comments on commit 09222b6

Please sign in to comment.