diff options
| -rw-r--r-- | drivers/scsi/qla2xxx/qla_target.c | 25 | ||||
| -rw-r--r-- | drivers/scsi/qla2xxx/qla_target.h | 1 | ||||
| -rw-r--r-- | drivers/scsi/qla2xxx/tcm_qla2xxx.c | 73 |
3 files changed, 85 insertions, 14 deletions
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 0e09d8f433d1..62aa5584f644 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
| @@ -557,6 +557,7 @@ static bool qlt_check_fcport_exist(struct scsi_qla_host *vha, | |||
| 557 | int pmap_len; | 557 | int pmap_len; |
| 558 | fc_port_t *fcport; | 558 | fc_port_t *fcport; |
| 559 | int global_resets; | 559 | int global_resets; |
| 560 | unsigned long flags; | ||
| 560 | 561 | ||
| 561 | retry: | 562 | retry: |
| 562 | global_resets = atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count); | 563 | global_resets = atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count); |
| @@ -625,10 +626,10 @@ retry: | |||
| 625 | sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain, | 626 | sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain, |
| 626 | fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id); | 627 | fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id); |
| 627 | 628 | ||
| 628 | sess->s_id = fcport->d_id; | 629 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 629 | sess->loop_id = fcport->loop_id; | 630 | ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id, |
| 630 | sess->conf_compl_supported = !!(fcport->flags & | 631 | (fcport->flags & FCF_CONF_COMP_SUPPORTED)); |
| 631 | FCF_CONF_COMP_SUPPORTED); | 632 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 632 | 633 | ||
| 633 | res = true; | 634 | res = true; |
| 634 | 635 | ||
| @@ -740,10 +741,9 @@ static struct qla_tgt_sess *qlt_create_sess( | |||
| 740 | qlt_undelete_sess(sess); | 741 | qlt_undelete_sess(sess); |
| 741 | 742 | ||
| 742 | kref_get(&sess->se_sess->sess_kref); | 743 | kref_get(&sess->se_sess->sess_kref); |
| 743 | sess->s_id = fcport->d_id; | 744 | ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id, |
| 744 | sess->loop_id = fcport->loop_id; | 745 | (fcport->flags & FCF_CONF_COMP_SUPPORTED)); |
| 745 | sess->conf_compl_supported = !!(fcport->flags & | 746 | |
| 746 | FCF_CONF_COMP_SUPPORTED); | ||
| 747 | if (sess->local && !local) | 747 | if (sess->local && !local) |
| 748 | sess->local = 0; | 748 | sess->local = 0; |
| 749 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 749 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| @@ -796,8 +796,7 @@ static struct qla_tgt_sess *qlt_create_sess( | |||
| 796 | */ | 796 | */ |
| 797 | kref_get(&sess->se_sess->sess_kref); | 797 | kref_get(&sess->se_sess->sess_kref); |
| 798 | 798 | ||
| 799 | sess->conf_compl_supported = !!(fcport->flags & | 799 | sess->conf_compl_supported = (fcport->flags & FCF_CONF_COMP_SUPPORTED); |
| 800 | FCF_CONF_COMP_SUPPORTED); | ||
| 801 | BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name)); | 800 | BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name)); |
| 802 | memcpy(sess->port_name, fcport->port_name, sizeof(sess->port_name)); | 801 | memcpy(sess->port_name, fcport->port_name, sizeof(sess->port_name)); |
| 803 | 802 | ||
| @@ -869,10 +868,8 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) | |||
| 869 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf007, | 868 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf007, |
| 870 | "Reappeared sess %p\n", sess); | 869 | "Reappeared sess %p\n", sess); |
| 871 | } | 870 | } |
| 872 | sess->s_id = fcport->d_id; | 871 | ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id, |
| 873 | sess->loop_id = fcport->loop_id; | 872 | (fcport->flags & FCF_CONF_COMP_SUPPORTED)); |
| 874 | sess->conf_compl_supported = !!(fcport->flags & | ||
| 875 | FCF_CONF_COMP_SUPPORTED); | ||
| 876 | } | 873 | } |
| 877 | 874 | ||
| 878 | if (sess && sess->local) { | 875 | if (sess && sess->local) { |
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 170af1571214..bad749561ec2 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h | |||
| @@ -648,6 +648,7 @@ struct qla_tgt_func_tmpl { | |||
| 648 | 648 | ||
| 649 | int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, | 649 | int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, |
| 650 | void *, uint8_t *, uint16_t); | 650 | void *, uint8_t *, uint16_t); |
| 651 | void (*update_sess)(struct qla_tgt_sess *, port_id_t, uint16_t, bool); | ||
| 651 | struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *, | 652 | struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *, |
| 652 | const uint16_t); | 653 | const uint16_t); |
| 653 | struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *, | 654 | struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *, |
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index d8211ccc413a..3d74f2f39ae1 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
| @@ -1457,6 +1457,78 @@ static int tcm_qla2xxx_check_initiator_node_acl( | |||
| 1457 | return 0; | 1457 | return 0; |
| 1458 | } | 1458 | } |
| 1459 | 1459 | ||
| 1460 | static void tcm_qla2xxx_update_sess(struct qla_tgt_sess *sess, port_id_t s_id, | ||
| 1461 | uint16_t loop_id, bool conf_compl_supported) | ||
| 1462 | { | ||
| 1463 | struct qla_tgt *tgt = sess->tgt; | ||
| 1464 | struct qla_hw_data *ha = tgt->ha; | ||
| 1465 | struct tcm_qla2xxx_lport *lport = ha->tgt.target_lport_ptr; | ||
| 1466 | struct se_node_acl *se_nacl = sess->se_sess->se_node_acl; | ||
| 1467 | struct tcm_qla2xxx_nacl *nacl = container_of(se_nacl, | ||
| 1468 | struct tcm_qla2xxx_nacl, se_node_acl); | ||
| 1469 | u32 key; | ||
| 1470 | |||
| 1471 | |||
| 1472 | if (sess->loop_id != loop_id || sess->s_id.b24 != s_id.b24) | ||
| 1473 | pr_info("Updating session %p from port %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x loop_id %d -> %d s_id %x:%x:%x -> %x:%x:%x\n", | ||
| 1474 | sess, | ||
| 1475 | sess->port_name[0], sess->port_name[1], | ||
| 1476 | sess->port_name[2], sess->port_name[3], | ||
| 1477 | sess->port_name[4], sess->port_name[5], | ||
| 1478 | sess->port_name[6], sess->port_name[7], | ||
| 1479 | sess->loop_id, loop_id, | ||
| 1480 | sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa, | ||
| 1481 | s_id.b.domain, s_id.b.area, s_id.b.al_pa); | ||
| 1482 | |||
| 1483 | if (sess->loop_id != loop_id) { | ||
| 1484 | /* | ||
| 1485 | * Because we can shuffle loop IDs around and we | ||
| 1486 | * update different sessions non-atomically, we might | ||
| 1487 | * have overwritten this session's old loop ID | ||
| 1488 | * already, and we might end up overwriting some other | ||
| 1489 | * session that will be updated later. So we have to | ||
| 1490 | * be extra careful and we can't warn about those things... | ||
| 1491 | */ | ||
| 1492 | if (lport->lport_loopid_map[sess->loop_id].se_nacl == se_nacl) | ||
| 1493 | lport->lport_loopid_map[sess->loop_id].se_nacl = NULL; | ||
| 1494 | |||
| 1495 | lport->lport_loopid_map[loop_id].se_nacl = se_nacl; | ||
| 1496 | |||
| 1497 | sess->loop_id = loop_id; | ||
| 1498 | } | ||
| 1499 | |||
| 1500 | if (sess->s_id.b24 != s_id.b24) { | ||
| 1501 | key = (((u32) sess->s_id.b.domain << 16) | | ||
| 1502 | ((u32) sess->s_id.b.area << 8) | | ||
| 1503 | ((u32) sess->s_id.b.al_pa)); | ||
| 1504 | |||
| 1505 | if (btree_lookup32(&lport->lport_fcport_map, key)) | ||
| 1506 | WARN(btree_remove32(&lport->lport_fcport_map, key) != se_nacl, | ||
| 1507 | "Found wrong se_nacl when updating s_id %x:%x:%x\n", | ||
| 1508 | sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa); | ||
| 1509 | else | ||
| 1510 | WARN(1, "No lport_fcport_map entry for s_id %x:%x:%x\n", | ||
| 1511 | sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa); | ||
| 1512 | |||
| 1513 | key = (((u32) s_id.b.domain << 16) | | ||
| 1514 | ((u32) s_id.b.area << 8) | | ||
| 1515 | ((u32) s_id.b.al_pa)); | ||
| 1516 | |||
| 1517 | if (btree_lookup32(&lport->lport_fcport_map, key)) { | ||
| 1518 | WARN(1, "Already have lport_fcport_map entry for s_id %x:%x:%x\n", | ||
| 1519 | s_id.b.domain, s_id.b.area, s_id.b.al_pa); | ||
| 1520 | btree_update32(&lport->lport_fcport_map, key, se_nacl); | ||
| 1521 | } else { | ||
| 1522 | btree_insert32(&lport->lport_fcport_map, key, se_nacl, GFP_ATOMIC); | ||
| 1523 | } | ||
| 1524 | |||
| 1525 | sess->s_id = s_id; | ||
| 1526 | nacl->nport_id = key; | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | sess->conf_compl_supported = conf_compl_supported; | ||
| 1530 | } | ||
| 1531 | |||
| 1460 | /* | 1532 | /* |
| 1461 | * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path. | 1533 | * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path. |
| 1462 | */ | 1534 | */ |
| @@ -1467,6 +1539,7 @@ static struct qla_tgt_func_tmpl tcm_qla2xxx_template = { | |||
| 1467 | .free_cmd = tcm_qla2xxx_free_cmd, | 1539 | .free_cmd = tcm_qla2xxx_free_cmd, |
| 1468 | .free_mcmd = tcm_qla2xxx_free_mcmd, | 1540 | .free_mcmd = tcm_qla2xxx_free_mcmd, |
| 1469 | .free_session = tcm_qla2xxx_free_session, | 1541 | .free_session = tcm_qla2xxx_free_session, |
| 1542 | .update_sess = tcm_qla2xxx_update_sess, | ||
| 1470 | .check_initiator_node_acl = tcm_qla2xxx_check_initiator_node_acl, | 1543 | .check_initiator_node_acl = tcm_qla2xxx_check_initiator_node_acl, |
| 1471 | .find_sess_by_s_id = tcm_qla2xxx_find_sess_by_s_id, | 1544 | .find_sess_by_s_id = tcm_qla2xxx_find_sess_by_s_id, |
| 1472 | .find_sess_by_loop_id = tcm_qla2xxx_find_sess_by_loop_id, | 1545 | .find_sess_by_loop_id = tcm_qla2xxx_find_sess_by_loop_id, |
