All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Mike Snitzer <snitzer@redhat.com>
Cc: dm-devel@redhat.com, babu.moger@netapp.com, agk@redhat.com
Subject: Re: [PATCH v2 2/5] scsi_dh: add scsi_dh_attached_handler_name
Date: Wed, 09 May 2012 08:57:53 +0200	[thread overview]
Message-ID: <4FAA1571.4090007@suse.de> (raw)
In-Reply-To: <1336514167-15393-3-git-send-email-snitzer@redhat.com>

On 05/08/2012 11:56 PM, Mike Snitzer wrote:
> Introduce scsi_dh_attached_handler_name() to retrieve the name of the
> scsi_dh that is attached to the scsi_device associated with the provided
> request queue.  Returns NULL if a scsi_dh is not attached.
> 
> Also, fix scsi_dh_{attach,detach} function header comments to document
> @q rather than @sdev.
> 
> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
> ---
>  drivers/scsi/device_handler/scsi_dh.c |   31 +++++++++++++++++++++++++++++--
>  include/scsi/scsi_dh.h                |    5 +++++
>  2 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
> index 48e46f5..7497c78 100644
> --- a/drivers/scsi/device_handler/scsi_dh.c
> +++ b/drivers/scsi/device_handler/scsi_dh.c
> @@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);
>  
>  /*
>   * scsi_dh_attach - Attach device handler
> - * @sdev - sdev the handler should be attached to
> + * @q - Request queue that is associated with the scsi_device
> + *      the handler should be attached to
>   * @name - name of the handler to attach
>   */
>  int scsi_dh_attach(struct request_queue *q, const char *name)
> @@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);
>  
>  /*
>   * scsi_dh_detach - Detach device handler
> - * @sdev - sdev the handler should be detached from
> + * @q - Request queue that is associated with the scsi_device
> + *      the handler should be detached from
>   *
>   * This function will detach the device handler only
>   * if the sdev is not part of the internal list, ie
> @@ -527,6 +529,31 @@ void scsi_dh_detach(struct request_queue *q)
>  }
>  EXPORT_SYMBOL_GPL(scsi_dh_detach);
>  
> +/*
> + * scsi_dh_attached_handler_name - Get attached device handler's name
> + * @q - Request queue that is associated with the scsi_device
> + *      that may have a device handler attached
> + *
> + * Returns name of attached scsi_dh, NULL if no handler is attached.
> + */
> +const char *scsi_dh_attached_handler_name(struct request_queue *q)
> +{
> +	unsigned long flags;
> +	struct scsi_device *sdev;
> +
> +	spin_lock_irqsave(q->queue_lock, flags);
> +	sdev = q->queuedata;
> +	if (!sdev || !get_device(&sdev->sdev_gendev))
> +		sdev = NULL;
> +	spin_unlock_irqrestore(q->queue_lock, flags);
> +
> +	if (!sdev || !sdev->scsi_dh_data)
> +		return NULL;
> +
> +	return sdev->scsi_dh_data->scsi_dh->name;
> +}
> +EXPORT_SYMBOL_GPL(scsi_dh_attached_handler_name);
> +
>  static struct notifier_block scsi_dh_nb = {
>  	.notifier_call = scsi_dh_notifier
>  };
> diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h
> index e3f2db2..94f502b 100644
> --- a/include/scsi/scsi_dh.h
> +++ b/include/scsi/scsi_dh.h
> @@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
>  extern int scsi_dh_handler_exist(const char *);
>  extern int scsi_dh_attach(struct request_queue *, const char *);
>  extern void scsi_dh_detach(struct request_queue *);
> +extern const char *scsi_dh_attached_handler_name(struct request_queue *q);
>  extern int scsi_dh_set_params(struct request_queue *, const char *);
>  #else
>  static inline int scsi_dh_activate(struct request_queue *req,
> @@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct request_queue *q)
>  {
>  	return;
>  }
> +static inline const char *scsi_dh_attached_handler_name(struct request_queue *q)
> +{
> +	return NULL;
> +}
>  static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
>  {
>  	return -SCSI_DH_NOSYS;

Acked-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

  reply	other threads:[~2012-05-09  6:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-08 21:56 [PATCH v2 0/5] dm mpath: add 'default_hw_handler' and 'no_partitions' features Mike Snitzer
2012-05-08 21:56 ` [PATCH v2 1/5] dm mpath: only try to load the scsi_dh module if the scsi_dh doesn't exist Mike Snitzer
2012-05-09  6:57   ` Hannes Reinecke
2012-05-09 22:54   ` Chandra Seetharaman
2012-05-08 21:56 ` [PATCH v2 2/5] scsi_dh: add scsi_dh_attached_handler_name Mike Snitzer
2012-05-09  6:57   ` Hannes Reinecke [this message]
2012-05-09 17:40   ` Moger, Babu
2012-05-09 20:41     ` [PATCH v3 " Mike Snitzer
2012-05-09 20:41     ` Mike Snitzer
2012-05-09 22:54       ` Chandra Seetharaman
2012-05-09 22:54       ` Chandra Seetharaman
2012-05-08 21:56 ` [PATCH v2 3/5] dm mpath: reduce size of multipath structure Mike Snitzer
2012-05-09  6:58   ` Hannes Reinecke
2012-05-08 21:56 ` [PATCH v2 4/5] dm mpath: add 'default_hw_handler' feature Mike Snitzer
2012-05-09 18:10   ` Moger, Babu
2012-05-09 19:17     ` Mike Snitzer
2012-05-09 20:35       ` Moger, Babu
2012-05-09 23:02   ` Chandra Seetharaman
2012-05-10 21:31   ` [PATCH v3 " Mike Snitzer
2012-05-17 21:15     ` Chandra Seetharaman
2012-05-08 21:56 ` [PATCH v2 5/5] dm mpath: add ability to disable partition creation Mike Snitzer
2012-05-09 23:04   ` Chandra Seetharaman

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=4FAA1571.4090007@suse.de \
    --to=hare@suse.de \
    --cc=agk@redhat.com \
    --cc=babu.moger@netapp.com \
    --cc=dm-devel@redhat.com \
    --cc=snitzer@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.