Skip to content

Commit

Permalink
target: Use a PASSTHROUGH flag instead of transport_types
Browse files Browse the repository at this point in the history
It seems like we only care if a transport is passthrough or not. Convert
transport_type to a flags field and replace TRANSPORT_PLUGIN_* with a
flag, TRANSPORT_FLAG_PASSTHROUGH.

Signed-off-by: Andy Grover <[email protected]>
Reviewed-by: Ilias Tsitsimpis <[email protected]>
Signed-off-by: Nicholas Bellinger <[email protected]>
  • Loading branch information
Andy Grover authored and Nicholas Bellinger committed May 31, 2015
1 parent 7bfea53 commit a354170
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions drivers/target/target_core_alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ target_alua_state_check(struct se_cmd *cmd)

if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)
return 0;
if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return 0;

if (!port)
Expand Down Expand Up @@ -2377,7 +2377,7 @@ ssize_t core_alua_store_secondary_write_metadata(

int core_setup_alua(struct se_device *dev)
{
if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV &&
if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) &&
!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) {
struct t10_alua_lu_gp_member *lu_gp_mem;

Expand Down
10 changes: 5 additions & 5 deletions drivers/target/target_core_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ static ssize_t target_core_dev_pr_show_attr_res_holder(struct se_device *dev,
{
int ret;

if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return sprintf(page, "Passthrough\n");

spin_lock(&dev->dev_reservation_lock);
Expand Down Expand Up @@ -962,7 +962,7 @@ SE_DEV_PR_ATTR_RO(res_pr_type);
static ssize_t target_core_dev_pr_show_attr_res_type(
struct se_device *dev, char *page)
{
if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return sprintf(page, "SPC_PASSTHROUGH\n");
else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
return sprintf(page, "SPC2_RESERVATIONS\n");
Expand All @@ -975,7 +975,7 @@ SE_DEV_PR_ATTR_RO(res_type);
static ssize_t target_core_dev_pr_show_attr_res_aptpl_active(
struct se_device *dev, char *page)
{
if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return 0;

return sprintf(page, "APTPL Bit Status: %s\n",
Expand All @@ -990,7 +990,7 @@ SE_DEV_PR_ATTR_RO(res_aptpl_active);
static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata(
struct se_device *dev, char *page)
{
if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return 0;

return sprintf(page, "Ready to process PR APTPL metadata..\n");
Expand Down Expand Up @@ -1037,7 +1037,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
u16 port_rpti = 0, tpgt = 0;
u8 type = 0, scope;

if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return 0;
if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/target/target_core_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ static void core_export_port(
list_add_tail(&port->sep_list, &dev->dev_sep_list);
spin_unlock(&dev->se_port_lock);

if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV &&
if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) &&
!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) {
tg_pt_gp_mem = core_alua_allocate_tg_pt_gp_mem(port);
if (IS_ERR(tg_pt_gp_mem) || !tg_pt_gp_mem) {
Expand Down Expand Up @@ -1604,7 +1604,7 @@ int target_configure_device(struct se_device *dev)
* anything virtual (IBLOCK, FILEIO, RAMDISK), but not for TCM/pSCSI
* passthrough because this is being provided by the backend LLD.
*/
if (dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV) {
if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)) {
strncpy(&dev->t10_wwn.vendor[0], "LIO-ORG", 8);
strncpy(&dev->t10_wwn.model[0],
dev->transport->inquiry_prod, 16);
Expand Down
1 change: 0 additions & 1 deletion drivers/target/target_core_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ static struct se_subsystem_api fileio_template = {
.inquiry_prod = "FILEIO",
.inquiry_rev = FD_VERSION,
.owner = THIS_MODULE,
.transport_type = TRANSPORT_PLUGIN_VHBA_PDEV,
.attach_hba = fd_attach_hba,
.detach_hba = fd_detach_hba,
.alloc_device = fd_alloc_device,
Expand Down
1 change: 0 additions & 1 deletion drivers/target/target_core_iblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,6 @@ static struct se_subsystem_api iblock_template = {
.inquiry_prod = "IBLOCK",
.inquiry_rev = IBLOCK_VERSION,
.owner = THIS_MODULE,
.transport_type = TRANSPORT_PLUGIN_VHBA_PDEV,
.attach_hba = iblock_attach_hba,
.detach_hba = iblock_detach_hba,
.alloc_device = iblock_alloc_device,
Expand Down
2 changes: 1 addition & 1 deletion drivers/target/target_core_pr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4093,7 +4093,7 @@ target_check_reservation(struct se_cmd *cmd)
return 0;
if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)
return 0;
if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return 0;

spin_lock(&dev->dev_reservation_lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/target/target_core_pscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ static struct configfs_attribute *pscsi_backend_dev_attrs[] = {
static struct se_subsystem_api pscsi_template = {
.name = "pscsi",
.owner = THIS_MODULE,
.transport_type = TRANSPORT_PLUGIN_PHBA_PDEV,
.transport_flags = TRANSPORT_FLAG_PASSTHROUGH,
.attach_hba = pscsi_attach_hba,
.detach_hba = pscsi_detach_hba,
.pmode_enable_hba = pscsi_pmode_enable_hba,
Expand Down
1 change: 0 additions & 1 deletion drivers/target/target_core_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ static struct se_subsystem_api rd_mcp_template = {
.name = "rd_mcp",
.inquiry_prod = "RAMDISK-MCP",
.inquiry_rev = RD_MCP_VERSION,
.transport_type = TRANSPORT_PLUGIN_VHBA_VDEV,
.attach_hba = rd_attach_hba,
.detach_hba = rd_detach_hba,
.alloc_device = rd_alloc_device,
Expand Down
6 changes: 3 additions & 3 deletions drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
* Check if SAM Task Attribute emulation is enabled for this
* struct se_device storage object
*/
if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return 0;

if (cmd->sam_task_attr == TCM_ACA_TAG) {
Expand Down Expand Up @@ -1787,7 +1787,7 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;

if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return false;

/*
Expand Down Expand Up @@ -1912,7 +1912,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;

if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
return;

if (cmd->sam_task_attr == TCM_SIMPLE_TAG) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/target/target_core_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ static struct se_subsystem_api tcmu_template = {
.inquiry_prod = "USER",
.inquiry_rev = TCMU_VERSION,
.owner = THIS_MODULE,
.transport_type = TRANSPORT_PLUGIN_PHBA_PDEV,
.transport_flags = TRANSPORT_FLAG_PASSTHROUGH,
.attach_hba = tcmu_attach_hba,
.detach_hba = tcmu_detach_hba,
.alloc_device = tcmu_alloc_device,
Expand Down
6 changes: 2 additions & 4 deletions include/target/target_core_backend.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#ifndef TARGET_CORE_BACKEND_H
#define TARGET_CORE_BACKEND_H

#define TRANSPORT_PLUGIN_PHBA_PDEV 1
#define TRANSPORT_PLUGIN_VHBA_PDEV 2
#define TRANSPORT_PLUGIN_VHBA_VDEV 3
#define TRANSPORT_FLAG_PASSTHROUGH 1

struct target_backend_cits {
struct config_item_type tb_dev_cit;
Expand All @@ -22,7 +20,7 @@ struct se_subsystem_api {
char inquiry_rev[4];
struct module *owner;

u8 transport_type;
u8 transport_flags;

int (*attach_hba)(struct se_hba *, u32);
void (*detach_hba)(struct se_hba *);
Expand Down

0 comments on commit a354170

Please sign in to comment.