|
@@ -55,24 +55,6 @@ static struct se_subsystem_api pscsi_template;
|
|
|
|
|
|
static void pscsi_req_done(struct request *, int);
|
|
static void pscsi_req_done(struct request *, int);
|
|
|
|
|
|
-/* pscsi_get_sh():
|
|
|
|
- *
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-static struct Scsi_Host *pscsi_get_sh(u32 host_no)
|
|
|
|
-{
|
|
|
|
- struct Scsi_Host *sh = NULL;
|
|
|
|
-
|
|
|
|
- sh = scsi_host_lookup(host_no);
|
|
|
|
- if (IS_ERR(sh)) {
|
|
|
|
- printk(KERN_ERR "Unable to locate SCSI HBA with Host ID:"
|
|
|
|
- " %u\n", host_no);
|
|
|
|
- return NULL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return sh;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/* pscsi_attach_hba():
|
|
/* pscsi_attach_hba():
|
|
*
|
|
*
|
|
* pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host.
|
|
* pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host.
|
|
@@ -80,28 +62,23 @@ static struct Scsi_Host *pscsi_get_sh(u32 host_no)
|
|
*/
|
|
*/
|
|
static int pscsi_attach_hba(struct se_hba *hba, u32 host_id)
|
|
static int pscsi_attach_hba(struct se_hba *hba, u32 host_id)
|
|
{
|
|
{
|
|
- int hba_depth;
|
|
|
|
struct pscsi_hba_virt *phv;
|
|
struct pscsi_hba_virt *phv;
|
|
|
|
|
|
phv = kzalloc(sizeof(struct pscsi_hba_virt), GFP_KERNEL);
|
|
phv = kzalloc(sizeof(struct pscsi_hba_virt), GFP_KERNEL);
|
|
- if (!(phv)) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate struct pscsi_hba_virt\n");
|
|
|
|
- return -1;
|
|
|
|
|
|
+ if (!phv) {
|
|
|
|
+ pr_err("Unable to allocate struct pscsi_hba_virt\n");
|
|
|
|
+ return -ENOMEM;
|
|
}
|
|
}
|
|
phv->phv_host_id = host_id;
|
|
phv->phv_host_id = host_id;
|
|
phv->phv_mode = PHV_VIRUTAL_HOST_ID;
|
|
phv->phv_mode = PHV_VIRUTAL_HOST_ID;
|
|
- hba_depth = PSCSI_VIRTUAL_HBA_DEPTH;
|
|
|
|
- atomic_set(&hba->left_queue_depth, hba_depth);
|
|
|
|
- atomic_set(&hba->max_queue_depth, hba_depth);
|
|
|
|
|
|
|
|
- hba->hba_ptr = (void *)phv;
|
|
|
|
|
|
+ hba->hba_ptr = phv;
|
|
|
|
|
|
- printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on"
|
|
|
|
|
|
+ pr_debug("CORE_HBA[%d] - TCM SCSI HBA Driver %s on"
|
|
" Generic Target Core Stack %s\n", hba->hba_id,
|
|
" Generic Target Core Stack %s\n", hba->hba_id,
|
|
PSCSI_VERSION, TARGET_CORE_MOD_VERSION);
|
|
PSCSI_VERSION, TARGET_CORE_MOD_VERSION);
|
|
- printk(KERN_INFO "CORE_HBA[%d] - Attached SCSI HBA to Generic"
|
|
|
|
- " Target Core with TCQ Depth: %d\n", hba->hba_id,
|
|
|
|
- atomic_read(&hba->max_queue_depth));
|
|
|
|
|
|
+ pr_debug("CORE_HBA[%d] - Attached SCSI HBA to Generic\n",
|
|
|
|
+ hba->hba_id);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -114,12 +91,12 @@ static void pscsi_detach_hba(struct se_hba *hba)
|
|
if (scsi_host) {
|
|
if (scsi_host) {
|
|
scsi_host_put(scsi_host);
|
|
scsi_host_put(scsi_host);
|
|
|
|
|
|
- printk(KERN_INFO "CORE_HBA[%d] - Detached SCSI HBA: %s from"
|
|
|
|
|
|
+ pr_debug("CORE_HBA[%d] - Detached SCSI HBA: %s from"
|
|
" Generic Target Core\n", hba->hba_id,
|
|
" Generic Target Core\n", hba->hba_id,
|
|
(scsi_host->hostt->name) ? (scsi_host->hostt->name) :
|
|
(scsi_host->hostt->name) ? (scsi_host->hostt->name) :
|
|
"Unknown");
|
|
"Unknown");
|
|
} else
|
|
} else
|
|
- printk(KERN_INFO "CORE_HBA[%d] - Detached Virtual SCSI HBA"
|
|
|
|
|
|
+ pr_debug("CORE_HBA[%d] - Detached Virtual SCSI HBA"
|
|
" from Generic Target Core\n", hba->hba_id);
|
|
" from Generic Target Core\n", hba->hba_id);
|
|
|
|
|
|
kfree(phv);
|
|
kfree(phv);
|
|
@@ -130,20 +107,17 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
|
|
{
|
|
{
|
|
struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr;
|
|
struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr;
|
|
struct Scsi_Host *sh = phv->phv_lld_host;
|
|
struct Scsi_Host *sh = phv->phv_lld_host;
|
|
- int hba_depth = PSCSI_VIRTUAL_HBA_DEPTH;
|
|
|
|
/*
|
|
/*
|
|
* Release the struct Scsi_Host
|
|
* Release the struct Scsi_Host
|
|
*/
|
|
*/
|
|
- if (!(mode_flag)) {
|
|
|
|
- if (!(sh))
|
|
|
|
|
|
+ if (!mode_flag) {
|
|
|
|
+ if (!sh)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
phv->phv_lld_host = NULL;
|
|
phv->phv_lld_host = NULL;
|
|
phv->phv_mode = PHV_VIRUTAL_HOST_ID;
|
|
phv->phv_mode = PHV_VIRUTAL_HOST_ID;
|
|
- atomic_set(&hba->left_queue_depth, hba_depth);
|
|
|
|
- atomic_set(&hba->max_queue_depth, hba_depth);
|
|
|
|
|
|
|
|
- printk(KERN_INFO "CORE_HBA[%d] - Disabled pSCSI HBA Passthrough"
|
|
|
|
|
|
+ pr_debug("CORE_HBA[%d] - Disabled pSCSI HBA Passthrough"
|
|
" %s\n", hba->hba_id, (sh->hostt->name) ?
|
|
" %s\n", hba->hba_id, (sh->hostt->name) ?
|
|
(sh->hostt->name) : "Unknown");
|
|
(sh->hostt->name) : "Unknown");
|
|
|
|
|
|
@@ -154,27 +128,17 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
|
|
* Otherwise, locate struct Scsi_Host from the original passed
|
|
* Otherwise, locate struct Scsi_Host from the original passed
|
|
* pSCSI Host ID and enable for phba mode
|
|
* pSCSI Host ID and enable for phba mode
|
|
*/
|
|
*/
|
|
- sh = pscsi_get_sh(phv->phv_host_id);
|
|
|
|
- if (!(sh)) {
|
|
|
|
- printk(KERN_ERR "pSCSI: Unable to locate SCSI Host for"
|
|
|
|
|
|
+ sh = scsi_host_lookup(phv->phv_host_id);
|
|
|
|
+ if (IS_ERR(sh)) {
|
|
|
|
+ pr_err("pSCSI: Unable to locate SCSI Host for"
|
|
" phv_host_id: %d\n", phv->phv_host_id);
|
|
" phv_host_id: %d\n", phv->phv_host_id);
|
|
- return -1;
|
|
|
|
|
|
+ return PTR_ERR(sh);
|
|
}
|
|
}
|
|
- /*
|
|
|
|
- * Usually the SCSI LLD will use the hostt->can_queue value to define
|
|
|
|
- * its HBA TCQ depth. Some other drivers (like 2.6 megaraid) don't set
|
|
|
|
- * this at all and set sh->can_queue at runtime.
|
|
|
|
- */
|
|
|
|
- hba_depth = (sh->hostt->can_queue > sh->can_queue) ?
|
|
|
|
- sh->hostt->can_queue : sh->can_queue;
|
|
|
|
-
|
|
|
|
- atomic_set(&hba->left_queue_depth, hba_depth);
|
|
|
|
- atomic_set(&hba->max_queue_depth, hba_depth);
|
|
|
|
|
|
|
|
phv->phv_lld_host = sh;
|
|
phv->phv_lld_host = sh;
|
|
phv->phv_mode = PHV_LLD_SCSI_HOST_NO;
|
|
phv->phv_mode = PHV_LLD_SCSI_HOST_NO;
|
|
|
|
|
|
- printk(KERN_INFO "CORE_HBA[%d] - Enabled pSCSI HBA Passthrough %s\n",
|
|
|
|
|
|
+ pr_debug("CORE_HBA[%d] - Enabled pSCSI HBA Passthrough %s\n",
|
|
hba->hba_id, (sh->hostt->name) ? (sh->hostt->name) : "Unknown");
|
|
hba->hba_id, (sh->hostt->name) ? (sh->hostt->name) : "Unknown");
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
@@ -236,7 +200,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
|
|
|
|
|
|
buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL);
|
|
buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL);
|
|
if (!buf)
|
|
if (!buf)
|
|
- return -1;
|
|
|
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
memset(cdb, 0, MAX_COMMAND_SIZE);
|
|
memset(cdb, 0, MAX_COMMAND_SIZE);
|
|
cdb[0] = INQUIRY;
|
|
cdb[0] = INQUIRY;
|
|
@@ -259,7 +223,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
|
|
|
|
|
|
out_free:
|
|
out_free:
|
|
kfree(buf);
|
|
kfree(buf);
|
|
- return -1;
|
|
|
|
|
|
+ return -EPERM;
|
|
}
|
|
}
|
|
|
|
|
|
static void
|
|
static void
|
|
@@ -293,15 +257,15 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev,
|
|
page_83 = &buf[off];
|
|
page_83 = &buf[off];
|
|
ident_len = page_83[3];
|
|
ident_len = page_83[3];
|
|
if (!ident_len) {
|
|
if (!ident_len) {
|
|
- printk(KERN_ERR "page_83[3]: identifier"
|
|
|
|
|
|
+ pr_err("page_83[3]: identifier"
|
|
" length zero!\n");
|
|
" length zero!\n");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- printk(KERN_INFO "T10 VPD Identifer Length: %d\n", ident_len);
|
|
|
|
|
|
+ pr_debug("T10 VPD Identifer Length: %d\n", ident_len);
|
|
|
|
|
|
vpd = kzalloc(sizeof(struct t10_vpd), GFP_KERNEL);
|
|
vpd = kzalloc(sizeof(struct t10_vpd), GFP_KERNEL);
|
|
if (!vpd) {
|
|
if (!vpd) {
|
|
- printk(KERN_ERR "Unable to allocate memory for"
|
|
|
|
|
|
+ pr_err("Unable to allocate memory for"
|
|
" struct t10_vpd\n");
|
|
" struct t10_vpd\n");
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
@@ -353,7 +317,7 @@ static struct se_device *pscsi_add_device_to_list(
|
|
if (!sd->queue_depth) {
|
|
if (!sd->queue_depth) {
|
|
sd->queue_depth = PSCSI_DEFAULT_QUEUEDEPTH;
|
|
sd->queue_depth = PSCSI_DEFAULT_QUEUEDEPTH;
|
|
|
|
|
|
- printk(KERN_ERR "Set broken SCSI Device %d:%d:%d"
|
|
|
|
|
|
+ pr_err("Set broken SCSI Device %d:%d:%d"
|
|
" queue_depth to %d\n", sd->channel, sd->id,
|
|
" queue_depth to %d\n", sd->channel, sd->id,
|
|
sd->lun, sd->queue_depth);
|
|
sd->lun, sd->queue_depth);
|
|
}
|
|
}
|
|
@@ -364,10 +328,8 @@ static struct se_device *pscsi_add_device_to_list(
|
|
q = sd->request_queue;
|
|
q = sd->request_queue;
|
|
limits = &dev_limits.limits;
|
|
limits = &dev_limits.limits;
|
|
limits->logical_block_size = sd->sector_size;
|
|
limits->logical_block_size = sd->sector_size;
|
|
- limits->max_hw_sectors = (sd->host->max_sectors > queue_max_hw_sectors(q)) ?
|
|
|
|
- queue_max_hw_sectors(q) : sd->host->max_sectors;
|
|
|
|
- limits->max_sectors = (sd->host->max_sectors > queue_max_sectors(q)) ?
|
|
|
|
- queue_max_sectors(q) : sd->host->max_sectors;
|
|
|
|
|
|
+ limits->max_hw_sectors = min_t(int, sd->host->max_sectors, queue_max_hw_sectors(q));
|
|
|
|
+ limits->max_sectors = min_t(int, sd->host->max_sectors, queue_max_sectors(q));
|
|
dev_limits.hw_queue_depth = sd->queue_depth;
|
|
dev_limits.hw_queue_depth = sd->queue_depth;
|
|
dev_limits.queue_depth = sd->queue_depth;
|
|
dev_limits.queue_depth = sd->queue_depth;
|
|
/*
|
|
/*
|
|
@@ -391,9 +353,9 @@ static struct se_device *pscsi_add_device_to_list(
|
|
pdv->pdv_sd = sd;
|
|
pdv->pdv_sd = sd;
|
|
|
|
|
|
dev = transport_add_device_to_core_hba(hba, &pscsi_template,
|
|
dev = transport_add_device_to_core_hba(hba, &pscsi_template,
|
|
- se_dev, dev_flags, (void *)pdv,
|
|
|
|
|
|
+ se_dev, dev_flags, pdv,
|
|
&dev_limits, NULL, NULL);
|
|
&dev_limits, NULL, NULL);
|
|
- if (!(dev)) {
|
|
|
|
|
|
+ if (!dev) {
|
|
pdv->pdv_sd = NULL;
|
|
pdv->pdv_sd = NULL;
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
@@ -423,14 +385,14 @@ static void *pscsi_allocate_virtdevice(struct se_hba *hba, const char *name)
|
|
struct pscsi_dev_virt *pdv;
|
|
struct pscsi_dev_virt *pdv;
|
|
|
|
|
|
pdv = kzalloc(sizeof(struct pscsi_dev_virt), GFP_KERNEL);
|
|
pdv = kzalloc(sizeof(struct pscsi_dev_virt), GFP_KERNEL);
|
|
- if (!(pdv)) {
|
|
|
|
- printk(KERN_ERR "Unable to allocate memory for struct pscsi_dev_virt\n");
|
|
|
|
|
|
+ if (!pdv) {
|
|
|
|
+ pr_err("Unable to allocate memory for struct pscsi_dev_virt\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
pdv->pdv_se_hba = hba;
|
|
pdv->pdv_se_hba = hba;
|
|
|
|
|
|
- printk(KERN_INFO "PSCSI: Allocated pdv: %p for %s\n", pdv, name);
|
|
|
|
- return (void *)pdv;
|
|
|
|
|
|
+ pr_debug("PSCSI: Allocated pdv: %p for %s\n", pdv, name);
|
|
|
|
+ return pdv;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -450,7 +412,7 @@ static struct se_device *pscsi_create_type_disk(
|
|
u32 dev_flags = 0;
|
|
u32 dev_flags = 0;
|
|
|
|
|
|
if (scsi_device_get(sd)) {
|
|
if (scsi_device_get(sd)) {
|
|
- printk(KERN_ERR "scsi_device_get() failed for %d:%d:%d:%d\n",
|
|
|
|
|
|
+ pr_err("scsi_device_get() failed for %d:%d:%d:%d\n",
|
|
sh->host_no, sd->channel, sd->id, sd->lun);
|
|
sh->host_no, sd->channel, sd->id, sd->lun);
|
|
spin_unlock_irq(sh->host_lock);
|
|
spin_unlock_irq(sh->host_lock);
|
|
return NULL;
|
|
return NULL;
|
|
@@ -463,19 +425,19 @@ static struct se_device *pscsi_create_type_disk(
|
|
bd = blkdev_get_by_path(se_dev->se_dev_udev_path,
|
|
bd = blkdev_get_by_path(se_dev->se_dev_udev_path,
|
|
FMODE_WRITE|FMODE_READ|FMODE_EXCL, pdv);
|
|
FMODE_WRITE|FMODE_READ|FMODE_EXCL, pdv);
|
|
if (IS_ERR(bd)) {
|
|
if (IS_ERR(bd)) {
|
|
- printk(KERN_ERR "pSCSI: blkdev_get_by_path() failed\n");
|
|
|
|
|
|
+ pr_err("pSCSI: blkdev_get_by_path() failed\n");
|
|
scsi_device_put(sd);
|
|
scsi_device_put(sd);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
pdv->pdv_bd = bd;
|
|
pdv->pdv_bd = bd;
|
|
|
|
|
|
dev = pscsi_add_device_to_list(hba, se_dev, pdv, sd, dev_flags);
|
|
dev = pscsi_add_device_to_list(hba, se_dev, pdv, sd, dev_flags);
|
|
- if (!(dev)) {
|
|
|
|
|
|
+ if (!dev) {
|
|
blkdev_put(pdv->pdv_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL);
|
|
blkdev_put(pdv->pdv_bd, FMODE_WRITE|FMODE_READ|FMODE_EXCL);
|
|
scsi_device_put(sd);
|
|
scsi_device_put(sd);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
- printk(KERN_INFO "CORE_PSCSI[%d] - Added TYPE_DISK for %d:%d:%d:%d\n",
|
|
|
|
|
|
+ pr_debug("CORE_PSCSI[%d] - Added TYPE_DISK for %d:%d:%d:%d\n",
|
|
phv->phv_host_id, sh->host_no, sd->channel, sd->id, sd->lun);
|
|
phv->phv_host_id, sh->host_no, sd->channel, sd->id, sd->lun);
|
|
|
|
|
|
return dev;
|
|
return dev;
|
|
@@ -497,7 +459,7 @@ static struct se_device *pscsi_create_type_rom(
|
|
u32 dev_flags = 0;
|
|
u32 dev_flags = 0;
|
|
|
|
|
|
if (scsi_device_get(sd)) {
|
|
if (scsi_device_get(sd)) {
|
|
- printk(KERN_ERR "scsi_device_get() failed for %d:%d:%d:%d\n",
|
|
|
|
|
|
+ pr_err("scsi_device_get() failed for %d:%d:%d:%d\n",
|
|
sh->host_no, sd->channel, sd->id, sd->lun);
|
|
sh->host_no, sd->channel, sd->id, sd->lun);
|
|
spin_unlock_irq(sh->host_lock);
|
|
spin_unlock_irq(sh->host_lock);
|
|
return NULL;
|
|
return NULL;
|
|
@@ -505,11 +467,11 @@ static struct se_device *pscsi_create_type_rom(
|
|
spin_unlock_irq(sh->host_lock);
|
|
spin_unlock_irq(sh->host_lock);
|
|
|
|
|
|
dev = pscsi_add_device_to_list(hba, se_dev, pdv, sd, dev_flags);
|
|
dev = pscsi_add_device_to_list(hba, se_dev, pdv, sd, dev_flags);
|
|
- if (!(dev)) {
|
|
|
|
|
|
+ if (!dev) {
|
|
scsi_device_put(sd);
|
|
scsi_device_put(sd);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
- printk(KERN_INFO "CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
|
|
|
|
|
|
+ pr_debug("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
|
|
phv->phv_host_id, scsi_device_type(sd->type), sh->host_no,
|
|
phv->phv_host_id, scsi_device_type(sd->type), sh->host_no,
|
|
sd->channel, sd->id, sd->lun);
|
|
sd->channel, sd->id, sd->lun);
|
|
|
|
|
|
@@ -533,10 +495,10 @@ static struct se_device *pscsi_create_type_other(
|
|
|
|
|
|
spin_unlock_irq(sh->host_lock);
|
|
spin_unlock_irq(sh->host_lock);
|
|
dev = pscsi_add_device_to_list(hba, se_dev, pdv, sd, dev_flags);
|
|
dev = pscsi_add_device_to_list(hba, se_dev, pdv, sd, dev_flags);
|
|
- if (!(dev))
|
|
|
|
|
|
+ if (!dev)
|
|
return NULL;
|
|
return NULL;
|
|
|
|
|
|
- printk(KERN_INFO "CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
|
|
|
|
|
|
+ pr_debug("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
|
|
phv->phv_host_id, scsi_device_type(sd->type), sh->host_no,
|
|
phv->phv_host_id, scsi_device_type(sd->type), sh->host_no,
|
|
sd->channel, sd->id, sd->lun);
|
|
sd->channel, sd->id, sd->lun);
|
|
|
|
|
|
@@ -555,8 +517,8 @@ static struct se_device *pscsi_create_virtdevice(
|
|
struct Scsi_Host *sh = phv->phv_lld_host;
|
|
struct Scsi_Host *sh = phv->phv_lld_host;
|
|
int legacy_mode_enable = 0;
|
|
int legacy_mode_enable = 0;
|
|
|
|
|
|
- if (!(pdv)) {
|
|
|
|
- printk(KERN_ERR "Unable to locate struct pscsi_dev_virt"
|
|
|
|
|
|
+ if (!pdv) {
|
|
|
|
+ pr_err("Unable to locate struct pscsi_dev_virt"
|
|
" parameter\n");
|
|
" parameter\n");
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
}
|
|
@@ -564,9 +526,9 @@ static struct se_device *pscsi_create_virtdevice(
|
|
* If not running in PHV_LLD_SCSI_HOST_NO mode, locate the
|
|
* If not running in PHV_LLD_SCSI_HOST_NO mode, locate the
|
|
* struct Scsi_Host we will need to bring the TCM/pSCSI object online
|
|
* struct Scsi_Host we will need to bring the TCM/pSCSI object online
|
|
*/
|
|
*/
|
|
- if (!(sh)) {
|
|
|
|
|
|
+ if (!sh) {
|
|
if (phv->phv_mode == PHV_LLD_SCSI_HOST_NO) {
|
|
if (phv->phv_mode == PHV_LLD_SCSI_HOST_NO) {
|
|
- printk(KERN_ERR "pSCSI: Unable to locate struct"
|
|
|
|
|
|
+ pr_err("pSCSI: Unable to locate struct"
|
|
" Scsi_Host for PHV_LLD_SCSI_HOST_NO\n");
|
|
" Scsi_Host for PHV_LLD_SCSI_HOST_NO\n");
|
|
return ERR_PTR(-ENODEV);
|
|
return ERR_PTR(-ENODEV);
|
|
}
|
|
}
|
|
@@ -575,7 +537,7 @@ static struct se_device *pscsi_create_virtdevice(
|
|
* reference, we enforce that udev_path has been set
|
|
* reference, we enforce that udev_path has been set
|
|
*/
|
|
*/
|
|
if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) {
|
|
if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) {
|
|
- printk(KERN_ERR "pSCSI: udev_path attribute has not"
|
|
|
|
|
|
+ pr_err("pSCSI: udev_path attribute has not"
|
|
" been set before ENABLE=1\n");
|
|
" been set before ENABLE=1\n");
|
|
return ERR_PTR(-EINVAL);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
}
|
|
@@ -586,8 +548,8 @@ static struct se_device *pscsi_create_virtdevice(
|
|
*/
|
|
*/
|
|
if (!(pdv->pdv_flags & PDF_HAS_VIRT_HOST_ID)) {
|
|
if (!(pdv->pdv_flags & PDF_HAS_VIRT_HOST_ID)) {
|
|
spin_lock(&hba->device_lock);
|
|
spin_lock(&hba->device_lock);
|
|
- if (!(list_empty(&hba->hba_dev_list))) {
|
|
|
|
- printk(KERN_ERR "pSCSI: Unable to set hba_mode"
|
|
|
|
|
|
+ if (!list_empty(&hba->hba_dev_list)) {
|
|
|
|
+ pr_err("pSCSI: Unable to set hba_mode"
|
|
" with active devices\n");
|
|
" with active devices\n");
|
|
spin_unlock(&hba->device_lock);
|
|
spin_unlock(&hba->device_lock);
|
|
return ERR_PTR(-EEXIST);
|
|
return ERR_PTR(-EEXIST);
|
|
@@ -601,16 +563,16 @@ static struct se_device *pscsi_create_virtdevice(
|
|
hba->hba_flags |= HBA_FLAGS_PSCSI_MODE;
|
|
hba->hba_flags |= HBA_FLAGS_PSCSI_MODE;
|
|
sh = phv->phv_lld_host;
|
|
sh = phv->phv_lld_host;
|
|
} else {
|
|
} else {
|
|
- sh = pscsi_get_sh(pdv->pdv_host_id);
|
|
|
|
- if (!(sh)) {
|
|
|
|
- printk(KERN_ERR "pSCSI: Unable to locate"
|
|
|
|
|
|
+ sh = scsi_host_lookup(pdv->pdv_host_id);
|
|
|
|
+ if (IS_ERR(sh)) {
|
|
|
|
+ pr_err("pSCSI: Unable to locate"
|
|
" pdv_host_id: %d\n", pdv->pdv_host_id);
|
|
" pdv_host_id: %d\n", pdv->pdv_host_id);
|
|
- return ERR_PTR(-ENODEV);
|
|
|
|
|
|
+ return (struct se_device *) sh;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID) {
|
|
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID) {
|
|
- printk(KERN_ERR "pSCSI: PHV_VIRUTAL_HOST_ID set while"
|
|
|
|
|
|
+ pr_err("pSCSI: PHV_VIRUTAL_HOST_ID set while"
|
|
" struct Scsi_Host exists\n");
|
|
" struct Scsi_Host exists\n");
|
|
return ERR_PTR(-EEXIST);
|
|
return ERR_PTR(-EEXIST);
|
|
}
|
|
}
|
|
@@ -639,7 +601,7 @@ static struct se_device *pscsi_create_virtdevice(
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(dev)) {
|
|
|
|
|
|
+ if (!dev) {
|
|
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID)
|
|
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID)
|
|
scsi_host_put(sh);
|
|
scsi_host_put(sh);
|
|
else if (legacy_mode_enable) {
|
|
else if (legacy_mode_enable) {
|
|
@@ -653,7 +615,7 @@ static struct se_device *pscsi_create_virtdevice(
|
|
}
|
|
}
|
|
spin_unlock_irq(sh->host_lock);
|
|
spin_unlock_irq(sh->host_lock);
|
|
|
|
|
|
- printk(KERN_ERR "pSCSI: Unable to locate %d:%d:%d:%d\n", sh->host_no,
|
|
|
|
|
|
+ pr_err("pSCSI: Unable to locate %d:%d:%d:%d\n", sh->host_no,
|
|
pdv->pdv_channel_id, pdv->pdv_target_id, pdv->pdv_lun_id);
|
|
pdv->pdv_channel_id, pdv->pdv_target_id, pdv->pdv_lun_id);
|
|
|
|
|
|
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID)
|
|
if (phv->phv_mode == PHV_VIRUTAL_HOST_ID)
|
|
@@ -728,13 +690,12 @@ static int pscsi_transport_complete(struct se_task *task)
|
|
*/
|
|
*/
|
|
if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) &&
|
|
if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) &&
|
|
(status_byte(result) << 1) == SAM_STAT_GOOD) {
|
|
(status_byte(result) << 1) == SAM_STAT_GOOD) {
|
|
- if (!TASK_CMD(task)->se_deve)
|
|
|
|
|
|
+ if (!task->task_se_cmd->se_deve)
|
|
goto after_mode_sense;
|
|
goto after_mode_sense;
|
|
|
|
|
|
- if (TASK_CMD(task)->se_deve->lun_flags &
|
|
|
|
|
|
+ if (task->task_se_cmd->se_deve->lun_flags &
|
|
TRANSPORT_LUNFLAGS_READ_ONLY) {
|
|
TRANSPORT_LUNFLAGS_READ_ONLY) {
|
|
- unsigned char *buf = (unsigned char *)
|
|
|
|
- T_TASK(task->task_se_cmd)->t_task_buf;
|
|
|
|
|
|
+ unsigned char *buf = transport_kmap_first_data_page(task->task_se_cmd);
|
|
|
|
|
|
if (cdb[0] == MODE_SENSE_10) {
|
|
if (cdb[0] == MODE_SENSE_10) {
|
|
if (!(buf[3] & 0x80))
|
|
if (!(buf[3] & 0x80))
|
|
@@ -743,6 +704,8 @@ static int pscsi_transport_complete(struct se_task *task)
|
|
if (!(buf[2] & 0x80))
|
|
if (!(buf[2] & 0x80))
|
|
buf[2] |= 0x80;
|
|
buf[2] |= 0x80;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ transport_kunmap_first_data_page(task->task_se_cmd);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
after_mode_sense:
|
|
after_mode_sense:
|
|
@@ -766,8 +729,8 @@ after_mode_sense:
|
|
u32 blocksize;
|
|
u32 blocksize;
|
|
|
|
|
|
buf = sg_virt(&sg[0]);
|
|
buf = sg_virt(&sg[0]);
|
|
- if (!(buf)) {
|
|
|
|
- printk(KERN_ERR "Unable to get buf for scatterlist\n");
|
|
|
|
|
|
+ if (!buf) {
|
|
|
|
+ pr_err("Unable to get buf for scatterlist\n");
|
|
goto after_mode_select;
|
|
goto after_mode_select;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -797,34 +760,20 @@ after_mode_select:
|
|
}
|
|
}
|
|
|
|
|
|
static struct se_task *
|
|
static struct se_task *
|
|
-pscsi_alloc_task(struct se_cmd *cmd)
|
|
|
|
|
|
+pscsi_alloc_task(unsigned char *cdb)
|
|
{
|
|
{
|
|
struct pscsi_plugin_task *pt;
|
|
struct pscsi_plugin_task *pt;
|
|
- unsigned char *cdb = T_TASK(cmd)->t_task_cdb;
|
|
|
|
|
|
|
|
- pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL);
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Dynamically alloc cdb space, since it may be larger than
|
|
|
|
+ * TCM_MAX_COMMAND_SIZE
|
|
|
|
+ */
|
|
|
|
+ pt = kzalloc(sizeof(*pt) + scsi_command_size(cdb), GFP_KERNEL);
|
|
if (!pt) {
|
|
if (!pt) {
|
|
- printk(KERN_ERR "Unable to allocate struct pscsi_plugin_task\n");
|
|
|
|
|
|
+ pr_err("Unable to allocate struct pscsi_plugin_task\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
- * If TCM Core is signaling a > TCM_MAX_COMMAND_SIZE allocation,
|
|
|
|
- * allocate the extended CDB buffer for per struct se_task context
|
|
|
|
- * pt->pscsi_cdb now.
|
|
|
|
- */
|
|
|
|
- if (T_TASK(cmd)->t_task_cdb != T_TASK(cmd)->__t_task_cdb) {
|
|
|
|
-
|
|
|
|
- pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL);
|
|
|
|
- if (!(pt->pscsi_cdb)) {
|
|
|
|
- printk(KERN_ERR "pSCSI: Unable to allocate extended"
|
|
|
|
- " pt->pscsi_cdb\n");
|
|
|
|
- kfree(pt);
|
|
|
|
- return NULL;
|
|
|
|
- }
|
|
|
|
- } else
|
|
|
|
- pt->pscsi_cdb = &pt->__pscsi_cdb[0];
|
|
|
|
-
|
|
|
|
return &pt->pscsi_task;
|
|
return &pt->pscsi_task;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -849,7 +798,7 @@ static inline void pscsi_blk_init_request(
|
|
* also set the end_io_data pointer.to struct se_task.
|
|
* also set the end_io_data pointer.to struct se_task.
|
|
*/
|
|
*/
|
|
req->end_io = pscsi_req_done;
|
|
req->end_io = pscsi_req_done;
|
|
- req->end_io_data = (void *)task;
|
|
|
|
|
|
+ req->end_io_data = task;
|
|
/*
|
|
/*
|
|
* Load the referenced struct se_task's SCSI CDB into
|
|
* Load the referenced struct se_task's SCSI CDB into
|
|
* include/linux/blkdev.h:struct request->cmd
|
|
* include/linux/blkdev.h:struct request->cmd
|
|
@@ -859,7 +808,7 @@ static inline void pscsi_blk_init_request(
|
|
/*
|
|
/*
|
|
* Setup pointer for outgoing sense data.
|
|
* Setup pointer for outgoing sense data.
|
|
*/
|
|
*/
|
|
- req->sense = (void *)&pt->pscsi_sense[0];
|
|
|
|
|
|
+ req->sense = &pt->pscsi_sense[0];
|
|
req->sense_len = 0;
|
|
req->sense_len = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -874,8 +823,8 @@ static int pscsi_blk_get_request(struct se_task *task)
|
|
pt->pscsi_req = blk_get_request(pdv->pdv_sd->request_queue,
|
|
pt->pscsi_req = blk_get_request(pdv->pdv_sd->request_queue,
|
|
(task->task_data_direction == DMA_TO_DEVICE),
|
|
(task->task_data_direction == DMA_TO_DEVICE),
|
|
GFP_KERNEL);
|
|
GFP_KERNEL);
|
|
- if (!(pt->pscsi_req) || IS_ERR(pt->pscsi_req)) {
|
|
|
|
- printk(KERN_ERR "PSCSI: blk_get_request() failed: %ld\n",
|
|
|
|
|
|
+ if (!pt->pscsi_req || IS_ERR(pt->pscsi_req)) {
|
|
|
|
+ pr_err("PSCSI: blk_get_request() failed: %ld\n",
|
|
IS_ERR(pt->pscsi_req));
|
|
IS_ERR(pt->pscsi_req));
|
|
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
|
return PYX_TRANSPORT_LU_COMM_FAILURE;
|
|
}
|
|
}
|
|
@@ -920,14 +869,7 @@ static int pscsi_do_task(struct se_task *task)
|
|
static void pscsi_free_task(struct se_task *task)
|
|
static void pscsi_free_task(struct se_task *task)
|
|
{
|
|
{
|
|
struct pscsi_plugin_task *pt = PSCSI_TASK(task);
|
|
struct pscsi_plugin_task *pt = PSCSI_TASK(task);
|
|
- struct se_cmd *cmd = task->task_se_cmd;
|
|
|
|
|
|
|
|
- /*
|
|
|
|
- * Release the extended CDB allocation from pscsi_alloc_task()
|
|
|
|
- * if one exists.
|
|
|
|
- */
|
|
|
|
- if (T_TASK(cmd)->t_task_cdb != T_TASK(cmd)->__t_task_cdb)
|
|
|
|
- kfree(pt->pscsi_cdb);
|
|
|
|
/*
|
|
/*
|
|
* We do not release the bio(s) here associated with this task, as
|
|
* We do not release the bio(s) here associated with this task, as
|
|
* this is handled by bio_put() and pscsi_bi_endio().
|
|
* this is handled by bio_put() and pscsi_bi_endio().
|
|
@@ -973,7 +915,7 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_hba *hba,
|
|
switch (token) {
|
|
switch (token) {
|
|
case Opt_scsi_host_id:
|
|
case Opt_scsi_host_id:
|
|
if (phv->phv_mode == PHV_LLD_SCSI_HOST_NO) {
|
|
if (phv->phv_mode == PHV_LLD_SCSI_HOST_NO) {
|
|
- printk(KERN_ERR "PSCSI[%d]: Unable to accept"
|
|
|
|
|
|
+ pr_err("PSCSI[%d]: Unable to accept"
|
|
" scsi_host_id while phv_mode =="
|
|
" scsi_host_id while phv_mode =="
|
|
" PHV_LLD_SCSI_HOST_NO\n",
|
|
" PHV_LLD_SCSI_HOST_NO\n",
|
|
phv->phv_host_id);
|
|
phv->phv_host_id);
|
|
@@ -982,14 +924,14 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_hba *hba,
|
|
}
|
|
}
|
|
match_int(args, &arg);
|
|
match_int(args, &arg);
|
|
pdv->pdv_host_id = arg;
|
|
pdv->pdv_host_id = arg;
|
|
- printk(KERN_INFO "PSCSI[%d]: Referencing SCSI Host ID:"
|
|
|
|
|
|
+ pr_debug("PSCSI[%d]: Referencing SCSI Host ID:"
|
|
" %d\n", phv->phv_host_id, pdv->pdv_host_id);
|
|
" %d\n", phv->phv_host_id, pdv->pdv_host_id);
|
|
pdv->pdv_flags |= PDF_HAS_VIRT_HOST_ID;
|
|
pdv->pdv_flags |= PDF_HAS_VIRT_HOST_ID;
|
|
break;
|
|
break;
|
|
case Opt_scsi_channel_id:
|
|
case Opt_scsi_channel_id:
|
|
match_int(args, &arg);
|
|
match_int(args, &arg);
|
|
pdv->pdv_channel_id = arg;
|
|
pdv->pdv_channel_id = arg;
|
|
- printk(KERN_INFO "PSCSI[%d]: Referencing SCSI Channel"
|
|
|
|
|
|
+ pr_debug("PSCSI[%d]: Referencing SCSI Channel"
|
|
" ID: %d\n", phv->phv_host_id,
|
|
" ID: %d\n", phv->phv_host_id,
|
|
pdv->pdv_channel_id);
|
|
pdv->pdv_channel_id);
|
|
pdv->pdv_flags |= PDF_HAS_CHANNEL_ID;
|
|
pdv->pdv_flags |= PDF_HAS_CHANNEL_ID;
|
|
@@ -997,7 +939,7 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_hba *hba,
|
|
case Opt_scsi_target_id:
|
|
case Opt_scsi_target_id:
|
|
match_int(args, &arg);
|
|
match_int(args, &arg);
|
|
pdv->pdv_target_id = arg;
|
|
pdv->pdv_target_id = arg;
|
|
- printk(KERN_INFO "PSCSI[%d]: Referencing SCSI Target"
|
|
|
|
|
|
+ pr_debug("PSCSI[%d]: Referencing SCSI Target"
|
|
" ID: %d\n", phv->phv_host_id,
|
|
" ID: %d\n", phv->phv_host_id,
|
|
pdv->pdv_target_id);
|
|
pdv->pdv_target_id);
|
|
pdv->pdv_flags |= PDF_HAS_TARGET_ID;
|
|
pdv->pdv_flags |= PDF_HAS_TARGET_ID;
|
|
@@ -1005,7 +947,7 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_hba *hba,
|
|
case Opt_scsi_lun_id:
|
|
case Opt_scsi_lun_id:
|
|
match_int(args, &arg);
|
|
match_int(args, &arg);
|
|
pdv->pdv_lun_id = arg;
|
|
pdv->pdv_lun_id = arg;
|
|
- printk(KERN_INFO "PSCSI[%d]: Referencing SCSI LUN ID:"
|
|
|
|
|
|
+ pr_debug("PSCSI[%d]: Referencing SCSI LUN ID:"
|
|
" %d\n", phv->phv_host_id, pdv->pdv_lun_id);
|
|
" %d\n", phv->phv_host_id, pdv->pdv_lun_id);
|
|
pdv->pdv_flags |= PDF_HAS_LUN_ID;
|
|
pdv->pdv_flags |= PDF_HAS_LUN_ID;
|
|
break;
|
|
break;
|
|
@@ -1028,9 +970,9 @@ static ssize_t pscsi_check_configfs_dev_params(
|
|
if (!(pdv->pdv_flags & PDF_HAS_CHANNEL_ID) ||
|
|
if (!(pdv->pdv_flags & PDF_HAS_CHANNEL_ID) ||
|
|
!(pdv->pdv_flags & PDF_HAS_TARGET_ID) ||
|
|
!(pdv->pdv_flags & PDF_HAS_TARGET_ID) ||
|
|
!(pdv->pdv_flags & PDF_HAS_LUN_ID)) {
|
|
!(pdv->pdv_flags & PDF_HAS_LUN_ID)) {
|
|
- printk(KERN_ERR "Missing scsi_channel_id=, scsi_target_id= and"
|
|
|
|
|
|
+ pr_err("Missing scsi_channel_id=, scsi_target_id= and"
|
|
" scsi_lun_id= parameters\n");
|
|
" scsi_lun_id= parameters\n");
|
|
- return -1;
|
|
|
|
|
|
+ return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -1090,7 +1032,7 @@ static void pscsi_bi_endio(struct bio *bio, int error)
|
|
bio_put(bio);
|
|
bio_put(bio);
|
|
}
|
|
}
|
|
|
|
|
|
-static inline struct bio *pscsi_get_bio(struct pscsi_dev_virt *pdv, int sg_num)
|
|
|
|
|
|
+static inline struct bio *pscsi_get_bio(int sg_num)
|
|
{
|
|
{
|
|
struct bio *bio;
|
|
struct bio *bio;
|
|
/*
|
|
/*
|
|
@@ -1098,8 +1040,8 @@ static inline struct bio *pscsi_get_bio(struct pscsi_dev_virt *pdv, int sg_num)
|
|
* in block/blk-core.c:blk_make_request()
|
|
* in block/blk-core.c:blk_make_request()
|
|
*/
|
|
*/
|
|
bio = bio_kmalloc(GFP_KERNEL, sg_num);
|
|
bio = bio_kmalloc(GFP_KERNEL, sg_num);
|
|
- if (!(bio)) {
|
|
|
|
- printk(KERN_ERR "PSCSI: bio_kmalloc() failed\n");
|
|
|
|
|
|
+ if (!bio) {
|
|
|
|
+ pr_err("PSCSI: bio_kmalloc() failed\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
bio->bi_end_io = pscsi_bi_endio;
|
|
bio->bi_end_io = pscsi_bi_endio;
|
|
@@ -1107,13 +1049,7 @@ static inline struct bio *pscsi_get_bio(struct pscsi_dev_virt *pdv, int sg_num)
|
|
return bio;
|
|
return bio;
|
|
}
|
|
}
|
|
|
|
|
|
-#if 0
|
|
|
|
-#define DEBUG_PSCSI(x...) printk(x)
|
|
|
|
-#else
|
|
|
|
-#define DEBUG_PSCSI(x...)
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-static int __pscsi_map_task_SG(
|
|
|
|
|
|
+static int __pscsi_map_SG(
|
|
struct se_task *task,
|
|
struct se_task *task,
|
|
struct scatterlist *task_sg,
|
|
struct scatterlist *task_sg,
|
|
u32 task_sg_num,
|
|
u32 task_sg_num,
|
|
@@ -1134,7 +1070,7 @@ static int __pscsi_map_task_SG(
|
|
return 0;
|
|
return 0;
|
|
/*
|
|
/*
|
|
* For SCF_SCSI_DATA_SG_IO_CDB, Use fs/bio.c:bio_add_page() to setup
|
|
* For SCF_SCSI_DATA_SG_IO_CDB, Use fs/bio.c:bio_add_page() to setup
|
|
- * the bio_vec maplist from TC< struct se_mem -> task->task_sg ->
|
|
|
|
|
|
+ * the bio_vec maplist from task->task_sg ->
|
|
* struct scatterlist memory. The struct se_task->task_sg[] currently needs
|
|
* struct scatterlist memory. The struct se_task->task_sg[] currently needs
|
|
* to be attached to struct bios for submission to Linux/SCSI using
|
|
* to be attached to struct bios for submission to Linux/SCSI using
|
|
* struct request to struct scsi_device->request_queue.
|
|
* struct request to struct scsi_device->request_queue.
|
|
@@ -1143,34 +1079,34 @@ static int __pscsi_map_task_SG(
|
|
* is ported to upstream SCSI passthrough functionality that accepts
|
|
* is ported to upstream SCSI passthrough functionality that accepts
|
|
* struct scatterlist->page_link or struct page as a paraemeter.
|
|
* struct scatterlist->page_link or struct page as a paraemeter.
|
|
*/
|
|
*/
|
|
- DEBUG_PSCSI("PSCSI: nr_pages: %d\n", nr_pages);
|
|
|
|
|
|
+ pr_debug("PSCSI: nr_pages: %d\n", nr_pages);
|
|
|
|
|
|
for_each_sg(task_sg, sg, task_sg_num, i) {
|
|
for_each_sg(task_sg, sg, task_sg_num, i) {
|
|
page = sg_page(sg);
|
|
page = sg_page(sg);
|
|
off = sg->offset;
|
|
off = sg->offset;
|
|
len = sg->length;
|
|
len = sg->length;
|
|
|
|
|
|
- DEBUG_PSCSI("PSCSI: i: %d page: %p len: %d off: %d\n", i,
|
|
|
|
|
|
+ pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i,
|
|
page, len, off);
|
|
page, len, off);
|
|
|
|
|
|
while (len > 0 && data_len > 0) {
|
|
while (len > 0 && data_len > 0) {
|
|
bytes = min_t(unsigned int, len, PAGE_SIZE - off);
|
|
bytes = min_t(unsigned int, len, PAGE_SIZE - off);
|
|
bytes = min(bytes, data_len);
|
|
bytes = min(bytes, data_len);
|
|
|
|
|
|
- if (!(bio)) {
|
|
|
|
|
|
+ if (!bio) {
|
|
nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
|
|
nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
|
|
nr_pages -= nr_vecs;
|
|
nr_pages -= nr_vecs;
|
|
/*
|
|
/*
|
|
* Calls bio_kmalloc() and sets bio->bi_end_io()
|
|
* Calls bio_kmalloc() and sets bio->bi_end_io()
|
|
*/
|
|
*/
|
|
- bio = pscsi_get_bio(pdv, nr_vecs);
|
|
|
|
- if (!(bio))
|
|
|
|
|
|
+ bio = pscsi_get_bio(nr_vecs);
|
|
|
|
+ if (!bio)
|
|
goto fail;
|
|
goto fail;
|
|
|
|
|
|
if (rw)
|
|
if (rw)
|
|
bio->bi_rw |= REQ_WRITE;
|
|
bio->bi_rw |= REQ_WRITE;
|
|
|
|
|
|
- DEBUG_PSCSI("PSCSI: Allocated bio: %p,"
|
|
|
|
|
|
+ pr_debug("PSCSI: Allocated bio: %p,"
|
|
" dir: %s nr_vecs: %d\n", bio,
|
|
" dir: %s nr_vecs: %d\n", bio,
|
|
(rw) ? "rw" : "r", nr_vecs);
|
|
(rw) ? "rw" : "r", nr_vecs);
|
|
/*
|
|
/*
|
|
@@ -1185,7 +1121,7 @@ static int __pscsi_map_task_SG(
|
|
tbio = tbio->bi_next = bio;
|
|
tbio = tbio->bi_next = bio;
|
|
}
|
|
}
|
|
|
|
|
|
- DEBUG_PSCSI("PSCSI: Calling bio_add_pc_page() i: %d"
|
|
|
|
|
|
+ pr_debug("PSCSI: Calling bio_add_pc_page() i: %d"
|
|
" bio: %p page: %p len: %d off: %d\n", i, bio,
|
|
" bio: %p page: %p len: %d off: %d\n", i, bio,
|
|
page, len, off);
|
|
page, len, off);
|
|
|
|
|
|
@@ -1194,11 +1130,11 @@ static int __pscsi_map_task_SG(
|
|
if (rc != bytes)
|
|
if (rc != bytes)
|
|
goto fail;
|
|
goto fail;
|
|
|
|
|
|
- DEBUG_PSCSI("PSCSI: bio->bi_vcnt: %d nr_vecs: %d\n",
|
|
|
|
|
|
+ pr_debug("PSCSI: bio->bi_vcnt: %d nr_vecs: %d\n",
|
|
bio->bi_vcnt, nr_vecs);
|
|
bio->bi_vcnt, nr_vecs);
|
|
|
|
|
|
if (bio->bi_vcnt > nr_vecs) {
|
|
if (bio->bi_vcnt > nr_vecs) {
|
|
- DEBUG_PSCSI("PSCSI: Reached bio->bi_vcnt max:"
|
|
|
|
|
|
+ pr_debug("PSCSI: Reached bio->bi_vcnt max:"
|
|
" %d i: %d bio: %p, allocating another"
|
|
" %d i: %d bio: %p, allocating another"
|
|
" bio\n", bio->bi_vcnt, i, bio);
|
|
" bio\n", bio->bi_vcnt, i, bio);
|
|
/*
|
|
/*
|
|
@@ -1220,15 +1156,15 @@ static int __pscsi_map_task_SG(
|
|
* Setup the primary pt->pscsi_req used for non BIDI and BIDI-COMMAND
|
|
* Setup the primary pt->pscsi_req used for non BIDI and BIDI-COMMAND
|
|
* primary SCSI WRITE poayload mapped for struct se_task->task_sg[]
|
|
* primary SCSI WRITE poayload mapped for struct se_task->task_sg[]
|
|
*/
|
|
*/
|
|
- if (!(bidi_read)) {
|
|
|
|
|
|
+ if (!bidi_read) {
|
|
/*
|
|
/*
|
|
* Starting with v2.6.31, call blk_make_request() passing in *hbio to
|
|
* Starting with v2.6.31, call blk_make_request() passing in *hbio to
|
|
* allocate the pSCSI task a struct request.
|
|
* allocate the pSCSI task a struct request.
|
|
*/
|
|
*/
|
|
pt->pscsi_req = blk_make_request(pdv->pdv_sd->request_queue,
|
|
pt->pscsi_req = blk_make_request(pdv->pdv_sd->request_queue,
|
|
hbio, GFP_KERNEL);
|
|
hbio, GFP_KERNEL);
|
|
- if (!(pt->pscsi_req)) {
|
|
|
|
- printk(KERN_ERR "pSCSI: blk_make_request() failed\n");
|
|
|
|
|
|
+ if (!pt->pscsi_req) {
|
|
|
|
+ pr_err("pSCSI: blk_make_request() failed\n");
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
@@ -1237,7 +1173,7 @@ static int __pscsi_map_task_SG(
|
|
*/
|
|
*/
|
|
pscsi_blk_init_request(task, pt, pt->pscsi_req, 0);
|
|
pscsi_blk_init_request(task, pt, pt->pscsi_req, 0);
|
|
|
|
|
|
- return task->task_sg_num;
|
|
|
|
|
|
+ return task->task_sg_nents;
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* Setup the secondary pt->pscsi_req->next_rq used for the extra BIDI-COMMAND
|
|
* Setup the secondary pt->pscsi_req->next_rq used for the extra BIDI-COMMAND
|
|
@@ -1245,13 +1181,13 @@ static int __pscsi_map_task_SG(
|
|
*/
|
|
*/
|
|
pt->pscsi_req->next_rq = blk_make_request(pdv->pdv_sd->request_queue,
|
|
pt->pscsi_req->next_rq = blk_make_request(pdv->pdv_sd->request_queue,
|
|
hbio, GFP_KERNEL);
|
|
hbio, GFP_KERNEL);
|
|
- if (!(pt->pscsi_req->next_rq)) {
|
|
|
|
- printk(KERN_ERR "pSCSI: blk_make_request() failed for BIDI\n");
|
|
|
|
|
|
+ if (!pt->pscsi_req->next_rq) {
|
|
|
|
+ pr_err("pSCSI: blk_make_request() failed for BIDI\n");
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
pscsi_blk_init_request(task, pt, pt->pscsi_req->next_rq, 1);
|
|
pscsi_blk_init_request(task, pt, pt->pscsi_req->next_rq, 1);
|
|
|
|
|
|
- return task->task_sg_num;
|
|
|
|
|
|
+ return task->task_sg_nents;
|
|
fail:
|
|
fail:
|
|
while (hbio) {
|
|
while (hbio) {
|
|
bio = hbio;
|
|
bio = hbio;
|
|
@@ -1262,7 +1198,10 @@ fail:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-static int pscsi_map_task_SG(struct se_task *task)
|
|
|
|
|
|
+/*
|
|
|
|
+ * pSCSI maps both ->map_control_SG() and ->map_data_SG() to a single call.
|
|
|
|
+ */
|
|
|
|
+static int pscsi_map_SG(struct se_task *task)
|
|
{
|
|
{
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
@@ -1270,14 +1209,14 @@ static int pscsi_map_task_SG(struct se_task *task)
|
|
* Setup the main struct request for the task->task_sg[] payload
|
|
* Setup the main struct request for the task->task_sg[] payload
|
|
*/
|
|
*/
|
|
|
|
|
|
- ret = __pscsi_map_task_SG(task, task->task_sg, task->task_sg_num, 0);
|
|
|
|
|
|
+ ret = __pscsi_map_SG(task, task->task_sg, task->task_sg_nents, 0);
|
|
if (ret >= 0 && task->task_sg_bidi) {
|
|
if (ret >= 0 && task->task_sg_bidi) {
|
|
/*
|
|
/*
|
|
* If present, set up the extra BIDI-COMMAND SCSI READ
|
|
* If present, set up the extra BIDI-COMMAND SCSI READ
|
|
* struct request and payload.
|
|
* struct request and payload.
|
|
*/
|
|
*/
|
|
- ret = __pscsi_map_task_SG(task, task->task_sg_bidi,
|
|
|
|
- task->task_sg_num, 1);
|
|
|
|
|
|
+ ret = __pscsi_map_SG(task, task->task_sg_bidi,
|
|
|
|
+ task->task_sg_nents, 1);
|
|
}
|
|
}
|
|
|
|
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
@@ -1285,33 +1224,6 @@ static int pscsi_map_task_SG(struct se_task *task)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-/* pscsi_map_task_non_SG():
|
|
|
|
- *
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-static int pscsi_map_task_non_SG(struct se_task *task)
|
|
|
|
-{
|
|
|
|
- struct se_cmd *cmd = TASK_CMD(task);
|
|
|
|
- struct pscsi_plugin_task *pt = PSCSI_TASK(task);
|
|
|
|
- struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr;
|
|
|
|
- int ret = 0;
|
|
|
|
-
|
|
|
|
- if (pscsi_blk_get_request(task) < 0)
|
|
|
|
- return PYX_TRANSPORT_LU_COMM_FAILURE;
|
|
|
|
-
|
|
|
|
- if (!task->task_size)
|
|
|
|
- return 0;
|
|
|
|
-
|
|
|
|
- ret = blk_rq_map_kern(pdv->pdv_sd->request_queue,
|
|
|
|
- pt->pscsi_req, T_TASK(cmd)->t_task_buf,
|
|
|
|
- task->task_size, GFP_KERNEL);
|
|
|
|
- if (ret < 0) {
|
|
|
|
- printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret);
|
|
|
|
- return PYX_TRANSPORT_LU_COMM_FAILURE;
|
|
|
|
- }
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static int pscsi_CDB_none(struct se_task *task)
|
|
static int pscsi_CDB_none(struct se_task *task)
|
|
{
|
|
{
|
|
return pscsi_blk_get_request(task);
|
|
return pscsi_blk_get_request(task);
|
|
@@ -1383,9 +1295,9 @@ static inline void pscsi_process_SAM_status(
|
|
struct pscsi_plugin_task *pt)
|
|
struct pscsi_plugin_task *pt)
|
|
{
|
|
{
|
|
task->task_scsi_status = status_byte(pt->pscsi_result);
|
|
task->task_scsi_status = status_byte(pt->pscsi_result);
|
|
- if ((task->task_scsi_status)) {
|
|
|
|
|
|
+ if (task->task_scsi_status) {
|
|
task->task_scsi_status <<= 1;
|
|
task->task_scsi_status <<= 1;
|
|
- printk(KERN_INFO "PSCSI Status Byte exception at task: %p CDB:"
|
|
|
|
|
|
+ pr_debug("PSCSI Status Byte exception at task: %p CDB:"
|
|
" 0x%02x Result: 0x%08x\n", task, pt->pscsi_cdb[0],
|
|
" 0x%02x Result: 0x%08x\n", task, pt->pscsi_cdb[0],
|
|
pt->pscsi_result);
|
|
pt->pscsi_result);
|
|
}
|
|
}
|
|
@@ -1395,18 +1307,16 @@ static inline void pscsi_process_SAM_status(
|
|
transport_complete_task(task, (!task->task_scsi_status));
|
|
transport_complete_task(task, (!task->task_scsi_status));
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- printk(KERN_INFO "PSCSI Host Byte exception at task: %p CDB:"
|
|
|
|
|
|
+ pr_debug("PSCSI Host Byte exception at task: %p CDB:"
|
|
" 0x%02x Result: 0x%08x\n", task, pt->pscsi_cdb[0],
|
|
" 0x%02x Result: 0x%08x\n", task, pt->pscsi_cdb[0],
|
|
pt->pscsi_result);
|
|
pt->pscsi_result);
|
|
task->task_scsi_status = SAM_STAT_CHECK_CONDITION;
|
|
task->task_scsi_status = SAM_STAT_CHECK_CONDITION;
|
|
task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
|
|
task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
|
|
- TASK_CMD(task)->transport_error_status =
|
|
|
|
|
|
+ task->task_se_cmd->transport_error_status =
|
|
PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
|
|
PYX_TRANSPORT_UNKNOWN_SAM_OPCODE;
|
|
transport_complete_task(task, 0);
|
|
transport_complete_task(task, 0);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
- return;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void pscsi_req_done(struct request *req, int uptodate)
|
|
static void pscsi_req_done(struct request *req, int uptodate)
|
|
@@ -1433,8 +1343,8 @@ static struct se_subsystem_api pscsi_template = {
|
|
.owner = THIS_MODULE,
|
|
.owner = THIS_MODULE,
|
|
.transport_type = TRANSPORT_PLUGIN_PHBA_PDEV,
|
|
.transport_type = TRANSPORT_PLUGIN_PHBA_PDEV,
|
|
.cdb_none = pscsi_CDB_none,
|
|
.cdb_none = pscsi_CDB_none,
|
|
- .map_task_non_SG = pscsi_map_task_non_SG,
|
|
|
|
- .map_task_SG = pscsi_map_task_SG,
|
|
|
|
|
|
+ .map_control_SG = pscsi_map_SG,
|
|
|
|
+ .map_data_SG = pscsi_map_SG,
|
|
.attach_hba = pscsi_attach_hba,
|
|
.attach_hba = pscsi_attach_hba,
|
|
.detach_hba = pscsi_detach_hba,
|
|
.detach_hba = pscsi_detach_hba,
|
|
.pmode_enable_hba = pscsi_pmode_enable_hba,
|
|
.pmode_enable_hba = pscsi_pmode_enable_hba,
|