linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out.
  2012-04-24 22:26 [v2 PATCH 0/4] bnx2fc version 1.0.11 Bhanu Prakash Gollapudi
@ 2012-04-24 22:26 ` Bhanu Prakash Gollapudi
  2012-05-04  8:49   ` Mike Christie
  0 siblings, 1 reply; 6+ messages in thread
From: Bhanu Prakash Gollapudi @ 2012-04-24 22:26 UTC (permalink / raw)
  To: JBottomley, linux-scsi; +Cc: Bhanu Prakash Gollapudi

When the task management IO times out, or a flush operation is performed while
task management IO is pending, driver is not cleaning up the IO. This patch
cleans up the IO for the above cases.

Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c  |   16 +++++++++++++++-
 drivers/scsi/bnx2fc/bnx2fc_tgt.c |   10 ++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 4843b42..27074ee 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -810,8 +810,22 @@ retry_tmf:
 	spin_lock_bh(&tgt->tgt_lock);
 
 	io_req->wait_for_comp = 0;
-	if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags)))
+	if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) {
 		set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags);
+		if (io_req->on_tmf_queue) {
+			list_del_init(&io_req->link);
+			io_req->on_tmf_queue = 0;
+		}
+		io_req->wait_for_comp = 1;
+		bnx2fc_initiate_cleanup(io_req);
+		spin_unlock_bh(&tgt->tgt_lock);
+		rc = wait_for_completion_timeout(&io_req->tm_done,
+						 BNX2FC_FW_TIMEOUT);
+		spin_lock_bh(&tgt->tgt_lock);
+		io_req->wait_for_comp = 0;
+		if (!rc)
+			kref_put(&io_req->refcount, bnx2fc_cmd_release);
+	}
 
 	spin_unlock_bh(&tgt->tgt_lock);
 
diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
index d3ee231..082a25c 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
@@ -185,6 +185,16 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt)
 		BUG_ON(rc);
 	}
 
+	list_for_each_safe(list, tmp, &tgt->active_tm_queue) {
+		i++;
+		io_req = (struct bnx2fc_cmd *)list;
+		list_del_init(&io_req->link);
+		io_req->on_tmf_queue = 0;
+		BNX2FC_IO_DBG(io_req, "tm_queue cleanup\n");
+		if (io_req->wait_for_comp)
+			complete(&io_req->tm_done);
+	}
+
 	list_for_each_safe(list, tmp, &tgt->els_queue) {
 		i++;
 		io_req = (struct bnx2fc_cmd *)list;
-- 
1.7.0.6



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out.
  2012-04-24 22:26 ` [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out Bhanu Prakash Gollapudi
@ 2012-05-04  8:49   ` Mike Christie
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Christie @ 2012-05-04  8:49 UTC (permalink / raw)
  To: Bhanu Prakash Gollapudi; +Cc: JBottomley, linux-scsi

On 04/24/2012 05:26 PM, Bhanu Prakash Gollapudi wrote:
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> index d3ee231..082a25c 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> @@ -185,6 +185,16 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport *tgt)
>  		BUG_ON(rc);
>  	}
>  
> +	list_for_each_safe(list, tmp, &tgt->active_tm_queue) {
> +		i++;
> +		io_req = (struct bnx2fc_cmd *)list;

Why didn't you use list_for_each_entry_safe()? Or, when using
list_for_each_safe, instead of the cast are we supposed to be using
list_entry()?


> +		list_del_init(&io_req->link);
> +		io_req->on_tmf_queue = 0;
> +		BNX2FC_IO_DBG(io_req, "tm_queue cleanup\n");
> +		if (io_req->wait_for_comp)
> +			complete(&io_req->tm_done);
> +	}
> +
>  	list_for_each_safe(list, tmp, &tgt->els_queue) {
>  		i++;
>  		io_req = (struct bnx2fc_cmd *)list;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out.
       [not found] <4FA85912.2030800@broadcom.com>
@ 2012-05-07 23:31 ` Bhanu Prakash Gollapudi
  2012-05-08  0:14   ` Mike Christie
  0 siblings, 1 reply; 6+ messages in thread
From: Bhanu Prakash Gollapudi @ 2012-05-07 23:31 UTC (permalink / raw)
  To: Mike Christie
  Cc: James Bottomley, linux-scsi@vger.kernel.org,
	Bhanu Prakash Gollapudi

On  05/04/2012 08:49 AM, Mike Christie wrote:
> On 04/24/2012 05:26 PM, Bhanu Prakash Gollapudi wrote:
>  > diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>  > index d3ee231..082a25c 100644
>  > --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>  > +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>  > @@ -185,6 +185,16 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport
> *tgt)
>  > BUG_ON(rc);
>  > }
>  >
>  > + list_for_each_safe(list, tmp, &tgt->active_tm_queue) {
>  > + i++;
>  > + io_req = (struct bnx2fc_cmd *)list;
>
> Why didn't you use list_for_each_entry_safe()? Or, when using
> list_for_each_safe, instead of the cast are we supposed to be using
> list_entry()?

Mike, the list is the first field in the structure, so the cast here is 
right.

Thanks,
Bhanu
>
>
>  > + list_del_init(&io_req->link);
>  > + io_req->on_tmf_queue = 0;
>  > + BNX2FC_IO_DBG(io_req, "tm_queue cleanup\n");
>  > + if (io_req->wait_for_comp)
>  > + complete(&io_req->tm_done);
>  > + }
>  > +
>  > list_for_each_safe(list, tmp, &tgt->els_queue) {
>  > i++;
>  > io_req = (struct bnx2fc_cmd *)list;



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out.
  2012-05-07 23:31 ` [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out Bhanu Prakash Gollapudi
@ 2012-05-08  0:14   ` Mike Christie
  2012-05-08  0:27     ` Mike Christie
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Christie @ 2012-05-08  0:14 UTC (permalink / raw)
  To: Bhanu Prakash Gollapudi; +Cc: James Bottomley, linux-scsi@vger.kernel.org

On 05/07/2012 06:31 PM, Bhanu Prakash Gollapudi wrote:
> On  05/04/2012 08:49 AM, Mike Christie wrote:
>> On 04/24/2012 05:26 PM, Bhanu Prakash Gollapudi wrote:
>>  > diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>> b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>  > index d3ee231..082a25c 100644
>>  > --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>  > +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>  > @@ -185,6 +185,16 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport
>> *tgt)
>>  > BUG_ON(rc);
>>  > }
>>  >
>>  > + list_for_each_safe(list, tmp, &tgt->active_tm_queue) {
>>  > + i++;
>>  > + io_req = (struct bnx2fc_cmd *)list;
>>
>> Why didn't you use list_for_each_entry_safe()? Or, when using
>> list_for_each_safe, instead of the cast are we supposed to be using
>> list_entry()?
> 
> Mike, the list is the first field in the structure, so the cast here is
> right.
> 

I am saying that normally if there is a function that does the same
thing we are supposed to use that instead.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out.
  2012-05-08  0:14   ` Mike Christie
@ 2012-05-08  0:27     ` Mike Christie
  2012-05-08  0:36       ` Bhanu Prakash Gollapudi
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Christie @ 2012-05-08  0:27 UTC (permalink / raw)
  To: Bhanu Prakash Gollapudi; +Cc: James Bottomley, linux-scsi@vger.kernel.org

On 05/07/2012 07:14 PM, Mike Christie wrote:
> On 05/07/2012 06:31 PM, Bhanu Prakash Gollapudi wrote:
>> On  05/04/2012 08:49 AM, Mike Christie wrote:
>>> On 04/24/2012 05:26 PM, Bhanu Prakash Gollapudi wrote:
>>>  > diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>> b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>  > index d3ee231..082a25c 100644
>>>  > --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>  > +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>  > @@ -185,6 +185,16 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport
>>> *tgt)
>>>  > BUG_ON(rc);
>>>  > }
>>>  >
>>>  > + list_for_each_safe(list, tmp, &tgt->active_tm_queue) {
>>>  > + i++;
>>>  > + io_req = (struct bnx2fc_cmd *)list;
>>>
>>> Why didn't you use list_for_each_entry_safe()? Or, when using
>>> list_for_each_safe, instead of the cast are we supposed to be using
>>> list_entry()?
>>
>> Mike, the list is the first field in the structure, so the cast here is
>> right.
>>
> 
> I am saying that normally if there is a function that does the same
> thing we are supposed to use that instead.

I think though since it works and it used throughout the driver already
it is ok to do. But I think in a patch later it should be changed.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out.
  2012-05-08  0:27     ` Mike Christie
@ 2012-05-08  0:36       ` Bhanu Prakash Gollapudi
  0 siblings, 0 replies; 6+ messages in thread
From: Bhanu Prakash Gollapudi @ 2012-05-08  0:36 UTC (permalink / raw)
  To: Mike Christie; +Cc: James Bottomley, linux-scsi@vger.kernel.org

On 5/7/2012 5:27 PM, Mike Christie wrote:
> On 05/07/2012 07:14 PM, Mike Christie wrote:
>> On 05/07/2012 06:31 PM, Bhanu Prakash Gollapudi wrote:
>>> On  05/04/2012 08:49 AM, Mike Christie wrote:
>>>> On 04/24/2012 05:26 PM, Bhanu Prakash Gollapudi wrote:
>>>>   >  diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>> b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>>   >  index d3ee231..082a25c 100644
>>>>   >  --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>>   >  +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
>>>>   >  @@ -185,6 +185,16 @@ void bnx2fc_flush_active_ios(struct bnx2fc_rport
>>>> *tgt)
>>>>   >  BUG_ON(rc);
>>>>   >  }
>>>>   >
>>>>   >  + list_for_each_safe(list, tmp,&tgt->active_tm_queue) {
>>>>   >  + i++;
>>>>   >  + io_req = (struct bnx2fc_cmd *)list;
>>>>
>>>> Why didn't you use list_for_each_entry_safe()? Or, when using
>>>> list_for_each_safe, instead of the cast are we supposed to be using
>>>> list_entry()?
>>>
>>> Mike, the list is the first field in the structure, so the cast here is
>>> right.
>>>
>>
>> I am saying that normally if there is a function that does the same
>> thing we are supposed to use that instead.
>
> I think though since it works and it used throughout the driver already
> it is ok to do. But I think in a patch later it should be changed.
>

Thanks Mike.  In my next opportunity to submit the code, I'll remember 
to do this.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-08  0:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4FA85912.2030800@broadcom.com>
2012-05-07 23:31 ` [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out Bhanu Prakash Gollapudi
2012-05-08  0:14   ` Mike Christie
2012-05-08  0:27     ` Mike Christie
2012-05-08  0:36       ` Bhanu Prakash Gollapudi
2012-04-24 22:26 [v2 PATCH 0/4] bnx2fc version 1.0.11 Bhanu Prakash Gollapudi
2012-04-24 22:26 ` [v2 PATCH 3/4] bnx2fc: cleanup task management IO when it times out Bhanu Prakash Gollapudi
2012-05-04  8:49   ` Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).