From: Mike Snitzer <snitzer@redhat.com>
To: Chandra Seetharaman <sekharan@us.ibm.com>
Cc: linux-scsi@vger.kernel.org, agk@redhat.com, hare@suse.de,
babu.moger@netapp.com, dm-devel@redhat.com
Subject: Re: [PATCH v4 2/5] scsi_dh: add scsi_dh_attached_handler_name
Date: Thu, 17 May 2012 17:23:34 -0400 [thread overview]
Message-ID: <20120517212333.GA5312@redhat.com> (raw)
In-Reply-To: <1337289153.2825.9.camel@chandra-lucid.austin.ibm.com>
On Thu, May 17 2012 at 5:12pm -0400,
Chandra Seetharaman <sekharan@us.ibm.com> wrote:
> > +/*
> > + * 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
> > + * @gfp - the GFP mask used in the kmalloc() call when allocating memory
> > + *
> > + * Returns name of attached handler, NULL if no handler is attached.
> > + * Caller must take care to free the returned string.
> > + */
> > +const char *scsi_dh_attached_handler_name(struct request_queue *q, gfp_t gfp)
> > +{
> > + unsigned long flags;
> > + struct scsi_device *sdev;
> > + const char *handler_name = NULL;
> > +
> > + 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)
>
> put_device() missing here.
Not that I can see. If sdev is NULL then get_device never succeeded.
(same pattern is used in scsi_dh_detach)
> > + return NULL;
> > +
> > + if (sdev->scsi_dh_data)
> > + handler_name = kstrdup(sdev->scsi_dh_data->scsi_dh->name, gfp);
> > +
> > + put_device(&sdev->sdev_gendev);
> > + return handler_name;
> > +}
> > +EXPORT_SYMBOL_GPL(scsi_dh_attached_handler_name);
> > +
> > static struct notifier_block scsi_dh_nb = {
> > .notifier_call = scsi_dh_notifier
> > };
> > Index: linux-2.6/include/scsi/scsi_dh.h
> > ===================================================================
> > --- linux-2.6.orig/include/scsi/scsi_dh.h
> > +++ linux-2.6/include/scsi/scsi_dh.h
> > @@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct reque
> > 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 *, gfp_t);
> > 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,11 @@ static inline void scsi_dh_detach(struct
> > {
> > return;
> > }
> > +static inline const char *scsi_dh_attached_handler_name(struct request_queue *q,
> > + gfp_t gfp)
> > +{
> > + return NULL;
> > +}
> > static inline int scsi_dh_set_params(struct request_queue *req, const char *params)
> > {
> > return -SCSI_DH_NOSYS;
> >
>
>
next prev parent reply other threads:[~2012-05-17 21:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-10 1:12 [PATCH v3 2/5] scsi_dh: add scsi_dh_attached_handler_name Mike Snitzer
2012-05-10 6:55 ` Christoph Hellwig
2012-05-10 14:10 ` Mike Snitzer
2012-05-10 18:14 ` Moger, Babu
2012-05-10 20:26 ` Moger, Babu
2012-05-10 21:31 ` [PATCH v4 " Mike Snitzer
2012-05-17 21:12 ` Chandra Seetharaman
2012-05-17 21:23 ` Mike Snitzer [this message]
2012-05-17 22:57 ` Chandra Seetharaman
2012-05-17 22:58 ` Chandra Seetharaman
2012-05-21 18:45 ` Mike Snitzer
2012-06-08 15:03 ` Hannes Reinecke
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=20120517212333.GA5312@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=babu.moger@netapp.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=sekharan@us.ibm.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 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).