From: Chandra Seetharaman <sekharan@us.ibm.com>
To: linux-scsi@vger.kernel.org
Cc: dm-devel@redhat.com, andmike@us.ibm.com, michaelc@cs.wisc.edu,
agk@redhat.com, James.Bottomley@HansenPartnership.com,
jens.axboe@oracle.com, dwysocha@redhat.com,
Benoit_Arthur@emc.com, asson_ronald@emc.com,
Chandra Seetharaman <sekharan@us.ibm.com>
Subject: [PATCH 07/10] scsi_dh: Add a single threaded workqueue for initializing paths
Date: Thu, 01 May 2008 14:50:22 -0700 [thread overview]
Message-ID: <20080501215022.27759.4186.sendpatchset@chandra-ubuntu> (raw)
In-Reply-To: <20080501214941.27759.95121.sendpatchset@chandra-ubuntu>
Subject: [PATCH 07/10] scsi_dh: Add a single threaded workqueue for initializing paths
From: Chandra Seetharaman <sekharan@us.ibm.com>
Before this patch set (SCSI hardware handlers), initialization of a
path was done asynchronously. Doing that requires a workqueue in each
device/hardware handler module and leads to unneccessary complication
in the device handler code, making it difficult to read the code and
follow the state diagram.
Moving that workqueue to this level makes the device handler code simpler.
Hence, the workqueue is moved to dm level.
A new workqueue is added instead of adding it to the existing workqueue
(kmpathd) for the following reasons:
1. Device activation has to happen faster, stacking them along
with the other workqueue might lead to unnecessary delay
in the activation of the path.
2. The effect could be felt the other way too. i.e the current
events that are handled by the existing workqueue might get
a delayed response.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
---
Index: linux-2.6.25/drivers/md/dm-mpath.c
===================================================================
--- linux-2.6.25.orig/drivers/md/dm-mpath.c
+++ linux-2.6.25/drivers/md/dm-mpath.c
@@ -63,6 +63,7 @@ struct multipath {
spinlock_t lock;
const char *hw_handler_name;
+ struct work_struct activate_path;
unsigned nr_priority_groups;
struct list_head priority_groups;
unsigned pg_init_required; /* pg_init needs calling? */
@@ -107,10 +108,10 @@ typedef int (*action_fn) (struct pgpath
static struct kmem_cache *_mpio_cache;
-static struct workqueue_struct *kmultipathd;
+static struct workqueue_struct *kmultipathd, *kmpath_handlerd;
static void process_queued_ios(struct work_struct *work);
static void trigger_event(struct work_struct *work);
-static void pg_init_done(struct dm_path *, int);
+static void activate_path(struct work_struct *work);
/*-----------------------------------------------
@@ -180,6 +181,7 @@ static struct multipath *alloc_multipath
m->queue_io = 1;
INIT_WORK(&m->process_queued_ios, process_queued_ios);
INIT_WORK(&m->trigger_event, trigger_event);
+ INIT_WORK(&m->activate_path, activate_path);
m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
if (!m->mpio_pool) {
kfree(m);
@@ -432,11 +434,8 @@ static void process_queued_ios(struct wo
out:
spin_unlock_irqrestore(&m->lock, flags);
- if (init_required) {
- struct dm_path *path = &pgpath->path;
- int ret = scsi_dh_activate(bdev_get_queue(path->dev->bdev));
- pg_init_done(path, ret);
- }
+ if (init_required)
+ queue_work(kmpath_handlerd, &m->activate_path);
if (!must_queue)
dispatch_queued_ios(m);
@@ -795,6 +794,7 @@ static void multipath_dtr(struct dm_targ
{
struct multipath *m = (struct multipath *) ti->private;
+ flush_workqueue(kmpath_handlerd);
flush_workqueue(kmultipathd);
free_multipath(m);
}
@@ -1112,6 +1112,17 @@ static void pg_init_done(struct dm_path
spin_unlock_irqrestore(&m->lock, flags);
}
+static void activate_path(struct work_struct *work)
+{
+ int ret;
+ struct multipath *m =
+ container_of(work, struct multipath, activate_path);
+ struct dm_path *path = &m->current_pgpath->path;
+
+ ret = scsi_dh_activate(bdev_get_queue(path->dev->bdev));
+ pg_init_done(path, ret);
+}
+
/*
* end_io handling
*/
@@ -1455,6 +1466,21 @@ static int __init dm_multipath_init(void
return -ENOMEM;
}
+ /*
+ * A separate workqueue is used to handle the device handlers
+ * to avoid overloading existing workqueue. Overloading the
+ * old workqueue would also create a bottleneck in the
+ * path of the storage hardware device activation.
+ */
+ kmpath_handlerd = create_singlethread_workqueue("kmpath_handlerd");
+ if (!kmpath_handlerd) {
+ DMERR("failed to create workqueue kmpath_handlerd");
+ destroy_workqueue(kmultipathd);
+ dm_unregister_target(&multipath_target);
+ kmem_cache_destroy(_mpio_cache);
+ return -ENOMEM;
+ }
+
DMINFO("version %u.%u.%u loaded",
multipath_target.version[0], multipath_target.version[1],
multipath_target.version[2]);
@@ -1466,6 +1492,7 @@ static void __exit dm_multipath_exit(voi
{
int r;
+ destroy_workqueue(kmpath_handlerd);
destroy_workqueue(kmultipathd);
r = dm_unregister_target(&multipath_target);
next prev parent reply other threads:[~2008-05-01 21:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-01 21:49 [PATCH 00/10] scsi_dh: Move hardware handlers from dm to SCSI Chandra Seetharaman
2008-05-01 21:49 ` [PATCH 01/10] scsi_dh: add infrastructure for SCSI Device Handlers Chandra Seetharaman
2008-05-01 21:49 ` [PATCH 02/10] scsi_dh: add lsi rdac device handler Chandra Seetharaman
2008-05-01 21:49 ` [PATCH 03/10] scsi_dh: add hp sw " Chandra Seetharaman
2008-05-01 21:50 ` [PATCH 04/10] scsi_dh: add EMC Clariion " Chandra Seetharaman
2008-05-01 21:50 ` [PATCH 05/10] scsi_dh: Use SCSI device handler in dm-multipath Chandra Seetharaman
2008-05-01 21:50 ` [PATCH 06/10] scsi_dh: Do not allow arguments for hardware handlers Chandra Seetharaman
2008-05-02 22:47 ` Alasdair G Kergon
2008-05-03 0:01 ` [dm-devel] " Chandra Seetharaman
2008-05-01 21:50 ` Chandra Seetharaman [this message]
2008-05-01 21:50 ` [PATCH 08/10] scsi_dh: Remove dm_pg_init_complete Chandra Seetharaman
2008-05-01 21:50 ` [PATCH 09/10] scsi_dh: Remove hardware handlers from dm Chandra Seetharaman
2008-05-01 21:50 ` [PATCH 10/10] scsi_dh: Remove hardware handler infrastructure " Chandra Seetharaman
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=20080501215022.27759.4186.sendpatchset@chandra-ubuntu \
--to=sekharan@us.ibm.com \
--cc=Benoit_Arthur@emc.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=agk@redhat.com \
--cc=andmike@us.ibm.com \
--cc=asson_ronald@emc.com \
--cc=dm-devel@redhat.com \
--cc=dwysocha@redhat.com \
--cc=jens.axboe@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
/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