[openib-general] [PATCH] iser: cleanup and re org

Or Gerlitz ogerlitz at voltaire.com
Tue Jan 31 04:16:34 PST 2006


commited to r5235

removed iser_task.c & iscsi_iser_cmd_task->task_lock, post_send_count and
sent fields. some re org of the dma-map/mem-reg and mem-unreg/dma-unmap
flow for ctasks. removed iser_regd_buf->data_cache and some more cleanups.

Signed-off-by: Or Gerlitz <ogerlitz at voltaire.com>

 Makefile         |    1
 iscsi_iser.c     |    4
 iscsi_iser.h     |   30 ++-----
 iser_initiator.c |  223 ++++++++++++++++++++++++++-----------------------------
 iser_memory.c    |    1
 iser_task.c      |  130 --------------------------------
 6 files changed, 120 insertions(+), 269 deletions(-)


Index: ulp/iser/iscsi_iser.h
===================================================================
--- ulp/iser/iscsi_iser.h	(revision 5228)
+++ ulp/iser/iscsi_iser.h	(revision 5235)
@@ -184,7 +184,6 @@ struct iser_mem_reg {
 
 struct iser_regd_buf {
 	struct iser_mem_reg reg; /* memory registration info */
-	kmem_cache_t *data_cache; /* data allocated from here, when set */
 	void *virt_addr;
 
 	struct iser_adaptor *p_adaptor;	   /* p_adaptor->device for dma_unmap */
@@ -198,14 +197,6 @@ struct iser_regd_buf {
 
 #define MAX_REGD_BUF_VECTOR_LEN	2
 
-enum iser_dto_type {
-	ISER_DTO_RCV = 0,	/* Receive buffer */
-	ISER_DTO_SEND,		/* Send buffer */
-	ISER_DTO_PASSIVE,	/* Passive side of a remote RDMA op */
-
-	ISER_DTO_TYPES_NUM
-};
-
 struct iser_dto {
 	struct iscsi_iser_cmd_task *p_task;
 	struct iscsi_iser_conn     *p_conn;
@@ -327,13 +318,12 @@ struct iscsi_iser_cmd_task {
 	struct iscsi_cmd	*hdr;			/* iSCSI PDU header points to desc->iscsi_hdr */
         int			itt;			/* this ITT */
 	struct iscsi_iser_conn  *conn;
-	spinlock_t 		task_lock;
+
 	enum iser_task_status 	status;
 	int                     command_sent;
 
 	int			datasn;			/* DataSN */
 	uint32_t		unsol_datasn;
-	int			sent;
 
 	int			imm_count;		/* imm-data (bytes)   */
 	int			unsol_count;		/* unsolicited (bytes)*/
@@ -345,8 +335,6 @@ struct iscsi_iser_cmd_task {
 	int			total_length;
 	struct iscsi_iser_mgmt_task	*mtask;			/* tmf mtask in progr */
 
-	unsigned int post_send_count; /* posted send buffers pending completion */
-
 	int dir[ISER_DIRS_NUM];	/* set if direction used */
 	struct iser_regd_buf rdma_regd[ISER_DIRS_NUM];	/* regd rdma buffer */
 	unsigned long data_len[ISER_DIRS_NUM];	/* total data length */
@@ -525,12 +513,21 @@ void iser_dto_send_create(struct iscsi_i
 
 
 /* iser_initiator.h */
+int iser_dma_map_task_data(struct iscsi_iser_cmd_task *p_iser_task,
+			   struct iser_data_buf       *p_data,
+			   enum   iser_data_dir       iser_dir,
+			   enum   dma_data_direction  dma_dir);
+
+void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task);
 
 void iser_rcv_completion(struct iser_desc *p_desc,
 			     unsigned long dto_xfer_len);
 
 void iser_snd_completion(struct iser_desc *p_desc);
 
+void iser_ctask_rdma_init(struct iscsi_iser_cmd_task *p_iser_task);
+void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *p_iser_task);
+
 /* iser_memory.h */
 
 /* regd_buf */
@@ -576,15 +573,8 @@ int iser_page_vec_build(struct iser_data
 			      int count);
 
 
-/* iser_task.h */
 
-void iser_task_init_lowpart(struct iscsi_iser_cmd_task *p_iser_task);
-void iser_task_finalize_lowpart(struct iscsi_iser_cmd_task *iser_task);
 
-void iser_task_post_send_count_inc(struct iscsi_iser_cmd_task *p_iser_task);
-int iser_task_post_send_count_dec_and_test(struct iscsi_iser_cmd_task *p_iser_task);
-void iser_task_set_status(struct iscsi_iser_cmd_task *p_iser_task,
-			  enum iser_task_status status);
 
 /* iser_verbs.h */
 /* ---------------------------------------------------------------------
Index: ulp/iser/iser_initiator.c
===================================================================
--- ulp/iser/iser_initiator.c	(revision 5228)
+++ ulp/iser/iser_initiator.c	(revision 5235)
@@ -40,7 +40,63 @@
 
 #include "iscsi_iser.h"
 
-static void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task);
+int iser_dma_map_task_data(struct iscsi_iser_cmd_task *p_iser_task,
+			   struct iser_data_buf       *p_data,
+			   enum   iser_data_dir       iser_dir,
+			   enum   dma_data_direction  dma_dir)
+{
+	struct device *dma_device;
+	dma_addr_t     dma_addr;
+	int            dma_nents;
+
+	p_iser_task->dir[iser_dir] = 1;
+	dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
+
+	if (p_data->type == ISER_BUF_TYPE_SINGLE) {
+		p_iser_task->data_len[iser_dir] = p_data->size;
+		dma_addr = dma_map_single(dma_device,p_data->p_buf, p_data->size,
+					  dma_dir);
+		if (dma_mapping_error(dma_addr)) {
+			iser_err("dma_map_single failed at %p\n", p_data->p_buf);
+			return -EINVAL;
+		}
+		p_data->dma_addr = dma_addr;
+	} else {
+		dma_nents = dma_map_sg(dma_device, p_data->p_buf, p_data->size,
+				       dma_dir);
+		if (dma_nents == 0) {
+			iser_err("dma_map_sg failed!!!\n");
+			return -EINVAL;
+		}
+		p_data->dma_nents = dma_nents;
+		p_iser_task->data_len[iser_dir] = iser_sg_size(p_data);
+	}
+	return 0;
+}
+
+void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task)
+{
+	struct device  *dma_device;
+	struct iser_data_buf *p_data;
+
+	dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
+
+	p_data = &p_iser_task->data[ISER_DIR_IN];
+	if (p_data->p_buf != NULL && p_data->type == ISER_BUF_TYPE_SCATTERLIST)
+		dma_unmap_sg(dma_device, p_data->p_buf, p_data->size,
+			     DMA_FROM_DEVICE);
+	else if (p_data->p_buf != NULL) /* p_data->type == ISER_BUF_TYPE_SINGLE */
+		dma_unmap_single(dma_device, p_data->dma_addr, p_data->size,
+				 DMA_FROM_DEVICE);
+
+	p_data = &p_iser_task->data[ISER_DIR_OUT];
+	if (p_data->p_buf != NULL && p_data->type == ISER_BUF_TYPE_SCATTERLIST)
+		dma_unmap_sg(dma_device, p_data->p_buf, p_data->size,
+			     DMA_TO_DEVICE);
+	else if (p_data->p_buf != NULL) /* p_data->type == ISER_BUF_TYPE_SINGLE */
+		dma_unmap_single(dma_device, p_data->dma_addr, p_data->size,
+				 DMA_TO_DEVICE);
+}
 
 /**
  * iser_reg_rdma_mem - Registers memory
@@ -74,7 +130,6 @@ static int iser_reg_rdma_mem(struct iscs
 		int aligned_len;
 
 		iser_dbg("converting sg to page_vec\n");
-		/* DMA_MAP: use task->data[IN/OUT] to check alignment */
 		aligned_len = iser_data_buf_aligned_len(p_mem,0);
 		if (aligned_len == p_mem->size)
 			cnt_to_reg = aligned_len;
@@ -121,35 +176,15 @@ static int iser_prepare_read_cmd(struct 
 {
 	struct iser_regd_buf *p_regd_buf;
 	int err;
-	dma_addr_t dma_addr;
-	int dma_nents;
-	struct device *dma_device;
 	struct iser_hdr *hdr = &p_iser_task->desc.iser_header;
 
-	p_iser_task->dir[ISER_DIR_IN] = 1;
-	dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
+	err = iser_dma_map_task_data(p_iser_task,
+				     buf_in,
+				     ISER_DIR_IN,
+				     DMA_FROM_DEVICE);
+	if(err)
+		return err;
 
-	if (buf_in->type == ISER_BUF_TYPE_SINGLE) {
-		p_iser_task->data_len[ISER_DIR_IN] = buf_in->size;
-		/* DMA_MAP: map single task->data[ISER_DIR_IN], store dma_addr */
-		dma_addr = dma_map_single(dma_device,buf_in->p_buf, buf_in->size,
-					  DMA_FROM_DEVICE);
-		if (dma_mapping_error(dma_addr)) {
-			iser_err("dma_map_single failed at %p\n", buf_in->p_buf);
-			return -EINVAL;
-		}
-		buf_in->dma_addr = dma_addr;
-	} else {
-		/* DMA_MAP: map sg task->data[ISER_DIR_IN], store in .dma_nents */
-		dma_nents = dma_map_sg(dma_device, buf_in->p_buf, buf_in->size,
-				       DMA_FROM_DEVICE);
-		if (dma_nents == 0) {
-			iser_err("dma_map_sg failed!!!\n");
-			return -EINVAL;
-		}
-		buf_in->dma_nents = dma_nents;
-		p_iser_task->data_len[ISER_DIR_IN] = iser_sg_size(buf_in);
-	}
 	if (edtl > p_iser_task->data_len[ISER_DIR_IN]) {
 		iser_err("Total data length: %ld, less than EDTL: "
 			 "%d, in READ cmd BHS itt: %d, p_conn: 0x%p\n",
@@ -192,38 +227,16 @@ iser_prepare_write_cmd(struct iscsi_iser
 {
 	struct iser_regd_buf *p_regd_buf;
 	int err;
-	dma_addr_t dma_addr;
-	int dma_nents;
-	struct device *dma_device;
 	struct iser_dto *p_send_dto = &p_iser_task->desc.dto;
 	struct iser_hdr *hdr = &p_iser_task->desc.iser_header;
 
-	p_iser_task->dir[ISER_DIR_OUT] = 1;
-	dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
-
-	iser_dbg("buf_out %p buf_out->type is %d\n", buf_out, buf_out->type);
+	err = iser_dma_map_task_data(p_iser_task,
+				     buf_out,
+				     ISER_DIR_OUT,
+				     DMA_TO_DEVICE);
+	if(err)
+		return err;
 
-	if (buf_out->type == ISER_BUF_TYPE_SINGLE) {
-		p_iser_task->data_len[ISER_DIR_OUT] = buf_out->size;
-		/* DMA_MAP: map single task->data[ISER_DIR_OUT], store dma_addr */
-		dma_addr = dma_map_single(dma_device, buf_out->p_buf, buf_out->size,
-					  DMA_TO_DEVICE);
-		if (dma_mapping_error(dma_addr)) {
-			iser_err("dma_map_single failed at %p\n", buf_out->p_buf);
-			return -EINVAL;
-		}
-		buf_out->dma_addr = dma_addr;
-	} else {
-		/* DMA_MAP: map sg task->data[ISER_DIR_OUT], store dma_nents */
-		dma_nents = dma_map_sg(dma_device, buf_out->p_buf, buf_out->size,
-				       DMA_TO_DEVICE);
-		if (dma_nents == 0) {
-			iser_err("dma_map_sg failed!!!\n");
-			return -EINVAL;
-		}
-		buf_out->dma_nents = dma_nents;
-		p_iser_task->data_len[ISER_DIR_OUT] = iser_sg_size(buf_out);
-	}
 	if (edtl > p_iser_task->data_len[ISER_DIR_OUT]) {
 		iser_err("Total data length: %ld, less than EDTL: %d, "
 			 "in WRITE cmd BHS itt: %d, p_conn: 0x%p\n",
@@ -306,7 +319,7 @@ int iser_send_command(struct iscsi_iser_
 	edtl = ntohl(hdr->data_length);
 
 	/* MERGE_CHANGE - temporal move it up */
-	iser_task_init_lowpart(p_ctask);
+
 
 	/* build the tx desc regd header and add it to the tx desc dto */
 	p_ctask->desc.type = ISCSI_TX_SCSI_COMMAND;
@@ -337,7 +350,6 @@ int iser_send_command(struct iscsi_iser_
 		if (err) goto send_command_error;
 	}
 
-	/* DMA_MAP: safe to dma_map now - map and flush the cache */
 	iser_reg_single(p_iser_conn->ib_conn->p_adaptor,
 			p_send_dto->regd[0], DMA_TO_DEVICE);
 
@@ -347,16 +359,11 @@ int iser_send_command(struct iscsi_iser_
 		goto send_command_error;
 	}
 
-	iser_task_set_status(p_ctask,ISER_TASK_STATUS_STARTED);
-	iser_task_post_send_count_inc(p_ctask);
+	p_ctask->status = ISER_TASK_STATUS_STARTED;
 
 	err = iser_start_send(&p_ctask->desc);
-	if (err) {
-		iser_task_post_send_count_dec_and_test(p_ctask);
-		goto send_command_error;
-	}
-
-	return 0;
+	if (!err)
+		return 0;
 
 send_command_error:
 	if (p_send_dto != NULL) {
@@ -415,7 +422,6 @@ int iser_send_data_out(struct iscsi_iser
 	p_send_dto->p_task = p_ctask;
 	iser_dto_send_create(p_iser_conn, tx_desc);
 
-	/* DMA_MAP: safe to dma_map now - map and flush the cache */
 	iser_reg_single(p_iser_conn->ib_conn->p_adaptor,
 			p_send_dto->regd[0], DMA_TO_DEVICE);
 
@@ -436,15 +442,10 @@ int iser_send_data_out(struct iscsi_iser
 	iser_dbg("data-out itt: %d, offset: %ld, sz: %ld\n",
 		 itt, buf_offset, data_seg_len);
 
-	iser_task_post_send_count_inc(p_ctask);
 
 	err = iser_start_send(tx_desc);
-	if (err) {
-		iser_task_post_send_count_dec_and_test(p_ctask);
-		goto send_data_out_error;
-	}
-
-	return 0;
+	if (!err)
+		return 0;
 
 send_data_out_error:
 	if (p_send_dto != NULL)
@@ -487,7 +488,6 @@ int iser_send_control(struct iscsi_iser_
 
 	p_iser_adaptor = p_iser_conn->ib_conn->p_adaptor;
 
-	/* DMA_MAP: safe to dma_map now - map and flush the cache */
 	iser_reg_single(p_iser_adaptor, p_send_dto->regd[0], DMA_TO_DEVICE);
 
 	itt = ntohl(p_mtask->hdr->itt);
@@ -561,7 +561,6 @@ void iser_rcv_completion(struct iser_des
 	int     rc, rx_data_size = 0;
 	unsigned int itt;
 	unsigned char opcode;
-	int no_more_task_sends = 0;
 
 	p_hdr = &p_rx_desc->iscsi_header;
 
@@ -602,11 +601,8 @@ void iser_rcv_completion(struct iser_des
 				 * sglist, anyway dma_unmap and free the copy */
 				iser_finalize_rdma_unaligned_sg(p_iser_task);
 
-			/* DMA_MAP: unmap according to task->data[dir].type/etc */
-			iser_dma_unmap_task_data(p_iser_task);
-			p_dto->p_task = p_iser_task;
-			iser_task_set_status(p_iser_task,
-					     ISER_TASK_STATUS_COMPLETED);
+			p_iser_task->status = ISER_TASK_STATUS_COMPLETED;
+			iser_ctask_rdma_finalize(p_iser_task);
 		}
 	}
 
@@ -614,18 +610,6 @@ void iser_rcv_completion(struct iser_des
 	if(rc)
 		iscsi_iser_conn_failure(p_iser_conn, rc);
 
-	if(p_iser_task != NULL) {
-		spin_lock(&p_iser_task->task_lock);
-		if(p_iser_task->post_send_count == 0)
-			no_more_task_sends = 1;
-		spin_unlock(&p_iser_task->task_lock);
-		if(no_more_task_sends)
-			iser_task_finalize_lowpart(p_iser_task);
-		else
-			iser_err("can't free iSER task:0x%p more %d sends\n",
-				 p_iser_task, p_iser_task->post_send_count);
-	}
-
 	iser_dto_free(p_dto);
 	kfree(p_rx_desc->data);
 	kmem_cache_free(ig.desc_cache, p_rx_desc);
@@ -658,33 +642,42 @@ void iser_snd_completion(struct iser_des
 		schedule_work(&p_iser_conn->xmitwork);
 	}
 	spin_unlock(&p_iser_conn->lock);
+}
+
+void iser_ctask_rdma_init(struct iscsi_iser_cmd_task *p_iser_task)
+
+{
+	p_iser_task->status = ISER_TASK_STATUS_INIT;
 
-	/* if the last sent PDU of the task, task can be freed */
-	if (p_dto->p_task != NULL &&
-	    iser_task_post_send_count_dec_and_test(p_dto->p_task))
-		iser_task_finalize_lowpart(p_dto->p_task);
+	p_iser_task->dir[ISER_DIR_IN] = 0;
+	p_iser_task->dir[ISER_DIR_OUT] = 0;
+
+	p_iser_task->data_len[ISER_DIR_IN] = 0;
+	p_iser_task->data_len[ISER_DIR_OUT] = 0;
+
+	memset(&p_iser_task->rdma_regd[ISER_DIR_IN], 0,
+	       sizeof(struct iser_regd_buf));
+	memset(&p_iser_task->rdma_regd[ISER_DIR_OUT], 0,
+	       sizeof(struct iser_regd_buf));
 }
 
-static void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *p_iser_task)
+void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *p_iser_task)
 {
-	struct device  *dma_device;
-	struct iser_data_buf *p_data;
+	int deferred;
 
-	dma_device = p_iser_task->conn->ib_conn->p_adaptor->device->dma_device;
+	if (p_iser_task->dir[ISER_DIR_IN]) {
+		deferred = iser_regd_buff_release
+			(&p_iser_task->rdma_regd[ISER_DIR_IN]);
+		if (deferred)
+			iser_bug("References remain for BUF-IN rdma reg\n");
+	}
 
-	p_data = &p_iser_task->data[ISER_DIR_IN];
-	if (p_data->p_buf != NULL && p_data->type == ISER_BUF_TYPE_SCATTERLIST)
-		dma_unmap_sg(dma_device, p_data->p_buf, p_data->size,
-			     DMA_FROM_DEVICE);
-	else if (p_data->p_buf != NULL) /* p_data->type == ISER_BUF_TYPE_SINGLE */
-		dma_unmap_single(dma_device, p_data->dma_addr, p_data->size,
-				 DMA_FROM_DEVICE);
+	if (p_iser_task->dir[ISER_DIR_OUT]) {
+		deferred = iser_regd_buff_release
+			(&p_iser_task->rdma_regd[ISER_DIR_OUT]);
+		if (deferred)
+			iser_bug("References remain for BUF-OUT rdma reg\n");
+	}
 
-	p_data = &p_iser_task->data[ISER_DIR_OUT];
-	if (p_data->p_buf != NULL && p_data->type == ISER_BUF_TYPE_SCATTERLIST)
-		dma_unmap_sg(dma_device, p_data->p_buf, p_data->size,
-			     DMA_TO_DEVICE);
-	else if (p_data->p_buf != NULL) /* p_data->type == ISER_BUF_TYPE_SINGLE */
-		dma_unmap_single(dma_device, p_data->dma_addr, p_data->size,
-				 DMA_TO_DEVICE);
+	iser_dma_unmap_task_data(p_iser_task);
 }
Index: ulp/iser/iser_memory.c
===================================================================
--- ulp/iser/iser_memory.c	(revision 5228)
+++ ulp/iser/iser_memory.c	(revision 5235)
@@ -103,7 +103,6 @@ int iser_regd_buff_release(struct iser_r
 		if(p_regd_buf->reg.rkey != 0)
 			iser_unreg_mem(&p_regd_buf->reg);
 
-		/* DMA_MAP: call dma_unmap_single */
 		if (p_regd_buf->dma_addr)
 			dma_unmap_single(
 				  p_regd_buf->p_adaptor->device->dma_device,
Index: ulp/iser/iscsi_iser.c
===================================================================
--- ulp/iser/iscsi_iser.c	(revision 5228)
+++ ulp/iser/iscsi_iser.c	(revision 5235)
@@ -135,8 +135,6 @@ static void iscsi_iser_cmd_init(struct i
 		if (!ctask->unsol_count)
 			/* No unsolicit Data-Out's */
 			ctask->hdr->flags |= ISCSI_FLAG_CMD_FINAL;
-		/*else
-			ctask->xmstate |= XMSTATE_UNS_HDR | XMSTATE_UNS_INIT;*/
 
 		/* bytes to be sent via RDMA operations */
 		ctask->rdma_data_count = ctask->total_length -
@@ -155,6 +153,8 @@ static void iscsi_iser_cmd_init(struct i
 		zero_data(ctask->hdr->dlength);
 		ctask->rdma_data_count = ctask->total_length;
 	}
+
+	iser_ctask_rdma_init(ctask);
 }
 
 /**
Index: ulp/iser/Makefile
===================================================================
--- ulp/iser/Makefile	(revision 5228)
+++ ulp/iser/Makefile	(revision 5235)
@@ -6,7 +6,6 @@ ib_iser-y			:= iser_mod.o \
 				   iser_verbs.o \
 				   iser_initiator.o \
 				   iser_memory.o \
-				   iser_task.o \
 				   iser_dto.o \
 				   iser_socket.o \
 				   iscsi_iser.o \
Index: ulp/iser/iser_task.c
===================================================================
--- ulp/iser/iser_task.c	(revision 5228)
+++ ulp/iser/iser_task.c	(revision 5235)
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 2006 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses.  You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *	- Redistributions of source code must retain the above
- *	  copyright notice, this list of conditions and the following
- *	  disclaimer.
- *
- *	- Redistributions in binary form must reproduce the above
- *	  copyright notice, this list of conditions and the following
- *	  disclaimer in the documentation and/or other materials
- *	  provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-#include "iscsi_iser.h"
-
-/**
- * iser_task_init_lowpart - Allocates and initializes a conn descriptor
- */
-void iser_task_init_lowpart(struct iscsi_iser_cmd_task *p_iser_task)
-
-{
-	spin_lock_init(&p_iser_task->task_lock);
-	p_iser_task->status = ISER_TASK_STATUS_INIT;
-	p_iser_task->post_send_count = 0;
-
-	p_iser_task->dir[ISER_DIR_IN] = 0;
-	p_iser_task->dir[ISER_DIR_OUT] = 0;
-
-	p_iser_task->data_len[ISER_DIR_IN] = 0;
-	p_iser_task->data_len[ISER_DIR_OUT] = 0;
-
-	memset(&p_iser_task->rdma_regd[ISER_DIR_IN], 0,
-	       sizeof(struct iser_regd_buf));
-	memset(&p_iser_task->rdma_regd[ISER_DIR_OUT], 0,
-	       sizeof(struct iser_regd_buf));
-}
-
-
-/**
- * iser_task_post_send_count_inc - Increments counter of
- * post-send buffers pending send completion
- */
-void iser_task_post_send_count_inc(struct iscsi_iser_cmd_task *p_iser_task)
-{
-	spin_lock_bh(&p_iser_task->task_lock);
-	p_iser_task->post_send_count++;
-	spin_unlock_bh(&p_iser_task->task_lock);
-}
-
-/**
- * iser_task_post_send_count_dec_and_test - Decrements counter
- * of post-send buffers pending
- * send completion and tests the task's eligibility for release.
- */
-int iser_task_post_send_count_dec_and_test(struct iscsi_iser_cmd_task *p_iser_task)
-{
-	int ret_val = 0;
-
-	spin_lock_bh(&p_iser_task->task_lock);
-	if (p_iser_task->post_send_count == 0) {
-		spin_unlock_bh(&p_iser_task->task_lock);
-		iser_bug("task: 0x%p, decrementing zero post_send_cnt\n",
-			 p_iser_task);
-	}
-	p_iser_task->post_send_count--;
-	if (p_iser_task->status == ISER_TASK_STATUS_COMPLETED &&
-	    p_iser_task->post_send_count == 0)
-		ret_val = 1;
-	spin_unlock_bh(&p_iser_task->task_lock);
-
-	return ret_val;
-}
-
-/**
- * iser_task_set_status - Sets atask status
- */
-void
-iser_task_set_status(struct iscsi_iser_cmd_task *p_iser_task,
-		     enum iser_task_status status)
-{
-	spin_lock_bh(&p_iser_task->task_lock);
-	p_iser_task->status = status;
-	spin_unlock_bh(&p_iser_task->task_lock);
-}
-
-/**
- * iser_task_free - Frees all task res
- */
-void iser_task_finalize_lowpart(struct iscsi_iser_cmd_task *p_iser_task)
-{
-	int deferred;
-
-	if (p_iser_task == NULL)
-		iser_bug("NULL task descriptor\n");
-
-	spin_lock_bh(&p_iser_task->task_lock);
-	if (p_iser_task->dir[ISER_DIR_IN]) {
-		deferred = iser_regd_buff_release
-			(&p_iser_task->rdma_regd[ISER_DIR_IN]);
-		if (deferred)
-			iser_bug("References remain for BUF-IN rdma reg\n");
-	}
-	if (p_iser_task->dir[ISER_DIR_OUT]) {
-		deferred = iser_regd_buff_release
-			(&p_iser_task->rdma_regd[ISER_DIR_OUT]);
-		if (deferred)
-			iser_bug("References remain for BUF-OUT rdma reg\n");
-	}
-	spin_unlock_bh(&p_iser_task->task_lock);
-}




More information about the general mailing list