From patchwork Tue Jun 8 10:26:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiyoshi Ueda X-Patchwork-Id: 104928 X-Patchwork-Delegate: agk@redhat.com Received: from mx02.colomx.prod.int.phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o58AVhS8017296 for ; Tue, 8 Jun 2010 10:32:19 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx02.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o58ATRl4024274; Tue, 8 Jun 2010 06:29:29 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o58ATRGN002512 for ; Tue, 8 Jun 2010 06:29:27 -0400 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.10]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o58ATMtB028841; Tue, 8 Jun 2010 06:29:22 -0400 Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp [202.32.8.193]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o58ATCP9027386; Tue, 8 Jun 2010 06:29:12 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.195]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id o58ATBJJ008456; Tue, 8 Jun 2010 19:29:11 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id o58ATB413587; Tue, 8 Jun 2010 19:29:11 +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 o58ATBYl007133; Tue, 8 Jun 2010 19:29:11 +0900 (JST) Received: from shoin.jp.nec.com ([10.26.220.3] [10.26.220.3]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-3406032; Tue, 8 Jun 2010 19:26:37 +0900 Received: from elcondor.linux.bs1.fc.nec.co.jp ([10.34.125.146] [10.34.125.146]) by mail.jp.nec.com with ESMTP; Tue, 8 Jun 2010 19:26:34 +0900 Message-ID: <4C0E1ADA.2030003@ct.jp.nec.com> Date: Tue, 08 Jun 2010 19:26:34 +0900 From: Kiyoshi Ueda User-Agent: Thunderbird 2.0.0.23 (X11/20090825) MIME-Version: 1.0 To: Alasdair Kergon References: <4C0E19A0.1040804@ct.jp.nec.com> In-Reply-To: <4C0E19A0.1040804@ct.jp.nec.com> X-RedHat-Spam-Score: -0.002 (SPF_HELO_PASS,SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.10 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [PATCH 2/3] dm: release _hash_lock when removing device in remove_all 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]); Tue, 08 Jun 2010 10:32:19 +0000 (UTC) Index: 2.6.35-rc1/drivers/md/dm-ioctl.c =================================================================== --- 2.6.35-rc1.orig/drivers/md/dm-ioctl.c +++ 2.6.35-rc1/drivers/md/dm-ioctl.c @@ -249,40 +249,42 @@ static void __hash_remove(struct hash_ce static void dm_hash_remove_all(int keep_open_devices) { - int i, dev_skipped, dev_removed; + int i, dev_skipped; struct hash_cell *hc; - struct list_head *tmp, *n; - - down_write(&_hash_lock); + struct mapped_device *md; retry: - dev_skipped = dev_removed = 0; - for (i = 0; i < NUM_BUCKETS; i++) { - list_for_each_safe (tmp, n, _name_buckets + i) { - hc = list_entry(tmp, struct hash_cell, name_list); + down_write(&_hash_lock); + for (dev_skipped = 0, i = 0; i < NUM_BUCKETS; i++) { + list_for_each_entry(hc, _name_buckets + i, name_list) { + md = hc->md; + dm_get(md); - if (keep_open_devices && - dm_lock_for_deletion(hc->md)) { + if (keep_open_devices && dm_lock_for_deletion(md)) { + dm_put(md); dev_skipped++; continue; } + __hash_remove(hc); - dev_removed = 1; - } - } + up_write(&_hash_lock); - /* - * Some mapped devices may be using other mapped devices, so if any - * still exist, repeat until we make no further progress. - */ - if (dev_skipped) { - if (dev_removed) - goto retry; + dm_put(md); - DMWARN("remove_all left %d open device(s)", dev_skipped); + /* + * Some mapped devices may be using other mapped + * devices, so repeat until we make no further + * progress. + * If a new mapped device is created here, it will be + * also removed. + */ + goto retry; + } } - up_write(&_hash_lock); + + if (dev_skipped) + DMWARN("remove_all left %d open device(s)", dev_skipped); } static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,