From patchwork Wed Jul 28 22:59:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: babu moger X-Patchwork-Id: 114928 Received: from mx01.colomx.prod.int.phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6SN2AcP001033 for ; Wed, 28 Jul 2010 23:02:46 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6SMxgZq023336; Wed, 28 Jul 2010 18:59:42 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6SMxedL025126 for ; Wed, 28 Jul 2010 18:59:40 -0400 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.12]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6SMxZiU022069 for ; Wed, 28 Jul 2010 18:59:35 -0400 Received: from na3sys009aog108.obsmtp.com (na3sys009aog108.obsmtp.com [74.125.149.199]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6SMxPbS020464 for ; Wed, 28 Jul 2010 18:59:25 -0400 Received: from source ([147.145.40.20]) by na3sys009aob108.postini.com ([74.125.148.12]) with SMTP ID DSNKTFC2TRhqKq8LC3LnyOCS844I2iANY01q@postini.com; Wed, 28 Jul 2010 15:59:26 PDT Received: from milmhbs0.lsil.com (mhbs.lsil.com [147.145.1.30]) by mail0.lsil.com (8.12.11/8.12.11) with ESMTP id o6SMxKFH000301; Wed, 28 Jul 2010 15:59:20 -0700 (PDT) Received: from coscas01.lsi.com (coscas01.co.lsil.com [172.21.36.60]) by milmhbs0.lsil.com (8.12.11/8.12.11) with ESMTP id o6SMxLJB025685; Wed, 28 Jul 2010 15:59:21 -0700 Received: from cosmail01.lsi.com ([172.21.36.24]) by coscas01.lsi.com ([172.21.36.60]) with mapi; Wed, 28 Jul 2010 16:59:20 -0600 From: "Moger, Babu" To: device-mapper development , "linux-scsi@vger.kernel.org" Date: Wed, 28 Jul 2010 16:59:06 -0600 Thread-Topic: [PATCH 2/6] scsi_dh : increment the refcounts while calling activate Thread-Index: AcsuqHtHS4zVojO3Rz6/9nZu2iYrcw== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: BCgX DXqv E5g0 FenY KNsa LE7g MLaB MaTn Mooh NjP3 OjpF Oyqn P6Y3 RQel UVVG VEwb; 2; ZABtAC0AZABlAHYAZQBsAEAAcgBlAGQAaABhAHQALgBjAG8AbQA7AGwAaQBuAHUAeAAtAHMAYwBzAGkAQAB2AGcAZQByAC4AawBlAHIAbgBlAGwALgBvAHIAZwA=; Sosha1_v1; 7; {A7361EE5-9127-465D-B082-883830E31CD8}; YgBhAGIAdQAuAG0AbwBnAGUAcgBAAGwAcwBpAC4AYwBvAG0A; Wed, 28 Jul 2010 22:59:06 GMT; WwBQAEEAVABDAEgAIAAyAC8ANgBdACAAcwBjAHMAaQBfAGQAaAAgADoAIABpAG4AYwByAGUAbQBlAG4AdAAgAHQAaABlACAAcgBlAGYAYwBvAHUAbgB0AHMAIAB3AGgAaQBsAGUAIABjAGEAbABsAGkAbgBnACAAYQBjAHQAaQB2AGEAdABlAA== x-cr-puzzleid: {A7361EE5-9127-465D-B082-883830E31CD8} acceptlanguage: en-US MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.12 X-Scanned-By: MIMEDefang 2.39 X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED,SPF_PASS) X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id o6SMxedL025126 X-loop: dm-devel@redhat.com Cc: "Stankey, Robert" Subject: [dm-devel] [PATCH 2/6] scsi_dh : increment the refcounts while calling activate 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]); Wed, 28 Jul 2010 23:02:46 +0000 (UTC) --- linux-2.6.35-rc5/drivers/scsi/device_handler/scsi_dh.c.orig 2010-07-23 05:40:11.000000000 -0500 +++ linux-2.6.35-rc5/drivers/scsi/device_handler/scsi_dh.c 2010-07-23 05:48:53.000000000 -0500 @@ -228,7 +228,8 @@ store_dh_state(struct device *dev, struc * Activate a device handler */ if (scsi_dh->activate) - err = scsi_dh->activate(sdev, NULL, NULL); + err = scsi_dh_activate(sdev->request_queue, + NULL, NULL); else err = 0; } @@ -431,6 +432,8 @@ EXPORT_SYMBOL_GPL(scsi_unregister_device * do not hold the lock in the caller which may be needed in fn. * @data - data passed to the function fn upon completion. * + * NOTE - Remember to call put_device and kref_put in the handler after + * calling the callback function. Otherwise things could become messy. */ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data) { @@ -450,9 +453,12 @@ int scsi_dh_activate(struct request_queu if (err) return err; - if (scsi_dh->activate) + if (scsi_dh->activate) { + kref_get(&sdev->scsi_dh_data->kref); err = scsi_dh->activate(sdev, fn, data); - put_device(&sdev->sdev_gendev); + } else + put_device(&sdev->sdev_gendev); + return err; } EXPORT_SYMBOL_GPL(scsi_dh_activate);