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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending

Pull SCSI target updates from Nicholas Bellinger:
"Things have been quiet this round with mostly bugfixes, percpu
conversions, and other minor iscsi-target conformance testing changes.

The highlights include:

- Add demo_mode_discovery attribute for iscsi-target (Thomas)
- Convert tcm_fc(FCoE) to use percpu-ida pre-allocation
- Add send completion interrupt coalescing for ib_isert
- Convert target-core to use percpu-refcounting for se_lun
- Fix mutex_trylock usage bug in iscsit_increment_maxcmdsn
- tcm_loop updates (Hannes)
- target-core ALUA cleanups + prep for v3.14 SCSI Referrals support (Hannes)

v3.14 is currently shaping to be a busy development cycle in target
land, with initial support for T10 Referrals and T10 DIF currently on
the roadmap"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (40 commits)
iscsi-target: chap auth shouldn't match username with trailing garbage
iscsi-target: fix extract_param to handle buffer length corner case
iscsi-target: Expose default_erl as TPG attribute
target_core_configfs: split up ALUA supported states
target_core_alua: Make supported states configurable
target_core_alua: Store supported ALUA states
target_core_alua: Rename ALUA_ACCESS_STATE_OPTIMIZED
target_core_alua: spellcheck
target core: rename (ex,im)plict -> (ex,im)plicit
percpu-refcount: Add percpu-refcount.o to obj-y
iscsi-target: Do not reject non-immediate CmdSNs exceeding MaxCmdSN
iscsi-target: Convert iscsi_session statistics to atomic_long_t
target: Convert se_device statistics to atomic_long_t
target: Fix delayed Task Aborted Status (TAS) handling bug
iscsi-target: Reject unsupported multi PDU text command sequence
ib_isert: Avoid duplicate iscsit_increment_maxcmdsn call
iscsi-target: Fix mutex_trylock usage in iscsit_increment_maxcmdsn
target: Core does not need blkdev.h
target: Pass through I/O topology for block backstores
iser-target: Avoid using FRMR for single dma entry requests
...

+1025 -805
+9 -9
Documentation/target/tcm_mod_builder.py
··· 440 440 buf += " /*\n" 441 441 buf += " * Setup default attribute lists for various fabric->tf_cit_tmpl\n" 442 442 buf += " */\n" 443 - buf += " TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n" 444 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL;\n" 445 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL;\n" 446 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL;\n" 447 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL;\n" 448 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n" 449 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n" 450 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n" 451 - buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n" 443 + buf += " fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n" 444 + buf += " fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = NULL;\n" 445 + buf += " fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;\n" 446 + buf += " fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;\n" 447 + buf += " fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;\n" 448 + buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n" 449 + buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n" 450 + buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n" 451 + buf += " fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n" 452 452 buf += " /*\n" 453 453 buf += " * Register the fabric for use within TCM\n" 454 454 buf += " */\n"
+71 -28
drivers/infiniband/ulp/isert/ib_isert.c
··· 22 22 #include <linux/socket.h> 23 23 #include <linux/in.h> 24 24 #include <linux/in6.h> 25 + #include <linux/llist.h> 25 26 #include <rdma/ib_verbs.h> 26 27 #include <rdma/rdma_cm.h> 27 28 #include <target/target_core_base.h> ··· 490 489 kref_init(&isert_conn->conn_kref); 491 490 kref_get(&isert_conn->conn_kref); 492 491 mutex_init(&isert_conn->conn_mutex); 492 + mutex_init(&isert_conn->conn_comp_mutex); 493 493 spin_lock_init(&isert_conn->conn_lock); 494 494 495 495 cma_id->context = isert_conn; ··· 845 843 } 846 844 847 845 static void 848 - isert_init_send_wr(struct isert_cmd *isert_cmd, struct ib_send_wr *send_wr) 846 + isert_init_send_wr(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, 847 + struct ib_send_wr *send_wr, bool coalesce) 849 848 { 849 + struct iser_tx_desc *tx_desc = &isert_cmd->tx_desc; 850 + 850 851 isert_cmd->rdma_wr.iser_ib_op = ISER_IB_SEND; 851 852 send_wr->wr_id = (unsigned long)&isert_cmd->tx_desc; 852 853 send_wr->opcode = IB_WR_SEND; 853 - send_wr->send_flags = IB_SEND_SIGNALED; 854 - send_wr->sg_list = &isert_cmd->tx_desc.tx_sg[0]; 854 + send_wr->sg_list = &tx_desc->tx_sg[0]; 855 855 send_wr->num_sge = isert_cmd->tx_desc.num_sge; 856 + /* 857 + * Coalesce send completion interrupts by only setting IB_SEND_SIGNALED 858 + * bit for every ISERT_COMP_BATCH_COUNT number of ib_post_send() calls. 859 + */ 860 + mutex_lock(&isert_conn->conn_comp_mutex); 861 + if (coalesce && 862 + ++isert_conn->conn_comp_batch < ISERT_COMP_BATCH_COUNT) { 863 + llist_add(&tx_desc->comp_llnode, &isert_conn->conn_comp_llist); 864 + mutex_unlock(&isert_conn->conn_comp_mutex); 865 + return; 866 + } 867 + isert_conn->conn_comp_batch = 0; 868 + tx_desc->comp_llnode_batch = llist_del_all(&isert_conn->conn_comp_llist); 869 + mutex_unlock(&isert_conn->conn_comp_mutex); 870 + 871 + send_wr->send_flags = IB_SEND_SIGNALED; 856 872 } 857 873 858 874 static int ··· 1602 1582 } 1603 1583 1604 1584 static void 1605 - isert_send_completion(struct iser_tx_desc *tx_desc, 1606 - struct isert_conn *isert_conn) 1585 + __isert_send_completion(struct iser_tx_desc *tx_desc, 1586 + struct isert_conn *isert_conn) 1607 1587 { 1608 1588 struct ib_device *ib_dev = isert_conn->conn_cm_id->device; 1609 1589 struct isert_cmd *isert_cmd = tx_desc->isert_cmd; ··· 1641 1621 dump_stack(); 1642 1622 break; 1643 1623 } 1624 + } 1625 + 1626 + static void 1627 + isert_send_completion(struct iser_tx_desc *tx_desc, 1628 + struct isert_conn *isert_conn) 1629 + { 1630 + struct llist_node *llnode = tx_desc->comp_llnode_batch; 1631 + struct iser_tx_desc *t; 1632 + /* 1633 + * Drain coalesced completion llist starting from comp_llnode_batch 1634 + * setup in isert_init_send_wr(), and then complete trailing tx_desc. 1635 + */ 1636 + while (llnode) { 1637 + t = llist_entry(llnode, struct iser_tx_desc, comp_llnode); 1638 + llnode = llist_next(llnode); 1639 + __isert_send_completion(t, isert_conn); 1640 + } 1641 + __isert_send_completion(tx_desc, isert_conn); 1644 1642 } 1645 1643 1646 1644 static void ··· 1831 1793 isert_cmd->tx_desc.num_sge = 2; 1832 1794 } 1833 1795 1834 - isert_init_send_wr(isert_cmd, send_wr); 1796 + isert_init_send_wr(isert_conn, isert_cmd, send_wr, true); 1835 1797 1836 1798 pr_debug("Posting SCSI Response IB_WR_SEND >>>>>>>>>>>>>>>>>>>>>>\n"); 1837 1799 ··· 1851 1813 &isert_cmd->tx_desc.iscsi_header, 1852 1814 nopout_response); 1853 1815 isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); 1854 - isert_init_send_wr(isert_cmd, send_wr); 1816 + isert_init_send_wr(isert_conn, isert_cmd, send_wr, false); 1855 1817 1856 1818 pr_debug("Posting NOPIN Response IB_WR_SEND >>>>>>>>>>>>>>>>>>>>>>\n"); 1857 1819 ··· 1869 1831 iscsit_build_logout_rsp(cmd, conn, (struct iscsi_logout_rsp *) 1870 1832 &isert_cmd->tx_desc.iscsi_header); 1871 1833 isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); 1872 - isert_init_send_wr(isert_cmd, send_wr); 1834 + isert_init_send_wr(isert_conn, isert_cmd, send_wr, false); 1873 1835 1874 1836 pr_debug("Posting Logout Response IB_WR_SEND >>>>>>>>>>>>>>>>>>>>>>\n"); 1875 1837 ··· 1887 1849 iscsit_build_task_mgt_rsp(cmd, conn, (struct iscsi_tm_rsp *) 1888 1850 &isert_cmd->tx_desc.iscsi_header); 1889 1851 isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); 1890 - isert_init_send_wr(isert_cmd, send_wr); 1852 + isert_init_send_wr(isert_conn, isert_cmd, send_wr, false); 1891 1853 1892 1854 pr_debug("Posting Task Management Response IB_WR_SEND >>>>>>>>>>>>>>>>>>>>>>\n"); 1893 1855 ··· 1919 1881 tx_dsg->lkey = isert_conn->conn_mr->lkey; 1920 1882 isert_cmd->tx_desc.num_sge = 2; 1921 1883 1922 - isert_init_send_wr(isert_cmd, send_wr); 1884 + isert_init_send_wr(isert_conn, isert_cmd, send_wr, false); 1923 1885 1924 1886 pr_debug("Posting Reject IB_WR_SEND >>>>>>>>>>>>>>>>>>>>>>\n"); 1925 1887 ··· 1959 1921 tx_dsg->lkey = isert_conn->conn_mr->lkey; 1960 1922 isert_cmd->tx_desc.num_sge = 2; 1961 1923 } 1962 - isert_init_send_wr(isert_cmd, send_wr); 1924 + isert_init_send_wr(isert_conn, isert_cmd, send_wr, false); 1963 1925 1964 1926 pr_debug("Posting Text Response IB_WR_SEND >>>>>>>>>>>>>>>>>>>>>>\n"); 1965 1927 ··· 2029 1991 2030 1992 if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { 2031 1993 data_left = se_cmd->data_length; 2032 - iscsit_increment_maxcmdsn(cmd, conn->sess); 2033 - cmd->stat_sn = conn->stat_sn++; 2034 1994 } else { 2035 1995 sg_off = cmd->write_data_done / PAGE_SIZE; 2036 1996 data_left = se_cmd->data_length - cmd->write_data_done; ··· 2240 2204 2241 2205 if (wr->iser_ib_op == ISER_IB_RDMA_WRITE) { 2242 2206 data_left = se_cmd->data_length; 2243 - iscsit_increment_maxcmdsn(cmd, conn->sess); 2244 - cmd->stat_sn = conn->stat_sn++; 2245 2207 } else { 2246 2208 sg_off = cmd->write_data_done / PAGE_SIZE; 2247 2209 data_left = se_cmd->data_length - cmd->write_data_done; ··· 2293 2259 data_len = min(data_left, rdma_write_max); 2294 2260 wr->cur_rdma_length = data_len; 2295 2261 2296 - spin_lock_irqsave(&isert_conn->conn_lock, flags); 2297 - fr_desc = list_first_entry(&isert_conn->conn_frwr_pool, 2298 - struct fast_reg_descriptor, list); 2299 - list_del(&fr_desc->list); 2300 - spin_unlock_irqrestore(&isert_conn->conn_lock, flags); 2301 - wr->fr_desc = fr_desc; 2262 + /* if there is a single dma entry, dma mr is sufficient */ 2263 + if (count == 1) { 2264 + ib_sge->addr = ib_sg_dma_address(ib_dev, &sg_start[0]); 2265 + ib_sge->length = ib_sg_dma_len(ib_dev, &sg_start[0]); 2266 + ib_sge->lkey = isert_conn->conn_mr->lkey; 2267 + wr->fr_desc = NULL; 2268 + } else { 2269 + spin_lock_irqsave(&isert_conn->conn_lock, flags); 2270 + fr_desc = list_first_entry(&isert_conn->conn_frwr_pool, 2271 + struct fast_reg_descriptor, list); 2272 + list_del(&fr_desc->list); 2273 + spin_unlock_irqrestore(&isert_conn->conn_lock, flags); 2274 + wr->fr_desc = fr_desc; 2302 2275 2303 - ret = isert_fast_reg_mr(fr_desc, isert_cmd, isert_conn, 2304 - ib_sge, offset, data_len); 2305 - if (ret) { 2306 - list_add_tail(&fr_desc->list, &isert_conn->conn_frwr_pool); 2307 - goto unmap_sg; 2276 + ret = isert_fast_reg_mr(fr_desc, isert_cmd, isert_conn, 2277 + ib_sge, offset, data_len); 2278 + if (ret) { 2279 + list_add_tail(&fr_desc->list, &isert_conn->conn_frwr_pool); 2280 + goto unmap_sg; 2281 + } 2308 2282 } 2309 2283 2310 2284 return 0; ··· 2348 2306 * Build isert_conn->tx_desc for iSCSI response PDU and attach 2349 2307 */ 2350 2308 isert_create_send_desc(isert_conn, isert_cmd, &isert_cmd->tx_desc); 2351 - iscsit_build_rsp_pdu(cmd, conn, false, (struct iscsi_scsi_rsp *) 2309 + iscsit_build_rsp_pdu(cmd, conn, true, (struct iscsi_scsi_rsp *) 2352 2310 &isert_cmd->tx_desc.iscsi_header); 2353 2311 isert_init_tx_hdrs(isert_conn, &isert_cmd->tx_desc); 2354 - isert_init_send_wr(isert_cmd, &isert_cmd->tx_desc.send_wr); 2312 + isert_init_send_wr(isert_conn, isert_cmd, 2313 + &isert_cmd->tx_desc.send_wr, true); 2355 2314 2356 2315 atomic_inc(&isert_conn->post_send_buf_count); 2357 2316
+6
drivers/infiniband/ulp/isert/ib_isert.h
··· 43 43 struct ib_sge tx_sg[2]; 44 44 int num_sge; 45 45 struct isert_cmd *isert_cmd; 46 + struct llist_node *comp_llnode_batch; 47 + struct llist_node comp_llnode; 46 48 struct ib_send_wr send_wr; 47 49 } __packed; 48 50 ··· 123 121 int conn_frwr_pool_size; 124 122 /* lock to protect frwr_pool */ 125 123 spinlock_t conn_lock; 124 + #define ISERT_COMP_BATCH_COUNT 8 125 + int conn_comp_batch; 126 + struct llist_head conn_comp_llist; 127 + struct mutex conn_comp_mutex; 126 128 }; 127 129 128 130 #define ISERT_MAX_CQ 64
-10
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 1352 1352 1353 1353 /* XXX(hch): this is a horrible layering violation.. */ 1354 1354 spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags); 1355 - ioctx->cmd.transport_state |= CMD_T_LUN_STOP; 1356 1355 ioctx->cmd.transport_state &= ~CMD_T_ACTIVE; 1357 1356 spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags); 1358 - 1359 - complete(&ioctx->cmd.transport_lun_stop_comp); 1360 1357 break; 1361 1358 case SRPT_STATE_CMD_RSP_SENT: 1362 1359 /* ··· 1361 1364 * not been received in time. 1362 1365 */ 1363 1366 srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx); 1364 - spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags); 1365 - ioctx->cmd.transport_state |= CMD_T_LUN_STOP; 1366 - spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags); 1367 1367 target_put_sess_cmd(ioctx->ch->sess, &ioctx->cmd); 1368 1368 break; 1369 1369 case SRPT_STATE_MGMT_RSP_SENT: ··· 1470 1476 { 1471 1477 struct se_cmd *cmd; 1472 1478 enum srpt_command_state state; 1473 - unsigned long flags; 1474 1479 1475 1480 cmd = &ioctx->cmd; 1476 1481 state = srpt_get_cmd_state(ioctx); ··· 1489 1496 __func__, __LINE__, state); 1490 1497 break; 1491 1498 case SRPT_RDMA_WRITE_LAST: 1492 - spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags); 1493 - ioctx->cmd.transport_state |= CMD_T_LUN_STOP; 1494 - spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags); 1495 1499 break; 1496 1500 default: 1497 1501 printk(KERN_ERR "%s[%d]: opcode = %u\n", __func__,
+28 -28
drivers/scsi/qla2xxx/tcm_qla2xxx.c
··· 330 330 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 331 331 struct tcm_qla2xxx_tpg, se_tpg); 332 332 333 - return QLA_TPG_ATTRIB(tpg)->generate_node_acls; 333 + return tpg->tpg_attrib.generate_node_acls; 334 334 } 335 335 336 336 static int tcm_qla2xxx_check_demo_mode_cache(struct se_portal_group *se_tpg) ··· 338 338 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 339 339 struct tcm_qla2xxx_tpg, se_tpg); 340 340 341 - return QLA_TPG_ATTRIB(tpg)->cache_dynamic_acls; 341 + return tpg->tpg_attrib.cache_dynamic_acls; 342 342 } 343 343 344 344 static int tcm_qla2xxx_check_demo_write_protect(struct se_portal_group *se_tpg) ··· 346 346 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 347 347 struct tcm_qla2xxx_tpg, se_tpg); 348 348 349 - return QLA_TPG_ATTRIB(tpg)->demo_mode_write_protect; 349 + return tpg->tpg_attrib.demo_mode_write_protect; 350 350 } 351 351 352 352 static int tcm_qla2xxx_check_prod_write_protect(struct se_portal_group *se_tpg) ··· 354 354 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 355 355 struct tcm_qla2xxx_tpg, se_tpg); 356 356 357 - return QLA_TPG_ATTRIB(tpg)->prod_mode_write_protect; 357 + return tpg->tpg_attrib.prod_mode_write_protect; 358 358 } 359 359 360 360 static int tcm_qla2xxx_check_demo_mode_login_only(struct se_portal_group *se_tpg) ··· 362 362 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 363 363 struct tcm_qla2xxx_tpg, se_tpg); 364 364 365 - return QLA_TPG_ATTRIB(tpg)->demo_mode_login_only; 365 + return tpg->tpg_attrib.demo_mode_login_only; 366 366 } 367 367 368 368 static struct se_node_acl *tcm_qla2xxx_alloc_fabric_acl( ··· 847 847 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ 848 848 struct tcm_qla2xxx_tpg, se_tpg); \ 849 849 \ 850 - return sprintf(page, "%u\n", QLA_TPG_ATTRIB(tpg)->name); \ 850 + return sprintf(page, "%u\n", tpg->tpg_attrib.name); \ 851 851 } \ 852 852 \ 853 853 static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \ ··· 1027 1027 * By default allow READ-ONLY TPG demo-mode access w/ cached dynamic 1028 1028 * NodeACLs 1029 1029 */ 1030 - QLA_TPG_ATTRIB(tpg)->generate_node_acls = 1; 1031 - QLA_TPG_ATTRIB(tpg)->demo_mode_write_protect = 1; 1032 - QLA_TPG_ATTRIB(tpg)->cache_dynamic_acls = 1; 1033 - QLA_TPG_ATTRIB(tpg)->demo_mode_login_only = 1; 1030 + tpg->tpg_attrib.generate_node_acls = 1; 1031 + tpg->tpg_attrib.demo_mode_write_protect = 1; 1032 + tpg->tpg_attrib.cache_dynamic_acls = 1; 1033 + tpg->tpg_attrib.demo_mode_login_only = 1; 1034 1034 1035 1035 ret = core_tpg_register(&tcm_qla2xxx_fabric_configfs->tf_ops, wwn, 1036 1036 &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL); ··· 1830 1830 /* 1831 1831 * Setup default attribute lists for various fabric->tf_cit_tmpl 1832 1832 */ 1833 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; 1834 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = tcm_qla2xxx_tpg_attrs; 1835 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = 1833 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; 1834 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_qla2xxx_tpg_attrs; 1835 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = 1836 1836 tcm_qla2xxx_tpg_attrib_attrs; 1837 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 1838 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 1839 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL; 1840 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 1841 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 1842 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; 1837 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 1838 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 1839 + fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL; 1840 + fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 1841 + fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 1842 + fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL; 1843 1843 /* 1844 1844 * Register the fabric for use within TCM 1845 1845 */ ··· 1870 1870 /* 1871 1871 * Setup default attribute lists for various npiv_fabric->tf_cit_tmpl 1872 1872 */ 1873 - TF_CIT_TMPL(npiv_fabric)->tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; 1874 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_base_cit.ct_attrs = NULL; 1875 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; 1876 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 1877 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 1878 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL; 1879 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 1880 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 1881 - TF_CIT_TMPL(npiv_fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; 1873 + npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; 1874 + npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = NULL; 1875 + npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 1876 + npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 1877 + npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 1878 + npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL; 1879 + npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 1880 + npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 1881 + npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL; 1882 1882 /* 1883 1883 * Register the npiv_fabric for use within TCM 1884 1884 */
-2
drivers/scsi/qla2xxx/tcm_qla2xxx.h
··· 45 45 struct se_portal_group se_tpg; 46 46 }; 47 47 48 - #define QLA_TPG_ATTRIB(tpg) (&(tpg)->tpg_attrib) 49 - 50 48 struct tcm_qla2xxx_fc_loopid { 51 49 struct se_node_acl *se_nacl; 52 50 };
+46 -44
drivers/target/iscsi/iscsi_target.c
··· 805 805 int iscsi_task_attr; 806 806 int sam_task_attr; 807 807 808 - spin_lock_bh(&conn->sess->session_stats_lock); 809 - conn->sess->cmd_pdus++; 810 - if (conn->sess->se_sess->se_node_acl) { 811 - spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock); 812 - conn->sess->se_sess->se_node_acl->num_cmds++; 813 - spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock); 814 - } 815 - spin_unlock_bh(&conn->sess->session_stats_lock); 808 + atomic_long_inc(&conn->sess->cmd_pdus); 816 809 817 810 hdr = (struct iscsi_scsi_req *) buf; 818 811 payload_length = ntoh24(hdr->dlength); ··· 1247 1254 int rc; 1248 1255 1249 1256 if (!payload_length) { 1250 - pr_err("DataOUT payload is ZERO, protocol error.\n"); 1251 - return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR, 1252 - buf); 1257 + pr_warn("DataOUT payload is ZERO, ignoring.\n"); 1258 + return 0; 1253 1259 } 1254 1260 1255 1261 /* iSCSI write */ 1256 - spin_lock_bh(&conn->sess->session_stats_lock); 1257 - conn->sess->rx_data_octets += payload_length; 1258 - if (conn->sess->se_sess->se_node_acl) { 1259 - spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock); 1260 - conn->sess->se_sess->se_node_acl->write_bytes += payload_length; 1261 - spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock); 1262 - } 1263 - spin_unlock_bh(&conn->sess->session_stats_lock); 1262 + atomic_long_add(payload_length, &conn->sess->rx_data_octets); 1264 1263 1265 1264 if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { 1266 1265 pr_err("DataSegmentLength: %u is greater than" ··· 1471 1486 1472 1487 static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) 1473 1488 { 1474 - struct iscsi_cmd *cmd; 1489 + struct iscsi_cmd *cmd = NULL; 1475 1490 struct iscsi_data *hdr = (struct iscsi_data *)buf; 1476 1491 int rc; 1477 1492 bool data_crc_failed = false; ··· 1937 1952 payload_length, conn->conn_ops->MaxXmitDataSegmentLength); 1938 1953 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, 1939 1954 (unsigned char *)hdr); 1955 + } 1956 + 1957 + if (!(hdr->flags & ISCSI_FLAG_CMD_FINAL) || 1958 + (hdr->flags & ISCSI_FLAG_TEXT_CONTINUE)) { 1959 + pr_err("Multi sequence text commands currently not supported\n"); 1960 + return iscsit_reject_cmd(cmd, ISCSI_REASON_CMD_NOT_SUPPORTED, 1961 + (unsigned char *)hdr); 1940 1962 } 1941 1963 1942 1964 pr_debug("Got Text Request: ITT: 0x%08x, CmdSN: 0x%08x," ··· 2622 2630 return -1; 2623 2631 } 2624 2632 2625 - spin_lock_bh(&conn->sess->session_stats_lock); 2626 - conn->sess->tx_data_octets += datain.length; 2627 - if (conn->sess->se_sess->se_node_acl) { 2628 - spin_lock(&conn->sess->se_sess->se_node_acl->stats_lock); 2629 - conn->sess->se_sess->se_node_acl->read_bytes += datain.length; 2630 - spin_unlock(&conn->sess->se_sess->se_node_acl->stats_lock); 2631 - } 2632 - spin_unlock_bh(&conn->sess->session_stats_lock); 2633 + atomic_long_add(datain.length, &conn->sess->tx_data_octets); 2633 2634 /* 2634 2635 * Special case for successfully execution w/ both DATAIN 2635 2636 * and Sense Data. ··· 3147 3162 if (inc_stat_sn) 3148 3163 cmd->stat_sn = conn->stat_sn++; 3149 3164 3150 - spin_lock_bh(&conn->sess->session_stats_lock); 3151 - conn->sess->rsp_pdus++; 3152 - spin_unlock_bh(&conn->sess->session_stats_lock); 3165 + atomic_long_inc(&conn->sess->rsp_pdus); 3153 3166 3154 3167 memset(hdr, 0, ISCSI_HDR_LEN); 3155 3168 hdr->opcode = ISCSI_OP_SCSI_CMD_RSP; ··· 3357 3374 struct iscsi_tiqn *tiqn; 3358 3375 struct iscsi_tpg_np *tpg_np; 3359 3376 int buffer_len, end_of_buf = 0, len = 0, payload_len = 0; 3377 + int target_name_printed; 3360 3378 unsigned char buf[ISCSI_IQN_LEN+12]; /* iqn + "TargetName=" + \0 */ 3361 3379 unsigned char *text_in = cmd->text_in_ptr, *text_ptr = NULL; 3362 3380 ··· 3395 3411 continue; 3396 3412 } 3397 3413 3398 - len = sprintf(buf, "TargetName=%s", tiqn->tiqn); 3399 - len += 1; 3400 - 3401 - if ((len + payload_len) > buffer_len) { 3402 - end_of_buf = 1; 3403 - goto eob; 3404 - } 3405 - memcpy(payload + payload_len, buf, len); 3406 - payload_len += len; 3414 + target_name_printed = 0; 3407 3415 3408 3416 spin_lock(&tiqn->tiqn_tpg_lock); 3409 3417 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) { 3418 + 3419 + /* If demo_mode_discovery=0 and generate_node_acls=0 3420 + * (demo mode dislabed) do not return 3421 + * TargetName+TargetAddress unless a NodeACL exists. 3422 + */ 3423 + 3424 + if ((tpg->tpg_attrib.generate_node_acls == 0) && 3425 + (tpg->tpg_attrib.demo_mode_discovery == 0) && 3426 + (!core_tpg_get_initiator_node_acl(&tpg->tpg_se_tpg, 3427 + cmd->conn->sess->sess_ops->InitiatorName))) { 3428 + continue; 3429 + } 3410 3430 3411 3431 spin_lock(&tpg->tpg_state_lock); 3412 3432 if ((tpg->tpg_state == TPG_STATE_FREE) || ··· 3425 3437 tpg_np_list) { 3426 3438 struct iscsi_np *np = tpg_np->tpg_np; 3427 3439 bool inaddr_any = iscsit_check_inaddr_any(np); 3440 + 3441 + if (!target_name_printed) { 3442 + len = sprintf(buf, "TargetName=%s", 3443 + tiqn->tiqn); 3444 + len += 1; 3445 + 3446 + if ((len + payload_len) > buffer_len) { 3447 + spin_unlock(&tpg->tpg_np_lock); 3448 + spin_unlock(&tiqn->tiqn_tpg_lock); 3449 + end_of_buf = 1; 3450 + goto eob; 3451 + } 3452 + memcpy(payload + payload_len, buf, len); 3453 + payload_len += len; 3454 + target_name_printed = 1; 3455 + } 3428 3456 3429 3457 len = sprintf(buf, "TargetAddress=" 3430 3458 "%s:%hu,%hu", ··· 4096 4092 * hit default in the switch below. 4097 4093 */ 4098 4094 memset(buffer, 0xff, ISCSI_HDR_LEN); 4099 - spin_lock_bh(&conn->sess->session_stats_lock); 4100 - conn->sess->conn_digest_errors++; 4101 - spin_unlock_bh(&conn->sess->session_stats_lock); 4095 + atomic_long_inc(&conn->sess->conn_digest_errors); 4102 4096 } else { 4103 4097 pr_debug("Got HeaderDigest CRC32C" 4104 4098 " 0x%08x\n", checksum); ··· 4383 4381 4384 4382 int iscsit_close_session(struct iscsi_session *sess) 4385 4383 { 4386 - struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess); 4384 + struct iscsi_portal_group *tpg = sess->tpg; 4387 4385 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; 4388 4386 4389 4387 if (atomic_read(&sess->nconn)) {
+5 -2
drivers/target/iscsi/iscsi_target_auth.c
··· 111 111 /* 112 112 * Set Identifier. 113 113 */ 114 - chap->id = ISCSI_TPG_C(conn)->tpg_chap_id++; 114 + chap->id = conn->tpg->tpg_chap_id++; 115 115 *aic_len += sprintf(aic_str + *aic_len, "CHAP_I=%d", chap->id); 116 116 *aic_len += 1; 117 117 pr_debug("[server] Sending CHAP_I=%d\n", chap->id); ··· 146 146 unsigned char client_digest[MD5_SIGNATURE_SIZE]; 147 147 unsigned char server_digest[MD5_SIGNATURE_SIZE]; 148 148 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; 149 + size_t compare_len; 149 150 struct iscsi_chap *chap = conn->auth_protocol; 150 151 struct crypto_hash *tfm; 151 152 struct hash_desc desc; ··· 185 184 goto out; 186 185 } 187 186 188 - if (memcmp(chap_n, auth->userid, strlen(auth->userid)) != 0) { 187 + /* Include the terminating NULL in the compare */ 188 + compare_len = strlen(auth->userid) + 1; 189 + if (strncmp(chap_n, auth->userid, compare_len) != 0) { 189 190 pr_err("CHAP_N values do not match!\n"); 190 191 goto out; 191 192 }
+53 -33
drivers/target/iscsi/iscsi_target_configfs.c
··· 372 372 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ 373 373 se_node_acl); \ 374 374 \ 375 - return sprintf(page, "%u\n", ISCSI_NODE_ATTRIB(nacl)->name); \ 375 + return sprintf(page, "%u\n", nacl->node_attrib.name); \ 376 376 } \ 377 377 \ 378 378 static ssize_t iscsi_nacl_attrib_store_##name( \ ··· 897 897 if (!se_nacl_new) 898 898 return ERR_PTR(-ENOMEM); 899 899 900 - cmdsn_depth = ISCSI_TPG_ATTRIB(tpg)->default_cmdsn_depth; 900 + cmdsn_depth = tpg->tpg_attrib.default_cmdsn_depth; 901 901 /* 902 902 * se_nacl_new may be released by core_tpg_add_initiator_node_acl() 903 903 * when converting a NdoeACL from demo mode -> explict ··· 920 920 return ERR_PTR(-ENOMEM); 921 921 } 922 922 923 - stats_cg->default_groups[0] = &NODE_STAT_GRPS(acl)->iscsi_sess_stats_group; 923 + stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group; 924 924 stats_cg->default_groups[1] = NULL; 925 - config_group_init_type_name(&NODE_STAT_GRPS(acl)->iscsi_sess_stats_group, 925 + config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group, 926 926 "iscsi_sess_stats", &iscsi_stat_sess_cit); 927 927 928 928 return se_nacl; ··· 967 967 if (iscsit_get_tpg(tpg) < 0) \ 968 968 return -EINVAL; \ 969 969 \ 970 - rb = sprintf(page, "%u\n", ISCSI_TPG_ATTRIB(tpg)->name); \ 970 + rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \ 971 971 iscsit_put_tpg(tpg); \ 972 972 return rb; \ 973 973 } \ ··· 1041 1041 */ 1042 1042 DEF_TPG_ATTRIB(prod_mode_write_protect); 1043 1043 TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); 1044 + /* 1045 + * Define iscsi_tpg_attrib_s_demo_mode_discovery, 1046 + */ 1047 + DEF_TPG_ATTRIB(demo_mode_discovery); 1048 + TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR); 1049 + /* 1050 + * Define iscsi_tpg_attrib_s_default_erl 1051 + */ 1052 + DEF_TPG_ATTRIB(default_erl); 1053 + TPG_ATTR(default_erl, S_IRUGO | S_IWUSR); 1044 1054 1045 1055 static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { 1046 1056 &iscsi_tpg_attrib_authentication.attr, ··· 1061 1051 &iscsi_tpg_attrib_cache_dynamic_acls.attr, 1062 1052 &iscsi_tpg_attrib_demo_mode_write_protect.attr, 1063 1053 &iscsi_tpg_attrib_prod_mode_write_protect.attr, 1054 + &iscsi_tpg_attrib_demo_mode_discovery.attr, 1055 + &iscsi_tpg_attrib_default_erl.attr, 1064 1056 NULL, 1065 1057 }; 1066 1058 ··· 1526 1514 return ERR_PTR(-ENOMEM); 1527 1515 } 1528 1516 1529 - stats_cg->default_groups[0] = &WWN_STAT_GRPS(tiqn)->iscsi_instance_group; 1530 - stats_cg->default_groups[1] = &WWN_STAT_GRPS(tiqn)->iscsi_sess_err_group; 1531 - stats_cg->default_groups[2] = &WWN_STAT_GRPS(tiqn)->iscsi_tgt_attr_group; 1532 - stats_cg->default_groups[3] = &WWN_STAT_GRPS(tiqn)->iscsi_login_stats_group; 1533 - stats_cg->default_groups[4] = &WWN_STAT_GRPS(tiqn)->iscsi_logout_stats_group; 1517 + stats_cg->default_groups[0] = &tiqn->tiqn_stat_grps.iscsi_instance_group; 1518 + stats_cg->default_groups[1] = &tiqn->tiqn_stat_grps.iscsi_sess_err_group; 1519 + stats_cg->default_groups[2] = &tiqn->tiqn_stat_grps.iscsi_tgt_attr_group; 1520 + stats_cg->default_groups[3] = &tiqn->tiqn_stat_grps.iscsi_login_stats_group; 1521 + stats_cg->default_groups[4] = &tiqn->tiqn_stat_grps.iscsi_logout_stats_group; 1534 1522 stats_cg->default_groups[5] = NULL; 1535 - config_group_init_type_name(&WWN_STAT_GRPS(tiqn)->iscsi_instance_group, 1523 + config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group, 1536 1524 "iscsi_instance", &iscsi_stat_instance_cit); 1537 - config_group_init_type_name(&WWN_STAT_GRPS(tiqn)->iscsi_sess_err_group, 1525 + config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group, 1538 1526 "iscsi_sess_err", &iscsi_stat_sess_err_cit); 1539 - config_group_init_type_name(&WWN_STAT_GRPS(tiqn)->iscsi_tgt_attr_group, 1527 + config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group, 1540 1528 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit); 1541 - config_group_init_type_name(&WWN_STAT_GRPS(tiqn)->iscsi_login_stats_group, 1529 + config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group, 1542 1530 "iscsi_login_stats", &iscsi_stat_login_cit); 1543 - config_group_init_type_name(&WWN_STAT_GRPS(tiqn)->iscsi_logout_stats_group, 1531 + config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group, 1544 1532 "iscsi_logout_stats", &iscsi_stat_logout_cit); 1545 1533 1546 1534 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn); ··· 1796 1784 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); 1797 1785 1798 1786 cmd->i_state = ISTATE_SEND_STATUS; 1787 + 1788 + if (cmd->se_cmd.scsi_status || cmd->sense_reason) { 1789 + iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); 1790 + return 0; 1791 + } 1799 1792 cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd); 1800 1793 1801 1794 return 0; ··· 1832 1815 { 1833 1816 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; 1834 1817 1835 - return ISCSI_TPG_ATTRIB(tpg)->default_cmdsn_depth; 1818 + return tpg->tpg_attrib.default_cmdsn_depth; 1836 1819 } 1837 1820 1838 1821 static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg) 1839 1822 { 1840 1823 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; 1841 1824 1842 - return ISCSI_TPG_ATTRIB(tpg)->generate_node_acls; 1825 + return tpg->tpg_attrib.generate_node_acls; 1843 1826 } 1844 1827 1845 1828 static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg) 1846 1829 { 1847 1830 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; 1848 1831 1849 - return ISCSI_TPG_ATTRIB(tpg)->cache_dynamic_acls; 1832 + return tpg->tpg_attrib.cache_dynamic_acls; 1850 1833 } 1851 1834 1852 1835 static int lio_tpg_check_demo_mode_write_protect( ··· 1854 1837 { 1855 1838 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; 1856 1839 1857 - return ISCSI_TPG_ATTRIB(tpg)->demo_mode_write_protect; 1840 + return tpg->tpg_attrib.demo_mode_write_protect; 1858 1841 } 1859 1842 1860 1843 static int lio_tpg_check_prod_mode_write_protect( ··· 1862 1845 { 1863 1846 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; 1864 1847 1865 - return ISCSI_TPG_ATTRIB(tpg)->prod_mode_write_protect; 1848 + return tpg->tpg_attrib.prod_mode_write_protect; 1866 1849 } 1867 1850 1868 1851 static void lio_tpg_release_fabric_acl( ··· 1925 1908 { 1926 1909 struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl, 1927 1910 se_node_acl); 1911 + struct se_portal_group *se_tpg = se_acl->se_tpg; 1912 + struct iscsi_portal_group *tpg = container_of(se_tpg, 1913 + struct iscsi_portal_group, tpg_se_tpg); 1928 1914 1929 - ISCSI_NODE_ATTRIB(acl)->nacl = acl; 1930 - iscsit_set_default_node_attribues(acl); 1915 + acl->node_attrib.nacl = acl; 1916 + iscsit_set_default_node_attribues(acl, tpg); 1931 1917 } 1932 1918 1933 1919 static int lio_check_stop_free(struct se_cmd *se_cmd) ··· 2015 1995 * Setup default attribute lists for various fabric->tf_cit_tmpl 2016 1996 * sturct config_item_type's 2017 1997 */ 2018 - TF_CIT_TMPL(fabric)->tfc_discovery_cit.ct_attrs = lio_target_discovery_auth_attrs; 2019 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = lio_target_wwn_attrs; 2020 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = lio_target_tpg_attrs; 2021 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = lio_target_tpg_attrib_attrs; 2022 - TF_CIT_TMPL(fabric)->tfc_tpg_auth_cit.ct_attrs = lio_target_tpg_auth_attrs; 2023 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = lio_target_tpg_param_attrs; 2024 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = lio_target_portal_attrs; 2025 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = lio_target_initiator_attrs; 2026 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = lio_target_nacl_attrib_attrs; 2027 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = lio_target_nacl_auth_attrs; 2028 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = lio_target_nacl_param_attrs; 1998 + fabric->tf_cit_tmpl.tfc_discovery_cit.ct_attrs = lio_target_discovery_auth_attrs; 1999 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = lio_target_wwn_attrs; 2000 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = lio_target_tpg_attrs; 2001 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = lio_target_tpg_attrib_attrs; 2002 + fabric->tf_cit_tmpl.tfc_tpg_auth_cit.ct_attrs = lio_target_tpg_auth_attrs; 2003 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = lio_target_tpg_param_attrs; 2004 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = lio_target_portal_attrs; 2005 + fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = lio_target_initiator_attrs; 2006 + fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = lio_target_nacl_attrib_attrs; 2007 + fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = lio_target_nacl_auth_attrs; 2008 + fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = lio_target_nacl_param_attrs; 2029 2009 2030 2010 ret = target_fabric_configfs_register(fabric); 2031 2011 if (ret < 0) {
+11 -23
drivers/target/iscsi/iscsi_target_core.h
··· 37 37 #define NA_RANDOM_DATAIN_PDU_OFFSETS 0 38 38 #define NA_RANDOM_DATAIN_SEQ_OFFSETS 0 39 39 #define NA_RANDOM_R2T_OFFSETS 0 40 - #define NA_DEFAULT_ERL 0 41 - #define NA_DEFAULT_ERL_MAX 2 42 - #define NA_DEFAULT_ERL_MIN 0 43 40 44 41 /* struct iscsi_tpg_attrib sanity values */ 45 42 #define TA_AUTHENTICATION 1 ··· 55 58 #define TA_DEMO_MODE_WRITE_PROTECT 1 56 59 /* Disabled by default in production mode w/ explict ACLs */ 57 60 #define TA_PROD_MODE_WRITE_PROTECT 0 61 + #define TA_DEMO_MODE_DISCOVERY 1 62 + #define TA_DEFAULT_ERL 0 58 63 #define TA_CACHE_CORE_NPS 0 59 64 60 65 ··· 191 192 CMDSN_NORMAL_OPERATION = 0, 192 193 CMDSN_LOWER_THAN_EXP = 1, 193 194 CMDSN_HIGHER_THAN_EXP = 2, 195 + CMDSN_MAXCMDSN_OVERRUN = 3, 194 196 }; 195 197 196 198 /* Used for iscsi_handle_immediate_data() return values */ ··· 650 650 /* Used for session reference counting */ 651 651 int session_usage_count; 652 652 int session_waiting_on_uc; 653 - u32 cmd_pdus; 654 - u32 rsp_pdus; 655 - u64 tx_data_octets; 656 - u64 rx_data_octets; 657 - u32 conn_digest_errors; 658 - u32 conn_timeout_errors; 653 + atomic_long_t cmd_pdus; 654 + atomic_long_t rsp_pdus; 655 + atomic_long_t tx_data_octets; 656 + atomic_long_t rx_data_octets; 657 + atomic_long_t conn_digest_errors; 658 + atomic_long_t conn_timeout_errors; 659 659 u64 creation_time; 660 - spinlock_t session_stats_lock; 661 660 /* Number of active connections */ 662 661 atomic_t nconn; 663 662 atomic_t session_continuation; ··· 754 755 struct se_node_acl se_node_acl; 755 756 }; 756 757 757 - #define NODE_STAT_GRPS(nacl) (&(nacl)->node_stat_grps) 758 - 759 - #define ISCSI_NODE_ATTRIB(t) (&(t)->node_attrib) 760 - #define ISCSI_NODE_AUTH(t) (&(t)->node_auth) 761 - 762 758 struct iscsi_tpg_attrib { 763 759 u32 authentication; 764 760 u32 login_timeout; ··· 763 769 u32 default_cmdsn_depth; 764 770 u32 demo_mode_write_protect; 765 771 u32 prod_mode_write_protect; 772 + u32 demo_mode_discovery; 773 + u32 default_erl; 766 774 struct iscsi_portal_group *tpg; 767 775 }; 768 776 ··· 831 835 struct list_head tpg_list; 832 836 } ____cacheline_aligned; 833 837 834 - #define ISCSI_TPG_C(c) ((struct iscsi_portal_group *)(c)->tpg) 835 - #define ISCSI_TPG_LUN(c, l) ((iscsi_tpg_list_t *)(c)->tpg->tpg_lun_list_t[l]) 836 - #define ISCSI_TPG_S(s) ((struct iscsi_portal_group *)(s)->tpg) 837 - #define ISCSI_TPG_ATTRIB(t) (&(t)->tpg_attrib) 838 - #define SE_TPG(tpg) (&(tpg)->tpg_se_tpg) 839 - 840 838 struct iscsi_wwn_stat_grps { 841 839 struct config_group iscsi_stat_group; 842 840 struct config_group iscsi_instance_group; ··· 860 870 struct iscsi_login_stats login_stats; 861 871 struct iscsi_logout_stats logout_stats; 862 872 } ____cacheline_aligned; 863 - 864 - #define WWN_STAT_GRPS(tiqn) (&(tiqn)->tiqn_stat_grps) 865 873 866 874 struct iscsit_global { 867 875 /* In core shutdown */
+1 -5
drivers/target/iscsi/iscsi_target_device.c
··· 58 58 59 59 cmd->maxcmdsn_inc = 1; 60 60 61 - if (!mutex_trylock(&sess->cmdsn_mutex)) { 62 - sess->max_cmd_sn += 1; 63 - pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn); 64 - return; 65 - } 61 + mutex_lock(&sess->cmdsn_mutex); 66 62 sess->max_cmd_sn += 1; 67 63 pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn); 68 64 mutex_unlock(&sess->cmdsn_mutex);
+6 -6
drivers/target/iscsi/iscsi_target_erl0.c
··· 757 757 static void iscsit_handle_time2retain_timeout(unsigned long data) 758 758 { 759 759 struct iscsi_session *sess = (struct iscsi_session *) data; 760 - struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess); 760 + struct iscsi_portal_group *tpg = sess->tpg; 761 761 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; 762 762 763 763 spin_lock_bh(&se_tpg->session_lock); ··· 785 785 tiqn->sess_err_stats.last_sess_failure_type = 786 786 ISCSI_SESS_ERR_CXN_TIMEOUT; 787 787 tiqn->sess_err_stats.cxn_timeout_errors++; 788 - sess->conn_timeout_errors++; 788 + atomic_long_inc(&sess->conn_timeout_errors); 789 789 spin_unlock(&tiqn->sess_err_stats.lock); 790 790 } 791 791 } ··· 801 801 * Only start Time2Retain timer when the associated TPG is still in 802 802 * an ACTIVE (eg: not disabled or shutdown) state. 803 803 */ 804 - spin_lock(&ISCSI_TPG_S(sess)->tpg_state_lock); 805 - tpg_active = (ISCSI_TPG_S(sess)->tpg_state == TPG_STATE_ACTIVE); 806 - spin_unlock(&ISCSI_TPG_S(sess)->tpg_state_lock); 804 + spin_lock(&sess->tpg->tpg_state_lock); 805 + tpg_active = (sess->tpg->tpg_state == TPG_STATE_ACTIVE); 806 + spin_unlock(&sess->tpg->tpg_state_lock); 807 807 808 808 if (!tpg_active) 809 809 return; ··· 829 829 */ 830 830 int iscsit_stop_time2retain_timer(struct iscsi_session *sess) 831 831 { 832 - struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess); 832 + struct iscsi_portal_group *tpg = sess->tpg; 833 833 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; 834 834 835 835 if (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)
+8 -9
drivers/target/iscsi/iscsi_target_login.c
··· 305 305 } 306 306 307 307 sess->creation_time = get_jiffies_64(); 308 - spin_lock_init(&sess->session_stats_lock); 309 308 /* 310 309 * The FFP CmdSN window values will be allocated from the TPG's 311 310 * Initiator Node's ACL once the login has been successfully completed. ··· 346 347 * Assign a new TPG Session Handle. Note this is protected with 347 348 * struct iscsi_portal_group->np_login_sem from iscsit_access_np(). 348 349 */ 349 - sess->tsih = ++ISCSI_TPG_S(sess)->ntsih; 350 + sess->tsih = ++sess->tpg->ntsih; 350 351 if (!sess->tsih) 351 - sess->tsih = ++ISCSI_TPG_S(sess)->ntsih; 352 + sess->tsih = ++sess->tpg->ntsih; 352 353 353 354 /* 354 355 * Create the default params from user defined values.. 355 356 */ 356 357 if (iscsi_copy_param_list(&conn->param_list, 357 - ISCSI_TPG_C(conn)->param_list, 1) < 0) { 358 + conn->tpg->param_list, 1) < 0) { 358 359 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 359 360 ISCSI_LOGIN_STATUS_NO_RESOURCES); 360 361 return -1; ··· 379 380 * In our case, we have already located the struct iscsi_tiqn at this point. 380 381 */ 381 382 memset(buf, 0, 32); 382 - sprintf(buf, "TargetPortalGroupTag=%hu", ISCSI_TPG_S(sess)->tpgt); 383 + sprintf(buf, "TargetPortalGroupTag=%hu", sess->tpg->tpgt); 383 384 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 384 385 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 385 386 ISCSI_LOGIN_STATUS_NO_RESOURCES); ··· 574 575 iscsi_login_set_conn_values(sess, conn, pdu->cid); 575 576 576 577 if (iscsi_copy_param_list(&conn->param_list, 577 - ISCSI_TPG_C(conn)->param_list, 0) < 0) { 578 + conn->tpg->param_list, 0) < 0) { 578 579 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 579 580 ISCSI_LOGIN_STATUS_NO_RESOURCES); 580 581 return -1; ··· 592 593 * In our case, we have already located the struct iscsi_tiqn at this point. 593 594 */ 594 595 memset(buf, 0, 32); 595 - sprintf(buf, "TargetPortalGroupTag=%hu", ISCSI_TPG_S(sess)->tpgt); 596 + sprintf(buf, "TargetPortalGroupTag=%hu", sess->tpg->tpgt); 596 597 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 597 598 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 598 599 ISCSI_LOGIN_STATUS_NO_RESOURCES); ··· 690 691 int stop_timer = 0; 691 692 struct iscsi_session *sess = conn->sess; 692 693 struct se_session *se_sess = sess->se_sess; 693 - struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess); 694 + struct iscsi_portal_group *tpg = sess->tpg; 694 695 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; 695 696 struct iscsi_thread_set *ts; 696 697 ··· 1153 1154 spin_lock_bh(&conn->sess->conn_lock); 1154 1155 if (conn->sess->session_state == TARG_SESS_STATE_FAILED) { 1155 1156 struct se_portal_group *se_tpg = 1156 - &ISCSI_TPG_C(conn)->tpg_se_tpg; 1157 + &conn->tpg->tpg_se_tpg; 1157 1158 1158 1159 atomic_set(&conn->sess->session_continuation, 0); 1159 1160 spin_unlock_bh(&conn->sess->conn_lock);
+5 -5
drivers/target/iscsi/iscsi_target_nego.c
··· 88 88 if (len < 0) 89 89 return -1; 90 90 91 - if (len > max_length) { 91 + if (len >= max_length) { 92 92 pr_err("Length of input: %d exceeds max_length:" 93 93 " %d\n", len, max_length); 94 94 return -1; ··· 140 140 iscsi_nacl = container_of(se_nacl, struct iscsi_node_acl, 141 141 se_node_acl); 142 142 143 - auth = ISCSI_NODE_AUTH(iscsi_nacl); 143 + auth = &iscsi_nacl->node_auth; 144 144 } 145 145 } else { 146 146 /* ··· 789 789 return -1; 790 790 791 791 if (!iscsi_check_negotiated_keys(conn->param_list)) { 792 - if (ISCSI_TPG_ATTRIB(ISCSI_TPG_C(conn))->authentication && 792 + if (conn->tpg->tpg_attrib.authentication && 793 793 !strncmp(param->value, NONE, 4)) { 794 794 pr_err("Initiator sent AuthMethod=None but" 795 795 " Target is enforcing iSCSI Authentication," ··· 799 799 return -1; 800 800 } 801 801 802 - if (ISCSI_TPG_ATTRIB(ISCSI_TPG_C(conn))->authentication && 802 + if (conn->tpg->tpg_attrib.authentication && 803 803 !login->auth_complete) 804 804 return 0; 805 805 ··· 862 862 } 863 863 864 864 if (!login->auth_complete && 865 - ISCSI_TPG_ATTRIB(ISCSI_TPG_C(conn))->authentication) { 865 + conn->tpg->tpg_attrib.authentication) { 866 866 pr_err("Initiator is requesting CSG: 1, has not been" 867 867 " successfully authenticated, and the Target is" 868 868 " enforcing iSCSI Authentication, login failed.\n");
+3 -2
drivers/target/iscsi/iscsi_target_nodeattrib.c
··· 33 33 } 34 34 35 35 void iscsit_set_default_node_attribues( 36 - struct iscsi_node_acl *acl) 36 + struct iscsi_node_acl *acl, 37 + struct iscsi_portal_group *tpg) 37 38 { 38 39 struct iscsi_node_attrib *a = &acl->node_attrib; 39 40 ··· 45 44 a->random_datain_pdu_offsets = NA_RANDOM_DATAIN_PDU_OFFSETS; 46 45 a->random_datain_seq_offsets = NA_RANDOM_DATAIN_SEQ_OFFSETS; 47 46 a->random_r2t_offsets = NA_RANDOM_R2T_OFFSETS; 48 - a->default_erl = NA_DEFAULT_ERL; 47 + a->default_erl = tpg->tpg_attrib.default_erl; 49 48 } 50 49 51 50 int iscsit_na_dataout_timeout(
+2 -1
drivers/target/iscsi/iscsi_target_nodeattrib.h
··· 1 1 #ifndef ISCSI_TARGET_NODEATTRIB_H 2 2 #define ISCSI_TARGET_NODEATTRIB_H 3 3 4 - extern void iscsit_set_default_node_attribues(struct iscsi_node_acl *); 4 + extern void iscsit_set_default_node_attribues(struct iscsi_node_acl *, 5 + struct iscsi_portal_group *); 5 6 extern int iscsit_na_dataout_timeout(struct iscsi_node_acl *, u32); 6 7 extern int iscsit_na_dataout_timeout_retries(struct iscsi_node_acl *, u32); 7 8 extern int iscsit_na_nopin_timeout(struct iscsi_node_acl *, u32);
+12 -10
drivers/target/iscsi/iscsi_target_stat.c
··· 792 792 if (se_sess) { 793 793 sess = se_sess->fabric_sess_ptr; 794 794 if (sess) 795 - ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus); 795 + ret = snprintf(page, PAGE_SIZE, "%lu\n", 796 + atomic_long_read(&sess->cmd_pdus)); 796 797 } 797 798 spin_unlock_bh(&se_nacl->nacl_sess_lock); 798 799 ··· 816 815 if (se_sess) { 817 816 sess = se_sess->fabric_sess_ptr; 818 817 if (sess) 819 - ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus); 818 + ret = snprintf(page, PAGE_SIZE, "%lu\n", 819 + atomic_long_read(&sess->rsp_pdus)); 820 820 } 821 821 spin_unlock_bh(&se_nacl->nacl_sess_lock); 822 822 ··· 840 838 if (se_sess) { 841 839 sess = se_sess->fabric_sess_ptr; 842 840 if (sess) 843 - ret = snprintf(page, PAGE_SIZE, "%llu\n", 844 - (unsigned long long)sess->tx_data_octets); 841 + ret = snprintf(page, PAGE_SIZE, "%lu\n", 842 + atomic_long_read(&sess->tx_data_octets)); 845 843 } 846 844 spin_unlock_bh(&se_nacl->nacl_sess_lock); 847 845 ··· 864 862 if (se_sess) { 865 863 sess = se_sess->fabric_sess_ptr; 866 864 if (sess) 867 - ret = snprintf(page, PAGE_SIZE, "%llu\n", 868 - (unsigned long long)sess->rx_data_octets); 865 + ret = snprintf(page, PAGE_SIZE, "%lu\n", 866 + atomic_long_read(&sess->rx_data_octets)); 869 867 } 870 868 spin_unlock_bh(&se_nacl->nacl_sess_lock); 871 869 ··· 888 886 if (se_sess) { 889 887 sess = se_sess->fabric_sess_ptr; 890 888 if (sess) 891 - ret = snprintf(page, PAGE_SIZE, "%u\n", 892 - sess->conn_digest_errors); 889 + ret = snprintf(page, PAGE_SIZE, "%lu\n", 890 + atomic_long_read(&sess->conn_digest_errors)); 893 891 } 894 892 spin_unlock_bh(&se_nacl->nacl_sess_lock); 895 893 ··· 912 910 if (se_sess) { 913 911 sess = se_sess->fabric_sess_ptr; 914 912 if (sess) 915 - ret = snprintf(page, PAGE_SIZE, "%u\n", 916 - sess->conn_timeout_errors); 913 + ret = snprintf(page, PAGE_SIZE, "%lu\n", 914 + atomic_long_read(&sess->conn_timeout_errors)); 917 915 } 918 916 spin_unlock_bh(&se_nacl->nacl_sess_lock); 919 917
+40 -2
drivers/target/iscsi/iscsi_target_tpg.c
··· 223 223 a->cache_dynamic_acls = TA_CACHE_DYNAMIC_ACLS; 224 224 a->demo_mode_write_protect = TA_DEMO_MODE_WRITE_PROTECT; 225 225 a->prod_mode_write_protect = TA_PROD_MODE_WRITE_PROTECT; 226 + a->demo_mode_discovery = TA_DEMO_MODE_DISCOVERY; 227 + a->default_erl = TA_DEFAULT_ERL; 226 228 } 227 229 228 230 int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg) ··· 239 237 if (iscsi_create_default_params(&tpg->param_list) < 0) 240 238 goto err_out; 241 239 242 - ISCSI_TPG_ATTRIB(tpg)->tpg = tpg; 240 + tpg->tpg_attrib.tpg = tpg; 243 241 244 242 spin_lock(&tpg->tpg_state_lock); 245 243 tpg->tpg_state = TPG_STATE_INACTIVE; ··· 332 330 return -EINVAL; 333 331 } 334 332 335 - if (ISCSI_TPG_ATTRIB(tpg)->authentication) { 333 + if (tpg->tpg_attrib.authentication) { 336 334 if (!strcmp(param->value, NONE)) { 337 335 ret = iscsi_update_param_value(param, CHAP); 338 336 if (ret) ··· 819 817 pr_debug("iSCSI_TPG[%hu] - Production Mode Write Protect bit:" 820 818 " %s\n", tpg->tpgt, (a->prod_mode_write_protect) ? 821 819 "ON" : "OFF"); 820 + 821 + return 0; 822 + } 823 + 824 + int iscsit_ta_demo_mode_discovery( 825 + struct iscsi_portal_group *tpg, 826 + u32 flag) 827 + { 828 + struct iscsi_tpg_attrib *a = &tpg->tpg_attrib; 829 + 830 + if ((flag != 0) && (flag != 1)) { 831 + pr_err("Illegal value %d\n", flag); 832 + return -EINVAL; 833 + } 834 + 835 + a->demo_mode_discovery = flag; 836 + pr_debug("iSCSI_TPG[%hu] - Demo Mode Discovery bit:" 837 + " %s\n", tpg->tpgt, (a->demo_mode_discovery) ? 838 + "ON" : "OFF"); 839 + 840 + return 0; 841 + } 842 + 843 + int iscsit_ta_default_erl( 844 + struct iscsi_portal_group *tpg, 845 + u32 default_erl) 846 + { 847 + struct iscsi_tpg_attrib *a = &tpg->tpg_attrib; 848 + 849 + if ((default_erl != 0) && (default_erl != 1) && (default_erl != 2)) { 850 + pr_err("Illegal value for default_erl: %u\n", default_erl); 851 + return -EINVAL; 852 + } 853 + 854 + a->default_erl = default_erl; 855 + pr_debug("iSCSI_TPG[%hu] - DefaultERL: %u\n", tpg->tpgt, a->default_erl); 822 856 823 857 return 0; 824 858 }
+2
drivers/target/iscsi/iscsi_target_tpg.h
··· 37 37 extern int iscsit_ta_cache_dynamic_acls(struct iscsi_portal_group *, u32); 38 38 extern int iscsit_ta_demo_mode_write_protect(struct iscsi_portal_group *, u32); 39 39 extern int iscsit_ta_prod_mode_write_protect(struct iscsi_portal_group *, u32); 40 + extern int iscsit_ta_demo_mode_discovery(struct iscsi_portal_group *, u32); 41 + extern int iscsit_ta_default_erl(struct iscsi_portal_group *, u32); 40 42 41 43 #endif /* ISCSI_TARGET_TPG_H */
+11 -9
drivers/target/iscsi/iscsi_target_util.c
··· 242 242 */ 243 243 if (iscsi_sna_gt(cmdsn, sess->max_cmd_sn)) { 244 244 pr_err("Received CmdSN: 0x%08x is greater than" 245 - " MaxCmdSN: 0x%08x, protocol error.\n", cmdsn, 245 + " MaxCmdSN: 0x%08x, ignoring.\n", cmdsn, 246 246 sess->max_cmd_sn); 247 - ret = CMDSN_ERROR_CANNOT_RECOVER; 247 + ret = CMDSN_MAXCMDSN_OVERRUN; 248 248 249 249 } else if (cmdsn == sess->exp_cmd_sn) { 250 250 sess->exp_cmd_sn++; ··· 303 303 ret = CMDSN_HIGHER_THAN_EXP; 304 304 break; 305 305 case CMDSN_LOWER_THAN_EXP: 306 + case CMDSN_MAXCMDSN_OVERRUN: 307 + default: 306 308 cmd->i_state = ISTATE_REMOVE; 307 309 iscsit_add_cmd_to_immediate_queue(cmd, conn, cmd->i_state); 308 - ret = cmdsn_ret; 309 - break; 310 - default: 311 - reason = ISCSI_REASON_PROTOCOL_ERROR; 312 - reject = true; 313 - ret = cmdsn_ret; 310 + /* 311 + * Existing callers for iscsit_sequence_cmd() will silently 312 + * ignore commands with CMDSN_LOWER_THAN_EXP, so force this 313 + * return for CMDSN_MAXCMDSN_OVERRUN as well.. 314 + */ 315 + ret = CMDSN_LOWER_THAN_EXP; 314 316 break; 315 317 } 316 318 mutex_unlock(&conn->sess->cmdsn_mutex); ··· 982 980 tiqn->sess_err_stats.last_sess_failure_type = 983 981 ISCSI_SESS_ERR_CXN_TIMEOUT; 984 982 tiqn->sess_err_stats.cxn_timeout_errors++; 985 - conn->sess->conn_timeout_errors++; 983 + atomic_long_inc(&conn->sess->conn_timeout_errors); 986 984 spin_unlock_bh(&tiqn->sess_err_stats.lock); 987 985 } 988 986 }
+217 -57
drivers/target/loopback/tcm_loop.c
··· 135 135 return sdev->queue_depth; 136 136 } 137 137 138 + static int tcm_loop_change_queue_type(struct scsi_device *sdev, int tag) 139 + { 140 + if (sdev->tagged_supported) { 141 + scsi_set_tag_type(sdev, tag); 142 + 143 + if (tag) 144 + scsi_activate_tcq(sdev, sdev->queue_depth); 145 + else 146 + scsi_deactivate_tcq(sdev, sdev->queue_depth); 147 + } else 148 + tag = 0; 149 + 150 + return tag; 151 + } 152 + 138 153 /* 139 154 * Locate the SAM Task Attr from struct scsi_cmnd * 140 155 */ ··· 193 178 set_host_byte(sc, DID_NO_CONNECT); 194 179 goto out_done; 195 180 } 196 - 181 + if (tl_tpg->tl_transport_status == TCM_TRANSPORT_OFFLINE) { 182 + set_host_byte(sc, DID_TRANSPORT_DISRUPTED); 183 + goto out_done; 184 + } 197 185 tl_nexus = tl_hba->tl_nexus; 198 186 if (!tl_nexus) { 199 187 scmd_printk(KERN_ERR, sc, "TCM_Loop I_T Nexus" ··· 251 233 } 252 234 253 235 tl_cmd->sc = sc; 236 + tl_cmd->sc_cmd_tag = sc->tag; 254 237 INIT_WORK(&tl_cmd->work, tcm_loop_submission_work); 255 238 queue_work(tcm_loop_workqueue, &tl_cmd->work); 256 239 return 0; ··· 261 242 * Called from SCSI EH process context to issue a LUN_RESET TMR 262 243 * to struct scsi_device 263 244 */ 264 - static int tcm_loop_device_reset(struct scsi_cmnd *sc) 245 + static int tcm_loop_issue_tmr(struct tcm_loop_tpg *tl_tpg, 246 + struct tcm_loop_nexus *tl_nexus, 247 + int lun, int task, enum tcm_tmreq_table tmr) 265 248 { 266 249 struct se_cmd *se_cmd = NULL; 267 - struct se_portal_group *se_tpg; 268 250 struct se_session *se_sess; 251 + struct se_portal_group *se_tpg; 269 252 struct tcm_loop_cmd *tl_cmd = NULL; 253 + struct tcm_loop_tmr *tl_tmr = NULL; 254 + int ret = TMR_FUNCTION_FAILED, rc; 255 + 256 + tl_cmd = kmem_cache_zalloc(tcm_loop_cmd_cache, GFP_KERNEL); 257 + if (!tl_cmd) { 258 + pr_err("Unable to allocate memory for tl_cmd\n"); 259 + return ret; 260 + } 261 + 262 + tl_tmr = kzalloc(sizeof(struct tcm_loop_tmr), GFP_KERNEL); 263 + if (!tl_tmr) { 264 + pr_err("Unable to allocate memory for tl_tmr\n"); 265 + goto release; 266 + } 267 + init_waitqueue_head(&tl_tmr->tl_tmr_wait); 268 + 269 + se_cmd = &tl_cmd->tl_se_cmd; 270 + se_tpg = &tl_tpg->tl_se_tpg; 271 + se_sess = tl_nexus->se_sess; 272 + /* 273 + * Initialize struct se_cmd descriptor from target_core_mod infrastructure 274 + */ 275 + transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, 276 + DMA_NONE, MSG_SIMPLE_TAG, 277 + &tl_cmd->tl_sense_buf[0]); 278 + 279 + rc = core_tmr_alloc_req(se_cmd, tl_tmr, tmr, GFP_KERNEL); 280 + if (rc < 0) 281 + goto release; 282 + 283 + if (tmr == TMR_ABORT_TASK) 284 + se_cmd->se_tmr_req->ref_task_tag = task; 285 + 286 + /* 287 + * Locate the underlying TCM struct se_lun 288 + */ 289 + if (transport_lookup_tmr_lun(se_cmd, lun) < 0) { 290 + ret = TMR_LUN_DOES_NOT_EXIST; 291 + goto release; 292 + } 293 + /* 294 + * Queue the TMR to TCM Core and sleep waiting for 295 + * tcm_loop_queue_tm_rsp() to wake us up. 296 + */ 297 + transport_generic_handle_tmr(se_cmd); 298 + wait_event(tl_tmr->tl_tmr_wait, atomic_read(&tl_tmr->tmr_complete)); 299 + /* 300 + * The TMR LUN_RESET has completed, check the response status and 301 + * then release allocations. 302 + */ 303 + ret = se_cmd->se_tmr_req->response; 304 + release: 305 + if (se_cmd) 306 + transport_generic_free_cmd(se_cmd, 1); 307 + else 308 + kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); 309 + kfree(tl_tmr); 310 + return ret; 311 + } 312 + 313 + static int tcm_loop_abort_task(struct scsi_cmnd *sc) 314 + { 270 315 struct tcm_loop_hba *tl_hba; 271 316 struct tcm_loop_nexus *tl_nexus; 272 - struct tcm_loop_tmr *tl_tmr = NULL; 273 317 struct tcm_loop_tpg *tl_tpg; 274 - int ret = FAILED, rc; 318 + int ret = FAILED; 319 + 275 320 /* 276 321 * Locate the tcm_loop_hba_t pointer 277 322 */ ··· 349 266 " active I_T Nexus\n"); 350 267 return FAILED; 351 268 } 352 - se_sess = tl_nexus->se_sess; 269 + 353 270 /* 354 - * Locate the tl_tpg and se_tpg pointers from TargetID in sc->device->id 271 + * Locate the tl_tpg pointer from TargetID in sc->device->id 355 272 */ 356 273 tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; 357 - se_tpg = &tl_tpg->tl_se_tpg; 274 + ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun, 275 + sc->tag, TMR_ABORT_TASK); 276 + return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED; 277 + } 358 278 359 - tl_cmd = kmem_cache_zalloc(tcm_loop_cmd_cache, GFP_KERNEL); 360 - if (!tl_cmd) { 361 - pr_err("Unable to allocate memory for tl_cmd\n"); 279 + /* 280 + * Called from SCSI EH process context to issue a LUN_RESET TMR 281 + * to struct scsi_device 282 + */ 283 + static int tcm_loop_device_reset(struct scsi_cmnd *sc) 284 + { 285 + struct tcm_loop_hba *tl_hba; 286 + struct tcm_loop_nexus *tl_nexus; 287 + struct tcm_loop_tpg *tl_tpg; 288 + int ret = FAILED; 289 + 290 + /* 291 + * Locate the tcm_loop_hba_t pointer 292 + */ 293 + tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); 294 + /* 295 + * Locate the tl_nexus and se_sess pointers 296 + */ 297 + tl_nexus = tl_hba->tl_nexus; 298 + if (!tl_nexus) { 299 + pr_err("Unable to perform device reset without" 300 + " active I_T Nexus\n"); 362 301 return FAILED; 363 302 } 303 + /* 304 + * Locate the tl_tpg pointer from TargetID in sc->device->id 305 + */ 306 + tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; 307 + ret = tcm_loop_issue_tmr(tl_tpg, tl_nexus, sc->device->lun, 308 + 0, TMR_LUN_RESET); 309 + return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED; 310 + } 364 311 365 - tl_tmr = kzalloc(sizeof(struct tcm_loop_tmr), GFP_KERNEL); 366 - if (!tl_tmr) { 367 - pr_err("Unable to allocate memory for tl_tmr\n"); 368 - goto release; 312 + static int tcm_loop_target_reset(struct scsi_cmnd *sc) 313 + { 314 + struct tcm_loop_hba *tl_hba; 315 + struct tcm_loop_tpg *tl_tpg; 316 + 317 + /* 318 + * Locate the tcm_loop_hba_t pointer 319 + */ 320 + tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); 321 + if (!tl_hba) { 322 + pr_err("Unable to perform device reset without" 323 + " active I_T Nexus\n"); 324 + return FAILED; 369 325 } 370 - init_waitqueue_head(&tl_tmr->tl_tmr_wait); 371 - 372 - se_cmd = &tl_cmd->tl_se_cmd; 373 326 /* 374 - * Initialize struct se_cmd descriptor from target_core_mod infrastructure 327 + * Locate the tl_tpg pointer from TargetID in sc->device->id 375 328 */ 376 - transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, 0, 377 - DMA_NONE, MSG_SIMPLE_TAG, 378 - &tl_cmd->tl_sense_buf[0]); 379 - 380 - rc = core_tmr_alloc_req(se_cmd, tl_tmr, TMR_LUN_RESET, GFP_KERNEL); 381 - if (rc < 0) 382 - goto release; 383 - /* 384 - * Locate the underlying TCM struct se_lun from sc->device->lun 385 - */ 386 - if (transport_lookup_tmr_lun(se_cmd, sc->device->lun) < 0) 387 - goto release; 388 - /* 389 - * Queue the TMR to TCM Core and sleep waiting for tcm_loop_queue_tm_rsp() 390 - * to wake us up. 391 - */ 392 - transport_generic_handle_tmr(se_cmd); 393 - wait_event(tl_tmr->tl_tmr_wait, atomic_read(&tl_tmr->tmr_complete)); 394 - /* 395 - * The TMR LUN_RESET has completed, check the response status and 396 - * then release allocations. 397 - */ 398 - ret = (se_cmd->se_tmr_req->response == TMR_FUNCTION_COMPLETE) ? 399 - SUCCESS : FAILED; 400 - release: 401 - if (se_cmd) 402 - transport_generic_free_cmd(se_cmd, 1); 403 - else 404 - kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); 405 - kfree(tl_tmr); 406 - return ret; 329 + tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; 330 + if (tl_tpg) { 331 + tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE; 332 + return SUCCESS; 333 + } 334 + return FAILED; 407 335 } 408 336 409 337 static int tcm_loop_slave_alloc(struct scsi_device *sd) ··· 425 331 426 332 static int tcm_loop_slave_configure(struct scsi_device *sd) 427 333 { 334 + if (sd->tagged_supported) { 335 + scsi_activate_tcq(sd, sd->queue_depth); 336 + scsi_adjust_queue_depth(sd, MSG_SIMPLE_TAG, 337 + sd->host->cmd_per_lun); 338 + } else { 339 + scsi_adjust_queue_depth(sd, 0, 340 + sd->host->cmd_per_lun); 341 + } 342 + 428 343 return 0; 429 344 } 430 345 ··· 443 340 .name = "TCM_Loopback", 444 341 .queuecommand = tcm_loop_queuecommand, 445 342 .change_queue_depth = tcm_loop_change_queue_depth, 343 + .change_queue_type = tcm_loop_change_queue_type, 344 + .eh_abort_handler = tcm_loop_abort_task, 446 345 .eh_device_reset_handler = tcm_loop_device_reset, 346 + .eh_target_reset_handler = tcm_loop_target_reset, 447 347 .can_queue = 1024, 448 348 .this_id = -1, 449 349 .sg_tablesize = 256, ··· 805 699 806 700 static u32 tcm_loop_get_task_tag(struct se_cmd *se_cmd) 807 701 { 808 - return 1; 702 + struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, 703 + struct tcm_loop_cmd, tl_se_cmd); 704 + 705 + return tl_cmd->sc_cmd_tag; 809 706 } 810 707 811 708 static int tcm_loop_get_cmd_state(struct se_cmd *se_cmd) ··· 1041 932 struct tcm_loop_nexus *tl_nexus; 1042 933 struct tcm_loop_hba *tl_hba = tpg->tl_hba; 1043 934 1044 - tl_nexus = tpg->tl_hba->tl_nexus; 935 + if (!tl_hba) 936 + return -ENODEV; 937 + 938 + tl_nexus = tl_hba->tl_nexus; 1045 939 if (!tl_nexus) 1046 940 return -ENODEV; 1047 941 ··· 1173 1061 1174 1062 TF_TPG_BASE_ATTR(tcm_loop, nexus, S_IRUGO | S_IWUSR); 1175 1063 1064 + static ssize_t tcm_loop_tpg_show_transport_status( 1065 + struct se_portal_group *se_tpg, 1066 + char *page) 1067 + { 1068 + struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, 1069 + struct tcm_loop_tpg, tl_se_tpg); 1070 + const char *status = NULL; 1071 + ssize_t ret = -EINVAL; 1072 + 1073 + switch (tl_tpg->tl_transport_status) { 1074 + case TCM_TRANSPORT_ONLINE: 1075 + status = "online"; 1076 + break; 1077 + case TCM_TRANSPORT_OFFLINE: 1078 + status = "offline"; 1079 + break; 1080 + default: 1081 + break; 1082 + } 1083 + 1084 + if (status) 1085 + ret = snprintf(page, PAGE_SIZE, "%s\n", status); 1086 + 1087 + return ret; 1088 + } 1089 + 1090 + static ssize_t tcm_loop_tpg_store_transport_status( 1091 + struct se_portal_group *se_tpg, 1092 + const char *page, 1093 + size_t count) 1094 + { 1095 + struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, 1096 + struct tcm_loop_tpg, tl_se_tpg); 1097 + 1098 + if (!strncmp(page, "online", 6)) { 1099 + tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE; 1100 + return count; 1101 + } 1102 + if (!strncmp(page, "offline", 7)) { 1103 + tl_tpg->tl_transport_status = TCM_TRANSPORT_OFFLINE; 1104 + return count; 1105 + } 1106 + return -EINVAL; 1107 + } 1108 + 1109 + TF_TPG_BASE_ATTR(tcm_loop, transport_status, S_IRUGO | S_IWUSR); 1110 + 1176 1111 static struct configfs_attribute *tcm_loop_tpg_attrs[] = { 1177 1112 &tcm_loop_tpg_nexus.attr, 1113 + &tcm_loop_tpg_transport_status.attr, 1178 1114 NULL, 1179 1115 }; 1180 1116 ··· 1494 1334 /* 1495 1335 * Setup default attribute lists for various fabric->tf_cit_tmpl 1496 1336 */ 1497 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = tcm_loop_wwn_attrs; 1498 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = tcm_loop_tpg_attrs; 1499 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; 1500 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 1501 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 1337 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_loop_wwn_attrs; 1338 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_loop_tpg_attrs; 1339 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 1340 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 1341 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 1502 1342 /* 1503 1343 * Once fabric->tf_ops has been setup, now register the fabric for 1504 1344 * use within TCM
+6
drivers/target/loopback/tcm_loop.h
··· 10 10 struct tcm_loop_cmd { 11 11 /* State of Linux/SCSI CDB+Data descriptor */ 12 12 u32 sc_cmd_state; 13 + /* Tagged command queueing */ 14 + u32 sc_cmd_tag; 13 15 /* Pointer to the CDB+Data descriptor from Linux/SCSI subsystem */ 14 16 struct scsi_cmnd *sc; 15 17 /* The TCM I/O descriptor that is accessed via container_of() */ ··· 42 40 struct se_node_acl se_node_acl; 43 41 }; 44 42 43 + #define TCM_TRANSPORT_ONLINE 0 44 + #define TCM_TRANSPORT_OFFLINE 1 45 + 45 46 struct tcm_loop_tpg { 46 47 unsigned short tl_tpgt; 48 + unsigned short tl_transport_status; 47 49 atomic_t tl_tpg_port_count; 48 50 struct se_portal_group tl_se_tpg; 49 51 struct tcm_loop_hba *tl_hba;
+9 -9
drivers/target/sbp/sbp_target.c
··· 2556 2556 /* 2557 2557 * Setup default attribute lists for various fabric->tf_cit_tmpl 2558 2558 */ 2559 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = sbp_wwn_attrs; 2560 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = sbp_tpg_base_attrs; 2561 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = sbp_tpg_attrib_attrs; 2562 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 2563 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 2564 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL; 2565 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 2566 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 2567 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; 2559 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = sbp_wwn_attrs; 2560 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = sbp_tpg_base_attrs; 2561 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = sbp_tpg_attrib_attrs; 2562 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 2563 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 2564 + fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL; 2565 + fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 2566 + fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 2567 + fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL; 2568 2568 2569 2569 ret = target_fabric_configfs_register(fabric); 2570 2570 if (ret < 0) {
+76 -74
drivers/target/target_core_alua.c
··· 44 44 static sense_reason_t core_alua_check_transition(int state, int *primary); 45 45 static int core_alua_set_tg_pt_secondary_state( 46 46 struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, 47 - struct se_port *port, int explict, int offline); 47 + struct se_port *port, int explicit, int offline); 48 48 49 49 static u16 alua_lu_gps_counter; 50 50 static u32 alua_lu_gps_count; ··· 117 117 /* 118 118 * Set supported ASYMMETRIC ACCESS State bits 119 119 */ 120 - buf[off] = 0x80; /* T_SUP */ 121 - buf[off] |= 0x40; /* O_SUP */ 122 - buf[off] |= 0x8; /* U_SUP */ 123 - buf[off] |= 0x4; /* S_SUP */ 124 - buf[off] |= 0x2; /* AN_SUP */ 125 - buf[off++] |= 0x1; /* AO_SUP */ 120 + buf[off++] |= tg_pt_gp->tg_pt_gp_alua_supported_states; 126 121 /* 127 122 * TARGET PORT GROUP 128 123 */ ··· 170 175 if (ext_hdr != 0) { 171 176 buf[4] = 0x10; 172 177 /* 173 - * Set the implict transition time (in seconds) for the application 178 + * Set the implicit transition time (in seconds) for the application 174 179 * client to use as a base for it's transition timeout value. 175 180 * 176 181 * Use the current tg_pt_gp_mem -> tg_pt_gp membership from the LUN ··· 183 188 spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); 184 189 tg_pt_gp = tg_pt_gp_mem->tg_pt_gp; 185 190 if (tg_pt_gp) 186 - buf[5] = tg_pt_gp->tg_pt_gp_implict_trans_secs; 191 + buf[5] = tg_pt_gp->tg_pt_gp_implicit_trans_secs; 187 192 spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); 188 193 } 189 194 } ··· 194 199 } 195 200 196 201 /* 197 - * SET_TARGET_PORT_GROUPS for explict ALUA operation. 202 + * SET_TARGET_PORT_GROUPS for explicit ALUA operation. 198 203 * 199 204 * See spc4r17 section 6.35 200 205 */ ··· 227 232 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 228 233 229 234 /* 230 - * Determine if explict ALUA via SET_TARGET_PORT_GROUPS is allowed 235 + * Determine if explicit ALUA via SET_TARGET_PORT_GROUPS is allowed 231 236 * for the local tg_pt_gp. 232 237 */ 233 238 l_tg_pt_gp_mem = l_port->sep_alua_tg_pt_gp_mem; ··· 246 251 } 247 252 spin_unlock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock); 248 253 249 - if (!(l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICT_ALUA)) { 254 + if (!(l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICIT_ALUA)) { 250 255 pr_debug("Unable to process SET_TARGET_PORT_GROUPS" 251 - " while TPGS_EXPLICT_ALUA is disabled\n"); 256 + " while TPGS_EXPLICIT_ALUA is disabled\n"); 252 257 rc = TCM_UNSUPPORTED_SCSI_OPCODE; 253 258 goto out; 254 259 } ··· 325 330 spin_unlock(&dev->t10_alua.tg_pt_gps_lock); 326 331 } else { 327 332 /* 328 - * Extact the RELATIVE TARGET PORT IDENTIFIER to identify 333 + * Extract the RELATIVE TARGET PORT IDENTIFIER to identify 329 334 * the Target Port in question for the the incoming 330 335 * SET_TARGET_PORT_GROUPS op. 331 336 */ ··· 482 487 u8 *alua_ascq) 483 488 { 484 489 /* 485 - * Allowed CDBs for ALUA_ACCESS_STATE_TRANSITIO as defined by 490 + * Allowed CDBs for ALUA_ACCESS_STATE_TRANSITION as defined by 486 491 * spc4r17 section 5.9.2.5 487 492 */ 488 493 switch (cdb[0]) { ··· 510 515 } 511 516 512 517 /* 513 - * return 1: Is used to signal LUN not accecsable, and check condition/not ready 518 + * return 1: Is used to signal LUN not accessible, and check condition/not ready 514 519 * return 0: Used to signal success 515 - * reutrn -1: Used to signal failure, and invalid cdb field 520 + * return -1: Used to signal failure, and invalid cdb field 516 521 */ 517 522 sense_reason_t 518 523 target_alua_state_check(struct se_cmd *cmd) ··· 561 566 nonop_delay_msecs = tg_pt_gp->tg_pt_gp_nonop_delay_msecs; 562 567 spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); 563 568 /* 564 - * Process ALUA_ACCESS_STATE_ACTIVE_OPTMIZED in a separate conditional 569 + * Process ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED in a separate conditional 565 570 * statement so the compiler knows explicitly to check this case first. 566 571 * For the Optimized ALUA access state case, we want to process the 567 572 * incoming fabric cmd ASAP.. 568 573 */ 569 - if (out_alua_state == ALUA_ACCESS_STATE_ACTIVE_OPTMIZED) 574 + if (out_alua_state == ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED) 570 575 return 0; 571 576 572 577 switch (out_alua_state) { ··· 615 620 } 616 621 617 622 /* 618 - * Check implict and explict ALUA state change request. 623 + * Check implicit and explicit ALUA state change request. 619 624 */ 620 625 static sense_reason_t 621 626 core_alua_check_transition(int state, int *primary) 622 627 { 623 628 switch (state) { 624 - case ALUA_ACCESS_STATE_ACTIVE_OPTMIZED: 629 + case ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED: 625 630 case ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED: 626 631 case ALUA_ACCESS_STATE_STANDBY: 627 632 case ALUA_ACCESS_STATE_UNAVAILABLE: ··· 649 654 static char *core_alua_dump_state(int state) 650 655 { 651 656 switch (state) { 652 - case ALUA_ACCESS_STATE_ACTIVE_OPTMIZED: 657 + case ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED: 653 658 return "Active/Optimized"; 654 659 case ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED: 655 660 return "Active/NonOptimized"; ··· 671 676 switch (status) { 672 677 case ALUA_STATUS_NONE: 673 678 return "None"; 674 - case ALUA_STATUS_ALTERED_BY_EXPLICT_STPG: 675 - return "Altered by Explict STPG"; 676 - case ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA: 677 - return "Altered by Implict ALUA"; 679 + case ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG: 680 + return "Altered by Explicit STPG"; 681 + case ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA: 682 + return "Altered by Implicit ALUA"; 678 683 default: 679 684 return "Unknown"; 680 685 } ··· 765 770 struct se_node_acl *nacl, 766 771 unsigned char *md_buf, 767 772 int new_state, 768 - int explict) 773 + int explicit) 769 774 { 770 775 struct se_dev_entry *se_deve; 771 776 struct se_lun_acl *lacl; ··· 779 784 old_state = atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state); 780 785 atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, 781 786 ALUA_ACCESS_STATE_TRANSITION); 782 - tg_pt_gp->tg_pt_gp_alua_access_status = (explict) ? 783 - ALUA_STATUS_ALTERED_BY_EXPLICT_STPG : 784 - ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA; 787 + tg_pt_gp->tg_pt_gp_alua_access_status = (explicit) ? 788 + ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG : 789 + ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA; 785 790 /* 786 791 * Check for the optional ALUA primary state transition delay 787 792 */ ··· 797 802 * change, a device server shall establish a unit attention 798 803 * condition for the initiator port associated with every I_T 799 804 * nexus with the additional sense code set to ASYMMETRIC 800 - * ACCESS STATE CHAGED. 805 + * ACCESS STATE CHANGED. 801 806 * 802 807 * After an explicit target port asymmetric access state 803 808 * change, a device server shall establish a unit attention ··· 816 821 lacl = se_deve->se_lun_acl; 817 822 /* 818 823 * se_deve->se_lun_acl pointer may be NULL for a 819 - * entry created without explict Node+MappedLUN ACLs 824 + * entry created without explicit Node+MappedLUN ACLs 820 825 */ 821 826 if (!lacl) 822 827 continue; 823 828 824 - if (explict && 829 + if (explicit && 825 830 (nacl != NULL) && (nacl == lacl->se_lun_nacl) && 826 831 (l_port != NULL) && (l_port == port)) 827 832 continue; ··· 861 866 atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, new_state); 862 867 863 868 pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu" 864 - " from primary access state %s to %s\n", (explict) ? "explict" : 865 - "implict", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item), 869 + " from primary access state %s to %s\n", (explicit) ? "explicit" : 870 + "implicit", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item), 866 871 tg_pt_gp->tg_pt_gp_id, core_alua_dump_state(old_state), 867 872 core_alua_dump_state(new_state)); 868 873 ··· 875 880 struct se_port *l_port, 876 881 struct se_node_acl *l_nacl, 877 882 int new_state, 878 - int explict) 883 + int explicit) 879 884 { 880 885 struct se_device *dev; 881 886 struct se_port *port; ··· 912 917 * success. 913 918 */ 914 919 core_alua_do_transition_tg_pt(l_tg_pt_gp, l_port, l_nacl, 915 - md_buf, new_state, explict); 920 + md_buf, new_state, explicit); 916 921 atomic_dec(&lu_gp->lu_gp_ref_cnt); 917 922 smp_mb__after_atomic_dec(); 918 923 kfree(md_buf); ··· 941 946 continue; 942 947 /* 943 948 * If the target behavior port asymmetric access state 944 - * is changed for any target port group accessiable via 949 + * is changed for any target port group accessible via 945 950 * a logical unit within a LU group, the target port 946 951 * behavior group asymmetric access states for the same 947 952 * target port group accessible via other logical units ··· 965 970 * success. 966 971 */ 967 972 core_alua_do_transition_tg_pt(tg_pt_gp, port, 968 - nacl, md_buf, new_state, explict); 973 + nacl, md_buf, new_state, explicit); 969 974 970 975 spin_lock(&dev->t10_alua.tg_pt_gps_lock); 971 976 atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); ··· 982 987 pr_debug("Successfully processed LU Group: %s all ALUA TG PT" 983 988 " Group IDs: %hu %s transition to primary state: %s\n", 984 989 config_item_name(&lu_gp->lu_gp_group.cg_item), 985 - l_tg_pt_gp->tg_pt_gp_id, (explict) ? "explict" : "implict", 990 + l_tg_pt_gp->tg_pt_gp_id, (explicit) ? "explicit" : "implicit", 986 991 core_alua_dump_state(new_state)); 987 992 988 993 atomic_dec(&lu_gp->lu_gp_ref_cnt); ··· 1029 1034 static int core_alua_set_tg_pt_secondary_state( 1030 1035 struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem, 1031 1036 struct se_port *port, 1032 - int explict, 1037 + int explicit, 1033 1038 int offline) 1034 1039 { 1035 1040 struct t10_alua_tg_pt_gp *tg_pt_gp; ··· 1056 1061 atomic_set(&port->sep_tg_pt_secondary_offline, 0); 1057 1062 1058 1063 md_buf_len = tg_pt_gp->tg_pt_gp_md_buf_len; 1059 - port->sep_tg_pt_secondary_stat = (explict) ? 1060 - ALUA_STATUS_ALTERED_BY_EXPLICT_STPG : 1061 - ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA; 1064 + port->sep_tg_pt_secondary_stat = (explicit) ? 1065 + ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG : 1066 + ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA; 1062 1067 1063 1068 pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu" 1064 - " to secondary access state: %s\n", (explict) ? "explict" : 1065 - "implict", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item), 1069 + " to secondary access state: %s\n", (explicit) ? "explicit" : 1070 + "implicit", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item), 1066 1071 tg_pt_gp->tg_pt_gp_id, (offline) ? "OFFLINE" : "ONLINE"); 1067 1072 1068 1073 spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); ··· 1227 1232 * struct se_device is released via core_alua_free_lu_gp_mem(). 1228 1233 * 1229 1234 * If the passed lu_gp does NOT match the default_lu_gp, assume 1230 - * we want to re-assocate a given lu_gp_mem with default_lu_gp. 1235 + * we want to re-associate a given lu_gp_mem with default_lu_gp. 1231 1236 */ 1232 1237 spin_lock(&lu_gp_mem->lu_gp_mem_lock); 1233 1238 if (lu_gp != default_lu_gp) ··· 1349 1354 tg_pt_gp->tg_pt_gp_dev = dev; 1350 1355 tg_pt_gp->tg_pt_gp_md_buf_len = ALUA_MD_BUF_LEN; 1351 1356 atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, 1352 - ALUA_ACCESS_STATE_ACTIVE_OPTMIZED); 1357 + ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED); 1353 1358 /* 1354 - * Enable both explict and implict ALUA support by default 1359 + * Enable both explicit and implicit ALUA support by default 1355 1360 */ 1356 1361 tg_pt_gp->tg_pt_gp_alua_access_type = 1357 - TPGS_EXPLICT_ALUA | TPGS_IMPLICT_ALUA; 1362 + TPGS_EXPLICIT_ALUA | TPGS_IMPLICIT_ALUA; 1358 1363 /* 1359 1364 * Set the default Active/NonOptimized Delay in milliseconds 1360 1365 */ 1361 1366 tg_pt_gp->tg_pt_gp_nonop_delay_msecs = ALUA_DEFAULT_NONOP_DELAY_MSECS; 1362 1367 tg_pt_gp->tg_pt_gp_trans_delay_msecs = ALUA_DEFAULT_TRANS_DELAY_MSECS; 1363 - tg_pt_gp->tg_pt_gp_implict_trans_secs = ALUA_DEFAULT_IMPLICT_TRANS_SECS; 1368 + tg_pt_gp->tg_pt_gp_implicit_trans_secs = ALUA_DEFAULT_IMPLICIT_TRANS_SECS; 1369 + 1370 + /* 1371 + * Enable all supported states 1372 + */ 1373 + tg_pt_gp->tg_pt_gp_alua_supported_states = 1374 + ALUA_T_SUP | ALUA_O_SUP | 1375 + ALUA_U_SUP | ALUA_S_SUP | ALUA_AN_SUP | ALUA_AO_SUP; 1364 1376 1365 1377 if (def_group) { 1366 1378 spin_lock(&dev->t10_alua.tg_pt_gps_lock); ··· 1467 1465 * been called from target_core_alua_drop_tg_pt_gp(). 1468 1466 * 1469 1467 * Here we remove *tg_pt_gp from the global list so that 1470 - * no assications *OR* explict ALUA via SET_TARGET_PORT_GROUPS 1468 + * no associations *OR* explicit ALUA via SET_TARGET_PORT_GROUPS 1471 1469 * can be made while we are releasing struct t10_alua_tg_pt_gp. 1472 1470 */ 1473 1471 spin_lock(&dev->t10_alua.tg_pt_gps_lock); ··· 1503 1501 * core_alua_free_tg_pt_gp_mem(). 1504 1502 * 1505 1503 * If the passed tg_pt_gp does NOT match the default_tg_pt_gp, 1506 - * assume we want to re-assocate a given tg_pt_gp_mem with 1504 + * assume we want to re-associate a given tg_pt_gp_mem with 1507 1505 * default_tg_pt_gp. 1508 1506 */ 1509 1507 spin_lock(&tg_pt_gp_mem->tg_pt_gp_mem_lock); ··· 1742 1740 struct t10_alua_tg_pt_gp *tg_pt_gp, 1743 1741 char *page) 1744 1742 { 1745 - if ((tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICT_ALUA) && 1746 - (tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICT_ALUA)) 1747 - return sprintf(page, "Implict and Explict\n"); 1748 - else if (tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICT_ALUA) 1749 - return sprintf(page, "Implict\n"); 1750 - else if (tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICT_ALUA) 1751 - return sprintf(page, "Explict\n"); 1743 + if ((tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICIT_ALUA) && 1744 + (tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICIT_ALUA)) 1745 + return sprintf(page, "Implicit and Explicit\n"); 1746 + else if (tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICIT_ALUA) 1747 + return sprintf(page, "Implicit\n"); 1748 + else if (tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICIT_ALUA) 1749 + return sprintf(page, "Explicit\n"); 1752 1750 else 1753 1751 return sprintf(page, "None\n"); 1754 1752 } ··· 1773 1771 } 1774 1772 if (tmp == 3) 1775 1773 tg_pt_gp->tg_pt_gp_alua_access_type = 1776 - TPGS_IMPLICT_ALUA | TPGS_EXPLICT_ALUA; 1774 + TPGS_IMPLICIT_ALUA | TPGS_EXPLICIT_ALUA; 1777 1775 else if (tmp == 2) 1778 - tg_pt_gp->tg_pt_gp_alua_access_type = TPGS_EXPLICT_ALUA; 1776 + tg_pt_gp->tg_pt_gp_alua_access_type = TPGS_EXPLICIT_ALUA; 1779 1777 else if (tmp == 1) 1780 - tg_pt_gp->tg_pt_gp_alua_access_type = TPGS_IMPLICT_ALUA; 1778 + tg_pt_gp->tg_pt_gp_alua_access_type = TPGS_IMPLICIT_ALUA; 1781 1779 else 1782 1780 tg_pt_gp->tg_pt_gp_alua_access_type = 0; 1783 1781 ··· 1846 1844 return count; 1847 1845 } 1848 1846 1849 - ssize_t core_alua_show_implict_trans_secs( 1847 + ssize_t core_alua_show_implicit_trans_secs( 1850 1848 struct t10_alua_tg_pt_gp *tg_pt_gp, 1851 1849 char *page) 1852 1850 { 1853 - return sprintf(page, "%d\n", tg_pt_gp->tg_pt_gp_implict_trans_secs); 1851 + return sprintf(page, "%d\n", tg_pt_gp->tg_pt_gp_implicit_trans_secs); 1854 1852 } 1855 1853 1856 - ssize_t core_alua_store_implict_trans_secs( 1854 + ssize_t core_alua_store_implicit_trans_secs( 1857 1855 struct t10_alua_tg_pt_gp *tg_pt_gp, 1858 1856 const char *page, 1859 1857 size_t count) ··· 1863 1861 1864 1862 ret = kstrtoul(page, 0, &tmp); 1865 1863 if (ret < 0) { 1866 - pr_err("Unable to extract implict_trans_secs\n"); 1864 + pr_err("Unable to extract implicit_trans_secs\n"); 1867 1865 return ret; 1868 1866 } 1869 - if (tmp > ALUA_MAX_IMPLICT_TRANS_SECS) { 1870 - pr_err("Passed implict_trans_secs: %lu, exceeds" 1871 - " ALUA_MAX_IMPLICT_TRANS_SECS: %d\n", tmp, 1872 - ALUA_MAX_IMPLICT_TRANS_SECS); 1867 + if (tmp > ALUA_MAX_IMPLICIT_TRANS_SECS) { 1868 + pr_err("Passed implicit_trans_secs: %lu, exceeds" 1869 + " ALUA_MAX_IMPLICIT_TRANS_SECS: %d\n", tmp, 1870 + ALUA_MAX_IMPLICIT_TRANS_SECS); 1873 1871 return -EINVAL; 1874 1872 } 1875 - tg_pt_gp->tg_pt_gp_implict_trans_secs = (int)tmp; 1873 + tg_pt_gp->tg_pt_gp_implicit_trans_secs = (int)tmp; 1876 1874 1877 1875 return count; 1878 1876 } ··· 1972 1970 return ret; 1973 1971 } 1974 1972 if ((tmp != ALUA_STATUS_NONE) && 1975 - (tmp != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) && 1976 - (tmp != ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA)) { 1973 + (tmp != ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG) && 1974 + (tmp != ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA)) { 1977 1975 pr_err("Illegal value for alua_tg_pt_status: %lu\n", 1978 1976 tmp); 1979 1977 return -EINVAL;
+22 -11
drivers/target/target_core_alua.h
··· 7 7 * from spc4r17 section 6.4.2 Table 135 8 8 */ 9 9 #define TPGS_NO_ALUA 0x00 10 - #define TPGS_IMPLICT_ALUA 0x10 11 - #define TPGS_EXPLICT_ALUA 0x20 10 + #define TPGS_IMPLICIT_ALUA 0x10 11 + #define TPGS_EXPLICIT_ALUA 0x20 12 12 13 13 /* 14 14 * ASYMMETRIC ACCESS STATE field 15 15 * 16 16 * from spc4r17 section 6.27 Table 245 17 17 */ 18 - #define ALUA_ACCESS_STATE_ACTIVE_OPTMIZED 0x0 18 + #define ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED 0x0 19 19 #define ALUA_ACCESS_STATE_ACTIVE_NON_OPTIMIZED 0x1 20 20 #define ALUA_ACCESS_STATE_STANDBY 0x2 21 21 #define ALUA_ACCESS_STATE_UNAVAILABLE 0x3 ··· 23 23 #define ALUA_ACCESS_STATE_TRANSITION 0xf 24 24 25 25 /* 26 + * from spc4r36j section 6.37 Table 306 27 + */ 28 + #define ALUA_T_SUP 0x80 29 + #define ALUA_O_SUP 0x40 30 + #define ALUA_LBD_SUP 0x10 31 + #define ALUA_U_SUP 0x08 32 + #define ALUA_S_SUP 0x04 33 + #define ALUA_AN_SUP 0x02 34 + #define ALUA_AO_SUP 0x01 35 + 36 + /* 26 37 * REPORT_TARGET_PORT_GROUP STATUS CODE 27 38 * 28 39 * from spc4r17 section 6.27 Table 246 29 40 */ 30 41 #define ALUA_STATUS_NONE 0x00 31 - #define ALUA_STATUS_ALTERED_BY_EXPLICT_STPG 0x01 32 - #define ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA 0x02 42 + #define ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG 0x01 43 + #define ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA 0x02 33 44 34 45 /* 35 46 * From spc4r17, Table D.1: ASC and ASCQ Assignement ··· 57 46 #define ALUA_DEFAULT_NONOP_DELAY_MSECS 100 58 47 #define ALUA_MAX_NONOP_DELAY_MSECS 10000 /* 10 seconds */ 59 48 /* 60 - * Used for implict and explict ALUA transitional delay, that is disabled 49 + * Used for implicit and explicit ALUA transitional delay, that is disabled 61 50 * by default, and is intended to be used for debugging client side ALUA code. 62 51 */ 63 52 #define ALUA_DEFAULT_TRANS_DELAY_MSECS 0 64 53 #define ALUA_MAX_TRANS_DELAY_MSECS 30000 /* 30 seconds */ 65 54 /* 66 - * Used for the recommended application client implict transition timeout 55 + * Used for the recommended application client implicit transition timeout 67 56 * in seconds, returned by the REPORT_TARGET_PORT_GROUPS w/ extended header. 68 57 */ 69 - #define ALUA_DEFAULT_IMPLICT_TRANS_SECS 0 70 - #define ALUA_MAX_IMPLICT_TRANS_SECS 255 58 + #define ALUA_DEFAULT_IMPLICIT_TRANS_SECS 0 59 + #define ALUA_MAX_IMPLICIT_TRANS_SECS 255 71 60 /* 72 61 * Used by core_alua_update_tpg_primary_metadata() and 73 62 * core_alua_update_tpg_secondary_metadata() ··· 124 113 char *); 125 114 extern ssize_t core_alua_store_trans_delay_msecs(struct t10_alua_tg_pt_gp *, 126 115 const char *, size_t); 127 - extern ssize_t core_alua_show_implict_trans_secs(struct t10_alua_tg_pt_gp *, 116 + extern ssize_t core_alua_show_implicit_trans_secs(struct t10_alua_tg_pt_gp *, 128 117 char *); 129 - extern ssize_t core_alua_store_implict_trans_secs(struct t10_alua_tg_pt_gp *, 118 + extern ssize_t core_alua_store_implicit_trans_secs(struct t10_alua_tg_pt_gp *, 130 119 const char *, size_t); 131 120 extern ssize_t core_alua_show_preferred_bit(struct t10_alua_tg_pt_gp *, 132 121 char *);
+107 -16
drivers/target/target_core_configfs.c
··· 177 177 * struct target_fabric_configfs *tf will contain a usage reference. 178 178 */ 179 179 pr_debug("Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> %p\n", 180 - &TF_CIT_TMPL(tf)->tfc_wwn_cit); 180 + &tf->tf_cit_tmpl.tfc_wwn_cit); 181 181 182 182 tf->tf_group.default_groups = tf->tf_default_groups; 183 183 tf->tf_group.default_groups[0] = &tf->tf_disc_group; 184 184 tf->tf_group.default_groups[1] = NULL; 185 185 186 186 config_group_init_type_name(&tf->tf_group, name, 187 - &TF_CIT_TMPL(tf)->tfc_wwn_cit); 187 + &tf->tf_cit_tmpl.tfc_wwn_cit); 188 188 config_group_init_type_name(&tf->tf_disc_group, "discovery_auth", 189 - &TF_CIT_TMPL(tf)->tfc_discovery_cit); 189 + &tf->tf_cit_tmpl.tfc_discovery_cit); 190 190 191 191 pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" 192 192 " %s\n", tf->tf_group.cg_item.ci_name); ··· 2036 2036 int new_state, ret; 2037 2037 2038 2038 if (!tg_pt_gp->tg_pt_gp_valid_id) { 2039 - pr_err("Unable to do implict ALUA on non valid" 2039 + pr_err("Unable to do implicit ALUA on non valid" 2040 2040 " tg_pt_gp ID: %hu\n", tg_pt_gp->tg_pt_gp_valid_id); 2041 2041 return -EINVAL; 2042 2042 } ··· 2049 2049 } 2050 2050 new_state = (int)tmp; 2051 2051 2052 - if (!(tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICT_ALUA)) { 2053 - pr_err("Unable to process implict configfs ALUA" 2054 - " transition while TPGS_IMPLICT_ALUA is disabled\n"); 2052 + if (!(tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICIT_ALUA)) { 2053 + pr_err("Unable to process implicit configfs ALUA" 2054 + " transition while TPGS_IMPLICIT_ALUA is disabled\n"); 2055 2055 return -EINVAL; 2056 2056 } 2057 2057 ··· 2097 2097 new_status = (int)tmp; 2098 2098 2099 2099 if ((new_status != ALUA_STATUS_NONE) && 2100 - (new_status != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) && 2101 - (new_status != ALUA_STATUS_ALTERED_BY_IMPLICT_ALUA)) { 2100 + (new_status != ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG) && 2101 + (new_status != ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA)) { 2102 2102 pr_err("Illegal ALUA access status: 0x%02x\n", 2103 2103 new_status); 2104 2104 return -EINVAL; ··· 2129 2129 } 2130 2130 2131 2131 SE_DEV_ALUA_TG_PT_ATTR(alua_access_type, S_IRUGO | S_IWUSR); 2132 + 2133 + /* 2134 + * alua_supported_states 2135 + */ 2136 + 2137 + #define SE_DEV_ALUA_SUPPORT_STATE_SHOW(_name, _var, _bit) \ 2138 + static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_support_##_name( \ 2139 + struct t10_alua_tg_pt_gp *t, char *p) \ 2140 + { \ 2141 + return sprintf(p, "%d\n", !!(t->_var & _bit)); \ 2142 + } 2143 + 2144 + #define SE_DEV_ALUA_SUPPORT_STATE_STORE(_name, _var, _bit) \ 2145 + static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_support_##_name(\ 2146 + struct t10_alua_tg_pt_gp *t, const char *p, size_t c) \ 2147 + { \ 2148 + unsigned long tmp; \ 2149 + int ret; \ 2150 + \ 2151 + if (!t->tg_pt_gp_valid_id) { \ 2152 + pr_err("Unable to do set ##_name ALUA state on non" \ 2153 + " valid tg_pt_gp ID: %hu\n", \ 2154 + t->tg_pt_gp_valid_id); \ 2155 + return -EINVAL; \ 2156 + } \ 2157 + \ 2158 + ret = kstrtoul(p, 0, &tmp); \ 2159 + if (ret < 0) { \ 2160 + pr_err("Invalid value '%s', must be '0' or '1'\n", p); \ 2161 + return -EINVAL; \ 2162 + } \ 2163 + if (tmp > 1) { \ 2164 + pr_err("Invalid value '%ld', must be '0' or '1'\n", tmp); \ 2165 + return -EINVAL; \ 2166 + } \ 2167 + if (!tmp) \ 2168 + t->_var |= _bit; \ 2169 + else \ 2170 + t->_var &= ~_bit; \ 2171 + \ 2172 + return c; \ 2173 + } 2174 + 2175 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(transitioning, 2176 + tg_pt_gp_alua_supported_states, ALUA_T_SUP); 2177 + SE_DEV_ALUA_SUPPORT_STATE_STORE(transitioning, 2178 + tg_pt_gp_alua_supported_states, ALUA_T_SUP); 2179 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_transitioning, S_IRUGO | S_IWUSR); 2180 + 2181 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(offline, 2182 + tg_pt_gp_alua_supported_states, ALUA_O_SUP); 2183 + SE_DEV_ALUA_SUPPORT_STATE_STORE(offline, 2184 + tg_pt_gp_alua_supported_states, ALUA_O_SUP); 2185 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_offline, S_IRUGO | S_IWUSR); 2186 + 2187 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(lba_dependent, 2188 + tg_pt_gp_alua_supported_states, ALUA_LBD_SUP); 2189 + SE_DEV_ALUA_SUPPORT_STATE_STORE(lba_dependent, 2190 + tg_pt_gp_alua_supported_states, ALUA_LBD_SUP); 2191 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_lba_dependent, S_IRUGO | S_IWUSR); 2192 + 2193 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(unavailable, 2194 + tg_pt_gp_alua_supported_states, ALUA_U_SUP); 2195 + SE_DEV_ALUA_SUPPORT_STATE_STORE(unavailable, 2196 + tg_pt_gp_alua_supported_states, ALUA_U_SUP); 2197 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_unavailable, S_IRUGO | S_IWUSR); 2198 + 2199 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(standby, 2200 + tg_pt_gp_alua_supported_states, ALUA_S_SUP); 2201 + SE_DEV_ALUA_SUPPORT_STATE_STORE(standby, 2202 + tg_pt_gp_alua_supported_states, ALUA_S_SUP); 2203 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_standby, S_IRUGO | S_IWUSR); 2204 + 2205 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(active_optimized, 2206 + tg_pt_gp_alua_supported_states, ALUA_AO_SUP); 2207 + SE_DEV_ALUA_SUPPORT_STATE_STORE(active_optimized, 2208 + tg_pt_gp_alua_supported_states, ALUA_AO_SUP); 2209 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_active_optimized, S_IRUGO | S_IWUSR); 2210 + 2211 + SE_DEV_ALUA_SUPPORT_STATE_SHOW(active_nonoptimized, 2212 + tg_pt_gp_alua_supported_states, ALUA_AN_SUP); 2213 + SE_DEV_ALUA_SUPPORT_STATE_STORE(active_nonoptimized, 2214 + tg_pt_gp_alua_supported_states, ALUA_AN_SUP); 2215 + SE_DEV_ALUA_TG_PT_ATTR(alua_support_active_nonoptimized, S_IRUGO | S_IWUSR); 2132 2216 2133 2217 /* 2134 2218 * alua_write_metadata ··· 2294 2210 SE_DEV_ALUA_TG_PT_ATTR(trans_delay_msecs, S_IRUGO | S_IWUSR); 2295 2211 2296 2212 /* 2297 - * implict_trans_secs 2213 + * implicit_trans_secs 2298 2214 */ 2299 - static ssize_t target_core_alua_tg_pt_gp_show_attr_implict_trans_secs( 2215 + static ssize_t target_core_alua_tg_pt_gp_show_attr_implicit_trans_secs( 2300 2216 struct t10_alua_tg_pt_gp *tg_pt_gp, 2301 2217 char *page) 2302 2218 { 2303 - return core_alua_show_implict_trans_secs(tg_pt_gp, page); 2219 + return core_alua_show_implicit_trans_secs(tg_pt_gp, page); 2304 2220 } 2305 2221 2306 - static ssize_t target_core_alua_tg_pt_gp_store_attr_implict_trans_secs( 2222 + static ssize_t target_core_alua_tg_pt_gp_store_attr_implicit_trans_secs( 2307 2223 struct t10_alua_tg_pt_gp *tg_pt_gp, 2308 2224 const char *page, 2309 2225 size_t count) 2310 2226 { 2311 - return core_alua_store_implict_trans_secs(tg_pt_gp, page, count); 2227 + return core_alua_store_implicit_trans_secs(tg_pt_gp, page, count); 2312 2228 } 2313 2229 2314 - SE_DEV_ALUA_TG_PT_ATTR(implict_trans_secs, S_IRUGO | S_IWUSR); 2230 + SE_DEV_ALUA_TG_PT_ATTR(implicit_trans_secs, S_IRUGO | S_IWUSR); 2315 2231 2316 2232 /* 2317 2233 * preferred ··· 2434 2350 &target_core_alua_tg_pt_gp_alua_access_state.attr, 2435 2351 &target_core_alua_tg_pt_gp_alua_access_status.attr, 2436 2352 &target_core_alua_tg_pt_gp_alua_access_type.attr, 2353 + &target_core_alua_tg_pt_gp_alua_support_transitioning.attr, 2354 + &target_core_alua_tg_pt_gp_alua_support_offline.attr, 2355 + &target_core_alua_tg_pt_gp_alua_support_lba_dependent.attr, 2356 + &target_core_alua_tg_pt_gp_alua_support_unavailable.attr, 2357 + &target_core_alua_tg_pt_gp_alua_support_standby.attr, 2358 + &target_core_alua_tg_pt_gp_alua_support_active_nonoptimized.attr, 2359 + &target_core_alua_tg_pt_gp_alua_support_active_optimized.attr, 2437 2360 &target_core_alua_tg_pt_gp_alua_write_metadata.attr, 2438 2361 &target_core_alua_tg_pt_gp_nonop_delay_msecs.attr, 2439 2362 &target_core_alua_tg_pt_gp_trans_delay_msecs.attr, 2440 - &target_core_alua_tg_pt_gp_implict_trans_secs.attr, 2363 + &target_core_alua_tg_pt_gp_implicit_trans_secs.attr, 2441 2364 &target_core_alua_tg_pt_gp_preferred.attr, 2442 2365 &target_core_alua_tg_pt_gp_tg_pt_gp_id.attr, 2443 2366 &target_core_alua_tg_pt_gp_members.attr,
+21 -14
drivers/target/target_core_device.c
··· 92 92 se_cmd->pr_res_key = deve->pr_res_key; 93 93 se_cmd->orig_fe_lun = unpacked_lun; 94 94 se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; 95 + 96 + percpu_ref_get(&se_lun->lun_ref); 97 + se_cmd->lun_ref_active = true; 95 98 } 96 99 spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); 97 100 ··· 122 119 se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0; 123 120 se_cmd->orig_fe_lun = 0; 124 121 se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; 122 + 123 + percpu_ref_get(&se_lun->lun_ref); 124 + se_cmd->lun_ref_active = true; 125 125 } 126 126 127 127 /* Directly associate cmd with se_dev */ 128 128 se_cmd->se_dev = se_lun->lun_se_dev; 129 129 130 - /* TODO: get rid of this and use atomics for stats */ 131 130 dev = se_lun->lun_se_dev; 132 - spin_lock_irqsave(&dev->stats_lock, flags); 133 - dev->num_cmds++; 131 + atomic_long_inc(&dev->num_cmds); 134 132 if (se_cmd->data_direction == DMA_TO_DEVICE) 135 - dev->write_bytes += se_cmd->data_length; 133 + atomic_long_add(se_cmd->data_length, &dev->write_bytes); 136 134 else if (se_cmd->data_direction == DMA_FROM_DEVICE) 137 - dev->read_bytes += se_cmd->data_length; 138 - spin_unlock_irqrestore(&dev->stats_lock, flags); 139 - 140 - spin_lock_irqsave(&se_lun->lun_cmd_lock, flags); 141 - list_add_tail(&se_cmd->se_lun_node, &se_lun->lun_cmd_list); 142 - spin_unlock_irqrestore(&se_lun->lun_cmd_lock, flags); 135 + atomic_long_add(se_cmd->data_length, &dev->read_bytes); 143 136 144 137 return 0; 145 138 } ··· 313 314 deve = nacl->device_list[mapped_lun]; 314 315 315 316 /* 316 - * Check if the call is handling demo mode -> explict LUN ACL 317 + * Check if the call is handling demo mode -> explicit LUN ACL 317 318 * transition. This transition must be for the same struct se_lun 318 319 * + mapped_lun that was setup in demo mode.. 319 320 */ 320 321 if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { 321 322 if (deve->se_lun_acl != NULL) { 322 323 pr_err("struct se_dev_entry->se_lun_acl" 323 - " already set for demo mode -> explict" 324 + " already set for demo mode -> explicit" 324 325 " LUN ACL transition\n"); 325 326 spin_unlock_irq(&nacl->device_list_lock); 326 327 return -EINVAL; ··· 328 329 if (deve->se_lun != lun) { 329 330 pr_err("struct se_dev_entry->se_lun does" 330 331 " match passed struct se_lun for demo mode" 331 - " -> explict LUN ACL transition\n"); 332 + " -> explicit LUN ACL transition\n"); 332 333 spin_unlock_irq(&nacl->device_list_lock); 333 334 return -EINVAL; 334 335 } ··· 1406 1407 struct se_device *target_alloc_device(struct se_hba *hba, const char *name) 1407 1408 { 1408 1409 struct se_device *dev; 1410 + struct se_lun *xcopy_lun; 1409 1411 1410 1412 dev = hba->transport->alloc_device(hba, name); 1411 1413 if (!dev) ··· 1423 1423 INIT_LIST_HEAD(&dev->state_list); 1424 1424 INIT_LIST_HEAD(&dev->qf_cmd_list); 1425 1425 INIT_LIST_HEAD(&dev->g_dev_node); 1426 - spin_lock_init(&dev->stats_lock); 1427 1426 spin_lock_init(&dev->execute_task_lock); 1428 1427 spin_lock_init(&dev->delayed_cmd_lock); 1429 1428 spin_lock_init(&dev->dev_reservation_lock); ··· 1467 1468 dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN; 1468 1469 dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS; 1469 1470 dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS; 1471 + 1472 + xcopy_lun = &dev->xcopy_lun; 1473 + xcopy_lun->lun_se_dev = dev; 1474 + init_completion(&xcopy_lun->lun_shutdown_comp); 1475 + INIT_LIST_HEAD(&xcopy_lun->lun_acl_list); 1476 + spin_lock_init(&xcopy_lun->lun_acl_lock); 1477 + spin_lock_init(&xcopy_lun->lun_sep_lock); 1478 + init_completion(&xcopy_lun->lun_ref_comp); 1470 1479 1471 1480 return dev; 1472 1481 }
+19 -19
drivers/target/target_core_fabric_configfs.c
··· 385 385 } 386 386 387 387 config_group_init_type_name(&lacl->se_lun_group, name, 388 - &TF_CIT_TMPL(tf)->tfc_tpg_mappedlun_cit); 388 + &tf->tf_cit_tmpl.tfc_tpg_mappedlun_cit); 389 389 config_group_init_type_name(&lacl->ml_stat_grps.stat_group, 390 - "statistics", &TF_CIT_TMPL(tf)->tfc_tpg_mappedlun_stat_cit); 390 + "statistics", &tf->tf_cit_tmpl.tfc_tpg_mappedlun_stat_cit); 391 391 lacl_cg->default_groups[0] = &lacl->ml_stat_grps.stat_group; 392 392 lacl_cg->default_groups[1] = NULL; 393 393 ··· 504 504 nacl_cg->default_groups[4] = NULL; 505 505 506 506 config_group_init_type_name(&se_nacl->acl_group, name, 507 - &TF_CIT_TMPL(tf)->tfc_tpg_nacl_base_cit); 507 + &tf->tf_cit_tmpl.tfc_tpg_nacl_base_cit); 508 508 config_group_init_type_name(&se_nacl->acl_attrib_group, "attrib", 509 - &TF_CIT_TMPL(tf)->tfc_tpg_nacl_attrib_cit); 509 + &tf->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit); 510 510 config_group_init_type_name(&se_nacl->acl_auth_group, "auth", 511 - &TF_CIT_TMPL(tf)->tfc_tpg_nacl_auth_cit); 511 + &tf->tf_cit_tmpl.tfc_tpg_nacl_auth_cit); 512 512 config_group_init_type_name(&se_nacl->acl_param_group, "param", 513 - &TF_CIT_TMPL(tf)->tfc_tpg_nacl_param_cit); 513 + &tf->tf_cit_tmpl.tfc_tpg_nacl_param_cit); 514 514 config_group_init_type_name(&se_nacl->acl_fabric_stat_group, 515 515 "fabric_statistics", 516 - &TF_CIT_TMPL(tf)->tfc_tpg_nacl_stat_cit); 516 + &tf->tf_cit_tmpl.tfc_tpg_nacl_stat_cit); 517 517 518 518 return &se_nacl->acl_group; 519 519 } ··· 595 595 596 596 se_tpg_np->tpg_np_parent = se_tpg; 597 597 config_group_init_type_name(&se_tpg_np->tpg_np_group, name, 598 - &TF_CIT_TMPL(tf)->tfc_tpg_np_base_cit); 598 + &tf->tf_cit_tmpl.tfc_tpg_np_base_cit); 599 599 600 600 return &se_tpg_np->tpg_np_group; 601 601 } ··· 899 899 } 900 900 901 901 config_group_init_type_name(&lun->lun_group, name, 902 - &TF_CIT_TMPL(tf)->tfc_tpg_port_cit); 902 + &tf->tf_cit_tmpl.tfc_tpg_port_cit); 903 903 config_group_init_type_name(&lun->port_stat_grps.stat_group, 904 - "statistics", &TF_CIT_TMPL(tf)->tfc_tpg_port_stat_cit); 904 + "statistics", &tf->tf_cit_tmpl.tfc_tpg_port_stat_cit); 905 905 lun_cg->default_groups[0] = &lun->port_stat_grps.stat_group; 906 906 lun_cg->default_groups[1] = NULL; 907 907 ··· 1056 1056 se_tpg->tpg_group.default_groups[6] = NULL; 1057 1057 1058 1058 config_group_init_type_name(&se_tpg->tpg_group, name, 1059 - &TF_CIT_TMPL(tf)->tfc_tpg_base_cit); 1059 + &tf->tf_cit_tmpl.tfc_tpg_base_cit); 1060 1060 config_group_init_type_name(&se_tpg->tpg_lun_group, "lun", 1061 - &TF_CIT_TMPL(tf)->tfc_tpg_lun_cit); 1061 + &tf->tf_cit_tmpl.tfc_tpg_lun_cit); 1062 1062 config_group_init_type_name(&se_tpg->tpg_np_group, "np", 1063 - &TF_CIT_TMPL(tf)->tfc_tpg_np_cit); 1063 + &tf->tf_cit_tmpl.tfc_tpg_np_cit); 1064 1064 config_group_init_type_name(&se_tpg->tpg_acl_group, "acls", 1065 - &TF_CIT_TMPL(tf)->tfc_tpg_nacl_cit); 1065 + &tf->tf_cit_tmpl.tfc_tpg_nacl_cit); 1066 1066 config_group_init_type_name(&se_tpg->tpg_attrib_group, "attrib", 1067 - &TF_CIT_TMPL(tf)->tfc_tpg_attrib_cit); 1067 + &tf->tf_cit_tmpl.tfc_tpg_attrib_cit); 1068 1068 config_group_init_type_name(&se_tpg->tpg_auth_group, "auth", 1069 - &TF_CIT_TMPL(tf)->tfc_tpg_auth_cit); 1069 + &tf->tf_cit_tmpl.tfc_tpg_auth_cit); 1070 1070 config_group_init_type_name(&se_tpg->tpg_param_group, "param", 1071 - &TF_CIT_TMPL(tf)->tfc_tpg_param_cit); 1071 + &tf->tf_cit_tmpl.tfc_tpg_param_cit); 1072 1072 1073 1073 return &se_tpg->tpg_group; 1074 1074 } ··· 1155 1155 wwn->wwn_group.default_groups[1] = NULL; 1156 1156 1157 1157 config_group_init_type_name(&wwn->wwn_group, name, 1158 - &TF_CIT_TMPL(tf)->tfc_tpg_cit); 1158 + &tf->tf_cit_tmpl.tfc_tpg_cit); 1159 1159 config_group_init_type_name(&wwn->fabric_stat_group, "fabric_statistics", 1160 - &TF_CIT_TMPL(tf)->tfc_wwn_fabric_stats_cit); 1160 + &tf->tf_cit_tmpl.tfc_wwn_fabric_stats_cit); 1161 1161 1162 1162 return &wwn->wwn_group; 1163 1163 }
+1 -1
drivers/target/target_core_file.c
··· 562 562 } else { 563 563 ret = fd_do_rw(cmd, sgl, sgl_nents, 1); 564 564 /* 565 - * Perform implict vfs_fsync_range() for fd_do_writev() ops 565 + * Perform implicit vfs_fsync_range() for fd_do_writev() ops 566 566 * for SCSI WRITEs with Forced Unit Access (FUA) set. 567 567 * Allow this to happen independent of WCE=0 setting. 568 568 */
+43
drivers/target/target_core_iblock.c
··· 710 710 return iblock_emulate_read_cap_with_block_size(dev, bd, q); 711 711 } 712 712 713 + static sector_t iblock_get_alignment_offset_lbas(struct se_device *dev) 714 + { 715 + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 716 + struct block_device *bd = ib_dev->ibd_bd; 717 + int ret; 718 + 719 + ret = bdev_alignment_offset(bd); 720 + if (ret == -1) 721 + return 0; 722 + 723 + /* convert offset-bytes to offset-lbas */ 724 + return ret / bdev_logical_block_size(bd); 725 + } 726 + 727 + static unsigned int iblock_get_lbppbe(struct se_device *dev) 728 + { 729 + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 730 + struct block_device *bd = ib_dev->ibd_bd; 731 + int logs_per_phys = bdev_physical_block_size(bd) / bdev_logical_block_size(bd); 732 + 733 + return ilog2(logs_per_phys); 734 + } 735 + 736 + static unsigned int iblock_get_io_min(struct se_device *dev) 737 + { 738 + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 739 + struct block_device *bd = ib_dev->ibd_bd; 740 + 741 + return bdev_io_min(bd); 742 + } 743 + 744 + static unsigned int iblock_get_io_opt(struct se_device *dev) 745 + { 746 + struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 747 + struct block_device *bd = ib_dev->ibd_bd; 748 + 749 + return bdev_io_opt(bd); 750 + } 751 + 713 752 static struct sbc_ops iblock_sbc_ops = { 714 753 .execute_rw = iblock_execute_rw, 715 754 .execute_sync_cache = iblock_execute_sync_cache, ··· 788 749 .show_configfs_dev_params = iblock_show_configfs_dev_params, 789 750 .get_device_type = sbc_get_device_type, 790 751 .get_blocks = iblock_get_blocks, 752 + .get_alignment_offset_lbas = iblock_get_alignment_offset_lbas, 753 + .get_lbppbe = iblock_get_lbppbe, 754 + .get_io_min = iblock_get_io_min, 755 + .get_io_opt = iblock_get_io_opt, 791 756 .get_write_cache = iblock_get_write_cache, 792 757 }; 793 758
+1 -3
drivers/target/target_core_internal.h
··· 75 75 76 76 struct se_node_acl *__core_tpg_get_initiator_node_acl(struct se_portal_group *tpg, 77 77 const char *); 78 - struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg, 79 - unsigned char *); 80 78 void core_tpg_add_node_to_devs(struct se_node_acl *, struct se_portal_group *); 81 79 void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *); 82 80 struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32); ··· 100 102 int transport_dump_vpd_ident_type(struct t10_vpd *, unsigned char *, int); 101 103 int transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int); 102 104 bool target_stop_cmd(struct se_cmd *cmd, unsigned long *flags); 103 - int transport_clear_lun_from_sessions(struct se_lun *); 105 + int transport_clear_lun_ref(struct se_lun *); 104 106 void transport_send_task_abort(struct se_cmd *); 105 107 sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size); 106 108 void target_qf_do_work(struct work_struct *work);
+12 -12
drivers/target/target_core_pr.c
··· 474 474 * statement. 475 475 */ 476 476 if (!ret && !other_cdb) { 477 - pr_debug("Allowing explict CDB: 0x%02x for %s" 477 + pr_debug("Allowing explicit CDB: 0x%02x for %s" 478 478 " reservation holder\n", cdb[0], 479 479 core_scsi3_pr_dump_type(pr_reg_type)); 480 480 ··· 507 507 */ 508 508 509 509 if (!registered_nexus) { 510 - pr_debug("Allowing implict CDB: 0x%02x" 510 + pr_debug("Allowing implicit CDB: 0x%02x" 511 511 " for %s reservation on unregistered" 512 512 " nexus\n", cdb[0], 513 513 core_scsi3_pr_dump_type(pr_reg_type)); ··· 522 522 * allow commands from registered nexuses. 523 523 */ 524 524 525 - pr_debug("Allowing implict CDB: 0x%02x for %s" 525 + pr_debug("Allowing implicit CDB: 0x%02x for %s" 526 526 " reservation\n", cdb[0], 527 527 core_scsi3_pr_dump_type(pr_reg_type)); 528 528 ··· 683 683 alua_port_list) { 684 684 /* 685 685 * This pointer will be NULL for demo mode MappedLUNs 686 - * that have not been make explict via a ConfigFS 686 + * that have not been make explicit via a ConfigFS 687 687 * MappedLUN group for the SCSI Initiator Node ACL. 688 688 */ 689 689 if (!deve_tmp->se_lun_acl) ··· 1158 1158 smp_mb__after_atomic_dec(); 1159 1159 } 1160 1160 1161 - static int core_scsi3_check_implict_release( 1161 + static int core_scsi3_check_implicit_release( 1162 1162 struct se_device *dev, 1163 1163 struct t10_pr_registration *pr_reg) 1164 1164 { ··· 1174 1174 } 1175 1175 if (pr_res_holder == pr_reg) { 1176 1176 /* 1177 - * Perform an implict RELEASE if the registration that 1177 + * Perform an implicit RELEASE if the registration that 1178 1178 * is being released is holding the reservation. 1179 1179 * 1180 1180 * From spc4r17, section 5.7.11.1: ··· 1192 1192 * For 'All Registrants' reservation types, all existing 1193 1193 * registrations are still processed as reservation holders 1194 1194 * in core_scsi3_pr_seq_non_holder() after the initial 1195 - * reservation holder is implictly released here. 1195 + * reservation holder is implicitly released here. 1196 1196 */ 1197 1197 } else if (pr_reg->pr_reg_all_tg_pt && 1198 1198 (!strcmp(pr_res_holder->pr_reg_nacl->initiatorname, ··· 2125 2125 /* 2126 2126 * sa_res_key=0 Unregister Reservation Key for registered I_T Nexus. 2127 2127 */ 2128 - pr_holder = core_scsi3_check_implict_release( 2128 + pr_holder = core_scsi3_check_implicit_release( 2129 2129 cmd->se_dev, pr_reg); 2130 2130 if (pr_holder < 0) { 2131 2131 ret = TCM_RESERVATION_CONFLICT; ··· 2402 2402 struct se_device *dev, 2403 2403 struct se_node_acl *se_nacl, 2404 2404 struct t10_pr_registration *pr_reg, 2405 - int explict) 2405 + int explicit) 2406 2406 { 2407 2407 struct target_core_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo; 2408 2408 char i_buf[PR_REG_ISID_ID_LEN]; ··· 2416 2416 2417 2417 pr_debug("SPC-3 PR [%s] Service Action: %s RELEASE cleared" 2418 2418 " reservation holder TYPE: %s ALL_TG_PT: %d\n", 2419 - tfo->get_fabric_name(), (explict) ? "explict" : "implict", 2419 + tfo->get_fabric_name(), (explicit) ? "explicit" : "implicit", 2420 2420 core_scsi3_pr_dump_type(pr_reg->pr_res_type), 2421 2421 (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); 2422 2422 pr_debug("SPC-3 PR [%s] RELEASE Node: %s%s\n", ··· 2692 2692 memset(i_buf, 0, PR_REG_ISID_ID_LEN); 2693 2693 core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN); 2694 2694 /* 2695 - * Do an implict RELEASE of the existing reservation. 2695 + * Do an implicit RELEASE of the existing reservation. 2696 2696 */ 2697 2697 if (dev->dev_pr_res_holder) 2698 2698 __core_scsi3_complete_pro_release(dev, nacl, ··· 2845 2845 * 5.7.11.4 Preempting, Table 52 and Figure 7. 2846 2846 * 2847 2847 * For a ZERO SA Reservation key, release 2848 - * all other registrations and do an implict 2848 + * all other registrations and do an implicit 2849 2849 * release of active persistent reservation. 2850 2850 * 2851 2851 * For a non-ZERO SA Reservation key, only
-1
drivers/target/target_core_rd.c
··· 27 27 #include <linux/string.h> 28 28 #include <linux/parser.h> 29 29 #include <linux/timer.h> 30 - #include <linux/blkdev.h> 31 30 #include <linux/slab.h> 32 31 #include <linux/spinlock.h> 33 32 #include <scsi/scsi.h>
+11 -1
drivers/target/target_core_sbc.c
··· 105 105 buf[9] = (dev->dev_attrib.block_size >> 16) & 0xff; 106 106 buf[10] = (dev->dev_attrib.block_size >> 8) & 0xff; 107 107 buf[11] = dev->dev_attrib.block_size & 0xff; 108 + 109 + if (dev->transport->get_lbppbe) 110 + buf[13] = dev->transport->get_lbppbe(dev) & 0x0f; 111 + 112 + if (dev->transport->get_alignment_offset_lbas) { 113 + u16 lalba = dev->transport->get_alignment_offset_lbas(dev); 114 + buf[14] = (lalba >> 8) & 0x3f; 115 + buf[15] = lalba & 0xff; 116 + } 117 + 108 118 /* 109 119 * Set Thin Provisioning Enable bit following sbc3r22 in section 110 120 * READ CAPACITY (16) byte 14 if emulate_tpu or emulate_tpws is enabled. 111 121 */ 112 122 if (dev->dev_attrib.emulate_tpu || dev->dev_attrib.emulate_tpws) 113 - buf[14] = 0x80; 123 + buf[14] |= 0x80; 114 124 115 125 rbuf = transport_kmap_data_sg(cmd); 116 126 if (rbuf) {
+12 -5
drivers/target/target_core_spc.c
··· 48 48 buf[5] = 0x80; 49 49 50 50 /* 51 - * Set TPGS field for explict and/or implict ALUA access type 51 + * Set TPGS field for explicit and/or implicit ALUA access type 52 52 * and opteration. 53 53 * 54 54 * See spc4r17 section 6.4.2 Table 135 ··· 452 452 struct se_device *dev = cmd->se_dev; 453 453 u32 max_sectors; 454 454 int have_tp = 0; 455 + int opt, min; 455 456 456 457 /* 457 458 * Following spc3r22 section 6.5.3 Block Limits VPD page, when ··· 476 475 /* 477 476 * Set OPTIMAL TRANSFER LENGTH GRANULARITY 478 477 */ 479 - put_unaligned_be16(1, &buf[6]); 478 + if (dev->transport->get_io_min && (min = dev->transport->get_io_min(dev))) 479 + put_unaligned_be16(min / dev->dev_attrib.block_size, &buf[6]); 480 + else 481 + put_unaligned_be16(1, &buf[6]); 480 482 481 483 /* 482 484 * Set MAXIMUM TRANSFER LENGTH ··· 491 487 /* 492 488 * Set OPTIMAL TRANSFER LENGTH 493 489 */ 494 - put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); 490 + if (dev->transport->get_io_opt && (opt = dev->transport->get_io_opt(dev))) 491 + put_unaligned_be32(opt / dev->dev_attrib.block_size, &buf[12]); 492 + else 493 + put_unaligned_be32(dev->dev_attrib.optimal_sectors, &buf[12]); 495 494 496 495 /* 497 496 * Exit now if we don't support TP. ··· 1257 1250 *size = (cdb[3] << 8) + cdb[4]; 1258 1251 1259 1252 /* 1260 - * Do implict HEAD_OF_QUEUE processing for INQUIRY. 1253 + * Do implicit HEAD_OF_QUEUE processing for INQUIRY. 1261 1254 * See spc4r17 section 5.3 1262 1255 */ 1263 1256 cmd->sam_task_attr = MSG_HEAD_TAG; ··· 1291 1284 cmd->execute_cmd = spc_emulate_report_luns; 1292 1285 *size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; 1293 1286 /* 1294 - * Do implict HEAD_OF_QUEUE processing for REPORT_LUNS 1287 + * Do implicit HEAD_OF_QUEUE processing for REPORT_LUNS 1295 1288 * See spc4r17 section 5.3 1296 1289 */ 1297 1290 cmd->sam_task_attr = MSG_HEAD_TAG;
+9 -7
drivers/target/target_core_stat.c
··· 32 32 #include <linux/utsname.h> 33 33 #include <linux/proc_fs.h> 34 34 #include <linux/seq_file.h> 35 - #include <linux/blkdev.h> 36 35 #include <linux/configfs.h> 37 36 #include <scsi/scsi.h> 38 37 #include <scsi/scsi_device.h> ··· 213 214 struct se_device *dev = 214 215 container_of(sgrps, struct se_device, dev_stat_grps); 215 216 216 - return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); 217 + return snprintf(page, PAGE_SIZE, "%lu\n", 218 + atomic_long_read(&dev->num_resets)); 217 219 } 218 220 DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets); 219 221 ··· 397 397 container_of(sgrps, struct se_device, dev_stat_grps); 398 398 399 399 /* scsiLuNumCommands */ 400 - return snprintf(page, PAGE_SIZE, "%llu\n", 401 - (unsigned long long)dev->num_cmds); 400 + return snprintf(page, PAGE_SIZE, "%lu\n", 401 + atomic_long_read(&dev->num_cmds)); 402 402 } 403 403 DEV_STAT_SCSI_LU_ATTR_RO(num_cmds); 404 404 ··· 409 409 container_of(sgrps, struct se_device, dev_stat_grps); 410 410 411 411 /* scsiLuReadMegaBytes */ 412 - return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->read_bytes >> 20)); 412 + return snprintf(page, PAGE_SIZE, "%lu\n", 413 + atomic_long_read(&dev->read_bytes) >> 20); 413 414 } 414 415 DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes); 415 416 ··· 421 420 container_of(sgrps, struct se_device, dev_stat_grps); 422 421 423 422 /* scsiLuWrittenMegaBytes */ 424 - return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->write_bytes >> 20)); 423 + return snprintf(page, PAGE_SIZE, "%lu\n", 424 + atomic_long_read(&dev->write_bytes) >> 20); 425 425 } 426 426 DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes); 427 427 ··· 433 431 container_of(sgrps, struct se_device, dev_stat_grps); 434 432 435 433 /* scsiLuInResets */ 436 - return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); 434 + return snprintf(page, PAGE_SIZE, "%lu\n", atomic_long_read(&dev->num_resets)); 437 435 } 438 436 DEV_STAT_SCSI_LU_ATTR_RO(resets); 439 437
+1 -3
drivers/target/target_core_tmr.c
··· 386 386 pr_debug("LUN_RESET: SCSI-2 Released reservation\n"); 387 387 } 388 388 389 - spin_lock_irq(&dev->stats_lock); 390 - dev->num_resets++; 391 - spin_unlock_irq(&dev->stats_lock); 389 + atomic_long_inc(&dev->num_resets); 392 390 393 391 pr_debug("LUN_RESET: %s for [%s] Complete\n", 394 392 (preempt_and_abort_list) ? "Preempt" : "TMR",
+26 -15
drivers/target/target_core_tpg.c
··· 116 116 117 117 return acl; 118 118 } 119 + EXPORT_SYMBOL(core_tpg_get_initiator_node_acl); 119 120 120 121 /* core_tpg_add_node_to_devs(): 121 122 * ··· 634 633 } 635 634 EXPORT_SYMBOL(core_tpg_set_initiator_node_tag); 636 635 636 + static void core_tpg_lun_ref_release(struct percpu_ref *ref) 637 + { 638 + struct se_lun *lun = container_of(ref, struct se_lun, lun_ref); 639 + 640 + complete(&lun->lun_ref_comp); 641 + } 642 + 637 643 static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) 638 644 { 639 645 /* Set in core_dev_setup_virtual_lun0() */ ··· 654 646 atomic_set(&lun->lun_acl_count, 0); 655 647 init_completion(&lun->lun_shutdown_comp); 656 648 INIT_LIST_HEAD(&lun->lun_acl_list); 657 - INIT_LIST_HEAD(&lun->lun_cmd_list); 658 649 spin_lock_init(&lun->lun_acl_lock); 659 - spin_lock_init(&lun->lun_cmd_lock); 660 650 spin_lock_init(&lun->lun_sep_lock); 651 + init_completion(&lun->lun_ref_comp); 661 652 662 - ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); 653 + ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release); 663 654 if (ret < 0) 664 655 return ret; 656 + 657 + ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); 658 + if (ret < 0) { 659 + percpu_ref_cancel_init(&lun->lun_ref); 660 + return ret; 661 + } 665 662 666 663 return 0; 667 664 } ··· 704 691 atomic_set(&lun->lun_acl_count, 0); 705 692 init_completion(&lun->lun_shutdown_comp); 706 693 INIT_LIST_HEAD(&lun->lun_acl_list); 707 - INIT_LIST_HEAD(&lun->lun_cmd_list); 708 694 spin_lock_init(&lun->lun_acl_lock); 709 - spin_lock_init(&lun->lun_cmd_lock); 710 695 spin_lock_init(&lun->lun_sep_lock); 696 + init_completion(&lun->lun_ref_comp); 711 697 } 712 698 713 699 se_tpg->se_tpg_type = se_tpg_type; ··· 827 815 { 828 816 int ret; 829 817 830 - ret = core_dev_export(lun_ptr, tpg, lun); 818 + ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release); 831 819 if (ret < 0) 832 820 return ret; 821 + 822 + ret = core_dev_export(lun_ptr, tpg, lun); 823 + if (ret < 0) { 824 + percpu_ref_cancel_init(&lun->lun_ref); 825 + return ret; 826 + } 833 827 834 828 spin_lock(&tpg->tpg_lun_lock); 835 829 lun->lun_access = lun_access; ··· 843 825 spin_unlock(&tpg->tpg_lun_lock); 844 826 845 827 return 0; 846 - } 847 - 848 - static void core_tpg_shutdown_lun( 849 - struct se_portal_group *tpg, 850 - struct se_lun *lun) 851 - { 852 - core_clear_lun_from_tpg(lun, tpg); 853 - transport_clear_lun_from_sessions(lun); 854 828 } 855 829 856 830 struct se_lun *core_tpg_pre_dellun( ··· 879 869 struct se_portal_group *tpg, 880 870 struct se_lun *lun) 881 871 { 882 - core_tpg_shutdown_lun(tpg, lun); 872 + core_clear_lun_from_tpg(lun, tpg); 873 + transport_clear_lun_ref(lun); 883 874 884 875 core_dev_unexport(lun->lun_se_dev, tpg, lun); 885 876
+14 -230
drivers/target/target_core_transport.c
··· 28 28 #include <linux/string.h> 29 29 #include <linux/timer.h> 30 30 #include <linux/slab.h> 31 - #include <linux/blkdev.h> 32 31 #include <linux/spinlock.h> 33 32 #include <linux/kthread.h> 34 33 #include <linux/in.h> ··· 472 473 pr_debug("TARGET_CORE[%s]: Deregistered fabric_sess\n", 473 474 se_tpg->se_tpg_tfo->get_fabric_name()); 474 475 /* 475 - * If last kref is dropping now for an explict NodeACL, awake sleeping 476 + * If last kref is dropping now for an explicit NodeACL, awake sleeping 476 477 * ->acl_free_comp caller to wakeup configfs se_node_acl->acl_group 477 478 * removal context. 478 479 */ ··· 513 514 spin_lock_irqsave(&cmd->t_state_lock, flags); 514 515 if (write_pending) 515 516 cmd->t_state = TRANSPORT_WRITE_PENDING; 516 - 517 - /* 518 - * Determine if IOCTL context caller in requesting the stopping of this 519 - * command for LUN shutdown purposes. 520 - */ 521 - if (cmd->transport_state & CMD_T_LUN_STOP) { 522 - pr_debug("%s:%d CMD_T_LUN_STOP for ITT: 0x%08x\n", 523 - __func__, __LINE__, cmd->se_tfo->get_task_tag(cmd)); 524 - 525 - cmd->transport_state &= ~CMD_T_ACTIVE; 526 - if (remove_from_lists) 527 - target_remove_from_state_list(cmd); 528 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 529 - 530 - complete(&cmd->transport_lun_stop_comp); 531 - return 1; 532 - } 533 517 534 518 if (remove_from_lists) { 535 519 target_remove_from_state_list(cmd); ··· 567 585 static void transport_lun_remove_cmd(struct se_cmd *cmd) 568 586 { 569 587 struct se_lun *lun = cmd->se_lun; 570 - unsigned long flags; 571 588 572 - if (!lun) 589 + if (!lun || !cmd->lun_ref_active) 573 590 return; 574 591 575 - spin_lock_irqsave(&lun->lun_cmd_lock, flags); 576 - if (!list_empty(&cmd->se_lun_node)) 577 - list_del_init(&cmd->se_lun_node); 578 - spin_unlock_irqrestore(&lun->lun_cmd_lock, flags); 592 + percpu_ref_put(&lun->lun_ref); 579 593 } 580 594 581 595 void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) ··· 646 668 cmd->transport_state |= CMD_T_FAILED; 647 669 648 670 /* 649 - * Check for case where an explict ABORT_TASK has been received 671 + * Check for case where an explicit ABORT_TASK has been received 650 672 * and transport_wait_for_tasks() will be waiting for completion.. 651 673 */ 652 674 if (cmd->transport_state & CMD_T_ABORTED && ··· 1070 1092 int task_attr, 1071 1093 unsigned char *sense_buffer) 1072 1094 { 1073 - INIT_LIST_HEAD(&cmd->se_lun_node); 1074 1095 INIT_LIST_HEAD(&cmd->se_delayed_node); 1075 1096 INIT_LIST_HEAD(&cmd->se_qf_node); 1076 1097 INIT_LIST_HEAD(&cmd->se_cmd_list); 1077 1098 INIT_LIST_HEAD(&cmd->state_list); 1078 - init_completion(&cmd->transport_lun_fe_stop_comp); 1079 - init_completion(&cmd->transport_lun_stop_comp); 1080 1099 init_completion(&cmd->t_transport_stop_comp); 1081 1100 init_completion(&cmd->cmd_wait_comp); 1082 1101 init_completion(&cmd->task_stop_comp); ··· 1694 1719 /* 1695 1720 * If the received CDB has aleady been aborted stop processing it here. 1696 1721 */ 1697 - if (transport_check_aborted_status(cmd, 1)) { 1698 - complete(&cmd->transport_lun_stop_comp); 1722 + if (transport_check_aborted_status(cmd, 1)) 1699 1723 return; 1700 - } 1701 1724 1702 - /* 1703 - * Determine if IOCTL context caller in requesting the stopping of this 1704 - * command for LUN shutdown purposes. 1705 - */ 1706 - spin_lock_irq(&cmd->t_state_lock); 1707 - if (cmd->transport_state & CMD_T_LUN_STOP) { 1708 - pr_debug("%s:%d CMD_T_LUN_STOP for ITT: 0x%08x\n", 1709 - __func__, __LINE__, cmd->se_tfo->get_task_tag(cmd)); 1710 - 1711 - cmd->transport_state &= ~CMD_T_ACTIVE; 1712 - spin_unlock_irq(&cmd->t_state_lock); 1713 - complete(&cmd->transport_lun_stop_comp); 1714 - return; 1715 - } 1716 1725 /* 1717 1726 * Determine if frontend context caller is requesting the stopping of 1718 1727 * this command for frontend exceptions. 1719 1728 */ 1729 + spin_lock_irq(&cmd->t_state_lock); 1720 1730 if (cmd->transport_state & CMD_T_STOP) { 1721 1731 pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08x\n", 1722 1732 __func__, __LINE__, ··· 2364 2404 } 2365 2405 EXPORT_SYMBOL(target_wait_for_sess_cmds); 2366 2406 2367 - /* transport_lun_wait_for_tasks(): 2368 - * 2369 - * Called from ConfigFS context to stop the passed struct se_cmd to allow 2370 - * an struct se_lun to be successfully shutdown. 2371 - */ 2372 - static int transport_lun_wait_for_tasks(struct se_cmd *cmd, struct se_lun *lun) 2373 - { 2374 - unsigned long flags; 2375 - int ret = 0; 2376 - 2377 - /* 2378 - * If the frontend has already requested this struct se_cmd to 2379 - * be stopped, we can safely ignore this struct se_cmd. 2380 - */ 2381 - spin_lock_irqsave(&cmd->t_state_lock, flags); 2382 - if (cmd->transport_state & CMD_T_STOP) { 2383 - cmd->transport_state &= ~CMD_T_LUN_STOP; 2384 - 2385 - pr_debug("ConfigFS ITT[0x%08x] - CMD_T_STOP, skipping\n", 2386 - cmd->se_tfo->get_task_tag(cmd)); 2387 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2388 - transport_cmd_check_stop(cmd, false, false); 2389 - return -EPERM; 2390 - } 2391 - cmd->transport_state |= CMD_T_LUN_FE_STOP; 2392 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2393 - 2394 - // XXX: audit task_flags checks. 2395 - spin_lock_irqsave(&cmd->t_state_lock, flags); 2396 - if ((cmd->transport_state & CMD_T_BUSY) && 2397 - (cmd->transport_state & CMD_T_SENT)) { 2398 - if (!target_stop_cmd(cmd, &flags)) 2399 - ret++; 2400 - } 2401 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2402 - 2403 - pr_debug("ConfigFS: cmd: %p stop tasks ret:" 2404 - " %d\n", cmd, ret); 2405 - if (!ret) { 2406 - pr_debug("ConfigFS: ITT[0x%08x] - stopping cmd....\n", 2407 - cmd->se_tfo->get_task_tag(cmd)); 2408 - wait_for_completion(&cmd->transport_lun_stop_comp); 2409 - pr_debug("ConfigFS: ITT[0x%08x] - stopped cmd....\n", 2410 - cmd->se_tfo->get_task_tag(cmd)); 2411 - } 2412 - 2413 - return 0; 2414 - } 2415 - 2416 - static void __transport_clear_lun_from_sessions(struct se_lun *lun) 2417 - { 2418 - struct se_cmd *cmd = NULL; 2419 - unsigned long lun_flags, cmd_flags; 2420 - /* 2421 - * Do exception processing and return CHECK_CONDITION status to the 2422 - * Initiator Port. 2423 - */ 2424 - spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags); 2425 - while (!list_empty(&lun->lun_cmd_list)) { 2426 - cmd = list_first_entry(&lun->lun_cmd_list, 2427 - struct se_cmd, se_lun_node); 2428 - list_del_init(&cmd->se_lun_node); 2429 - 2430 - spin_lock(&cmd->t_state_lock); 2431 - pr_debug("SE_LUN[%d] - Setting cmd->transport" 2432 - "_lun_stop for ITT: 0x%08x\n", 2433 - cmd->se_lun->unpacked_lun, 2434 - cmd->se_tfo->get_task_tag(cmd)); 2435 - cmd->transport_state |= CMD_T_LUN_STOP; 2436 - spin_unlock(&cmd->t_state_lock); 2437 - 2438 - spin_unlock_irqrestore(&lun->lun_cmd_lock, lun_flags); 2439 - 2440 - if (!cmd->se_lun) { 2441 - pr_err("ITT: 0x%08x, [i,t]_state: %u/%u\n", 2442 - cmd->se_tfo->get_task_tag(cmd), 2443 - cmd->se_tfo->get_cmd_state(cmd), cmd->t_state); 2444 - BUG(); 2445 - } 2446 - /* 2447 - * If the Storage engine still owns the iscsi_cmd_t, determine 2448 - * and/or stop its context. 2449 - */ 2450 - pr_debug("SE_LUN[%d] - ITT: 0x%08x before transport" 2451 - "_lun_wait_for_tasks()\n", cmd->se_lun->unpacked_lun, 2452 - cmd->se_tfo->get_task_tag(cmd)); 2453 - 2454 - if (transport_lun_wait_for_tasks(cmd, cmd->se_lun) < 0) { 2455 - spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags); 2456 - continue; 2457 - } 2458 - 2459 - pr_debug("SE_LUN[%d] - ITT: 0x%08x after transport_lun" 2460 - "_wait_for_tasks(): SUCCESS\n", 2461 - cmd->se_lun->unpacked_lun, 2462 - cmd->se_tfo->get_task_tag(cmd)); 2463 - 2464 - spin_lock_irqsave(&cmd->t_state_lock, cmd_flags); 2465 - if (!(cmd->transport_state & CMD_T_DEV_ACTIVE)) { 2466 - spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags); 2467 - goto check_cond; 2468 - } 2469 - cmd->transport_state &= ~CMD_T_DEV_ACTIVE; 2470 - target_remove_from_state_list(cmd); 2471 - spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags); 2472 - 2473 - /* 2474 - * The Storage engine stopped this struct se_cmd before it was 2475 - * send to the fabric frontend for delivery back to the 2476 - * Initiator Node. Return this SCSI CDB back with an 2477 - * CHECK_CONDITION status. 2478 - */ 2479 - check_cond: 2480 - transport_send_check_condition_and_sense(cmd, 2481 - TCM_NON_EXISTENT_LUN, 0); 2482 - /* 2483 - * If the fabric frontend is waiting for this iscsi_cmd_t to 2484 - * be released, notify the waiting thread now that LU has 2485 - * finished accessing it. 2486 - */ 2487 - spin_lock_irqsave(&cmd->t_state_lock, cmd_flags); 2488 - if (cmd->transport_state & CMD_T_LUN_FE_STOP) { 2489 - pr_debug("SE_LUN[%d] - Detected FE stop for" 2490 - " struct se_cmd: %p ITT: 0x%08x\n", 2491 - lun->unpacked_lun, 2492 - cmd, cmd->se_tfo->get_task_tag(cmd)); 2493 - 2494 - spin_unlock_irqrestore(&cmd->t_state_lock, 2495 - cmd_flags); 2496 - transport_cmd_check_stop(cmd, false, false); 2497 - complete(&cmd->transport_lun_fe_stop_comp); 2498 - spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags); 2499 - continue; 2500 - } 2501 - pr_debug("SE_LUN[%d] - ITT: 0x%08x finished processing\n", 2502 - lun->unpacked_lun, cmd->se_tfo->get_task_tag(cmd)); 2503 - 2504 - spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags); 2505 - spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags); 2506 - } 2507 - spin_unlock_irqrestore(&lun->lun_cmd_lock, lun_flags); 2508 - } 2509 - 2510 - static int transport_clear_lun_thread(void *p) 2407 + static int transport_clear_lun_ref_thread(void *p) 2511 2408 { 2512 2409 struct se_lun *lun = p; 2513 2410 2514 - __transport_clear_lun_from_sessions(lun); 2411 + percpu_ref_kill(&lun->lun_ref); 2412 + 2413 + wait_for_completion(&lun->lun_ref_comp); 2515 2414 complete(&lun->lun_shutdown_comp); 2516 2415 2517 2416 return 0; 2518 2417 } 2519 2418 2520 - int transport_clear_lun_from_sessions(struct se_lun *lun) 2419 + int transport_clear_lun_ref(struct se_lun *lun) 2521 2420 { 2522 2421 struct task_struct *kt; 2523 2422 2524 - kt = kthread_run(transport_clear_lun_thread, lun, 2423 + kt = kthread_run(transport_clear_lun_ref_thread, lun, 2525 2424 "tcm_cl_%u", lun->unpacked_lun); 2526 2425 if (IS_ERR(kt)) { 2527 2426 pr_err("Unable to start clear_lun thread\n"); ··· 2413 2594 !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) { 2414 2595 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2415 2596 return false; 2416 - } 2417 - /* 2418 - * If we are already stopped due to an external event (ie: LUN shutdown) 2419 - * sleep until the connection can have the passed struct se_cmd back. 2420 - * The cmd->transport_lun_stopped_sem will be upped by 2421 - * transport_clear_lun_from_sessions() once the ConfigFS context caller 2422 - * has completed its operation on the struct se_cmd. 2423 - */ 2424 - if (cmd->transport_state & CMD_T_LUN_STOP) { 2425 - pr_debug("wait_for_tasks: Stopping" 2426 - " wait_for_completion(&cmd->t_tasktransport_lun_fe" 2427 - "_stop_comp); for ITT: 0x%08x\n", 2428 - cmd->se_tfo->get_task_tag(cmd)); 2429 - /* 2430 - * There is a special case for WRITES where a FE exception + 2431 - * LUN shutdown means ConfigFS context is still sleeping on 2432 - * transport_lun_stop_comp in transport_lun_wait_for_tasks(). 2433 - * We go ahead and up transport_lun_stop_comp just to be sure 2434 - * here. 2435 - */ 2436 - spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2437 - complete(&cmd->transport_lun_stop_comp); 2438 - wait_for_completion(&cmd->transport_lun_fe_stop_comp); 2439 - spin_lock_irqsave(&cmd->t_state_lock, flags); 2440 - 2441 - target_remove_from_state_list(cmd); 2442 - /* 2443 - * At this point, the frontend who was the originator of this 2444 - * struct se_cmd, now owns the structure and can be released through 2445 - * normal means below. 2446 - */ 2447 - pr_debug("wait_for_tasks: Stopped" 2448 - " wait_for_completion(&cmd->t_tasktransport_lun_fe_" 2449 - "stop_comp); for ITT: 0x%08x\n", 2450 - cmd->se_tfo->get_task_tag(cmd)); 2451 - 2452 - cmd->transport_state &= ~CMD_T_LUN_STOP; 2453 2597 } 2454 2598 2455 2599 if (!(cmd->transport_state & CMD_T_ACTIVE)) { ··· 2692 2910 cmd->t_task_cdb[0], cmd->se_tfo->get_task_tag(cmd)); 2693 2911 2694 2912 cmd->se_cmd_flags |= SCF_SENT_DELAYED_TAS; 2913 + cmd->scsi_status = SAM_STAT_TASK_ABORTED; 2695 2914 trace_target_cmd_complete(cmd); 2696 2915 cmd->se_tfo->queue_status(cmd); 2697 2916 ··· 2721 2938 if (cmd->se_tfo->write_pending_status(cmd) != 0) { 2722 2939 cmd->transport_state |= CMD_T_ABORTED; 2723 2940 smp_mb__after_atomic_inc(); 2941 + return; 2724 2942 } 2725 2943 } 2726 2944 cmd->scsi_status = SAM_STAT_TASK_ABORTED;
+1 -1
drivers/target/target_core_ua.h
··· 19 19 #define ASCQ_2AH_RESERVATIONS_RELEASED 0x04 20 20 #define ASCQ_2AH_REGISTRATIONS_PREEMPTED 0x05 21 21 #define ASCQ_2AH_ASYMMETRIC_ACCESS_STATE_CHANGED 0x06 22 - #define ASCQ_2AH_IMPLICT_ASYMMETRIC_ACCESS_STATE_TRANSITION_FAILED 0x07 22 + #define ASCQ_2AH_IMPLICIT_ASYMMETRIC_ACCESS_STATE_TRANSITION_FAILED 0x07 23 23 #define ASCQ_2AH_PRIORITY_CHANGED 0x08 24 24 25 25 #define ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS 0x09
+1 -18
drivers/target/target_core_xcopy.c
··· 405 405 struct xcopy_pt_cmd *xpt_cmd = container_of(se_cmd, 406 406 struct xcopy_pt_cmd, se_cmd); 407 407 408 - if (xpt_cmd->remote_port) 409 - kfree(se_cmd->se_lun); 410 - 411 408 kfree(xpt_cmd); 412 409 } 413 410 ··· 569 572 return 0; 570 573 } 571 574 572 - pt_cmd->se_lun = kzalloc(sizeof(struct se_lun), GFP_KERNEL); 573 - if (!pt_cmd->se_lun) { 574 - pr_err("Unable to allocate pt_cmd->se_lun\n"); 575 - return -ENOMEM; 576 - } 577 - init_completion(&pt_cmd->se_lun->lun_shutdown_comp); 578 - INIT_LIST_HEAD(&pt_cmd->se_lun->lun_cmd_list); 579 - INIT_LIST_HEAD(&pt_cmd->se_lun->lun_acl_list); 580 - spin_lock_init(&pt_cmd->se_lun->lun_acl_lock); 581 - spin_lock_init(&pt_cmd->se_lun->lun_cmd_lock); 582 - spin_lock_init(&pt_cmd->se_lun->lun_sep_lock); 583 - 575 + pt_cmd->se_lun = &se_dev->xcopy_lun; 584 576 pt_cmd->se_dev = se_dev; 585 577 586 578 pr_debug("Setup emulated se_dev: %p from se_dev\n", pt_cmd->se_dev); 587 - pt_cmd->se_lun->lun_se_dev = se_dev; 588 579 pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD | SCF_CMD_XCOPY_PASSTHROUGH; 589 580 590 581 pr_debug("Setup emulated se_dev: %p to pt_cmd->se_lun->lun_se_dev\n", ··· 643 658 return 0; 644 659 645 660 out: 646 - if (remote_port == true) 647 - kfree(cmd->se_lun); 648 661 return ret; 649 662 } 650 663
+1
drivers/target/tcm_fc/tcm_fc.h
··· 22 22 #define FT_NAMELEN 32 /* length of ASCII WWPNs including pad */ 23 23 #define FT_TPG_NAMELEN 32 /* max length of TPG name */ 24 24 #define FT_LUN_NAMELEN 32 /* max length of LUN name */ 25 + #define TCM_FC_DEFAULT_TAGS 512 /* tags used for per-session preallocation */ 25 26 26 27 struct ft_transport_id { 27 28 __u8 format;
+14 -4
drivers/target/tcm_fc/tfc_cmd.c
··· 28 28 #include <linux/configfs.h> 29 29 #include <linux/ctype.h> 30 30 #include <linux/hash.h> 31 + #include <linux/percpu_ida.h> 31 32 #include <asm/unaligned.h> 32 33 #include <scsi/scsi.h> 33 34 #include <scsi/scsi_host.h> ··· 90 89 { 91 90 struct fc_frame *fp; 92 91 struct fc_lport *lport; 92 + struct se_session *se_sess; 93 93 94 94 if (!cmd) 95 95 return; 96 + se_sess = cmd->sess->se_sess; 96 97 fp = cmd->req_frame; 97 98 lport = fr_dev(fp); 98 99 if (fr_seq(fp)) 99 100 lport->tt.seq_release(fr_seq(fp)); 100 101 fc_frame_free(fp); 102 + percpu_ida_free(&se_sess->sess_tag_pool, cmd->se_cmd.map_tag); 101 103 ft_sess_put(cmd->sess); /* undo get from lookup at recv */ 102 - kfree(cmd); 103 104 } 104 105 105 106 void ft_release_cmd(struct se_cmd *se_cmd) ··· 435 432 { 436 433 struct ft_cmd *cmd; 437 434 struct fc_lport *lport = sess->tport->lport; 435 + struct se_session *se_sess = sess->se_sess; 436 + int tag; 438 437 439 - cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC); 440 - if (!cmd) 438 + tag = percpu_ida_alloc(&se_sess->sess_tag_pool, GFP_ATOMIC); 439 + if (tag < 0) 441 440 goto busy; 441 + 442 + cmd = &((struct ft_cmd *)se_sess->sess_cmd_map)[tag]; 443 + memset(cmd, 0, sizeof(struct ft_cmd)); 444 + 445 + cmd->se_cmd.map_tag = tag; 442 446 cmd->sess = sess; 443 447 cmd->seq = lport->tt.seq_assign(lport, fp); 444 448 if (!cmd->seq) { 445 - kfree(cmd); 449 + percpu_ida_free(&se_sess->sess_tag_pool, tag); 446 450 goto busy; 447 451 } 448 452 cmd->req_frame = fp; /* hold frame during cmd */
+9 -9
drivers/target/tcm_fc/tfc_conf.c
··· 571 571 /* 572 572 * Setup default attribute lists for various fabric->tf_cit_tmpl 573 573 */ 574 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = ft_wwn_attrs; 575 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL; 576 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; 577 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 578 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 579 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = 574 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = ft_wwn_attrs; 575 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = NULL; 576 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 577 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 578 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 579 + fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = 580 580 ft_nacl_base_attrs; 581 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 582 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 583 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; 581 + fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 582 + fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 583 + fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL; 584 584 /* 585 585 * register the fabric for use within TCM 586 586 */
+2 -1
drivers/target/tcm_fc/tfc_sess.c
··· 210 210 if (!sess) 211 211 return NULL; 212 212 213 - sess->se_sess = transport_init_session(); 213 + sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS, 214 + sizeof(struct ft_cmd)); 214 215 if (IS_ERR(sess->se_sess)) { 215 216 kfree(sess); 216 217 return NULL;
+9 -9
drivers/usb/gadget/tcm_usb_gadget.c
··· 1923 1923 } 1924 1924 1925 1925 fabric->tf_ops = usbg_ops; 1926 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = usbg_wwn_attrs; 1927 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = usbg_base_attrs; 1928 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; 1929 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 1930 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 1931 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL; 1932 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 1933 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 1934 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; 1926 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = usbg_wwn_attrs; 1927 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = usbg_base_attrs; 1928 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 1929 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 1930 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 1931 + fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL; 1932 + fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 1933 + fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 1934 + fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL; 1935 1935 ret = target_fabric_configfs_register(fabric); 1936 1936 if (ret < 0) { 1937 1937 printk(KERN_ERR "target_fabric_configfs_register() failed"
+9 -9
drivers/vhost/scsi.c
··· 2168 2168 /* 2169 2169 * Setup default attribute lists for various fabric->tf_cit_tmpl 2170 2170 */ 2171 - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = tcm_vhost_wwn_attrs; 2172 - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = tcm_vhost_tpg_attrs; 2173 - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; 2174 - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; 2175 - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; 2176 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL; 2177 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 2178 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 2179 - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; 2171 + fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_vhost_wwn_attrs; 2172 + fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_vhost_tpg_attrs; 2173 + fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 2174 + fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 2175 + fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 2176 + fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL; 2177 + fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; 2178 + fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL; 2179 + fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL; 2180 2180 /* 2181 2181 * Register the fabric for use within TCM 2182 2182 */
+5
include/target/target_core_backend.h
··· 34 34 sense_reason_t (*parse_cdb)(struct se_cmd *cmd); 35 35 u32 (*get_device_type)(struct se_device *); 36 36 sector_t (*get_blocks)(struct se_device *); 37 + sector_t (*get_alignment_offset_lbas)(struct se_device *); 38 + /* lbppbe = logical blocks per physical block exponent. see SBC-3 */ 39 + unsigned int (*get_lbppbe)(struct se_device *); 40 + unsigned int (*get_io_min)(struct se_device *); 41 + unsigned int (*get_io_opt)(struct se_device *); 37 42 unsigned char *(*get_sense_buffer)(struct se_cmd *); 38 43 bool (*get_write_cache)(struct se_device *); 39 44 };
+42 -42
include/target/target_core_base.h
··· 227 227 228 228 /* fabric independent task management response values */ 229 229 enum tcm_tmrsp_table { 230 + TMR_FUNCTION_FAILED = 0, 230 231 TMR_FUNCTION_COMPLETE = 1, 231 232 TMR_TASK_DOES_NOT_EXIST = 2, 232 233 TMR_LUN_DOES_NOT_EXIST = 3, ··· 283 282 struct t10_alua_tg_pt_gp { 284 283 u16 tg_pt_gp_id; 285 284 int tg_pt_gp_valid_id; 285 + int tg_pt_gp_alua_supported_states; 286 286 int tg_pt_gp_alua_access_status; 287 287 int tg_pt_gp_alua_access_type; 288 288 int tg_pt_gp_nonop_delay_msecs; 289 289 int tg_pt_gp_trans_delay_msecs; 290 - int tg_pt_gp_implict_trans_secs; 290 + int tg_pt_gp_implicit_trans_secs; 291 291 int tg_pt_gp_pref; 292 292 int tg_pt_gp_write_metadata; 293 293 /* Used by struct t10_alua_tg_pt_gp->tg_pt_gp_md_buf_len */ ··· 444 442 /* Used for sense data */ 445 443 void *sense_buffer; 446 444 struct list_head se_delayed_node; 447 - struct list_head se_lun_node; 448 445 struct list_head se_qf_node; 449 446 struct se_device *se_dev; 450 447 struct se_dev_entry *se_deve; ··· 471 470 #define CMD_T_SENT (1 << 4) 472 471 #define CMD_T_STOP (1 << 5) 473 472 #define CMD_T_FAILED (1 << 6) 474 - #define CMD_T_LUN_STOP (1 << 7) 475 - #define CMD_T_LUN_FE_STOP (1 << 8) 476 - #define CMD_T_DEV_ACTIVE (1 << 9) 477 - #define CMD_T_REQUEST_STOP (1 << 10) 478 - #define CMD_T_BUSY (1 << 11) 473 + #define CMD_T_DEV_ACTIVE (1 << 7) 474 + #define CMD_T_REQUEST_STOP (1 << 8) 475 + #define CMD_T_BUSY (1 << 9) 479 476 spinlock_t t_state_lock; 480 477 struct completion t_transport_stop_comp; 481 - struct completion transport_lun_fe_stop_comp; 482 - struct completion transport_lun_stop_comp; 483 478 484 479 struct work_struct work; 485 480 ··· 495 498 496 499 /* backend private data */ 497 500 void *priv; 501 + 502 + /* Used for lun->lun_ref counting */ 503 + bool lun_ref_active; 498 504 }; 499 505 500 506 struct se_ua { ··· 628 628 struct config_group da_group; 629 629 }; 630 630 631 + struct se_port_stat_grps { 632 + struct config_group stat_group; 633 + struct config_group scsi_port_group; 634 + struct config_group scsi_tgt_port_group; 635 + struct config_group scsi_transport_group; 636 + }; 637 + 638 + struct se_lun { 639 + #define SE_LUN_LINK_MAGIC 0xffff7771 640 + u32 lun_link_magic; 641 + /* See transport_lun_status_table */ 642 + enum transport_lun_status_table lun_status; 643 + u32 lun_access; 644 + u32 lun_flags; 645 + u32 unpacked_lun; 646 + atomic_t lun_acl_count; 647 + spinlock_t lun_acl_lock; 648 + spinlock_t lun_sep_lock; 649 + struct completion lun_shutdown_comp; 650 + struct list_head lun_acl_list; 651 + struct se_device *lun_se_dev; 652 + struct se_port *lun_sep; 653 + struct config_group lun_group; 654 + struct se_port_stat_grps port_stat_grps; 655 + struct completion lun_ref_comp; 656 + struct percpu_ref lun_ref; 657 + }; 658 + 631 659 struct se_dev_stat_grps { 632 660 struct config_group stat_group; 633 661 struct config_group scsi_dev_group; ··· 684 656 /* Pointer to transport specific device structure */ 685 657 u32 dev_index; 686 658 u64 creation_time; 687 - u32 num_resets; 688 - u64 num_cmds; 689 - u64 read_bytes; 690 - u64 write_bytes; 691 - spinlock_t stats_lock; 659 + atomic_long_t num_resets; 660 + atomic_long_t num_cmds; 661 + atomic_long_t read_bytes; 662 + atomic_long_t write_bytes; 692 663 /* Active commands on this virtual SE device */ 693 664 atomic_t simple_cmds; 694 665 atomic_t dev_ordered_id; ··· 738 711 struct se_subsystem_api *transport; 739 712 /* Linked list for struct se_hba struct se_device list */ 740 713 struct list_head dev_list; 714 + struct se_lun xcopy_lun; 741 715 }; 742 716 743 717 struct se_hba { ··· 756 728 struct config_group hba_group; 757 729 struct mutex hba_access_mutex; 758 730 struct se_subsystem_api *transport; 759 - }; 760 - 761 - struct se_port_stat_grps { 762 - struct config_group stat_group; 763 - struct config_group scsi_port_group; 764 - struct config_group scsi_tgt_port_group; 765 - struct config_group scsi_transport_group; 766 - }; 767 - 768 - struct se_lun { 769 - #define SE_LUN_LINK_MAGIC 0xffff7771 770 - u32 lun_link_magic; 771 - /* See transport_lun_status_table */ 772 - enum transport_lun_status_table lun_status; 773 - u32 lun_access; 774 - u32 lun_flags; 775 - u32 unpacked_lun; 776 - atomic_t lun_acl_count; 777 - spinlock_t lun_acl_lock; 778 - spinlock_t lun_cmd_lock; 779 - spinlock_t lun_sep_lock; 780 - struct completion lun_shutdown_comp; 781 - struct list_head lun_cmd_list; 782 - struct list_head lun_acl_list; 783 - struct se_device *lun_se_dev; 784 - struct se_port *lun_sep; 785 - struct config_group lun_group; 786 - struct se_port_stat_grps port_stat_grps; 787 731 }; 788 732 789 733 struct scsi_port_stats {
-1
include/target/target_core_configfs.h
··· 54 54 struct target_fabric_configfs_template tf_cit_tmpl; 55 55 }; 56 56 57 - #define TF_CIT_TMPL(tf) (&(tf)->tf_cit_tmpl)
+2
include/target/target_core_fabric.h
··· 137 137 void __target_execute_cmd(struct se_cmd *); 138 138 int transport_lookup_tmr_lun(struct se_cmd *, u32); 139 139 140 + struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg, 141 + unsigned char *); 140 142 struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *, 141 143 unsigned char *); 142 144 void core_tpg_clear_object_luns(struct se_portal_group *);
+2 -2
lib/Makefile
··· 13 13 sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ 14 14 proportions.o flex_proportions.o prio_heap.o ratelimit.o show_mem.o \ 15 15 is_single_threaded.o plist.o decompress.o kobject_uevent.o \ 16 - earlycpio.o percpu-refcount.o percpu_ida.o 16 + earlycpio.o 17 17 18 18 obj-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o 19 19 lib-$(CONFIG_MMU) += ioremap.o ··· 26 26 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ 27 27 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \ 28 28 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \ 29 - percpu_ida.o 29 + percpu-refcount.o percpu_ida.o 30 30 obj-y += string_helpers.o 31 31 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o 32 32 obj-y += kstrtox.o
+2 -3
lib/percpu_ida.c
··· 117 117 min(pool->nr_free, pool->percpu_batch_size)); 118 118 } 119 119 120 - static inline unsigned alloc_local_tag(struct percpu_ida *pool, 121 - struct percpu_ida_cpu *tags) 120 + static inline unsigned alloc_local_tag(struct percpu_ida_cpu *tags) 122 121 { 123 122 int tag = -ENOSPC; 124 123 ··· 158 159 tags = this_cpu_ptr(pool->tag_cpu); 159 160 160 161 /* Fastpath */ 161 - tag = alloc_local_tag(pool, tags); 162 + tag = alloc_local_tag(tags); 162 163 if (likely(tag >= 0)) { 163 164 local_irq_restore(flags); 164 165 return tag;