Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106583
b: refs/heads/master
c: ae11b1b
h: refs/heads/master
i:
  106581: 602ff5e
  106579: ddce57e
  106575: f4a578a
v: v3
  • Loading branch information
Hannes Reinecke authored and James Bottomley committed Jul 26, 2008
1 parent 0965dec commit 30045e6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 057ea7c9683c3d684128cced796f03c179ecf1c2
refs/heads/master: ae11b1b36da726a8a93409b896704edc6b4f3402
13 changes: 13 additions & 0 deletions trunk/drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,12 @@ static struct priority_group *alloc_priority_group(void)
static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
{
struct pgpath *pgpath, *tmp;
struct multipath *m = ti->private;

list_for_each_entry_safe(pgpath, tmp, pgpaths, list) {
list_del(&pgpath->list);
if (m->hw_handler_name)
scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev));
dm_put_device(ti, pgpath->path.dev);
free_pgpath(pgpath);
}
Expand Down Expand Up @@ -548,6 +551,7 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
{
int r;
struct pgpath *p;
struct multipath *m = ti->private;

/* we need at least a path arg */
if (as->argc < 1) {
Expand All @@ -566,6 +570,15 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
goto bad;
}

if (m->hw_handler_name) {
r = scsi_dh_attach(bdev_get_queue(p->path.dev->bdev),
m->hw_handler_name);
if (r < 0) {
dm_put_device(ti, p->path.dev);
goto bad;
}
}

r = ps->type->add_path(ps, &p->path, as->argc, as->argv, &ti->error);
if (r) {
dm_put_device(ti, p->path.dev);
Expand Down
64 changes: 64 additions & 0 deletions trunk/drivers/scsi/device_handler/scsi_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,70 @@ int scsi_dh_handler_exist(const char *name)
}
EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);

/*
* scsi_dh_handler_attach - Attach device handler
* @sdev - sdev the handler should be attached to
* @name - name of the handler to attach
*/
int scsi_dh_attach(struct request_queue *q, const char *name)
{
unsigned long flags;
struct scsi_device *sdev;
struct scsi_device_handler *scsi_dh;
int err = 0;

scsi_dh = get_device_handler(name);
if (!scsi_dh)
return -EINVAL;

spin_lock_irqsave(q->queue_lock, flags);
sdev = q->queuedata;
if (!sdev || !get_device(&sdev->sdev_gendev))
err = -ENODEV;
spin_unlock_irqrestore(q->queue_lock, flags);

if (!err) {
err = scsi_dh_handler_attach(sdev, scsi_dh);

put_device(&sdev->sdev_gendev);
}
return err;
}
EXPORT_SYMBOL_GPL(scsi_dh_attach);

/*
* scsi_dh_handler_detach - Detach device handler
* @sdev - sdev 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
* if it has been attached manually.
*/
void scsi_dh_detach(struct request_queue *q)
{
unsigned long flags;
struct scsi_device *sdev;
struct scsi_device_handler *scsi_dh = 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;

if (sdev->scsi_dh_data) {
/* if sdev is not on internal list, detach */
scsi_dh = sdev->scsi_dh_data->scsi_dh;
if (!device_handler_match(scsi_dh, sdev))
scsi_dh_handler_detach(sdev, scsi_dh);
}
put_device(&sdev->sdev_gendev);
}
EXPORT_SYMBOL_GPL(scsi_dh_detach);

static struct notifier_block scsi_dh_nb = {
.notifier_call = scsi_dh_notifier
};
Expand Down
10 changes: 10 additions & 0 deletions trunk/include/scsi/scsi_dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ enum {
#if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE)
extern int scsi_dh_activate(struct request_queue *);
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 *);
#else
static inline int scsi_dh_activate(struct request_queue *req)
{
Expand All @@ -67,4 +69,12 @@ static inline int scsi_dh_handler_exist(const char *name)
{
return 0;
}
static inline int scsi_dh_attach(struct request_queue *req, const char *name)
{
return SCSI_DH_NOSYS;
}
static inline void scsi_dh_detach(struct request_queue *q)
{
return;
}
#endif

0 comments on commit 30045e6

Please sign in to comment.