Libiscsi: Changing header iscsi_in_pdu
socket: need to malloc hdr include/iscsi-private: changing iscsi_in_pdu hdr to char* instead of static array for more convinient iser pdu creation. To use iscsi_in_pdu in iSER without making a copy of it we need to change hdr to pointer from static array, Because of that, iscsi_tcp flow need to do szmalloc (small zero malloc) hdr when creating new iscsi_in_pdu. iscsi_in_pdu is being malloced once per each received pdu. This change is reducing iscsi_in_pdu struct size but adding extra allocation of the same size we reduced from the struct. Signed-off-by: Roy Shterman <roysh@mellanox.com>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
2671e10565
commit
bc64420bad
@@ -55,7 +55,7 @@ struct iscsi_in_pdu {
|
|||||||
struct iscsi_in_pdu *next;
|
struct iscsi_in_pdu *next;
|
||||||
|
|
||||||
long long hdr_pos;
|
long long hdr_pos;
|
||||||
unsigned char hdr[ISCSI_RAW_HEADER_SIZE + ISCSI_DIGEST_SIZE];
|
unsigned char *hdr;
|
||||||
|
|
||||||
long long data_pos;
|
long long data_pos;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|||||||
@@ -549,6 +549,7 @@ iscsi_read_from_socket(struct iscsi_context *iscsi)
|
|||||||
|
|
||||||
if (iscsi->incoming == NULL) {
|
if (iscsi->incoming == NULL) {
|
||||||
iscsi->incoming = iscsi_szmalloc(iscsi, sizeof(struct iscsi_in_pdu));
|
iscsi->incoming = iscsi_szmalloc(iscsi, sizeof(struct iscsi_in_pdu));
|
||||||
|
iscsi->incoming->hdr = iscsi_szmalloc(iscsi, ISCSI_RAW_HEADER_SIZE + ISCSI_DIGEST_SIZE);
|
||||||
if (iscsi->incoming == NULL) {
|
if (iscsi->incoming == NULL) {
|
||||||
iscsi_set_error(iscsi, "Out-of-memory: failed to malloc iscsi_in_pdu");
|
iscsi_set_error(iscsi, "Out-of-memory: failed to malloc iscsi_in_pdu");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -951,6 +952,7 @@ static int iscsi_tcp_queue_pdu(struct iscsi_context *iscsi,
|
|||||||
void
|
void
|
||||||
iscsi_free_iscsi_in_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
iscsi_free_iscsi_in_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||||
{
|
{
|
||||||
|
iscsi_free(iscsi, in->hdr);
|
||||||
iscsi_free(iscsi, in->data);
|
iscsi_free(iscsi, in->data);
|
||||||
in->data=NULL;
|
in->data=NULL;
|
||||||
iscsi_sfree(iscsi, in);
|
iscsi_sfree(iscsi, in);
|
||||||
|
|||||||
Reference in New Issue
Block a user