From patchwork Mon Nov 9 22:24:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: malahal naineni X-Patchwork-Id: 58860 X-Patchwork-Delegate: agk@redhat.com 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 nA9MOWf5002773 for ; Mon, 9 Nov 2009 22:24:32 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 3D8F2619186; Mon, 9 Nov 2009 17:24:32 -0500 (EST) Received: from int-mx08.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nA9MOU9s031858 for ; Mon, 9 Nov 2009 17:24:30 -0500 Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.13]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA9MOUQH022617 for ; Mon, 9 Nov 2009 17:24:30 -0500 Received: from e5.ny.us.ibm.com (e5.ny.us.ibm.com [32.97.182.145]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA9MORfo014083 for ; Mon, 9 Nov 2009 17:24:28 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e5.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id nA9ME0f9021857 for ; Mon, 9 Nov 2009 17:14:00 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nA9MOQJE1515602 for ; Mon, 9 Nov 2009 17:24:26 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id nA9IJi0M030700 for ; Mon, 9 Nov 2009 13:19:44 -0500 Received: from malahal.localdomain (malahal.beaverton.ibm.com [9.47.17.130]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id nA9IJi5X030680 for ; Mon, 9 Nov 2009 13:19:44 -0500 Received: by malahal.localdomain (Postfix, from userid 155450) id BC4BD160199; Mon, 9 Nov 2009 14:24:25 -0800 (PST) Date: Mon, 9 Nov 2009 14:24:25 -0800 From: malahal@us.ibm.com To: dm-devel@redhat.com Subject: Re: [dm-devel] [PATCH] a deadlock bug in the kernel-side device mapper code Message-ID: <20091109222425.GA3577@us.ibm.com> Mail-Followup-To: dm-devel@redhat.com References: <4AF2D176.4010000@actcom.co.il> <20091105142435.GQ13375@agk-dp.fab.redhat.com> <20091109085142.GA4432@linux.vnet.ibm.com> <20091109175730.GA12556@us.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091109175730.GA12556@us.ibm.com> X-Operating-System: Linux 2.0.32 on an i486 User-Agent: Mutt/1.5.20 (2009-06-14) X-RedHat-Spam-Score: -4 (RCVD_IN_DNSWL_MED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.13 X-loop: dm-devel@redhat.com 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 diff -r e4c5c66b9a17 drivers/md/dm-ioctl.c --- a/drivers/md/dm-ioctl.c Mon Nov 09 13:38:38 2009 -0800 +++ b/drivers/md/dm-ioctl.c Mon Nov 09 14:21:13 2009 -0800 @@ -1595,7 +1595,6 @@ if (!md) return -ENXIO; - dm_get(md); mutex_lock(&_name_read_lock); hc = dm_get_mdptr(md); if (!hc || hc->md != md) { @@ -1610,7 +1609,6 @@ out: mutex_unlock(&_name_read_lock); - dm_put(md); return r; } diff -r e4c5c66b9a17 drivers/md/dm.c --- a/drivers/md/dm.c Mon Nov 09 13:38:38 2009 -0800 +++ b/drivers/md/dm.c Mon Nov 09 14:21:13 2009 -0800 @@ -1998,28 +1998,24 @@ if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) return NULL; - spin_lock(&_minor_lock); - md = idr_find(&_minor_idr, minor); if (md && (md == MINOR_ALLOCED || (MINOR(disk_devt(dm_disk(md))) != minor) || - test_bit(DMF_FREEING, &md->flags))) { - md = NULL; - goto out; - } - -out: - spin_unlock(&_minor_lock); + test_bit(DMF_FREEING, &md->flags))) + return NULL; return md; } struct mapped_device *dm_get_md(dev_t dev) { - struct mapped_device *md = dm_find_md(dev); + struct mapped_device *md; + spin_lock(&_minor_lock); + md = dm_find_md(dev); if (md) dm_get(md); + spin_unlock(&_minor_lock); return md; } @@ -2584,11 +2580,17 @@ if (&md->kobj != kobj) return NULL; + spin_lock(&_minor_lock); + if (test_bit(DMF_FREEING, &md->flags) || test_bit(DMF_DELETING, &md->flags)) - return NULL; + md = NULL; - dm_get(md); + if (md) + dm_get(md); + + spin_unlock(&_minor_lock); + return md; }