Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] fnic: New debug flags and debug log messages

Added new fnic debug flags for identifying IO state at every stage of IO while
debugging and also added more log messages for better debugging capability.

Signed-off-by: Sesidhar Baddela <sebaddel@cisco.com>
Signed-off-by: Hiral Patel <hiralpat@cisco.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Hiral Patel and committed by
James Bottomley
14eb5d90 a0bf1ca2

+132 -21
+23 -8
drivers/scsi/fnic/fnic.h
··· 59 59 * Command flags to identify the type of command and for other future 60 60 * use. 61 61 */ 62 - #define FNIC_NO_FLAGS 0 63 - #define FNIC_CDB_REQ BIT(1) /* All IOs with a valid CDB */ 64 - #define FNIC_BLOCKING_REQ BIT(2) /* All blocking Requests */ 65 - #define FNIC_DEVICE_RESET BIT(3) /* Device reset request */ 66 - #define FNIC_DEV_RST_PENDING BIT(4) /* Device reset pending */ 67 - #define FNIC_DEV_RST_TIMED_OUT BIT(5) /* Device reset timed out */ 68 - #define FNIC_DEV_RST_TERM_ISSUED BIT(6) /* Device reset terminate */ 69 - #define FNIC_DEV_RST_DONE BIT(7) /* Device reset done */ 62 + #define FNIC_NO_FLAGS 0 63 + #define FNIC_IO_INITIALIZED BIT(0) 64 + #define FNIC_IO_ISSUED BIT(1) 65 + #define FNIC_IO_DONE BIT(2) 66 + #define FNIC_IO_REQ_NULL BIT(3) 67 + #define FNIC_IO_ABTS_PENDING BIT(4) 68 + #define FNIC_IO_ABORTED BIT(5) 69 + #define FNIC_IO_ABTS_ISSUED BIT(6) 70 + #define FNIC_IO_TERM_ISSUED BIT(7) 71 + #define FNIC_IO_INTERNAL_TERM_ISSUED BIT(8) 72 + #define FNIC_IO_ABT_TERM_DONE BIT(9) 73 + #define FNIC_IO_ABT_TERM_REQ_NULL BIT(10) 74 + #define FNIC_IO_ABT_TERM_TIMED_OUT BIT(11) 75 + #define FNIC_DEVICE_RESET BIT(12) /* Device reset request */ 76 + #define FNIC_DEV_RST_ISSUED BIT(13) 77 + #define FNIC_DEV_RST_TIMED_OUT BIT(14) 78 + #define FNIC_DEV_RST_ABTS_ISSUED BIT(15) 79 + #define FNIC_DEV_RST_TERM_ISSUED BIT(16) 80 + #define FNIC_DEV_RST_DONE BIT(17) 81 + #define FNIC_DEV_RST_REQ_NULL BIT(18) 82 + #define FNIC_DEV_RST_ABTS_DONE BIT(19) 83 + #define FNIC_DEV_RST_TERM_DONE BIT(20) 84 + #define FNIC_DEV_RST_ABTS_PENDING BIT(21) 70 85 71 86 /* 72 87 * Usage of the scsi_cmnd scratchpad.
+3 -1
drivers/scsi/fnic/fnic_io.h
··· 45 45 }; 46 46 47 47 enum fnic_ioreq_state { 48 - FNIC_IOREQ_CMD_PENDING = 0, 48 + FNIC_IOREQ_NOT_INITED = 0, 49 + FNIC_IOREQ_CMD_PENDING, 49 50 FNIC_IOREQ_ABTS_PENDING, 50 51 FNIC_IOREQ_ABTS_COMPLETE, 51 52 FNIC_IOREQ_CMD_COMPLETE, ··· 61 60 u8 sgl_type; /* device DMA descriptor list type */ 62 61 u8 io_completed:1; /* set to 1 when fw completes IO */ 63 62 u32 port_id; /* remote port DID */ 63 + unsigned long start_time; /* in jiffies */ 64 64 struct completion *abts_done; /* completion for abts */ 65 65 struct completion *dr_done; /* completion for device reset */ 66 66 };
+106 -12
drivers/scsi/fnic/fnic_scsi.c
··· 47 47 }; 48 48 49 49 static const char *fnic_ioreq_state_str[] = { 50 + [FNIC_IOREQ_NOT_INITED] = "FNIC_IOREQ_NOT_INITED", 50 51 [FNIC_IOREQ_CMD_PENDING] = "FNIC_IOREQ_CMD_PENDING", 51 52 [FNIC_IOREQ_ABTS_PENDING] = "FNIC_IOREQ_ABTS_PENDING", 52 53 [FNIC_IOREQ_ABTS_COMPLETE] = "FNIC_IOREQ_ABTS_COMPLETE", ··· 350 349 351 350 if (unlikely(!vnic_wq_copy_desc_avail(wq))) { 352 351 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); 352 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 353 + "fnic_queue_wq_copy_desc failure - no descriptors\n"); 353 354 return SCSI_MLQUEUE_HOST_BUSY; 354 355 } 355 356 ··· 423 420 * caller disabling them. 424 421 */ 425 422 spin_unlock(lp->host->host_lock); 426 - CMD_FLAGS(sc) = FNIC_CDB_REQ; 423 + CMD_STATE(sc) = FNIC_IOREQ_NOT_INITED; 424 + CMD_FLAGS(sc) = FNIC_NO_FLAGS; 427 425 428 426 /* Get a new io_req for this SCSI IO */ 429 427 io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); ··· 471 467 472 468 /* initialize rest of io_req */ 473 469 io_req->port_id = rport->port_id; 470 + io_req->start_time = jiffies; 474 471 CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; 475 472 CMD_SP(sc) = (char *)io_req; 473 + CMD_FLAGS(sc) |= FNIC_IO_INITIALIZED; 476 474 sc->scsi_done = done; 477 475 478 476 /* create copy wq desc and enqueue it */ ··· 496 490 fnic_release_ioreq_buf(fnic, io_req, sc); 497 491 mempool_free(io_req, fnic->io_req_pool); 498 492 } 493 + } else { 494 + /* REVISIT: Use per IO lock in the final code */ 495 + CMD_FLAGS(sc) |= FNIC_IO_ISSUED; 499 496 } 500 497 out: 501 498 atomic_dec(&fnic->in_flight); ··· 703 694 struct scsi_cmnd *sc; 704 695 unsigned long flags; 705 696 spinlock_t *io_lock; 697 + unsigned long start_time; 706 698 707 699 /* Decode the cmpl description to get the io_req id */ 708 700 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); 709 701 fcpio_tag_id_dec(&tag, &id); 702 + icmnd_cmpl = &desc->u.icmnd_cmpl; 710 703 711 704 if (id >= FNIC_MAX_IO_REQ) { 712 705 shost_printk(KERN_ERR, fnic->lport->host, ··· 719 708 720 709 sc = scsi_host_find_tag(fnic->lport->host, id); 721 710 WARN_ON_ONCE(!sc); 722 - if (!sc) 711 + if (!sc) { 712 + shost_printk(KERN_ERR, fnic->lport->host, 713 + "icmnd_cmpl sc is null - " 714 + "hdr status = %s tag = 0x%x desc = 0x%p\n", 715 + fnic_fcpio_status_to_str(hdr_status), id, desc); 723 716 return; 717 + } 724 718 725 719 io_lock = fnic_io_lock_hash(fnic, sc); 726 720 spin_lock_irqsave(io_lock, flags); 727 721 io_req = (struct fnic_io_req *)CMD_SP(sc); 728 722 WARN_ON_ONCE(!io_req); 729 723 if (!io_req) { 724 + CMD_FLAGS(sc) |= FNIC_IO_REQ_NULL; 730 725 spin_unlock_irqrestore(io_lock, flags); 726 + shost_printk(KERN_ERR, fnic->lport->host, 727 + "icmnd_cmpl io_req is null - " 728 + "hdr status = %s tag = 0x%x sc 0x%p\n", 729 + fnic_fcpio_status_to_str(hdr_status), id, sc); 731 730 return; 732 731 } 732 + start_time = io_req->start_time; 733 733 734 734 /* firmware completed the io */ 735 735 io_req->io_completed = 1; ··· 751 729 */ 752 730 if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { 753 731 spin_unlock_irqrestore(io_lock, flags); 732 + CMD_FLAGS(sc) |= FNIC_IO_ABTS_PENDING; 733 + switch (hdr_status) { 734 + case FCPIO_SUCCESS: 735 + CMD_FLAGS(sc) |= FNIC_IO_DONE; 736 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 737 + "icmnd_cmpl ABTS pending hdr status = %s " 738 + "sc 0x%p scsi_status %x residual %d\n", 739 + fnic_fcpio_status_to_str(hdr_status), sc, 740 + icmnd_cmpl->scsi_status, 741 + icmnd_cmpl->residual); 742 + break; 743 + case FCPIO_ABORTED: 744 + CMD_FLAGS(sc) |= FNIC_IO_ABORTED; 745 + break; 746 + default: 747 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 748 + "icmnd_cmpl abts pending " 749 + "hdr status = %s tag = 0x%x sc = 0x%p\n", 750 + fnic_fcpio_status_to_str(hdr_status), 751 + id, sc); 752 + break; 753 + } 754 754 return; 755 755 } 756 756 ··· 856 812 857 813 /* Break link with the SCSI command */ 858 814 CMD_SP(sc) = NULL; 815 + CMD_FLAGS(sc) |= FNIC_IO_DONE; 859 816 860 817 spin_unlock_irqrestore(io_lock, flags); 861 818 ··· 893 848 struct fnic_io_req *io_req; 894 849 unsigned long flags; 895 850 spinlock_t *io_lock; 851 + unsigned long start_time; 896 852 897 853 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); 898 854 fcpio_tag_id_dec(&tag, &id); ··· 907 861 908 862 sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK); 909 863 WARN_ON_ONCE(!sc); 910 - if (!sc) 864 + if (!sc) { 865 + shost_printk(KERN_ERR, fnic->lport->host, 866 + "itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n", 867 + fnic_fcpio_status_to_str(hdr_status), id); 911 868 return; 912 - 869 + } 913 870 io_lock = fnic_io_lock_hash(fnic, sc); 914 871 spin_lock_irqsave(io_lock, flags); 915 872 io_req = (struct fnic_io_req *)CMD_SP(sc); 916 873 WARN_ON_ONCE(!io_req); 917 874 if (!io_req) { 918 875 spin_unlock_irqrestore(io_lock, flags); 876 + CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL; 877 + shost_printk(KERN_ERR, fnic->lport->host, 878 + "itmf_cmpl io_req is null - " 879 + "hdr status = %s tag = 0x%x sc 0x%p\n", 880 + fnic_fcpio_status_to_str(hdr_status), id, sc); 919 881 return; 920 882 } 883 + start_time = io_req->start_time; 921 884 922 885 if ((id & FNIC_TAG_ABORT) && (id & FNIC_TAG_DEV_RST)) { 923 886 /* Abort and terminate completion of device reset req */ ··· 950 895 CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; 951 896 CMD_ABTS_STATUS(sc) = hdr_status; 952 897 898 + CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE; 953 899 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 954 900 "abts cmpl recd. id %d status %s\n", 955 901 (int)(id & FNIC_TAG_MASK), ··· 983 927 CMD_LR_STATUS(sc) = hdr_status; 984 928 if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { 985 929 spin_unlock_irqrestore(io_lock, flags); 930 + CMD_FLAGS(sc) |= FNIC_DEV_RST_ABTS_PENDING; 986 931 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 987 932 "Terminate pending " 988 933 "dev reset cmpl recd. id %d status %s\n", ··· 1089 1032 unsigned long flags = 0; 1090 1033 struct scsi_cmnd *sc; 1091 1034 spinlock_t *io_lock; 1035 + unsigned long start_time = 0; 1092 1036 1093 1037 for (i = 0; i < FNIC_MAX_IO_REQ; i++) { 1094 1038 if (i == exclude_id) ··· 1132 1074 * If there is a scsi_cmnd associated with this io_req, then 1133 1075 * free the corresponding state 1134 1076 */ 1077 + start_time = io_req->start_time; 1135 1078 fnic_release_ioreq_buf(fnic, io_req, sc); 1136 1079 mempool_free(io_req, fnic->io_req_pool); 1137 1080 ··· 1156 1097 struct scsi_cmnd *sc; 1157 1098 unsigned long flags; 1158 1099 spinlock_t *io_lock; 1100 + unsigned long start_time = 0; 1159 1101 1160 1102 /* get the tag reference */ 1161 1103 fcpio_tag_id_dec(&desc->hdr.tag, &id); ··· 1186 1126 1187 1127 spin_unlock_irqrestore(io_lock, flags); 1188 1128 1129 + start_time = io_req->start_time; 1189 1130 fnic_release_ioreq_buf(fnic, io_req, sc); 1190 1131 mempool_free(io_req, fnic->io_req_pool); 1191 1132 ··· 1224 1163 if (!vnic_wq_copy_desc_avail(wq)) { 1225 1164 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); 1226 1165 atomic_dec(&fnic->in_flight); 1227 - shost_printk(KERN_DEBUG, fnic->lport->host, 1166 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1228 1167 "fnic_queue_abort_io_req: failure: no descriptors\n"); 1229 1168 return 1; 1230 1169 } ··· 1274 1213 } 1275 1214 1276 1215 if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) && 1277 - (!(CMD_FLAGS(sc) & FNIC_DEV_RST_PENDING))) { 1216 + (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) { 1278 1217 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1279 1218 "fnic_rport_exch_reset dev rst not pending sc 0x%p\n", 1280 1219 sc); ··· 1297 1236 fnic_ioreq_state_to_str(CMD_STATE(sc))); 1298 1237 } 1299 1238 1239 + if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) { 1240 + shost_printk(KERN_ERR, fnic->lport->host, 1241 + "rport_exch_reset " 1242 + "IO not yet issued %p tag 0x%x flags " 1243 + "%x state %d\n", 1244 + sc, tag, CMD_FLAGS(sc), CMD_STATE(sc)); 1245 + } 1300 1246 old_ioreq_state = CMD_STATE(sc); 1301 1247 CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; 1302 1248 CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; ··· 1341 1273 spin_lock_irqsave(io_lock, flags); 1342 1274 if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) 1343 1275 CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED; 1276 + else 1277 + CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED; 1344 1278 spin_unlock_irqrestore(io_lock, flags); 1345 1279 } 1346 1280 } ··· 1394 1324 } 1395 1325 1396 1326 if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) && 1397 - (!(CMD_FLAGS(sc) & FNIC_DEV_RST_PENDING))) { 1327 + (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) { 1398 1328 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1399 1329 "fnic_terminate_rport_io dev rst not pending sc 0x%p\n", 1400 1330 sc); ··· 1414 1344 "fnic_terminate_rport_io: io_req->abts_done is set " 1415 1345 "state is %s\n", 1416 1346 fnic_ioreq_state_to_str(CMD_STATE(sc))); 1347 + } 1348 + if (!(CMD_FLAGS(sc) & FNIC_IO_ISSUED)) { 1349 + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 1350 + "fnic_terminate_rport_io " 1351 + "IO not yet issued %p tag 0x%x flags " 1352 + "%x state %d\n", 1353 + sc, tag, CMD_FLAGS(sc), CMD_STATE(sc)); 1417 1354 } 1418 1355 old_ioreq_state = CMD_STATE(sc); 1419 1356 CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; ··· 1459 1382 spin_lock_irqsave(io_lock, flags); 1460 1383 if (CMD_FLAGS(sc) & FNIC_DEVICE_RESET) 1461 1384 CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED; 1385 + else 1386 + CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED; 1462 1387 spin_unlock_irqrestore(io_lock, flags); 1463 1388 } 1464 1389 } ··· 1480 1401 struct fc_rport *rport; 1481 1402 spinlock_t *io_lock; 1482 1403 unsigned long flags; 1404 + unsigned long start_time = 0; 1483 1405 int ret = SUCCESS; 1484 - u32 task_req; 1406 + u32 task_req = 0; 1485 1407 struct scsi_lun fc_lun; 1486 1408 int tag; 1487 1409 DECLARE_COMPLETION_ONSTACK(tm_done); ··· 1569 1489 ret = FAILED; 1570 1490 goto fnic_abort_cmd_end; 1571 1491 } 1492 + if (task_req == FCPIO_ITMF_ABT_TASK) 1493 + CMD_FLAGS(sc) |= FNIC_IO_ABTS_ISSUED; 1494 + else 1495 + CMD_FLAGS(sc) |= FNIC_IO_TERM_ISSUED; 1572 1496 1573 1497 /* 1574 1498 * We queued an abort IO, wait for its completion. ··· 1591 1507 io_req = (struct fnic_io_req *)CMD_SP(sc); 1592 1508 if (!io_req) { 1593 1509 spin_unlock_irqrestore(io_lock, flags); 1510 + CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL; 1594 1511 ret = FAILED; 1595 1512 goto fnic_abort_cmd_end; 1596 1513 } ··· 1600 1515 /* fw did not complete abort, timed out */ 1601 1516 if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { 1602 1517 spin_unlock_irqrestore(io_lock, flags); 1518 + CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_TIMED_OUT; 1603 1519 ret = FAILED; 1604 1520 goto fnic_abort_cmd_end; 1605 1521 } ··· 1616 1530 1617 1531 spin_unlock_irqrestore(io_lock, flags); 1618 1532 1533 + start_time = io_req->start_time; 1619 1534 fnic_release_ioreq_buf(fnic, io_req, sc); 1620 1535 mempool_free(io_req, fnic->io_req_pool); 1621 1536 1622 1537 fnic_abort_cmd_end: 1623 1538 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1624 - "Returning from abort cmd %s\n", 1539 + "Returning from abort cmd type %x %s\n", task_req, 1625 1540 (ret == SUCCESS) ? 1626 1541 "SUCCESS" : "FAILED"); 1627 1542 return ret; ··· 1653 1566 free_wq_copy_descs(fnic, wq); 1654 1567 1655 1568 if (!vnic_wq_copy_desc_avail(wq)) { 1569 + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1570 + "queue_dr_io_req failure - no descriptors\n"); 1656 1571 ret = -EAGAIN; 1657 1572 goto lr_io_req_end; 1658 1573 } ··· 1726 1637 continue; 1727 1638 } 1728 1639 if ((CMD_FLAGS(sc) & FNIC_DEVICE_RESET) && 1729 - (!(CMD_FLAGS(sc) & FNIC_DEV_RST_PENDING))) { 1640 + (!(CMD_FLAGS(sc) & FNIC_DEV_RST_ISSUED))) { 1730 1641 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, 1731 1642 "%s dev rst not pending sc 0x%p\n", __func__, 1732 1643 sc); ··· 1782 1693 CMD_FLAGS(sc) |= FNIC_DEV_RST_TERM_ISSUED; 1783 1694 spin_unlock_irqrestore(io_lock, flags); 1784 1695 } 1696 + CMD_FLAGS(sc) |= FNIC_IO_INTERNAL_TERM_ISSUED; 1785 1697 1786 1698 wait_for_completion_timeout(&tm_done, 1787 1699 msecs_to_jiffies ··· 1793 1703 io_req = (struct fnic_io_req *)CMD_SP(sc); 1794 1704 if (!io_req) { 1795 1705 spin_unlock_irqrestore(io_lock, flags); 1706 + CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_REQ_NULL; 1796 1707 continue; 1797 1708 } 1798 1709 ··· 1802 1711 /* if abort is still pending with fw, fail */ 1803 1712 if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { 1804 1713 spin_unlock_irqrestore(io_lock, flags); 1714 + CMD_FLAGS(sc) |= FNIC_IO_ABT_TERM_DONE; 1805 1715 ret = 1; 1806 1716 goto clean_pending_aborts_end; 1807 1717 } ··· 1897 1805 int ret = FAILED; 1898 1806 spinlock_t *io_lock; 1899 1807 unsigned long flags; 1808 + unsigned long start_time = 0; 1900 1809 struct scsi_lun fc_lun; 1901 1810 int tag; 1902 1811 DECLARE_COMPLETION_ONSTACK(tm_done); ··· 1923 1830 if (fc_remote_port_chkready(rport)) 1924 1831 goto fnic_device_reset_end; 1925 1832 1926 - CMD_FLAGS(sc) = (FNIC_DEVICE_RESET | FNIC_BLOCKING_REQ); 1833 + CMD_FLAGS(sc) = FNIC_DEVICE_RESET; 1927 1834 /* Allocate tag if not present */ 1928 1835 1929 1836 tag = sc->request->tag; ··· 1970 1877 goto fnic_device_reset_clean; 1971 1878 } 1972 1879 spin_lock_irqsave(io_lock, flags); 1973 - CMD_FLAGS(sc) |= FNIC_DEV_RST_PENDING; 1880 + CMD_FLAGS(sc) |= FNIC_DEV_RST_ISSUED; 1974 1881 spin_unlock_irqrestore(io_lock, flags); 1975 1882 1976 1883 /* ··· 2088 1995 spin_unlock_irqrestore(io_lock, flags); 2089 1996 2090 1997 if (io_req) { 1998 + start_time = io_req->start_time; 2091 1999 fnic_release_ioreq_buf(fnic, io_req, sc); 2092 2000 mempool_free(io_req, fnic->io_req_pool); 2093 2001 }