Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 5751
b: refs/heads/master
c: 5c44cd2
h: refs/heads/master
i:
  5749: a9e875c
  5747: 90f02a9
  5743: 3a25018
v: v3
  • Loading branch information
James.Smart@Emulex.Com authored and James Bottomley committed Aug 8, 2005
1 parent ca5ef09 commit 1da8086
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 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: 9c472dd9197429a37691e91c938660a062bf20b0
refs/heads/master: 5c44cd2afad3f7b015542187e147a820600172f1
16 changes: 15 additions & 1 deletion trunk/drivers/scsi/scsi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,23 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
unsigned long flags;
const int size = sizeof(struct scsi_target)
+ shost->transportt->target_size;
struct scsi_target *starget = kmalloc(size, GFP_ATOMIC);
struct scsi_target *starget;
struct scsi_target *found_target;

/*
* Obtain the real parent from the transport. The transport
* is allowed to fail (no error) if there is nothing at that
* target id.
*/
if (shost->transportt->target_parent) {
spin_lock_irqsave(shost->host_lock, flags);
parent = shost->transportt->target_parent(shost, channel, id);
spin_unlock_irqrestore(shost->host_lock, flags);
if (!parent)
return NULL;
}

starget = kmalloc(size, GFP_KERNEL);
if (!starget) {
printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
return NULL;
Expand Down
19 changes: 19 additions & 0 deletions trunk/drivers/scsi/scsi_transport_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,23 @@ static int fc_rport_match(struct attribute_container *cont,
return &i->rport_attr_cont.ac == cont;
}


/*
* Must be called with shost->host_lock held
*/
static struct device *fc_target_parent(struct Scsi_Host *shost,
int channel, uint id)
{
struct fc_rport *rport;

list_for_each_entry(rport, &fc_host_rports(shost), peers)
if ((rport->channel == channel) &&
(rport->scsi_target_id == id))
return &rport->dev;

return NULL;
}

struct scsi_transport_template *
fc_attach_transport(struct fc_function_template *ft)
{
Expand Down Expand Up @@ -1057,6 +1074,8 @@ fc_attach_transport(struct fc_function_template *ft)

/* Transport uses the shost workq for scsi scanning */
i->t.create_work_queue = 1;

i->t.target_parent = fc_target_parent;

/*
* Setup SCSI Target Attributes.
Expand Down
8 changes: 8 additions & 0 deletions trunk/include/scsi/scsi_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ struct scsi_transport_template {
struct transport_container target_attrs;
struct transport_container device_attrs;

/*
* If set, call target_parent prior to allocating a scsi_target,
* so we get the appropriate parent for the target. This function
* is required for transports like FC and iSCSI that do not put the
* scsi_target under scsi_host.
*/
struct device *(*target_parent)(struct Scsi_Host *, int, uint);

/* The size of the specific transport attribute structure (a
* space of this size will be left at the end of the
* scsi_* structure */
Expand Down

0 comments on commit 1da8086

Please sign in to comment.