From patchwork Tue Feb 17 13:47:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikanth Karthikesan X-Patchwork-Id: 7609 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1HDpJ6X026554 for ; Tue, 17 Feb 2009 13:51:20 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 4F9A1619662; Tue, 17 Feb 2009 08:51:17 -0500 (EST) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n1HDpFLU022868 for ; Tue, 17 Feb 2009 08:51:15 -0500 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n1HDpDxW016961; Tue, 17 Feb 2009 08:51:13 -0500 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n1HDo6cX016265; Tue, 17 Feb 2009 08:50:07 -0500 Received: from Relay1.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 943E247794; Tue, 17 Feb 2009 14:50:06 +0100 (CET) From: Nikanth Karthikesan Organization: suse.de To: Alasdair G Kergon Date: Tue, 17 Feb 2009 19:17:37 +0530 User-Agent: KMail/1.10.3 (Linux/2.6.27.7-9-default; KDE/4.1.3; x86_64; ; ) MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200902171917.38252.knikanth@suse.de> X-RedHat-Spam-Score: -3.675 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [PATCH] dm mpath: delay retry activate_path on SCSI_DH_RETRY X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Delay retry to activate_path if it returns SCSI_DH_RETRY. Signed-off-by: Nikanth Karthikesan --- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 095f77b..af54632 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -65,12 +65,14 @@ struct multipath { spinlock_t lock; const char *hw_handler_name; - struct work_struct activate_path; + struct delayed_work activate_path; struct pgpath *pgpath_to_activate; unsigned nr_priority_groups; struct list_head priority_groups; unsigned pg_init_required; /* pg_init needs calling? */ unsigned pg_init_in_progress; /* Only one pg_init allowed at once */ + unsigned long pg_init_jiffy; /* To delay retry if SCSI_DH_RETRY */ +#define SCSI_DH_RETRY_DELAY ((HZ * 2)) unsigned nr_valid_paths; /* Total number of usable paths */ struct pgpath *current_pgpath; @@ -203,7 +205,7 @@ static struct multipath *alloc_multipath(struct dm_target *ti) 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); + INIT_DELAYED_WORK(&m->activate_path, activate_path); m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); if (!m->mpio_pool) { kfree(m); @@ -431,6 +433,8 @@ static void process_queued_ios(struct work_struct *work) struct pgpath *pgpath = NULL; unsigned init_required = 0, must_queue = 1; unsigned long flags; + unsigned long delay = 0; + unsigned long now; spin_lock_irqsave(&m->lock, flags); @@ -452,13 +456,20 @@ static void process_queued_ios(struct work_struct *work) m->pg_init_required = 0; m->pg_init_in_progress = 1; init_required = 1; + /* Delay retry due to SCSI_DH_RETRY */ + if (m->pg_init_jiffy) { + now = jiffies; + if (time_after(now, m->pg_init_jiffy)) + delay = now - m->pg_init_jiffy; + m->pg_init_jiffy = 0; + } } out: spin_unlock_irqrestore(&m->lock, flags); if (init_required) - queue_work(kmpath_handlerd, &m->activate_path); + queue_delayed_work(kmpath_handlerd, &m->activate_path, delay); if (!must_queue) dispatch_queued_ios(m); @@ -1060,6 +1071,7 @@ static void pg_init_done(struct dm_path *path, int errors) struct priority_group *pg = pgpath->pg; struct multipath *m = pg->m; unsigned long flags; + bool delay = false; /* device or driver problems */ switch (errors) { @@ -1084,8 +1096,11 @@ static void pg_init_done(struct dm_path *path, int errors) */ bypass_pg(m, pg, 1); break; - /* TODO: For SCSI_DH_RETRY we should wait a couple seconds */ + /* + * For SCSI_DH_RETRY we wait for a couple seconds. + */ case SCSI_DH_RETRY: + delay = true; case SCSI_DH_IMM_RETRY: case SCSI_DH_RES_TEMP_UNAVAIL: if (pg_init_limit_reached(m, pgpath)) @@ -1112,6 +1127,10 @@ static void pg_init_done(struct dm_path *path, int errors) } m->pg_init_in_progress = 0; + if (delay) + m->pg_init_jiffy = jiffies + SCSI_DH_RETRY_DELAY; + else + m->pg_init_jiffy = 0; queue_work(kmultipathd, &m->process_queued_ios); spin_unlock_irqrestore(&m->lock, flags); } @@ -1120,7 +1139,7 @@ static void activate_path(struct work_struct *work) { int ret; struct multipath *m = - container_of(work, struct multipath, activate_path); + container_of(work, struct multipath, activate_path.work); struct dm_path *path; unsigned long flags;