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 git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending

Pull SCSI target fixes from Nicholas Bellinger:
"These are mostly minor fixes, with the exception of the following that
address fall-out from recent v4.1-rc1 changes:

- regression fix related to the big fabric API registration changes
and configfs_depend_item() usage, that required cherry-picking one
of HCH's patches from for-next to address the issue for v4.1 code.

- remaining TCM-USER -v2 related changes to enforce full CDB
passthrough from Andy + Ilias.

Also included is a target_core_pscsi driver fix from Andy that
addresses a long standing issue with a Scsi_Host reference being
leaked on PSCSI device shutdown"

* git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
iser-target: Fix error path in isert_create_pi_ctx()
target: Use a PASSTHROUGH flag instead of transport_types
target: Move passthrough CDB parsing into a common function
target/user: Only support full command pass-through
target/user: Update example code for new ABI requirements
target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST
target: Fix se_tpg_tfo->tf_subsys regression + remove tf_subsystem
target: Drop signal_pending checks after interruptible lock acquire
target: Add missing parentheses
target: Fix bidi command handling
target/user: Disallow full passthrough (pass_level=0)
ISCSI: fix minor memory leak

+180 -287
+7 -26
Documentation/target/tcmu-design.txt
··· 15 15 a) Discovering and configuring TCMU uio devices 16 16 b) Waiting for events on the device(s) 17 17 c) Managing the command ring 18 - 3) Command filtering and pass_level 19 - 4) A final note 18 + 3) A final note 20 19 21 20 22 21 TCM Userspace Design ··· 323 324 /* Process events from cmd ring until we catch up with cmd_head */ 324 325 while (ent != (void *)mb + mb->cmdr_off + mb->cmd_head) { 325 326 326 - if (tcmu_hdr_get_op(&ent->hdr) == TCMU_OP_CMD) { 327 + if (tcmu_hdr_get_op(ent->hdr.len_op) == TCMU_OP_CMD) { 327 328 uint8_t *cdb = (void *)mb + ent->req.cdb_off; 328 329 bool success = true; 329 330 ··· 338 339 ent->rsp.scsi_status = SCSI_CHECK_CONDITION; 339 340 } 340 341 } 342 + else if (tcmu_hdr_get_op(ent->hdr.len_op) != TCMU_OP_PAD) { 343 + /* Tell the kernel we didn't handle unknown opcodes */ 344 + ent->hdr.uflags |= TCMU_UFLAG_UNKNOWN_OP; 345 + } 341 346 else { 342 - /* Do nothing for PAD entries */ 347 + /* Do nothing for PAD entries except update cmd_tail */ 343 348 } 344 349 345 350 /* update cmd_tail */ ··· 361 358 362 359 return 0; 363 360 } 364 - 365 - 366 - Command filtering and pass_level 367 - -------------------------------- 368 - 369 - TCMU supports a "pass_level" option with valid values of 0 or 1. When 370 - the value is 0 (the default), nearly all SCSI commands received for 371 - the device are passed through to the handler. This allows maximum 372 - flexibility but increases the amount of code required by the handler, 373 - to support all mandatory SCSI commands. If pass_level is set to 1, 374 - then only IO-related commands are presented, and the rest are handled 375 - by LIO's in-kernel command emulation. The commands presented at level 376 - 1 include all versions of: 377 - 378 - READ 379 - WRITE 380 - WRITE_VERIFY 381 - XDWRITEREAD 382 - WRITE_SAME 383 - COMPARE_AND_WRITE 384 - SYNCHRONIZE_CACHE 385 - UNMAP 386 361 387 362 388 363 A final note
+3 -3
drivers/infiniband/ulp/isert/ib_isert.c
··· 547 547 return 0; 548 548 549 549 err_prot_mr: 550 - ib_dereg_mr(desc->pi_ctx->prot_mr); 550 + ib_dereg_mr(pi_ctx->prot_mr); 551 551 err_prot_frpl: 552 - ib_free_fast_reg_page_list(desc->pi_ctx->prot_frpl); 552 + ib_free_fast_reg_page_list(pi_ctx->prot_frpl); 553 553 err_pi_ctx: 554 - kfree(desc->pi_ctx); 554 + kfree(pi_ctx); 555 555 556 556 return ret; 557 557 }
+2 -4
drivers/scsi/qla2xxx/tcm_qla2xxx.c
··· 1020 1020 struct se_portal_group *se_tpg = &base_tpg->se_tpg; 1021 1021 struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha; 1022 1022 1023 - if (!configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys, 1024 - &se_tpg->tpg_group.cg_item)) { 1023 + if (!target_depend_item(&se_tpg->tpg_group.cg_item)) { 1025 1024 atomic_set(&base_tpg->lport_tpg_enabled, 1); 1026 1025 qlt_enable_vha(base_vha); 1027 1026 } ··· 1036 1037 1037 1038 if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) { 1038 1039 atomic_set(&base_tpg->lport_tpg_enabled, 0); 1039 - configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys, 1040 - &se_tpg->tpg_group.cg_item); 1040 + target_undepend_item(&se_tpg->tpg_group.cg_item); 1041 1041 } 1042 1042 complete(&base_tpg->tpg_base_comp); 1043 1043 }
+1 -1
drivers/target/iscsi/iscsi_target.c
··· 230 230 * Here we serialize access across the TIQN+TPG Tuple. 231 231 */ 232 232 ret = down_interruptible(&tpg->np_login_sem); 233 - if ((ret != 0) || signal_pending(current)) 233 + if (ret != 0) 234 234 return -1; 235 235 236 236 spin_lock_bh(&tpg->tpg_state_lock);
+1
drivers/target/iscsi/iscsi_target_login.c
··· 346 346 if (IS_ERR(sess->se_sess)) { 347 347 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 348 348 ISCSI_LOGIN_STATUS_NO_RESOURCES); 349 + kfree(sess->sess_ops); 349 350 kfree(sess); 350 351 return -ENOMEM; 351 352 }
+1 -4
drivers/target/iscsi/iscsi_target_tpg.c
··· 161 161 int iscsit_get_tpg( 162 162 struct iscsi_portal_group *tpg) 163 163 { 164 - int ret; 165 - 166 - ret = mutex_lock_interruptible(&tpg->tpg_access_lock); 167 - return ((ret != 0) || signal_pending(current)) ? -1 : 0; 164 + return mutex_lock_interruptible(&tpg->tpg_access_lock); 168 165 } 169 166 170 167 void iscsit_put_tpg(struct iscsi_portal_group *tpg)
+2 -2
drivers/target/target_core_alua.c
··· 704 704 705 705 if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) 706 706 return 0; 707 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 707 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 708 708 return 0; 709 709 710 710 if (!port) ··· 2377 2377 2378 2378 int core_setup_alua(struct se_device *dev) 2379 2379 { 2380 - if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV && 2380 + if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) && 2381 2381 !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) { 2382 2382 struct t10_alua_lu_gp_member *lu_gp_mem; 2383 2383
+19 -21
drivers/target/target_core_configfs.c
··· 212 212 213 213 pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:" 214 214 " %s\n", tf->tf_group.cg_item.ci_name); 215 - /* 216 - * Setup tf_ops.tf_subsys pointer for usage with configfs_depend_item() 217 - */ 218 - tf->tf_ops.tf_subsys = tf->tf_subsys; 219 215 tf->tf_fabric = &tf->tf_group.cg_item; 220 216 pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric" 221 217 " for %s\n", name); ··· 287 291 }, 288 292 }; 289 293 290 - struct configfs_subsystem *target_core_subsystem[] = { 291 - &target_core_fabrics, 292 - NULL, 293 - }; 294 + int target_depend_item(struct config_item *item) 295 + { 296 + return configfs_depend_item(&target_core_fabrics, item); 297 + } 298 + EXPORT_SYMBOL(target_depend_item); 299 + 300 + void target_undepend_item(struct config_item *item) 301 + { 302 + return configfs_undepend_item(&target_core_fabrics, item); 303 + } 304 + EXPORT_SYMBOL(target_undepend_item); 294 305 295 306 /*############################################################################## 296 307 // Start functions called by external Target Fabrics Modules ··· 470 467 * struct target_fabric_configfs->tf_cit_tmpl 471 468 */ 472 469 tf->tf_module = fo->module; 473 - tf->tf_subsys = target_core_subsystem[0]; 474 470 snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", fo->name); 475 471 476 472 tf->tf_ops = *fo; ··· 811 809 { 812 810 int ret; 813 811 814 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 812 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 815 813 return sprintf(page, "Passthrough\n"); 816 814 817 815 spin_lock(&dev->dev_reservation_lock); ··· 962 960 static ssize_t target_core_dev_pr_show_attr_res_type( 963 961 struct se_device *dev, char *page) 964 962 { 965 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 963 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 966 964 return sprintf(page, "SPC_PASSTHROUGH\n"); 967 965 else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) 968 966 return sprintf(page, "SPC2_RESERVATIONS\n"); ··· 975 973 static ssize_t target_core_dev_pr_show_attr_res_aptpl_active( 976 974 struct se_device *dev, char *page) 977 975 { 978 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 976 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 979 977 return 0; 980 978 981 979 return sprintf(page, "APTPL Bit Status: %s\n", ··· 990 988 static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata( 991 989 struct se_device *dev, char *page) 992 990 { 993 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 991 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 994 992 return 0; 995 993 996 994 return sprintf(page, "Ready to process PR APTPL metadata..\n"); ··· 1037 1035 u16 port_rpti = 0, tpgt = 0; 1038 1036 u8 type = 0, scope; 1039 1037 1040 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 1038 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1041 1039 return 0; 1042 1040 if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) 1043 1041 return 0; ··· 2872 2870 { 2873 2871 struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL; 2874 2872 struct config_group *lu_gp_cg = NULL; 2875 - struct configfs_subsystem *subsys; 2873 + struct configfs_subsystem *subsys = &target_core_fabrics; 2876 2874 struct t10_alua_lu_gp *lu_gp; 2877 2875 int ret; 2878 2876 ··· 2880 2878 " Engine: %s on %s/%s on "UTS_RELEASE"\n", 2881 2879 TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine); 2882 2880 2883 - subsys = target_core_subsystem[0]; 2884 2881 config_group_init(&subsys->su_group); 2885 2882 mutex_init(&subsys->su_mutex); 2886 2883 ··· 3009 3008 3010 3009 static void __exit target_core_exit_configfs(void) 3011 3010 { 3012 - struct configfs_subsystem *subsys; 3013 3011 struct config_group *hba_cg, *alua_cg, *lu_gp_cg; 3014 3012 struct config_item *item; 3015 3013 int i; 3016 - 3017 - subsys = target_core_subsystem[0]; 3018 3014 3019 3015 lu_gp_cg = &alua_lu_gps_group; 3020 3016 for (i = 0; lu_gp_cg->default_groups[i]; i++) { ··· 3043 3045 * We expect subsys->su_group.default_groups to be released 3044 3046 * by configfs subsystem provider logic.. 3045 3047 */ 3046 - configfs_unregister_subsystem(subsys); 3047 - kfree(subsys->su_group.default_groups); 3048 + configfs_unregister_subsystem(&target_core_fabrics); 3049 + kfree(target_core_fabrics.su_group.default_groups); 3048 3050 3049 3051 core_alua_free_lu_gp(default_lu_gp); 3050 3052 default_lu_gp = NULL;
+76 -2
drivers/target/target_core_device.c
··· 33 33 #include <linux/kthread.h> 34 34 #include <linux/in.h> 35 35 #include <linux/export.h> 36 + #include <asm/unaligned.h> 36 37 #include <net/sock.h> 37 38 #include <net/tcp.h> 38 39 #include <scsi/scsi.h> ··· 528 527 list_add_tail(&port->sep_list, &dev->dev_sep_list); 529 528 spin_unlock(&dev->se_port_lock); 530 529 531 - if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV && 530 + if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) && 532 531 !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) { 533 532 tg_pt_gp_mem = core_alua_allocate_tg_pt_gp_mem(port); 534 533 if (IS_ERR(tg_pt_gp_mem) || !tg_pt_gp_mem) { ··· 1604 1603 * anything virtual (IBLOCK, FILEIO, RAMDISK), but not for TCM/pSCSI 1605 1604 * passthrough because this is being provided by the backend LLD. 1606 1605 */ 1607 - if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV) { 1606 + if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)) { 1608 1607 strncpy(&dev->t10_wwn.vendor[0], "LIO-ORG", 8); 1609 1608 strncpy(&dev->t10_wwn.model[0], 1610 1609 dev->transport->inquiry_prod, 16); ··· 1708 1707 target_free_device(g_lun0_dev); 1709 1708 core_delete_hba(hba); 1710 1709 } 1710 + 1711 + /* 1712 + * Common CDB parsing for kernel and user passthrough. 1713 + */ 1714 + sense_reason_t 1715 + passthrough_parse_cdb(struct se_cmd *cmd, 1716 + sense_reason_t (*exec_cmd)(struct se_cmd *cmd)) 1717 + { 1718 + unsigned char *cdb = cmd->t_task_cdb; 1719 + 1720 + /* 1721 + * Clear a lun set in the cdb if the initiator talking to use spoke 1722 + * and old standards version, as we can't assume the underlying device 1723 + * won't choke up on it. 1724 + */ 1725 + switch (cdb[0]) { 1726 + case READ_10: /* SBC - RDProtect */ 1727 + case READ_12: /* SBC - RDProtect */ 1728 + case READ_16: /* SBC - RDProtect */ 1729 + case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */ 1730 + case VERIFY: /* SBC - VRProtect */ 1731 + case VERIFY_16: /* SBC - VRProtect */ 1732 + case WRITE_VERIFY: /* SBC - VRProtect */ 1733 + case WRITE_VERIFY_12: /* SBC - VRProtect */ 1734 + case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */ 1735 + break; 1736 + default: 1737 + cdb[1] &= 0x1f; /* clear logical unit number */ 1738 + break; 1739 + } 1740 + 1741 + /* 1742 + * For REPORT LUNS we always need to emulate the response, for everything 1743 + * else, pass it up. 1744 + */ 1745 + if (cdb[0] == REPORT_LUNS) { 1746 + cmd->execute_cmd = spc_emulate_report_luns; 1747 + return TCM_NO_SENSE; 1748 + } 1749 + 1750 + /* Set DATA_CDB flag for ops that should have it */ 1751 + switch (cdb[0]) { 1752 + case READ_6: 1753 + case READ_10: 1754 + case READ_12: 1755 + case READ_16: 1756 + case WRITE_6: 1757 + case WRITE_10: 1758 + case WRITE_12: 1759 + case WRITE_16: 1760 + case WRITE_VERIFY: 1761 + case WRITE_VERIFY_12: 1762 + case 0x8e: /* WRITE_VERIFY_16 */ 1763 + case COMPARE_AND_WRITE: 1764 + case XDWRITEREAD_10: 1765 + cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 1766 + break; 1767 + case VARIABLE_LENGTH_CMD: 1768 + switch (get_unaligned_be16(&cdb[8])) { 1769 + case READ_32: 1770 + case WRITE_32: 1771 + case 0x0c: /* WRITE_VERIFY_32 */ 1772 + case XDWRITEREAD_32: 1773 + cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 1774 + break; 1775 + } 1776 + } 1777 + 1778 + cmd->execute_cmd = exec_cmd; 1779 + 1780 + return TCM_NO_SENSE; 1781 + } 1782 + EXPORT_SYMBOL(passthrough_parse_cdb);
-1
drivers/target/target_core_file.c
··· 958 958 .inquiry_prod = "FILEIO", 959 959 .inquiry_rev = FD_VERSION, 960 960 .owner = THIS_MODULE, 961 - .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, 962 961 .attach_hba = fd_attach_hba, 963 962 .detach_hba = fd_detach_hba, 964 963 .alloc_device = fd_alloc_device,
-1
drivers/target/target_core_iblock.c
··· 904 904 .inquiry_prod = "IBLOCK", 905 905 .inquiry_rev = IBLOCK_VERSION, 906 906 .owner = THIS_MODULE, 907 - .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, 908 907 .attach_hba = iblock_attach_hba, 909 908 .detach_hba = iblock_detach_hba, 910 909 .alloc_device = iblock_alloc_device,
-3
drivers/target/target_core_internal.h
··· 4 4 /* target_core_alua.c */ 5 5 extern struct t10_alua_lu_gp *default_lu_gp; 6 6 7 - /* target_core_configfs.c */ 8 - extern struct configfs_subsystem *target_core_subsystem[]; 9 - 10 7 /* target_core_device.c */ 11 8 extern struct mutex g_device_mutex; 12 9 extern struct list_head g_device_list;
+8 -26
drivers/target/target_core_pr.c
··· 1367 1367 1368 1368 static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg) 1369 1369 { 1370 - return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, 1371 - &tpg->tpg_group.cg_item); 1370 + return target_depend_item(&tpg->tpg_group.cg_item); 1372 1371 } 1373 1372 1374 1373 static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) 1375 1374 { 1376 - configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, 1377 - &tpg->tpg_group.cg_item); 1378 - 1375 + target_undepend_item(&tpg->tpg_group.cg_item); 1379 1376 atomic_dec_mb(&tpg->tpg_pr_ref_count); 1380 1377 } 1381 1378 1382 1379 static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl) 1383 1380 { 1384 - struct se_portal_group *tpg = nacl->se_tpg; 1385 - 1386 1381 if (nacl->dynamic_node_acl) 1387 1382 return 0; 1388 - 1389 - return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, 1390 - &nacl->acl_group.cg_item); 1383 + return target_depend_item(&nacl->acl_group.cg_item); 1391 1384 } 1392 1385 1393 1386 static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) 1394 1387 { 1395 - struct se_portal_group *tpg = nacl->se_tpg; 1396 - 1397 - if (nacl->dynamic_node_acl) { 1398 - atomic_dec_mb(&nacl->acl_pr_ref_count); 1399 - return; 1400 - } 1401 - 1402 - configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, 1403 - &nacl->acl_group.cg_item); 1404 - 1388 + if (!nacl->dynamic_node_acl) 1389 + target_undepend_item(&nacl->acl_group.cg_item); 1405 1390 atomic_dec_mb(&nacl->acl_pr_ref_count); 1406 1391 } 1407 1392 ··· 1404 1419 nacl = lun_acl->se_lun_nacl; 1405 1420 tpg = nacl->se_tpg; 1406 1421 1407 - return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, 1408 - &lun_acl->se_lun_group.cg_item); 1422 + return target_depend_item(&lun_acl->se_lun_group.cg_item); 1409 1423 } 1410 1424 1411 1425 static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) ··· 1422 1438 nacl = lun_acl->se_lun_nacl; 1423 1439 tpg = nacl->se_tpg; 1424 1440 1425 - configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, 1426 - &lun_acl->se_lun_group.cg_item); 1427 - 1441 + target_undepend_item(&lun_acl->se_lun_group.cg_item); 1428 1442 atomic_dec_mb(&se_deve->pr_ref_count); 1429 1443 } 1430 1444 ··· 4093 4111 return 0; 4094 4112 if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) 4095 4113 return 0; 4096 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 4114 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 4097 4115 return 0; 4098 4116 4099 4117 spin_lock(&dev->dev_reservation_lock);
+5 -53
drivers/target/target_core_pscsi.c
··· 521 521 " pdv_host_id: %d\n", pdv->pdv_host_id); 522 522 return -EINVAL; 523 523 } 524 + pdv->pdv_lld_host = sh; 524 525 } 525 526 } else { 526 527 if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) { ··· 604 603 if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) && 605 604 (phv->phv_lld_host != NULL)) 606 605 scsi_host_put(phv->phv_lld_host); 606 + else if (pdv->pdv_lld_host) 607 + scsi_host_put(pdv->pdv_lld_host); 607 608 608 609 if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM)) 609 610 scsi_device_put(sd); ··· 973 970 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 974 971 } 975 972 976 - /* 977 - * Clear a lun set in the cdb if the initiator talking to use spoke 978 - * and old standards version, as we can't assume the underlying device 979 - * won't choke up on it. 980 - */ 981 - static inline void pscsi_clear_cdb_lun(unsigned char *cdb) 982 - { 983 - switch (cdb[0]) { 984 - case READ_10: /* SBC - RDProtect */ 985 - case READ_12: /* SBC - RDProtect */ 986 - case READ_16: /* SBC - RDProtect */ 987 - case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */ 988 - case VERIFY: /* SBC - VRProtect */ 989 - case VERIFY_16: /* SBC - VRProtect */ 990 - case WRITE_VERIFY: /* SBC - VRProtect */ 991 - case WRITE_VERIFY_12: /* SBC - VRProtect */ 992 - case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */ 993 - break; 994 - default: 995 - cdb[1] &= 0x1f; /* clear logical unit number */ 996 - break; 997 - } 998 - } 999 - 1000 973 static sense_reason_t 1001 974 pscsi_parse_cdb(struct se_cmd *cmd) 1002 975 { 1003 - unsigned char *cdb = cmd->t_task_cdb; 1004 - 1005 976 if (cmd->se_cmd_flags & SCF_BIDI) 1006 977 return TCM_UNSUPPORTED_SCSI_OPCODE; 1007 978 1008 - pscsi_clear_cdb_lun(cdb); 1009 - 1010 - /* 1011 - * For REPORT LUNS we always need to emulate the response, for everything 1012 - * else the default for pSCSI is to pass the command to the underlying 1013 - * LLD / physical hardware. 1014 - */ 1015 - switch (cdb[0]) { 1016 - case REPORT_LUNS: 1017 - cmd->execute_cmd = spc_emulate_report_luns; 1018 - return 0; 1019 - case READ_6: 1020 - case READ_10: 1021 - case READ_12: 1022 - case READ_16: 1023 - case WRITE_6: 1024 - case WRITE_10: 1025 - case WRITE_12: 1026 - case WRITE_16: 1027 - case WRITE_VERIFY: 1028 - cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 1029 - /* FALLTHROUGH*/ 1030 - default: 1031 - cmd->execute_cmd = pscsi_execute_cmd; 1032 - return 0; 1033 - } 979 + return passthrough_parse_cdb(cmd, pscsi_execute_cmd); 1034 980 } 1035 981 1036 982 static sense_reason_t ··· 1141 1189 static struct se_subsystem_api pscsi_template = { 1142 1190 .name = "pscsi", 1143 1191 .owner = THIS_MODULE, 1144 - .transport_type = TRANSPORT_PLUGIN_PHBA_PDEV, 1192 + .transport_flags = TRANSPORT_FLAG_PASSTHROUGH, 1145 1193 .attach_hba = pscsi_attach_hba, 1146 1194 .detach_hba = pscsi_detach_hba, 1147 1195 .pmode_enable_hba = pscsi_pmode_enable_hba,
+1
drivers/target/target_core_pscsi.h
··· 45 45 int pdv_lun_id; 46 46 struct block_device *pdv_bd; 47 47 struct scsi_device *pdv_sd; 48 + struct Scsi_Host *pdv_lld_host; 48 49 } ____cacheline_aligned; 49 50 50 51 typedef enum phv_modes {
-1
drivers/target/target_core_rd.c
··· 733 733 .name = "rd_mcp", 734 734 .inquiry_prod = "RAMDISK-MCP", 735 735 .inquiry_rev = RD_MCP_VERSION, 736 - .transport_type = TRANSPORT_PLUGIN_VHBA_VDEV, 737 736 .attach_hba = rd_attach_hba, 738 737 .detach_hba = rd_detach_hba, 739 738 .alloc_device = rd_alloc_device,
+1 -1
drivers/target/target_core_sbc.c
··· 568 568 * comparision using SGLs at cmd->t_bidi_data_sg.. 569 569 */ 570 570 rc = down_interruptible(&dev->caw_sem); 571 - if ((rc != 0) || signal_pending(current)) { 571 + if (rc != 0) { 572 572 cmd->transport_complete_callback = NULL; 573 573 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 574 574 }
+6 -7
drivers/target/target_core_transport.c
··· 1196 1196 * Check if SAM Task Attribute emulation is enabled for this 1197 1197 * struct se_device storage object 1198 1198 */ 1199 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 1199 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1200 1200 return 0; 1201 1201 1202 1202 if (cmd->sam_task_attr == TCM_ACA_TAG) { ··· 1770 1770 sectors, 0, NULL, 0); 1771 1771 if (unlikely(cmd->pi_err)) { 1772 1772 spin_lock_irq(&cmd->t_state_lock); 1773 - cmd->transport_state &= ~CMD_T_BUSY|CMD_T_SENT; 1773 + cmd->transport_state &= ~(CMD_T_BUSY|CMD_T_SENT); 1774 1774 spin_unlock_irq(&cmd->t_state_lock); 1775 1775 transport_generic_request_failure(cmd, cmd->pi_err); 1776 1776 return -1; ··· 1787 1787 { 1788 1788 struct se_device *dev = cmd->se_dev; 1789 1789 1790 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 1790 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1791 1791 return false; 1792 1792 1793 1793 /* ··· 1868 1868 1869 1869 if (target_handle_task_attr(cmd)) { 1870 1870 spin_lock_irq(&cmd->t_state_lock); 1871 - cmd->transport_state &= ~CMD_T_BUSY|CMD_T_SENT; 1871 + cmd->transport_state &= ~(CMD_T_BUSY | CMD_T_SENT); 1872 1872 spin_unlock_irq(&cmd->t_state_lock); 1873 1873 return; 1874 1874 } ··· 1912 1912 { 1913 1913 struct se_device *dev = cmd->se_dev; 1914 1914 1915 - if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) 1915 + if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1916 1916 return; 1917 1917 1918 1918 if (cmd->sam_task_attr == TCM_SIMPLE_TAG) { ··· 1957 1957 case DMA_TO_DEVICE: 1958 1958 if (cmd->se_cmd_flags & SCF_BIDI) { 1959 1959 ret = cmd->se_tfo->queue_data_in(cmd); 1960 - if (ret < 0) 1961 - break; 1960 + break; 1962 1961 } 1963 1962 /* Fall through for DMA_TO_DEVICE */ 1964 1963 case DMA_NONE:
+32 -111
drivers/target/target_core_user.c
··· 71 71 u32 host_id; 72 72 }; 73 73 74 - /* User wants all cmds or just some */ 75 - enum passthru_level { 76 - TCMU_PASS_ALL = 0, 77 - TCMU_PASS_IO, 78 - TCMU_PASS_INVALID, 79 - }; 80 - 81 74 #define TCMU_CONFIG_LEN 256 82 75 83 76 struct tcmu_dev { ··· 82 89 #define TCMU_DEV_BIT_OPEN 0 83 90 #define TCMU_DEV_BIT_BROKEN 1 84 91 unsigned long flags; 85 - enum passthru_level pass_level; 86 92 87 93 struct uio_info uio_info; 88 94 ··· 675 683 setup_timer(&udev->timeout, tcmu_device_timedout, 676 684 (unsigned long)udev); 677 685 678 - udev->pass_level = TCMU_PASS_ALL; 679 - 680 686 return &udev->se_dev; 681 687 } 682 688 ··· 938 948 } 939 949 940 950 enum { 941 - Opt_dev_config, Opt_dev_size, Opt_err, Opt_pass_level, 951 + Opt_dev_config, Opt_dev_size, Opt_hw_block_size, Opt_err, 942 952 }; 943 953 944 954 static match_table_t tokens = { 945 955 {Opt_dev_config, "dev_config=%s"}, 946 956 {Opt_dev_size, "dev_size=%u"}, 947 - {Opt_pass_level, "pass_level=%u"}, 957 + {Opt_hw_block_size, "hw_block_size=%u"}, 948 958 {Opt_err, NULL} 949 959 }; 950 960 ··· 955 965 char *orig, *ptr, *opts, *arg_p; 956 966 substring_t args[MAX_OPT_ARGS]; 957 967 int ret = 0, token; 958 - int arg; 968 + unsigned long tmp_ul; 959 969 960 970 opts = kstrdup(page, GFP_KERNEL); 961 971 if (!opts) ··· 988 998 if (ret < 0) 989 999 pr_err("kstrtoul() failed for dev_size=\n"); 990 1000 break; 991 - case Opt_pass_level: 992 - match_int(args, &arg); 993 - if (arg >= TCMU_PASS_INVALID) { 994 - pr_warn("TCMU: Invalid pass_level: %d\n", arg); 1001 + case Opt_hw_block_size: 1002 + arg_p = match_strdup(&args[0]); 1003 + if (!arg_p) { 1004 + ret = -ENOMEM; 995 1005 break; 996 1006 } 997 - 998 - pr_debug("TCMU: Setting pass_level to %d\n", arg); 999 - udev->pass_level = arg; 1007 + ret = kstrtoul(arg_p, 0, &tmp_ul); 1008 + kfree(arg_p); 1009 + if (ret < 0) { 1010 + pr_err("kstrtoul() failed for hw_block_size=\n"); 1011 + break; 1012 + } 1013 + if (!tmp_ul) { 1014 + pr_err("hw_block_size must be nonzero\n"); 1015 + break; 1016 + } 1017 + dev->dev_attrib.hw_block_size = tmp_ul; 1000 1018 break; 1001 1019 default: 1002 1020 break; ··· 1022 1024 1023 1025 bl = sprintf(b + bl, "Config: %s ", 1024 1026 udev->dev_config[0] ? udev->dev_config : "NULL"); 1025 - bl += sprintf(b + bl, "Size: %zu PassLevel: %u\n", 1026 - udev->dev_size, udev->pass_level); 1027 + bl += sprintf(b + bl, "Size: %zu\n", udev->dev_size); 1027 1028 1028 1029 return bl; 1029 1030 } ··· 1036 1039 } 1037 1040 1038 1041 static sense_reason_t 1039 - tcmu_execute_rw(struct se_cmd *se_cmd, struct scatterlist *sgl, u32 sgl_nents, 1040 - enum dma_data_direction data_direction) 1041 - { 1042 - int ret; 1043 - 1044 - ret = tcmu_queue_cmd(se_cmd); 1045 - 1046 - if (ret != 0) 1047 - return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1048 - else 1049 - return TCM_NO_SENSE; 1050 - } 1051 - 1052 - static sense_reason_t 1053 1042 tcmu_pass_op(struct se_cmd *se_cmd) 1054 1043 { 1055 1044 int ret = tcmu_queue_cmd(se_cmd); ··· 1046 1063 return TCM_NO_SENSE; 1047 1064 } 1048 1065 1049 - static struct sbc_ops tcmu_sbc_ops = { 1050 - .execute_rw = tcmu_execute_rw, 1051 - .execute_sync_cache = tcmu_pass_op, 1052 - .execute_write_same = tcmu_pass_op, 1053 - .execute_write_same_unmap = tcmu_pass_op, 1054 - .execute_unmap = tcmu_pass_op, 1055 - }; 1056 - 1057 1066 static sense_reason_t 1058 1067 tcmu_parse_cdb(struct se_cmd *cmd) 1059 1068 { 1060 - unsigned char *cdb = cmd->t_task_cdb; 1061 - struct tcmu_dev *udev = TCMU_DEV(cmd->se_dev); 1062 - sense_reason_t ret; 1063 - 1064 - switch (udev->pass_level) { 1065 - case TCMU_PASS_ALL: 1066 - /* We're just like pscsi, then */ 1067 - /* 1068 - * For REPORT LUNS we always need to emulate the response, for everything 1069 - * else, pass it up. 1070 - */ 1071 - switch (cdb[0]) { 1072 - case REPORT_LUNS: 1073 - cmd->execute_cmd = spc_emulate_report_luns; 1074 - break; 1075 - case READ_6: 1076 - case READ_10: 1077 - case READ_12: 1078 - case READ_16: 1079 - case WRITE_6: 1080 - case WRITE_10: 1081 - case WRITE_12: 1082 - case WRITE_16: 1083 - case WRITE_VERIFY: 1084 - cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 1085 - /* FALLTHROUGH */ 1086 - default: 1087 - cmd->execute_cmd = tcmu_pass_op; 1088 - } 1089 - ret = TCM_NO_SENSE; 1090 - break; 1091 - case TCMU_PASS_IO: 1092 - ret = sbc_parse_cdb(cmd, &tcmu_sbc_ops); 1093 - break; 1094 - default: 1095 - pr_err("Unknown tcm-user pass level %d\n", udev->pass_level); 1096 - ret = TCM_CHECK_CONDITION_ABORT_CMD; 1097 - } 1098 - 1099 - return ret; 1069 + return passthrough_parse_cdb(cmd, tcmu_pass_op); 1100 1070 } 1101 1071 1102 - DEF_TB_DEFAULT_ATTRIBS(tcmu); 1072 + DEF_TB_DEV_ATTRIB_RO(tcmu, hw_pi_prot_type); 1073 + TB_DEV_ATTR_RO(tcmu, hw_pi_prot_type); 1074 + 1075 + DEF_TB_DEV_ATTRIB_RO(tcmu, hw_block_size); 1076 + TB_DEV_ATTR_RO(tcmu, hw_block_size); 1077 + 1078 + DEF_TB_DEV_ATTRIB_RO(tcmu, hw_max_sectors); 1079 + TB_DEV_ATTR_RO(tcmu, hw_max_sectors); 1080 + 1081 + DEF_TB_DEV_ATTRIB_RO(tcmu, hw_queue_depth); 1082 + TB_DEV_ATTR_RO(tcmu, hw_queue_depth); 1103 1083 1104 1084 static struct configfs_attribute *tcmu_backend_dev_attrs[] = { 1105 - &tcmu_dev_attrib_emulate_model_alias.attr, 1106 - &tcmu_dev_attrib_emulate_dpo.attr, 1107 - &tcmu_dev_attrib_emulate_fua_write.attr, 1108 - &tcmu_dev_attrib_emulate_fua_read.attr, 1109 - &tcmu_dev_attrib_emulate_write_cache.attr, 1110 - &tcmu_dev_attrib_emulate_ua_intlck_ctrl.attr, 1111 - &tcmu_dev_attrib_emulate_tas.attr, 1112 - &tcmu_dev_attrib_emulate_tpu.attr, 1113 - &tcmu_dev_attrib_emulate_tpws.attr, 1114 - &tcmu_dev_attrib_emulate_caw.attr, 1115 - &tcmu_dev_attrib_emulate_3pc.attr, 1116 - &tcmu_dev_attrib_pi_prot_type.attr, 1117 1085 &tcmu_dev_attrib_hw_pi_prot_type.attr, 1118 - &tcmu_dev_attrib_pi_prot_format.attr, 1119 - &tcmu_dev_attrib_enforce_pr_isids.attr, 1120 - &tcmu_dev_attrib_is_nonrot.attr, 1121 - &tcmu_dev_attrib_emulate_rest_reord.attr, 1122 - &tcmu_dev_attrib_force_pr_aptpl.attr, 1123 1086 &tcmu_dev_attrib_hw_block_size.attr, 1124 - &tcmu_dev_attrib_block_size.attr, 1125 1087 &tcmu_dev_attrib_hw_max_sectors.attr, 1126 - &tcmu_dev_attrib_optimal_sectors.attr, 1127 1088 &tcmu_dev_attrib_hw_queue_depth.attr, 1128 - &tcmu_dev_attrib_queue_depth.attr, 1129 - &tcmu_dev_attrib_max_unmap_lba_count.attr, 1130 - &tcmu_dev_attrib_max_unmap_block_desc_count.attr, 1131 - &tcmu_dev_attrib_unmap_granularity.attr, 1132 - &tcmu_dev_attrib_unmap_granularity_alignment.attr, 1133 - &tcmu_dev_attrib_max_write_same_len.attr, 1134 1089 NULL, 1135 1090 }; 1136 1091 ··· 1077 1156 .inquiry_prod = "USER", 1078 1157 .inquiry_rev = TCMU_VERSION, 1079 1158 .owner = THIS_MODULE, 1080 - .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, 1159 + .transport_flags = TRANSPORT_FLAG_PASSTHROUGH, 1081 1160 .attach_hba = tcmu_attach_hba, 1082 1161 .detach_hba = tcmu_detach_hba, 1083 1162 .alloc_device = tcmu_alloc_device,
+6 -9
drivers/target/target_core_xcopy.c
··· 58 58 bool src) 59 59 { 60 60 struct se_device *se_dev; 61 - struct configfs_subsystem *subsys = target_core_subsystem[0]; 62 61 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn; 63 62 int rc; 64 63 ··· 89 90 " se_dev\n", xop->src_dev); 90 91 } 91 92 92 - rc = configfs_depend_item(subsys, 93 - &se_dev->dev_group.cg_item); 93 + rc = target_depend_item(&se_dev->dev_group.cg_item); 94 94 if (rc != 0) { 95 95 pr_err("configfs_depend_item attempt failed:" 96 96 " %d for se_dev: %p\n", rc, se_dev); ··· 97 99 return rc; 98 100 } 99 101 100 - pr_debug("Called configfs_depend_item for subsys: %p se_dev: %p" 101 - " se_dev->se_dev_group: %p\n", subsys, se_dev, 102 + pr_debug("Called configfs_depend_item for se_dev: %p" 103 + " se_dev->se_dev_group: %p\n", se_dev, 102 104 &se_dev->dev_group); 103 105 104 106 mutex_unlock(&g_device_mutex); ··· 371 373 372 374 static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop) 373 375 { 374 - struct configfs_subsystem *subsys = target_core_subsystem[0]; 375 376 struct se_device *remote_dev; 376 377 377 378 if (xop->op_origin == XCOL_SOURCE_RECV_OP) ··· 378 381 else 379 382 remote_dev = xop->src_dev; 380 383 381 - pr_debug("Calling configfs_undepend_item for subsys: %p" 384 + pr_debug("Calling configfs_undepend_item for" 382 385 " remote_dev: %p remote_dev->dev_group: %p\n", 383 - subsys, remote_dev, &remote_dev->dev_group.cg_item); 386 + remote_dev, &remote_dev->dev_group.cg_item); 384 387 385 - configfs_undepend_item(subsys, &remote_dev->dev_group.cg_item); 388 + target_undepend_item(&remote_dev->dev_group.cg_item); 386 389 } 387 390 388 391 static void xcopy_pt_release_cmd(struct se_cmd *se_cmd)
+2 -4
drivers/vhost/scsi.c
··· 1409 1409 * dependency now. 1410 1410 */ 1411 1411 se_tpg = &tpg->se_tpg; 1412 - ret = configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys, 1413 - &se_tpg->tpg_group.cg_item); 1412 + ret = target_depend_item(&se_tpg->tpg_group.cg_item); 1414 1413 if (ret) { 1415 1414 pr_warn("configfs_depend_item() failed: %d\n", ret); 1416 1415 kfree(vs_tpg); ··· 1512 1513 * to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur. 1513 1514 */ 1514 1515 se_tpg = &tpg->se_tpg; 1515 - configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys, 1516 - &se_tpg->tpg_group.cg_item); 1516 + target_undepend_item(&se_tpg->tpg_group.cg_item); 1517 1517 } 1518 1518 if (match) { 1519 1519 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
+4 -4
include/target/target_core_backend.h
··· 1 1 #ifndef TARGET_CORE_BACKEND_H 2 2 #define TARGET_CORE_BACKEND_H 3 3 4 - #define TRANSPORT_PLUGIN_PHBA_PDEV 1 5 - #define TRANSPORT_PLUGIN_VHBA_PDEV 2 6 - #define TRANSPORT_PLUGIN_VHBA_VDEV 3 4 + #define TRANSPORT_FLAG_PASSTHROUGH 1 7 5 8 6 struct target_backend_cits { 9 7 struct config_item_type tb_dev_cit; ··· 20 22 char inquiry_rev[4]; 21 23 struct module *owner; 22 24 23 - u8 transport_type; 25 + u8 transport_flags; 24 26 25 27 int (*attach_hba)(struct se_hba *, u32); 26 28 void (*detach_hba)(struct se_hba *); ··· 136 138 int se_dev_set_max_sectors(struct se_device *, u32); 137 139 int se_dev_set_optimal_sectors(struct se_device *, u32); 138 140 int se_dev_set_block_size(struct se_device *, u32); 141 + sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, 142 + sense_reason_t (*exec_cmd)(struct se_cmd *cmd)); 139 143 140 144 #endif /* TARGET_CORE_BACKEND_H */
-2
include/target/target_core_configfs.h
··· 40 40 struct config_item *tf_fabric; 41 41 /* Passed from fabric modules */ 42 42 struct config_item_type *tf_fabric_cit; 43 - /* Pointer to target core subsystem */ 44 - struct configfs_subsystem *tf_subsys; 45 43 /* Pointer to fabric's struct module */ 46 44 struct module *tf_module; 47 45 struct target_core_fabric_ops tf_ops;
+3 -1
include/target/target_core_fabric.h
··· 4 4 struct target_core_fabric_ops { 5 5 struct module *module; 6 6 const char *name; 7 - struct configfs_subsystem *tf_subsys; 8 7 char *(*get_fabric_name)(void); 9 8 u8 (*get_fabric_proto_ident)(struct se_portal_group *); 10 9 char *(*tpg_get_wwn)(struct se_portal_group *); ··· 107 108 108 109 int target_register_template(const struct target_core_fabric_ops *fo); 109 110 void target_unregister_template(const struct target_core_fabric_ops *fo); 111 + 112 + int target_depend_item(struct config_item *item); 113 + void target_undepend_item(struct config_item *item); 110 114 111 115 struct se_session *transport_init_session(enum target_prot_op); 112 116 int transport_alloc_session_tags(struct se_session *, unsigned int,