dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Shyam Iyer <shyam_iyer@dell.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: "Moger, Babu" <Babu.Moger@lsi.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"Stankey, Robert" <Robert.Stankey@lsi.com>
Subject: Re: [dm-devel] [PATCH 2/6] scsi_dh : increment the refcounts while calling activate
Date: Thu, 29 Jul 2010 00:46:51 -0400	[thread overview]
Message-ID: <4C5107BB.8020201@dell.com> (raw)
In-Reply-To: <E463DF2B2E584B4A82673F53D62C2EF4D05DC422@cosmail01.lsi.com>

On 07/28/2010 06:59 PM, Moger, Babu wrote:
> Hold the refcounts for device and scsi_dh_data while calling handler's activate. This will make sure that devices and scsi_dh_data are not removed while activate is still in progress. Make sure to call put_device and kref_put in the handler after activate is complete.
>
> Signed-off-by: Babu Moger<babu.moger@lsi.com>
> ---
> --- 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);
>    
Why not kref_put here instead of in the device handler.. It is easier to 
associate the ref counts..

Also, you are removing the put_device here and adding them to the device 
handler which can be avoided ..
> -	put_device(&sdev->sdev_gendev);
> +	} else
> +		put_device(&sdev->sdev_gendev);
> +
>   	return err;
>   }
>   EXPORT_SYMBOL_GPL(scsi_dh_activate);
>
>
>
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
>    

-Shyam Iyer

  reply	other threads:[~2010-07-29  4:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-28 22:59 [PATCH 2/6] scsi_dh : increment the refcounts while calling activate Moger, Babu
2010-07-29  4:46 ` Shyam Iyer [this message]
2010-07-30  0:08 ` James Bottomley
2010-07-30 18:15   ` Moger, Babu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5107BB.8020201@dell.com \
    --to=shyam_iyer@dell.com \
    --cc=Babu.Moger@lsi.com \
    --cc=Robert.Stankey@lsi.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).