Add a new helper function iscsi_allocate_pdu_with_itt_flags()

This function can allocate a new pdu using a specific itt value
and specific flags instead of using the defaults of, next iff, no flags set.

This can be used when we need to allocate additional PDUs in a chain,
for commands that span across multiple PDUs and where all need to keep
the same itt value.

For example
   ->WRITE10 cdb
   ->DATAOUT
   -<RESPONSE

Here the DATAOUT PDU belongs to the same task that was started by write10
so it need to use the same itt value.
This commit is contained in:
Ronnie Sahlberg
2011-01-02 17:49:12 +11:00
parent 1569624fd2
commit 9cd03ca559
2 changed files with 18 additions and 5 deletions

View File

@@ -175,6 +175,11 @@ void iscsi_free_scsi_cbdata(struct iscsi_scsi_cbdata *scsi_cbdata);
struct iscsi_pdu *iscsi_allocate_pdu(struct iscsi_context *iscsi,
enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode);
struct iscsi_pdu *iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi,
enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode,
uint32_t itt,
uint32_t flags);
void iscsi_free_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
void iscsi_pdu_set_pduflags(struct iscsi_pdu *pdu, unsigned char flags);
void iscsi_pdu_set_immediate(struct iscsi_pdu *pdu);

View File

@@ -26,8 +26,8 @@
#include "slist.h"
struct iscsi_pdu *
iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode)
iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode, uint32_t itt, uint32_t flags)
{
struct iscsi_pdu *pdu;
@@ -58,14 +58,22 @@ iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
}
/* itt */
*(uint32_t *)&pdu->outdata.data[16] = htonl(iscsi->itt);
pdu->itt = iscsi->itt;
iscsi_pdu_set_itt(pdu, itt);
pdu->itt = itt;
iscsi->itt++;
/* flags */
pdu->flags = flags;
return pdu;
}
struct iscsi_pdu *
iscsi_allocate_pdu(struct iscsi_context *iscsi, enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode)
{
return iscsi_allocate_pdu_with_itt_flags(iscsi, opcode, response_opcode, iscsi->itt++, 0);
}
void
iscsi_free_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
{