From patchwork Wed Nov 11 01:16:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alasdair G Kergon X-Patchwork-Id: 59224 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 nAB1Gudi028715 for ; Wed, 11 Nov 2009 01:16:56 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 CC165619A4F; Tue, 10 Nov 2009 20:16:55 -0500 (EST) Received: from int-mx02.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 nAB1GsiH012923 for ; Tue, 10 Nov 2009 20:16:54 -0500 Received: from agk-dp.fab.redhat.com (agk-dp.fab.redhat.com [10.33.0.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAB1Gr7v004126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Nov 2009 20:16:54 -0500 Received: from agk by agk-dp.fab.redhat.com with local (Exim 4.69) (envelope-from ) id 1N81pM-0003lU-Lx; Wed, 11 Nov 2009 01:16:52 +0000 Date: Wed, 11 Nov 2009 01:16:52 +0000 From: Alasdair G Kergon To: dm-devel@redhat.com Message-ID: <20091111011652.GK17055@agk-dp.fab.redhat.com> Mail-Followup-To: dm-devel@redhat.com, Mike Snitzer , Mikulas Patocka , Jonathan Brassow , Kiyoshi Ueda , Jun'ichi Nomura , Milan Broz , Zdenek Kabelac , Heinz Mauelshagen MIME-Version: 1.0 Content-Disposition: inline Organization: Red Hat UK Ltd. Registered in England and Wales, number 03798903. Registered Office: Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE. User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Kiyoshi Ueda , Mike Snitzer , Heinz Mauelshagen , Mikulas Patocka , Zdenek Kabelac , "Jun'ichi Nomura" , Milan Broz Subject: [dm-devel] dm: bind new table before destroying old 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 Index: linux-2.6.32-rc6/drivers/md/dm-table.c =================================================================== --- linux-2.6.32-rc6.orig/drivers/md/dm-table.c +++ linux-2.6.32-rc6/drivers/md/dm-table.c @@ -237,6 +237,9 @@ void dm_table_destroy(struct dm_table *t { unsigned int i; + if (!t) + return; + while (atomic_read(&t->holders)) msleep(1); smp_mb(); Index: linux-2.6.32-rc6/drivers/md/dm.c =================================================================== --- linux-2.6.32-rc6.orig/drivers/md/dm.c +++ linux-2.6.32-rc6/drivers/md/dm.c @@ -2070,7 +2070,10 @@ static int __bind(struct mapped_device * return 0; } -static void __unbind(struct mapped_device *md) +/* + * Returns unbound table for the caller to free. + */ +struct dm_table *__unbind(struct mapped_device *md) { struct dm_table *map = md->map; unsigned long flags; @@ -2082,7 +2085,8 @@ static void __unbind(struct mapped_devic write_lock_irqsave(&md->map_lock, flags); md->map = NULL; write_unlock_irqrestore(&md->map_lock, flags); - dm_table_destroy(map); + + return map; } /* @@ -2175,7 +2179,7 @@ void dm_put(struct mapped_device *md) } dm_sysfs_exit(md); dm_table_put(map); - __unbind(md); + dm_table_destroy(__unbind(md)); free_dev(md); } } @@ -2381,8 +2385,9 @@ int dm_swap_table(struct mapped_device * goto out; } - __unbind(md); + map = __unbind(md); r = __bind(md, table, &limits); + dm_table_destroy(map); out: mutex_unlock(&md->suspend_lock);