From patchwork Mon Feb 1 04:22:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiyoshi Ueda X-Patchwork-Id: 76028 X-Patchwork-Delegate: agk@redhat.com Received: from mx01.util.phx2.redhat.com (mx1-phx2.redhat.com [209.132.183.26]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o114PJIW005924 for ; Mon, 1 Feb 2010 04:25:55 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.util.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o114NRG0020869; Sun, 31 Jan 2010 23:23:27 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o114NQ1f004375 for ; Sun, 31 Jan 2010 23:23:26 -0500 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.12]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o114NLWp003359; Sun, 31 Jan 2010 23:23:21 -0500 Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp [202.32.8.206]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o114N5J4009070; Sun, 31 Jan 2010 23:23:06 -0500 Received: from mailgate3.nec.co.jp ([10.7.69.192]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id o114N4f5016065; Mon, 1 Feb 2010 13:23:04 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id o114N4e29480; Mon, 1 Feb 2010 13:23:04 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv.nec.co.jp (8.13.8/8.13.4) with ESMTP id o114N3B9002538; Mon, 1 Feb 2010 13:23:03 +0900 (JST) Received: from yonosuke.jp.nec.com ([10.26.220.15] [10.26.220.15]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-254985; Mon, 1 Feb 2010 13:22:23 +0900 Received: from elcondor.linux.bs1.fc.nec.co.jp ([10.34.125.195] [10.34.125.195]) by mail.jp.nec.com with ESMTP; Mon, 1 Feb 2010 13:22:23 +0900 Message-ID: <4B6656FF.5000701@ct.jp.nec.com> Date: Mon, 01 Feb 2010 13:22:23 +0900 From: Kiyoshi Ueda User-Agent: Thunderbird 2.0.0.23 (X11/20090825) MIME-Version: 1.0 To: device-mapper development , Alasdair Kergon References: <4B665507.8080205@ct.jp.nec.com> In-Reply-To: <4B665507.8080205@ct.jp.nec.com> X-RedHat-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.12 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 3/4] dm-mpath: separate pg-init handling from process_queued_ios() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 01 Feb 2010 04:25:55 +0000 (UTC) Index: 2.6.33-rc6/drivers/md/dm-mpath.c =================================================================== --- 2.6.33-rc6.orig/drivers/md/dm-mpath.c +++ 2.6.33-rc6/drivers/md/dm-mpath.c @@ -235,6 +235,21 @@ static void free_multipath(struct multip * Path selection *-----------------------------------------------*/ +static void __pg_init(struct multipath *m) +{ + struct pgpath *pgpath; + + m->pg_init_count++; + m->pg_init_required = 0; + list_for_each_entry(pgpath, &m->current_pg->pgpaths, list) { + /* Skip failed paths */ + if (!pgpath->is_active) + continue; + if (queue_work(kmpath_handlerd, &pgpath->activate_path)) + m->pg_init_in_progress++; + } +} + static void __switch_pg(struct multipath *m, struct pgpath *pgpath) { m->current_pg = pgpath->pg; @@ -350,8 +365,9 @@ static int map_io(struct multipath *m, s /* Queue for the daemon to resubmit */ list_add_tail(&clone->queuelist, &m->queued_ios); m->queue_size++; - if ((m->pg_init_required && !m->pg_init_in_progress) || - !m->queue_io) + if (m->pg_init_required && !m->pg_init_in_progress && pgpath) + __pg_init(m); + else if (!m->queue_io) queue_work(kmultipathd, &m->process_queued_ios); pgpath = NULL; r = DM_MAPIO_SUBMITTED; @@ -439,7 +455,7 @@ static void process_queued_ios(struct wo { struct multipath *m = container_of(work, struct multipath, process_queued_ios); - struct pgpath *pgpath = NULL, *tmp; + struct pgpath *pgpath = NULL; unsigned must_queue = 1; unsigned long flags; @@ -457,17 +473,9 @@ static void process_queued_ios(struct wo (!pgpath && !m->queue_if_no_path)) must_queue = 0; - if (m->pg_init_required && !m->pg_init_in_progress && pgpath) { - m->pg_init_count++; - m->pg_init_required = 0; - list_for_each_entry(tmp, &pgpath->pg->pgpaths, list) { - /* Skip failed paths */ - if (!tmp->is_active) - continue; - if (queue_work(kmpath_handlerd, &tmp->activate_path)) - m->pg_init_in_progress++; - } - } + if (m->pg_init_required && !m->pg_init_in_progress && pgpath) + __pg_init(m); + out: spin_unlock_irqrestore(&m->lock, flags); if (!must_queue) @@ -1215,9 +1223,24 @@ static void pg_init_done(void *data, int /* Activations of other paths are still on going */ goto out; - if (!m->pg_init_required) - m->queue_io = 0; + if (m->pg_init_required) { + /* Requested retry or a new pg-init */ + if (likely(m->current_pgpath)) { + __pg_init(m); + goto out; + } + + /* + * The condition requiring pg-init has been changed by someone + * after the pg-init had been requested. + * Cancel m->pg_init_required here explicitly, and start over + * from path selection. + */ + m->pg_init_required = 0; + m->current_pg = NULL; + } + m->queue_io = 0; queue_work(kmultipathd, &m->process_queued_ios); /*