[ofw] [SRP] pending queue cleanup for abort command

Alex Estrin alex.estrin at qlogic.com
Mon Feb 25 06:47:53 PST 2008


Hello,

Proposed patch adds look-up of pending queue and descriptor cleanup for
abort command.

Please review.

Thanks,
Alex.


Index: srp_data_path.c
===================================================================
--- srp_data_path.c	(revision 945)
+++ srp_data_path.c	(working copy)
@@ -1300,6 +1300,18 @@
 
 	iu_tag = get_srp_information_unit_tag( (srp_information_unit_t
*)p_srb_send_descriptor->data_segment );
 
+	p_send_descriptor =
srp_find_matching_pending_descriptor(&p_srp_session->descriptors, iu_tag
);
+	
+	/*complete pending locally as failed */
+	if( p_send_descriptor != NULL )
+	{
+		p_srb->SrbStatus = SRB_STATUS_ABORT_FAILED;
+		p_srb->ScsiStatus = SCSISTAT_COMMAND_TERMINATED;
+
+		__srp_clean_send_descriptor( p_send_descriptor,
p_srp_session );
+		goto exit;
+	}
+
 	p_send_descriptor = srp_find_matching_send_descriptor(
&p_srp_session->descriptors, iu_tag );
 	if ( p_send_descriptor == NULL )
 	{
@@ -1310,6 +1322,12 @@
 
 	CL_ASSERT( p_srb_send_descriptor == p_send_descriptor );
 
+	if( __srp_clean_send_descriptor( p_send_descriptor,
p_srp_session ) != IB_SUCCESS )
+	{
+		p_srb->SrbStatus = SRB_STATUS_ABORT_FAILED;
+		goto exit;
+	}
+
 	p_srb->NextSrb->SrbStatus = SRB_STATUS_ABORTED;
 
 	/* create and send abort request to the VFx */
Index: srp_descriptors.c
===================================================================
--- srp_descriptors.c	(revision 945)
+++ srp_descriptors.c	(working copy)
@@ -566,6 +566,42 @@
 	return ( status );
 }
 
+static srp_send_descriptor_t*
+__srp_find_matching_send_descriptor(
+	IN		cl_qlist_t
*p_descriptors_list,
+	IN		uint64_t			tag )
+{
+	srp_send_descriptor_t	*p_send_descriptor;
+
+	SRP_ENTER( SRP_DBG_DATA );
+	/* assumed list lock is taken outside */
+	p_send_descriptor = (srp_send_descriptor_t *)cl_qlist_head(
p_descriptors_list );
+	CL_ASSERT( p_descriptors_list ==
p_send_descriptor->list_item.p_list );
+
+	while ( p_send_descriptor != (srp_send_descriptor_t
*)cl_qlist_end( p_descriptors_list ) )
+	{
+		SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA, ("cmd tag
= 0x%I64x.\n",
+			get_srp_command_tag( (srp_cmd_t
*)p_send_descriptor->data_segment )) );
+
+		if ( get_srp_command_tag( (srp_cmd_t
*)p_send_descriptor->data_segment ) == tag )
+		{
+			CL_ASSERT( p_descriptors_list ==
p_send_descriptor->list_item.p_list );
+			cl_qlist_remove_item( p_descriptors_list,
&p_send_descriptor->list_item );
+			goto exit;
+		}
+
+		p_send_descriptor = (srp_send_descriptor_t
*)cl_qlist_next( &p_send_descriptor->list_item );
+	}
+
+	/* This is not an error. The request may have been aborted */
+	p_send_descriptor = NULL;
+
+exit:
+	SRP_EXIT( SRP_DBG_DATA );
+
+	return ( p_send_descriptor );
+}
+
 /* srp_find_matching_send_descriptor */
 /*!
 Given a received response find the matching send descriptor
@@ -588,32 +624,29 @@
 
 	cl_spinlock_acquire( &p_descriptors->sent_list_lock );
 
-	p_send_descriptor = (srp_send_descriptor_t *)cl_qlist_head(
&p_descriptors->sent_descriptors );
-	CL_ASSERT( &p_descriptors->sent_descriptors ==
p_send_descriptor->list_item.p_list );
+	p_send_descriptor = __srp_find_matching_send_descriptor(
&p_descriptors->sent_descriptors, tag );
 
-	SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA,
-		("rsp tag = 0x%I64x.\n", tag) );
+	cl_spinlock_release( &p_descriptors->sent_list_lock );
 
-	while ( p_send_descriptor != (srp_send_descriptor_t
*)cl_qlist_end( &p_descriptors->sent_descriptors ) )
-	{
-		SRP_PRINT( TRACE_LEVEL_VERBOSE, SRP_DBG_DATA, ("cmd tag
= 0x%I64x.\n",
-			get_srp_command_tag( (srp_cmd_t
*)p_send_descriptor->data_segment )) );
+	SRP_EXIT( SRP_DBG_DATA );
 
-		if ( get_srp_command_tag( (srp_cmd_t
*)p_send_descriptor->data_segment ) == tag )
-		{
-			CL_ASSERT( &p_descriptors->sent_descriptors ==
p_send_descriptor->list_item.p_list );
-			cl_qlist_remove_item(
&p_descriptors->sent_descriptors, &p_send_descriptor->list_item );
-			goto exit;
-		}
+	return ( p_send_descriptor );
+}
 
-		p_send_descriptor = (srp_send_descriptor_t
*)cl_qlist_next( &p_send_descriptor->list_item );
-	}
+srp_send_descriptor_t*
+srp_find_matching_pending_descriptor(
+	IN      srp_descriptors_t       *p_descriptors,
+	IN      uint64_t                tag )
+{
+	srp_send_descriptor_t		*p_send_descriptor;
+	
+	SRP_ENTER( SRP_DBG_DATA );
+	
+	cl_spinlock_acquire( &p_descriptors->pending_list_lock );
 
-	/* This is not an error. The request may have been aborted */
-	p_send_descriptor = NULL;
+	p_send_descriptor = __srp_find_matching_send_descriptor(
&p_descriptors->pending_descriptors, tag );
 
-exit:
-	cl_spinlock_release( &p_descriptors->sent_list_lock );
+	cl_spinlock_release( &p_descriptors->pending_list_lock );
 
 	SRP_EXIT( SRP_DBG_DATA );
 
Index: srp_descriptors.h
===================================================================
--- srp_descriptors.h	(revision 945)
+++ srp_descriptors.h	(working copy)
@@ -131,6 +131,11 @@
 	IN      srp_descriptors_t       *p_descriptors,
 	IN      uint64_t                tag ) ;
 
+srp_send_descriptor_t*
+srp_find_matching_pending_descriptor(
+	IN      srp_descriptors_t       *p_descriptors,
+	IN      uint64_t                tag ) ;
+
 void
 srp_build_send_descriptor(
 	IN      PVOID               p_dev_ext,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: srp_pend_desc_cleanup.diff
Type: application/octet-stream
Size: 5212 bytes
Desc: srp_pend_desc_cleanup.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080225/c0d3e908/attachment.obj>


More information about the ofw mailing list