public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org,
	schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
	Swen Schillig <swen@vnet.ibm.com>,
	Christof Schmitt <christof.schmitt@de.ibm.com>
Subject: [patch 09/13] zfcp: deadlock via shared work queue tasks
Date: Wed, 01 Oct 2008 12:42:22 +0200	[thread overview]
Message-ID: <20081001104803.099733000@de.ibm.com> (raw)
In-Reply-To: 20081001104213.585200000@de.ibm.com

[-- Attachment #1: zfcp_workqueue_race.diff --]
[-- Type: text/plain, Size: 3004 bytes --]

From: Swen Schillig <swen@vnet.ibm.com>

Each adapter reopen trigger automatically a scan_port task which
is waiting for the ERP to be finished before further processing.
Since the initial device setup enqueues adapter, port and LUN which
are individual ERP actions, this process would start after 
everything is done. Unfortunately the port_reopen requires another
scheduled work to be finished which is queued after the automatic
scan_port -> deadlock !

This fix creates an own work queue for ERP based nameserver requests.

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
---
 drivers/s390/scsi/zfcp_aux.c |    2 ++
 drivers/s390/scsi/zfcp_def.h |    1 +
 drivers/s390/scsi/zfcp_erp.c |    4 ++--
 drivers/s390/scsi/zfcp_fsf.c |    2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

--- a/drivers/s390/scsi/zfcp_aux.c	2008-10-01 11:09:06.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_aux.c	2008-10-01 11:09:57.000000000 +0200
@@ -168,6 +168,8 @@ static int __init zfcp_module_init(void)
 	if (!zfcp_data.gid_pn_cache)
 		goto out_gid_cache;
 
+	zfcp_data.work_queue = create_singlethread_workqueue("zfcp_wq");
+
 	INIT_LIST_HEAD(&zfcp_data.adapter_list_head);
 	sema_init(&zfcp_data.config_sema, 1);
 	rwlock_init(&zfcp_data.config_lock);
--- a/drivers/s390/scsi/zfcp_def.h	2008-10-01 11:09:06.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_def.h	2008-10-01 11:09:57.000000000 +0200
@@ -602,6 +602,7 @@ struct zfcp_data {
 	struct kmem_cache	*fsf_req_qtcb_cache;
 	struct kmem_cache	*sr_buffer_cache;
 	struct kmem_cache	*gid_pn_cache;
+	struct workqueue_struct	*work_queue;
 };
 
 /* struct used by memory pools for fsf_requests */
--- a/drivers/s390/scsi/zfcp_erp.c	2008-10-01 11:09:06.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_erp.c	2008-10-01 11:09:57.000000000 +0200
@@ -869,7 +869,7 @@ static int zfcp_erp_port_strategy_open_c
 		if (fc_host_port_type(adapter->scsi_host) == FC_PORTTYPE_PTP)
 			return zfcp_erp_open_ptp_port(act);
 		if (!(p_status & ZFCP_STATUS_PORT_DID_DID)) {
-			schedule_work(&port->gid_pn_work);
+			queue_work(zfcp_data.work_queue, &port->gid_pn_work);
 			return ZFCP_ERP_CONTINUES;
 		}
 	case ZFCP_ERP_STEP_NAMESERVER_LOOKUP:
@@ -1209,7 +1209,7 @@ static void zfcp_erp_schedule_work(struc
 	atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
 	INIT_WORK(&p->work, zfcp_erp_scsi_scan);
 	p->unit = unit;
-	schedule_work(&p->work);
+	queue_work(zfcp_data.work_queue, &p->work);
 }
 
 static void zfcp_erp_rport_register(struct zfcp_port *port)
--- a/drivers/s390/scsi/zfcp_fsf.c	2008-10-01 11:09:31.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_fsf.c	2008-10-01 11:09:57.000000000 +0200
@@ -329,7 +329,7 @@ static void zfcp_fsf_status_read_handler
 	zfcp_fsf_req_free(req);
 
 	atomic_inc(&adapter->stat_miss);
-	schedule_work(&adapter->stat_work);
+	queue_work(zfcp_data.work_queue, &adapter->stat_work);
 }
 
 static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)

-- 

  parent reply	other threads:[~2008-10-01 10:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-01 10:42 [patch 00/13] zfcp updates for 2.6.28 Christof Schmitt
2008-10-01 10:42 ` [patch 01/13] zfcp: add queue_full sysfs attribute Christof Schmitt
2008-10-01 10:42 ` [patch 02/13] zfcp: Update message with input from review Christof Schmitt
2008-10-01 10:42 ` [patch 03/13] zfcp: remove unused references, declarations and flags Christof Schmitt
2008-10-01 10:42 ` [patch 04/13] zfcp: attach and release SAN nameserver port on demand Christof Schmitt
2008-10-01 10:42 ` [patch 05/13] zfcp: remove all typedefs and replace them with standards Christof Schmitt
2008-10-01 10:42 ` [patch 06/13] zfcp: Simplify get_adapter_by_busid Christof Schmitt
2008-10-01 10:42 ` [patch 07/13] zfcp: Simplify zfcp data structures Christof Schmitt
2008-10-01 10:42 ` [patch 08/13] zfcp: put threshold data in hba trace Christof Schmitt
2008-10-01 10:42 ` Christof Schmitt [this message]
2008-10-01 10:42 ` [patch 10/13] zfcp: prevent fc_remote_port_delete calls for unregistered rport Christof Schmitt
2008-10-01 10:42 ` [patch 11/13] zfcp: fix erp list usage without using locks Christof Schmitt
2008-10-01 10:42 ` [patch 12/13] zfcp: wait on SCSI work to be finished before proceeding with init dev Christof Schmitt
2008-10-01 10:42 ` [patch 13/13] zfcp: fix double dbf id usage Christof Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081001104803.099733000@de.ibm.com \
    --to=christof.schmitt@de.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=swen@vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox