diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-23 14:35:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-23 14:35:37 -0400 |
commit | f5bcf5f44796bf30a058a01c10a61b19784f0540 (patch) | |
tree | 1c78ecbb2a21f880a1508dc2fcbbcc4b169f43f3 /drivers/scsi/libfc/fc_fcp.c | |
parent | defe9104833b5ad309447bbc1fcb8e5981b2d3e1 (diff) | |
parent | 129dd98194747a3b8ac1ff876d8d1f2440660d01 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (38 commits)
fusion: mptsas, fix lock imbalance
[SCSI] scsi_transport_fc: replace BUS_ID_SIZE by fixed count
sd, sr: fix Driver 'sd' needs updating message
scsi_transport_iscsi: return -EOVERFLOW for Too many iscsi targets
fc_transport: Selective return value from BSG timeout function
fc_transport: The softirq_done function registration for BSG request
sym53c8xx: ratelimit parity errors
explain the hidden scsi_wait_scan Kconfig variable
ibmvfc: Fix endless PRLI loop in discovery
ibmvfc: Process async events before command responses
libfc: Add runtime debugging with debug_logging module parameter
libfcoe: Add runtime debugging with module param debug_logging
fcoe: Add runtime debug logging with module parameter debug_logging
scsi_debug: Add support for physical block exponent and alignment
cnic: add NETDEV_1000 and NETDEVICES to Kconfig select
cnic: Fix __symbol_get() build error.
Revert "[SCSI] cnic: fix error: implicit declaration of function ‘__symbol_get’"
ipr: differentiate pci-x and pci-e based adapters
ipr: add test for MSI interrupt support
scsi_transport_spi: Blacklist Ultrium-3 tape for IU transfers
...
Diffstat (limited to 'drivers/scsi/libfc/fc_fcp.c')
-rw-r--r-- | drivers/scsi/libfc/fc_fcp.c | 97 |
1 files changed, 50 insertions, 47 deletions
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index ad8b747837b0..e303e0d12c4b 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c | |||
@@ -43,13 +43,9 @@ MODULE_AUTHOR("Open-FCoE.org"); | |||
43 | MODULE_DESCRIPTION("libfc"); | 43 | MODULE_DESCRIPTION("libfc"); |
44 | MODULE_LICENSE("GPL v2"); | 44 | MODULE_LICENSE("GPL v2"); |
45 | 45 | ||
46 | static int fc_fcp_debug; | 46 | unsigned int fc_debug_logging; |
47 | 47 | module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR); | |
48 | #define FC_DEBUG_FCP(fmt...) \ | 48 | MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); |
49 | do { \ | ||
50 | if (fc_fcp_debug) \ | ||
51 | FC_DBG(fmt); \ | ||
52 | } while (0) | ||
53 | 49 | ||
54 | static struct kmem_cache *scsi_pkt_cachep; | 50 | static struct kmem_cache *scsi_pkt_cachep; |
55 | 51 | ||
@@ -347,8 +343,8 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
347 | if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && | 343 | if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && |
348 | fc_frame_crc_check(fp)) | 344 | fc_frame_crc_check(fp)) |
349 | goto crc_err; | 345 | goto crc_err; |
350 | FC_DEBUG_FCP("data received past end. len %zx offset %zx " | 346 | FC_FCP_DBG(fsp, "data received past end. len %zx offset %zx " |
351 | "data_len %x\n", len, offset, fsp->data_len); | 347 | "data_len %x\n", len, offset, fsp->data_len); |
352 | fc_fcp_retry_cmd(fsp); | 348 | fc_fcp_retry_cmd(fsp); |
353 | return; | 349 | return; |
354 | } | 350 | } |
@@ -411,7 +407,8 @@ crc_err: | |||
411 | stats->ErrorFrames++; | 407 | stats->ErrorFrames++; |
412 | /* FIXME - per cpu count, not total count! */ | 408 | /* FIXME - per cpu count, not total count! */ |
413 | if (stats->InvalidCRCCount++ < 5) | 409 | if (stats->InvalidCRCCount++ < 5) |
414 | printk(KERN_WARNING "CRC error on data frame for port (%6x)\n", | 410 | printk(KERN_WARNING "libfc: CRC error on data " |
411 | "frame for port (%6x)\n", | ||
415 | fc_host_port_id(lp->host)); | 412 | fc_host_port_id(lp->host)); |
416 | /* | 413 | /* |
417 | * Assume the frame is total garbage. | 414 | * Assume the frame is total garbage. |
@@ -475,14 +472,14 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
475 | WARN_ON(seq_blen <= 0); | 472 | WARN_ON(seq_blen <= 0); |
476 | if (unlikely(offset + seq_blen > fsp->data_len)) { | 473 | if (unlikely(offset + seq_blen > fsp->data_len)) { |
477 | /* this should never happen */ | 474 | /* this should never happen */ |
478 | FC_DEBUG_FCP("xfer-ready past end. seq_blen %zx offset %zx\n", | 475 | FC_FCP_DBG(fsp, "xfer-ready past end. seq_blen %zx " |
479 | seq_blen, offset); | 476 | "offset %zx\n", seq_blen, offset); |
480 | fc_fcp_send_abort(fsp); | 477 | fc_fcp_send_abort(fsp); |
481 | return 0; | 478 | return 0; |
482 | } else if (offset != fsp->xfer_len) { | 479 | } else if (offset != fsp->xfer_len) { |
483 | /* Out of Order Data Request - no problem, but unexpected. */ | 480 | /* Out of Order Data Request - no problem, but unexpected. */ |
484 | FC_DEBUG_FCP("xfer-ready non-contiguous. " | 481 | FC_FCP_DBG(fsp, "xfer-ready non-contiguous. " |
485 | "seq_blen %zx offset %zx\n", seq_blen, offset); | 482 | "seq_blen %zx offset %zx\n", seq_blen, offset); |
486 | } | 483 | } |
487 | 484 | ||
488 | /* | 485 | /* |
@@ -493,7 +490,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
493 | t_blen = fsp->max_payload; | 490 | t_blen = fsp->max_payload; |
494 | if (lp->seq_offload) { | 491 | if (lp->seq_offload) { |
495 | t_blen = min(seq_blen, (size_t)lp->lso_max); | 492 | t_blen = min(seq_blen, (size_t)lp->lso_max); |
496 | FC_DEBUG_FCP("fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", | 493 | FC_FCP_DBG(fsp, "fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", |
497 | fsp, seq_blen, lp->lso_max, t_blen); | 494 | fsp, seq_blen, lp->lso_max, t_blen); |
498 | } | 495 | } |
499 | 496 | ||
@@ -694,7 +691,7 @@ static void fc_fcp_reduce_can_queue(struct fc_lport *lp) | |||
694 | if (!can_queue) | 691 | if (!can_queue) |
695 | can_queue = 1; | 692 | can_queue = 1; |
696 | lp->host->can_queue = can_queue; | 693 | lp->host->can_queue = can_queue; |
697 | shost_printk(KERN_ERR, lp->host, "Could not allocate frame.\n" | 694 | shost_printk(KERN_ERR, lp->host, "libfc: Could not allocate frame.\n" |
698 | "Reducing can_queue to %d.\n", can_queue); | 695 | "Reducing can_queue to %d.\n", can_queue); |
699 | done: | 696 | done: |
700 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 697 | spin_unlock_irqrestore(lp->host->host_lock, flags); |
@@ -768,7 +765,7 @@ static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
768 | 765 | ||
769 | fc_fcp_resp(fsp, fp); | 766 | fc_fcp_resp(fsp, fp); |
770 | } else { | 767 | } else { |
771 | FC_DBG("unexpected frame. r_ctl %x\n", r_ctl); | 768 | FC_FCP_DBG(fsp, "unexpected frame. r_ctl %x\n", r_ctl); |
772 | } | 769 | } |
773 | unlock: | 770 | unlock: |
774 | fc_fcp_unlock_pkt(fsp); | 771 | fc_fcp_unlock_pkt(fsp); |
@@ -877,17 +874,17 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
877 | return; | 874 | return; |
878 | } | 875 | } |
879 | fsp->status_code = FC_DATA_OVRRUN; | 876 | fsp->status_code = FC_DATA_OVRRUN; |
880 | FC_DBG("tgt %6x xfer len %zx greater than expected len %x. " | 877 | FC_FCP_DBG(fsp, "tgt %6x xfer len %zx greater than expected, " |
881 | "data len %x\n", | 878 | "len %x, data len %x\n", |
882 | fsp->rport->port_id, | 879 | fsp->rport->port_id, |
883 | fsp->xfer_len, expected_len, fsp->data_len); | 880 | fsp->xfer_len, expected_len, fsp->data_len); |
884 | } | 881 | } |
885 | fc_fcp_complete_locked(fsp); | 882 | fc_fcp_complete_locked(fsp); |
886 | return; | 883 | return; |
887 | 884 | ||
888 | len_err: | 885 | len_err: |
889 | FC_DBG("short FCP response. flags 0x%x len %u respl %u snsl %u\n", | 886 | FC_FCP_DBG(fsp, "short FCP response. flags 0x%x len %u respl %u " |
890 | flags, fr_len(fp), respl, snsl); | 887 | "snsl %u\n", flags, fr_len(fp), respl, snsl); |
891 | err: | 888 | err: |
892 | fsp->status_code = FC_ERROR; | 889 | fsp->status_code = FC_ERROR; |
893 | fc_fcp_complete_locked(fsp); | 890 | fc_fcp_complete_locked(fsp); |
@@ -1107,13 +1104,11 @@ static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
1107 | if (fc_fcp_lock_pkt(fsp)) | 1104 | if (fc_fcp_lock_pkt(fsp)) |
1108 | return; | 1105 | return; |
1109 | 1106 | ||
1110 | switch (error) { | 1107 | if (error == -FC_EX_CLOSED) { |
1111 | case -FC_EX_CLOSED: | ||
1112 | fc_fcp_retry_cmd(fsp); | 1108 | fc_fcp_retry_cmd(fsp); |
1113 | goto unlock; | 1109 | goto unlock; |
1114 | default: | ||
1115 | FC_DBG("unknown error %ld\n", PTR_ERR(fp)); | ||
1116 | } | 1110 | } |
1111 | |||
1117 | /* | 1112 | /* |
1118 | * clear abort pending, because the lower layer | 1113 | * clear abort pending, because the lower layer |
1119 | * decided to force completion. | 1114 | * decided to force completion. |
@@ -1145,10 +1140,10 @@ static int fc_fcp_pkt_abort(struct fc_lport *lp, struct fc_fcp_pkt *fsp) | |||
1145 | fsp->wait_for_comp = 0; | 1140 | fsp->wait_for_comp = 0; |
1146 | 1141 | ||
1147 | if (!rc) { | 1142 | if (!rc) { |
1148 | FC_DBG("target abort cmd failed\n"); | 1143 | FC_FCP_DBG(fsp, "target abort cmd failed\n"); |
1149 | rc = FAILED; | 1144 | rc = FAILED; |
1150 | } else if (fsp->state & FC_SRB_ABORTED) { | 1145 | } else if (fsp->state & FC_SRB_ABORTED) { |
1151 | FC_DBG("target abort cmd passed\n"); | 1146 | FC_FCP_DBG(fsp, "target abort cmd passed\n"); |
1152 | rc = SUCCESS; | 1147 | rc = SUCCESS; |
1153 | fc_fcp_complete_locked(fsp); | 1148 | fc_fcp_complete_locked(fsp); |
1154 | } | 1149 | } |
@@ -1213,7 +1208,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
1213 | spin_unlock_bh(&fsp->scsi_pkt_lock); | 1208 | spin_unlock_bh(&fsp->scsi_pkt_lock); |
1214 | 1209 | ||
1215 | if (!rc) { | 1210 | if (!rc) { |
1216 | FC_DBG("lun reset failed\n"); | 1211 | FC_SCSI_DBG(lp, "lun reset failed\n"); |
1217 | return FAILED; | 1212 | return FAILED; |
1218 | } | 1213 | } |
1219 | 1214 | ||
@@ -1221,7 +1216,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
1221 | if (fsp->cdb_status != FCP_TMF_CMPL) | 1216 | if (fsp->cdb_status != FCP_TMF_CMPL) |
1222 | return FAILED; | 1217 | return FAILED; |
1223 | 1218 | ||
1224 | FC_DBG("lun reset to lun %u completed\n", lun); | 1219 | FC_SCSI_DBG(lp, "lun reset to lun %u completed\n", lun); |
1225 | fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED); | 1220 | fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED); |
1226 | return SUCCESS; | 1221 | return SUCCESS; |
1227 | } | 1222 | } |
@@ -1388,13 +1383,13 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
1388 | rjt = fc_frame_payload_get(fp, sizeof(*rjt)); | 1383 | rjt = fc_frame_payload_get(fp, sizeof(*rjt)); |
1389 | switch (rjt->er_reason) { | 1384 | switch (rjt->er_reason) { |
1390 | default: | 1385 | default: |
1391 | FC_DEBUG_FCP("device %x unexpected REC reject " | 1386 | FC_FCP_DBG(fsp, "device %x unexpected REC reject " |
1392 | "reason %d expl %d\n", | 1387 | "reason %d expl %d\n", |
1393 | fsp->rport->port_id, rjt->er_reason, | 1388 | fsp->rport->port_id, rjt->er_reason, |
1394 | rjt->er_explan); | 1389 | rjt->er_explan); |
1395 | /* fall through */ | 1390 | /* fall through */ |
1396 | case ELS_RJT_UNSUP: | 1391 | case ELS_RJT_UNSUP: |
1397 | FC_DEBUG_FCP("device does not support REC\n"); | 1392 | FC_FCP_DBG(fsp, "device does not support REC\n"); |
1398 | rp = fsp->rport->dd_data; | 1393 | rp = fsp->rport->dd_data; |
1399 | /* | 1394 | /* |
1400 | * if we do not spport RECs or got some bogus | 1395 | * if we do not spport RECs or got some bogus |
@@ -1514,8 +1509,8 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
1514 | break; | 1509 | break; |
1515 | 1510 | ||
1516 | default: | 1511 | default: |
1517 | FC_DBG("REC %p fid %x error unexpected error %d\n", | 1512 | FC_FCP_DBG(fsp, "REC %p fid %x error unexpected error %d\n", |
1518 | fsp, fsp->rport->port_id, error); | 1513 | fsp, fsp->rport->port_id, error); |
1519 | fsp->status_code = FC_CMD_PLOGO; | 1514 | fsp->status_code = FC_CMD_PLOGO; |
1520 | /* fall through */ | 1515 | /* fall through */ |
1521 | 1516 | ||
@@ -1524,9 +1519,9 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
1524 | * Assume REC or LS_ACC was lost. | 1519 | * Assume REC or LS_ACC was lost. |
1525 | * The exchange manager will have aborted REC, so retry. | 1520 | * The exchange manager will have aborted REC, so retry. |
1526 | */ | 1521 | */ |
1527 | FC_DBG("REC fid %x error error %d retry %d/%d\n", | 1522 | FC_FCP_DBG(fsp, "REC fid %x error error %d retry %d/%d\n", |
1528 | fsp->rport->port_id, error, fsp->recov_retry, | 1523 | fsp->rport->port_id, error, fsp->recov_retry, |
1529 | FC_MAX_RECOV_RETRY); | 1524 | FC_MAX_RECOV_RETRY); |
1530 | if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY) | 1525 | if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY) |
1531 | fc_fcp_rec(fsp); | 1526 | fc_fcp_rec(fsp); |
1532 | else | 1527 | else |
@@ -2011,9 +2006,11 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) | |||
2011 | if (lp->state != LPORT_ST_READY) | 2006 | if (lp->state != LPORT_ST_READY) |
2012 | return rc; | 2007 | return rc; |
2013 | 2008 | ||
2009 | FC_SCSI_DBG(lp, "Resetting rport (%6x)\n", rport->port_id); | ||
2010 | |||
2014 | fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO); | 2011 | fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO); |
2015 | if (fsp == NULL) { | 2012 | if (fsp == NULL) { |
2016 | FC_DBG("could not allocate scsi_pkt\n"); | 2013 | printk(KERN_WARNING "libfc: could not allocate scsi_pkt\n"); |
2017 | sc_cmd->result = DID_NO_CONNECT << 16; | 2014 | sc_cmd->result = DID_NO_CONNECT << 16; |
2018 | goto out; | 2015 | goto out; |
2019 | } | 2016 | } |
@@ -2048,17 +2045,21 @@ int fc_eh_host_reset(struct scsi_cmnd *sc_cmd) | |||
2048 | struct fc_lport *lp = shost_priv(shost); | 2045 | struct fc_lport *lp = shost_priv(shost); |
2049 | unsigned long wait_tmo; | 2046 | unsigned long wait_tmo; |
2050 | 2047 | ||
2048 | FC_SCSI_DBG(lp, "Resetting host\n"); | ||
2049 | |||
2051 | lp->tt.lport_reset(lp); | 2050 | lp->tt.lport_reset(lp); |
2052 | wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; | 2051 | wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; |
2053 | while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo)) | 2052 | while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo)) |
2054 | msleep(1000); | 2053 | msleep(1000); |
2055 | 2054 | ||
2056 | if (fc_fcp_lport_queue_ready(lp)) { | 2055 | if (fc_fcp_lport_queue_ready(lp)) { |
2057 | shost_printk(KERN_INFO, shost, "Host reset succeeded.\n"); | 2056 | shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded " |
2057 | "on port (%6x)\n", fc_host_port_id(lp->host)); | ||
2058 | return SUCCESS; | 2058 | return SUCCESS; |
2059 | } else { | 2059 | } else { |
2060 | shost_printk(KERN_INFO, shost, "Host reset failed. " | 2060 | shost_printk(KERN_INFO, shost, "libfc: Host reset failed, " |
2061 | "lport not ready.\n"); | 2061 | "port (%6x) is not ready.\n", |
2062 | fc_host_port_id(lp->host)); | ||
2062 | return FAILED; | 2063 | return FAILED; |
2063 | } | 2064 | } |
2064 | } | 2065 | } |
@@ -2117,7 +2118,8 @@ void fc_fcp_destroy(struct fc_lport *lp) | |||
2117 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 2118 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); |
2118 | 2119 | ||
2119 | if (!list_empty(&si->scsi_pkt_queue)) | 2120 | if (!list_empty(&si->scsi_pkt_queue)) |
2120 | printk(KERN_ERR "Leaked scsi packets.\n"); | 2121 | printk(KERN_ERR "libfc: Leaked SCSI packets when destroying " |
2122 | "port (%6x)\n", fc_host_port_id(lp->host)); | ||
2121 | 2123 | ||
2122 | mempool_destroy(si->scsi_pkt_pool); | 2124 | mempool_destroy(si->scsi_pkt_pool); |
2123 | kfree(si); | 2125 | kfree(si); |
@@ -2166,7 +2168,8 @@ static int __init libfc_init(void) | |||
2166 | sizeof(struct fc_fcp_pkt), | 2168 | sizeof(struct fc_fcp_pkt), |
2167 | 0, SLAB_HWCACHE_ALIGN, NULL); | 2169 | 0, SLAB_HWCACHE_ALIGN, NULL); |
2168 | if (scsi_pkt_cachep == NULL) { | 2170 | if (scsi_pkt_cachep == NULL) { |
2169 | FC_DBG("Unable to allocate SRB cache...module load failed!"); | 2171 | printk(KERN_ERR "libfc: Unable to allocate SRB cache, " |
2172 | "module load failed!"); | ||
2170 | return -ENOMEM; | 2173 | return -ENOMEM; |
2171 | } | 2174 | } |
2172 | 2175 | ||