From patchwork Wed Jan 7 20:41:43 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: 1240 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 n07KcDaM003741 for ; Wed, 7 Jan 2009 12:38:13 -0800 Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 877CC8E0143; Wed, 7 Jan 2009 15:41:48 -0500 (EST) Received: from int-mx2.corp.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 n07Kfj6P002494 for ; Wed, 7 Jan 2009 15:41:46 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n07Kfkg4011334; Wed, 7 Jan 2009 15:41:46 -0500 Received: from agk.fab.redhat.com (agk.fab.redhat.com [10.33.0.19]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n07KfjSR013111; Wed, 7 Jan 2009 15:41:45 -0500 Received: from agk by agk.fab.redhat.com with local (Exim 4.34) id 1LKfDj-0000Fy-U0; Wed, 07 Jan 2009 20:41:43 +0000 Date: Wed, 7 Jan 2009 20:41:43 +0000 From: Alasdair G Kergon To: dm-devel@redhat.com Message-ID: <20090107204143.GR3512@agk.fab.redhat.com> Mail-Followup-To: dm-devel@redhat.com, Cheng Renquan Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.4.1i Organization: Red Hat UK Ltd. Registered in England and Wales, number 04098903. Registered Office: Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE. X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-loop: dm-devel@redhat.com Cc: Cheng Renquan Subject: [dm-devel] [2.6.29 PATCH 01/02] dm target: use module refcount directly 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 From: Cheng Renquan The tt_internal's 'use' field is superfluous: the module's refcount can do the work properly. An acceptable side-effect is that this increases the reference counts reported by 'lsmod'. Remove the superfluous test when removing a target module. Signed-off-by: Cheng Renquan Reviewed-by: Alasdair G Kergon Signed-off-by: Alasdair G Kergon Reviewed-by: Jonathan Brassow --- drivers/md/dm-target.c | 20 +++----------------- 1 files changed, 3 insertions(+), 17 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6.28/drivers/md/dm-target.c =================================================================== --- linux-2.6.28.orig/drivers/md/dm-target.c 2009-01-07 20:29:57.000000000 +0000 +++ linux-2.6.28/drivers/md/dm-target.c 2009-01-07 20:30:57.000000000 +0000 @@ -18,7 +18,6 @@ struct tt_internal { struct target_type tt; struct list_head list; - long use; }; static LIST_HEAD(_targets); @@ -44,12 +43,8 @@ static struct tt_internal *get_target_ty down_read(&_lock); ti = __find_target_type(name); - if (ti) { - if ((ti->use == 0) && !try_module_get(ti->tt.module)) - ti = NULL; - else - ti->use++; - } + if (ti && !try_module_get(ti->tt.module)) + ti = NULL; up_read(&_lock); return ti; @@ -77,10 +72,7 @@ void dm_put_target_type(struct target_ty struct tt_internal *ti = (struct tt_internal *) t; down_read(&_lock); - if (--ti->use == 0) - module_put(ti->tt.module); - - BUG_ON(ti->use < 0); + module_put(ti->tt.module); up_read(&_lock); return; @@ -140,12 +132,6 @@ void dm_unregister_target(struct target_ BUG(); } - if (ti->use) { - DMCRIT("Attempt to unregister target still in use: %s", - t->name); - BUG(); - } - list_del(&ti->list); kfree(ti);