Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316797
b: refs/heads/master
c: 7e8a74b
h: refs/heads/master
i:
  316795: 21669d2
v: v3
  • Loading branch information
Mike Snitzer authored and James Bottomley committed Jul 20, 2012
1 parent 318cd5d commit e2d02ef
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6aca4112f67b67d0a2f60326a1331a4125564ca7
refs/heads/master: 7e8a74b177f17d100916b6ad415450f7c9508691
38 changes: 36 additions & 2 deletions trunk/drivers/scsi/device_handler/scsi_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -527,6 +529,38 @@ 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
* @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)
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
};
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/scsi/scsi_dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *, gfp_t);
extern int scsi_dh_set_params(struct request_queue *, const char *);
#else
static inline int scsi_dh_activate(struct request_queue *req,
Expand All @@ -80,6 +81,11 @@ static inline void scsi_dh_detach(struct request_queue *q)
{
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;
Expand Down

0 comments on commit e2d02ef

Please sign in to comment.