From patchwork Wed Oct 30 03:26:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Merla, ShivaKrishna" X-Patchwork-Id: 3113411 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6A936BF924 for ; Wed, 30 Oct 2013 07:12:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E6C720200 for ; Wed, 30 Oct 2013 07:12:35 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id 829BD201FE for ; Wed, 30 Oct 2013 07:12:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9U78T5A003310; Wed, 30 Oct 2013 03:08:30 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9U3Qf8q012292 for ; Tue, 29 Oct 2013 23:26:41 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9U3QfBj025886; Tue, 29 Oct 2013 23:26:41 -0400 Received: from mx1.netapp.com (mx1.netapp.com [216.240.18.38]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9U3QdcV021130; Tue, 29 Oct 2013 23:26:39 -0400 X-IronPort-AV: E=Sophos;i="4.93,597,1378882800"; d="scan'208";a="288908842" Received: from vmwexceht03-prd.hq.netapp.com ([10.106.76.241]) by mx1-out.netapp.com with ESMTP; 29 Oct 2013 20:26:39 -0700 Received: from SACEXCMBX02-PRD.hq.netapp.com ([169.254.1.86]) by vmwexceht03-prd.hq.netapp.com ([10.106.76.241]) with mapi id 14.03.0123.003; Tue, 29 Oct 2013 20:26:39 -0700 From: "Merla, ShivaKrishna" To: "dm-devel@redhat.com" Thread-Topic: [PATCH][RESEND]dm-mpath: fix for race condition between multipath_dtr and pg_init_done. Thread-Index: Ac7VH3MfKuY0y7MNRZKOmzMuLxb0GQ== Date: Wed, 30 Oct 2013 03:26:38 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.106.53.51] MIME-Version: 1.0 X-RedHat-Spam-Score: -7.805 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id r9U3Qf8q012292 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 30 Oct 2013 03:07:12 -0400 Cc: "agk@redhat.com" , "snitzer@redhat.com" Subject: [dm-devel] [PATCH][RESEND]dm-mpath: fix for race condition between multipath_dtr and pg_init_done. 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-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Whenever multipath_dtr is happening, we should prevent queueing any further path activation work. There was a kernel panic where after pg_init_done() decrements pg_init_in_progress to 0, wait_for_pg_init_completion call assumes there are no more pending path management commands. But if pg_init_required is set by pg_init_done call due to retriable mode_select errors , then process_queued_ios() will again queue the path activation work. If free_multipath call has been completed by the time activate_path work is called, kernel panic was seen on accessing multipath members. BUG: unable to handle kernel NULL pointer dereference at 0000000000000090 RIP: 0010:[] [] activate_path+0x1b/0x30 [dm_multipath] [] worker_thread+0x170/0x2a0 [] ? autoremove_wake_function+0x0/0x40 Signed-off-by: Shiva Krishna Merla Reviewed-by: Krishnasamy Somasundaram Tested-by: Speagle Andy --- -- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- a/drivers/md/dm-mpath.c 2013-01-29 10:12:10.000000000 -0600 +++ b/drivers/md/dm-mpath.c 2013-10-29 21:02:03.267685017 -0500 @@ -73,6 +73,7 @@ struct multipath { wait_queue_head_t pg_init_wait; /* Wait for pg_init completion */ + unsigned dtr_in_progress; /* multipath destroy in progress */ unsigned pg_init_required; /* pg_init needs calling? */ unsigned pg_init_in_progress; /* Only one pg_init allowed at once */ unsigned pg_init_delay_retry; /* Delay pg_init retry? */ @@ -498,7 +499,8 @@ 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) + if (m->pg_init_required && !m->pg_init_in_progress && pgpath && + !m->dtr_in_progress) __pg_init_all_paths(m); spin_unlock_irqrestore(&m->lock, flags); @@ -951,6 +953,11 @@ static void flush_multipath_work(struct static void multipath_dtr(struct dm_target *ti) { struct multipath *m = ti->private; + unsigned long flags; + + spin_lock_irqsave(&m->lock, flags); + m->dtr_in_progress = 1; + spin_unlock_irqrestore(&m->lock, flags); flush_multipath_work(m); free_multipath(m); @@ -1164,7 +1171,7 @@ static int pg_init_limit_reached(struct spin_lock_irqsave(&m->lock, flags); - if (m->pg_init_count <= m->pg_init_retries) + if (m->pg_init_count <= m->pg_init_retries && !m->dtr_in_progress) m->pg_init_required = 1; else limit_reached = 1;