target: passthrough command removal
Subsystems (2)
cover target: passthrough command removal
From: Nicholas Bellinger <[email protected]>
Greetings folks,
This is hch's series with my improvements to convert Target/pSCSI to use scsi_execute_req() during backend se_subsystem_api->create_virtdevice() in order to remove the legacy SCF_CMD_PASSTHROUGH I/O logic. In modern v4.0 target code this logic was only used during initial device setup to extract INQUIRY, EVPD 0x80/0x83 INQUIRY, and READ_CAPACITY for target mode infrastructure.
My changes to the original series include a fix in patch #2 to pscsi_get_blocks() for IBLOCK -> TCM_Loop -> PSCSI which caused an OOPs during testing, and in #3 to work with the underlying SCSI LLD -> SDF_FIRMWARE_VPD_UNIT_SERIAL case to parse what EVPD identifers 'the underlying HW' actually gives us in via /sys/kernel/config/target/core/$PSCSI_HBA/$DEV/wwn/vpd_*.
This patch also keeps the Linux/SCSI style standard INQUIRY parsing in scsi_dump_inquiry() during transport_add_device_to_core_hba() which is helpful for debugging with all different types of backends enabled..
Currently this series has been merged into lio-core-2.6.git/remove-passthrough, but I think at this point with a few more days testing and review it will be ready to merged into master and other lio-4.0 development branches.
Here is the special case of IBLOCK -> TCM_Loop -> pSCSI running on .37-rc2 in order to test the TCM/pSCSI EVPD refactoring in patch #3
PSCSI: Allocated pdv: ece8b120 for tcm_loop_lunTarget_Core_ConfigFS: Allocated struct se_subsystem_dev: df57e030 se_dev_su_ptr: ece8b120 PSCSI[1]: Referencing SCSI Host ID: 5
PSCSI[1]: Referencing SCSI Channel ID: 0
PSCSI[1]: Referencing SCSI Target ID: 1
PSCSI[1]: Referencing SCSI LUN ID: 0Target_Core_ConfigFS: pscsi_1/tcm_loop_lun set udev_path: /dev/sdg
pscsi: Using SPC_PASSTHROUGH, no reservation emulation
pscsi: Using SPC_ALUA_PASSTHROUGH, no ALUA emulation
Vendor: LIO-ORG Model: IBLOCK Revision: 4.0
Type: Direct-Access ANSI SCSI revision: 05
T10 VPD Identifer Length: 16
T10 VPD Identifier Association: addressed logical unit
T10 VPD Identifier Type: NAA
T10 VPD Binary Device Identifier: 36001405a97e4ce21c0711de829b000c2
T10 VPD Identifer Length: 48
T10 VPD Identifier Association: addressed logical unit
T10 VPD Identifier Type: T10 Vendor ID based
T10 VPD ASCII Device Identifier: LIO-ORG
T10 VPD Identifer Length: 4
T10 VPD Protocol Identifier: SAS Serial SCSI Protocol
T10 VPD Identifier Association: target port
T10 VPD Identifier Type: Relative target port identifier
T10 VPD Binary Device Identifier: 400000001
T10 VPD Identifer Length: 4
T10 VPD Protocol Identifier: SAS Serial SCSI Protocol
T10 VPD Identifier Association: target port
T10 VPD Identifier Type: Unsupported: 0x05
T10 VPD Identifer Length: 4
T10 VPD Identifier Association: addressed logical unit
T10 VPD Identifier Type: Unsupported: 0x06
T10 VPD Identifer Length: 32
T10 VPD Protocol Identifier: SAS Serial SCSI Protocol
T10 VPD Identifier Association: target port
T10 VPD Identifier Type: SCSI name string
T10 VPD UTF-8 Device Identifier: naa.60014051ff57aebc,t,0x0001 CORE_PSCSI[1] - Added TYPE_DISK for 5:0:1:0Target_Core_ConfigFS: Registered se_dev->se_dev_ptr: df5ad020
and from /sys/kernel/config/target/core/$PSCSI_HBA/$DEV/wwn/*
target:/sys/kernel/config/target/core/pscsi_1/tcm_loop_lun# cat wwn/vpd_* T10 VPD Identifier Association: addressed logical unit T10 VPD Identifier Type: NAA T10 VPD Binary Device Identifier: 36001405a97e4ce21c0711de829b000c2 T10 VPD Identifier Association: addressed logical unit T10 VPD Identifier Type: T10 Vendor ID based T10 VPD ASCII Device Identifier: LIO-ORG T10 VPD Identifier Association: target port T10 VPD Identifier Type: Relative target port identifier T10 VPD Binary Device Identifier: 400000001 T10 VPD Identifier Association: target port T10 VPD Identifier Type: SCSI name string T10 VPD UTF-8 Device Identifier: naa.60014051ff57aebc,t,0x0001 T10 VPD Protocol Identifier: SAS Serial SCSI Protocol T10 VPD Protocol Identifier: SAS Serial SCSI Protocol T10 VPD Unit Serial Number: a97e4ce21c0711de829b000c2943d57b
A big thanks again to Christoph for taking the time to do a proper removeal of SCF_CMD_PASSTHROUGH, and dropping another ~400 LOC from drivers/target !!
Christoph Hellwig (4):
target-pscsi: query tape blocksize using scsi_execute_req
target: always get capacity from ->get_blocks
target-pscsi: get inquiry data using scsi_execute_req
target: remove passthrough support
drivers/target/target_core_configfs.c | 2 - drivers/target/target_core_pscsi.c | 214 +++++++-- drivers/target/target_core_tmr.c | 5 +- drivers/target/target_core_transport.c | 819 +++++--------------------------- include/target/target_core_base.h | 38 +- include/target/target_core_transport.h | 9 +- 6 files changed, 310 insertions(+), 777 deletions(-)
PATCH 1/4 target-pscsi: query tape blocksize using scsi_execute_req
From: Christoph Hellwig <[email protected]>
Use the native Linux scsi execution support instead of the target passthrough support to get the tape blocksize
--- drivers/target/target_core_pscsi.c | 66 ++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 37 deletions(-)
drivers/target/target_core_pscsi.c +29 -37
@@ -181,6 +181,33 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)return 1 ; } +static void pscsi_tape_read_blocksize (struct se_device *dev, +struct scsi_device *sdev) +{ +unsigned char cdb[MAX_COMMAND_SIZE ], *buf; + + buf =kzalloc (12 ,GFP_KERNEL ); +if (!buf) +return ; + +memset (cdb,0 ,MAX_COMMAND_SIZE ); + cdb[0 ] =MODE_SENSE ; + cdb[4 ] =0x0c ;/* 12 bytes */ + +if (!scsi_execute_req (sdev, cdb,DMA_FROM_DEVICE , buf,12 ,NULL , +HZ ,1 ,NULL )) + goto out_free; + +/* +* If MODE_SENSE still returns zero, set the default value to 1024. +*/ + sdev->sector_size = (buf[9 ] <<16 ) | (buf[10 ] <<8 ) | (buf[11 ]); +if (!sdev->sector_size) + sdev->sector_size =1024 ; +out_free: +kfree (buf); +} +/* pscsi_add_device_to_list(): * *
@@ -245,43 +272,8 @@ static struct se_device *pscsi_add_device_to_list(/* * For TYPE_TAPE, attempt to determine blocksize with MODE_SENSE. */ -if (sd->type ==TYPE_TAPE ) { -unsigned char *buf =NULL , cdb[MAX_COMMAND_SIZE ]; -struct se_cmd *cmd; -u32 blocksize; - -memset (cdb,0 ,MAX_COMMAND_SIZE ); - cdb[0 ] =MODE_SENSE ; - cdb[4 ] =0x0c ;/* 12 bytes */ - - cmd =transport_allocate_passthrough (&cdb[0 ], -DMA_FROM_DEVICE ,0 ,NULL ,0 ,12 , dev); -if (!(cmd)) { -printk (KERN_ERR "Unable to determine blocksize for" -" TYPE_TAPE\n" ); - goto out; - } - -if (transport_generic_passthrough (cmd) <0 ) { -printk (KERN_ERR "Unable to determine blocksize for" -" TYPE_TAPE\n" ); - goto out; - } - - buf = (unsigned char *)T_TASK (cmd)->t_task_buf; - blocksize = (buf[9 ] <<16 ) | (buf[10 ] <<8 ) | (buf[11 ]); - -/* -* If MODE_SENSE still returns zero, set the default value -* to 1024. -*/ - sd->sector_size = blocksize; -if (!(sd->sector_size)) - sd->sector_size =1024 ; - -transport_passthrough_release (cmd); - } -out: +if (sd->type ==TYPE_TAPE ) +pscsi_tape_read_blocksize (dev, sd);return dev; }
Signature · 1 line
1.5.6.5
PATCH 2/4 target: always get capacity from ->get_blocks
In reply to Nicholas A. BellingerFrom: Christoph Hellwig <[email protected]>
Always use the ->get_blocks method to get the device capacity instead of using passthrough commands. Implement a get_blocks method for pscsi by Looking at the Linux struct block_device for disks.
--- drivers/target/target_core_pscsi.c | 12 +++++ drivers/target/target_core_transport.c | 73 +------------------------------- 2 files changed, 14 insertions(+), 71 deletions(-)
drivers/target/target_core_pscsi.c +12 -0
@@ -1228,6 +1228,17 @@ static u32 pscsi_get_dma_length(u32 task_size, struct se_device *dev)return PAGE_SIZE ; } +static sector_t pscsi_get_blocks (struct se_device *dev) +{ +struct pscsi_dev_virt *pdv = dev->dev_ptr; + +if (pdv->pdv_bd && pdv->pdv_bd->bd_part) +return pdv->pdv_bd->bd_part->nr_sects; + +dump_stack (); +return 0 ; +} +/* pscsi_handle_SAM_STATUS_failures(): * *
@@ -1307,6 +1318,7 @@ static struct se_subsystem_api pscsi_template = { .get_device_rev = pscsi_get_device_rev, .get_device_type = pscsi_get_device_type, .get_dma_length = pscsi_get_dma_length, + .get_blocks = pscsi_get_blocks, };static int __init pscsi_module_init (void )
drivers/target/target_core_transport.c +2 -71
86 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH 3/4 target-pscsi: get inquiry data using scsi_execute_req
In reply to Nicholas A. BellingerFrom: Christoph Hellwig <[email protected]>
For virtual devices we have all inquiry data already in struct t10_wwn, so remove the passthrough inquiry from common code. Instead use Linux SCSI command execution to fill the inquiry data for physical devices.
Tested backend registerion with emulated EVPD 0x83 from IBLOCK -> TCM_Loop -> pSCSI on .37-rc2.
--- drivers/target/target_core_configfs.c | 2 - drivers/target/target_core_pscsi.c | 140 +++++++++++++++++ drivers/target/target_core_transport.c | 266 ++++++-------------------------- include/target/target_core_transport.h | 5 +- 4 files changed, 192 insertions(+), 221 deletions(-)
drivers/target/target_core_configfs.c +0 -2
@@ -895,8 +895,6 @@ static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial(printk (KERN_INFO "Target_Core_ConfigFS: Set emulated VPD Unit Serial:" " %s\n" , su_dev->t10_wwn.unit_serial); -if (dev) -transport_rescan_evpd_device_ident (dev);return count; }
drivers/target/target_core_pscsi.c +140 -0
158 lines not on this page · raw message
drivers/target/target_core_transport.c +48 -218
348 lines not on this page · raw message
include/target/target_core_transport.h +4 -1
@@ -153,13 +153,16 @@ extern void transport_dump_dev_info(struct se_device *, struct se_lun *, unsigned long long, char *, int *);extern void transport_dump_vpd_proto_id (struct t10_vpd *,unsigned char *,int ); +extern void transport_set_vpd_proto_id (struct t10_vpd *,unsigned char *);extern int transport_dump_vpd_assoc (struct t10_vpd *,unsigned char *,int ); +extern int transport_set_vpd_assoc (struct t10_vpd *,unsigned char *);extern int transport_dump_vpd_ident_type (struct t10_vpd *,unsigned char *,int ); +extern int transport_set_vpd_ident_type (struct t10_vpd *,unsigned char *);extern int transport_dump_vpd_ident (struct t10_vpd *,unsigned char *,int ); -extern int transport_rescan_evpd_device_ident (struct se_device *); +extern int transport_set_vpd_ident (struct t10_vpd *,unsigned char *); extern struct se_device *transport_add_device_to_core_hba(struct se_hba *, struct se_subsystem_api *, struct se_subsystem_dev *, u32,
Signature · 1 line
1.5.6.5
PATCH 4/4 target: remove passthrough support
In reply to Nicholas A. BellingerFrom: Christoph Hellwig <[email protected]>
The SCF_CMD_PASSTHROUGH cmd passthrough support, which is a method of building an se_cmd for submission to a TCM backend se_device w/o an active fabric module se_port. This logic was originally used to obtain standard INQUIRY, EVPD 0x80/0x83 INQUIRY, and READ_CAPACITY during the backend ->create_virtdevice() -> se_device creation process.
This includes the removal of the main transport_allocate_passthrough() setup and completion code, along with the removal of a handful of special cases in the primary I/O setup and completion path, as well as code in transport_cmd_check_stop(), transport_lun_remove_cmd(), and transport_processing_shutdown().
Finally, this simplifys the cruft in transport_release_cmd_to_pool() now that SCF_CMD_PASSTHROUGH is no more..
Lightly tested and working OK with TCM_Loop + xfs_repair on .37-rc2 w/ TCM/IBLOCK LVM backend.
--- drivers/target/target_core_tmr.c | 5 +- drivers/target/target_core_transport.c | 480 ++++---------------------------- include/target/target_core_base.h | 38 ++-- include/target/target_core_transport.h | 4 - 4 files changed, 77 insertions(+), 450 deletions(-)
drivers/target/target_core_tmr.c +2 -3
@@ -248,11 +248,10 @@ int core_tmr_lun_reset(spin_unlock_irqrestore (&dev->execute_task_lock, flags);spin_lock_irqsave (&T_TASK (cmd)->t_state_lock, flags); -DEBUG_LR ("LUN_RESET: %s cmd: %p se_fabric_cmd_ptr: %p task: %p" +DEBUG_LR ("LUN_RESET: %s cmd: %p task: %p" " ITT/CmdSN: 0x%08x/0x%08x, i_state: %d, t_state/" "def_t_state: %d/%d cdb: 0x%02x\n" , - (preempt_and_abort_list) ?"Preempt" :"" , cmd, - cmd->se_fabric_cmd_ptr, task, + (preempt_and_abort_list) ?"Preempt" :"" , cmd, task,CMD_TFO (cmd)->get_task_tag (cmd),0 ,CMD_TFO (cmd)->get_cmd_state (cmd), cmd->t_state, cmd->deferred_t_state,T_TASK (cmd)->t_task_cdb[0 ]);
drivers/target/target_core_transport.c +58 -422
671 lines not on this page · raw message
include/target/target_core_base.h +17 -21
@@ -111,24 +111,23 @@ enum se_cmd_flags_table {SCF_SCSI_NON_DATA_CDB =0x00000040 ,SCF_SCSI_CDB_EXCEPTION =0x00000080 ,SCF_SCSI_RESERVATION_CONFLICT =0x00000100 , -SCF_CMD_PASSTHROUGH =0x00000200 , -SCF_CMD_PASSTHROUGH_NOALLOC =0x00000400 , -SCF_SE_CMD_FAILED =0x00000800 , -SCF_SE_LUN_CMD =0x00001000 , -SCF_SE_ALLOW_EOO =0x00002000 , -SCF_SE_DISABLE_ONLINE_CHECK =0x00004000 , -SCF_SENT_CHECK_CONDITION =0x00008000 , -SCF_OVERFLOW_BIT =0x00010000 , -SCF_UNDERFLOW_BIT =0x00020000 , -SCF_SENT_DELAYED_TAS =0x00040000 , -SCF_ALUA_NON_OPTIMIZED =0x00080000 , -SCF_DELAYED_CMD_FROM_SAM_ATTR =0x00100000 , -SCF_PASSTHROUGH_SG_TO_MEM =0x00200000 , -SCF_PASSTHROUGH_CONTIG_TO_SG =0x00400000 , -SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC =0x00800000 , -SCF_EMULATE_SYNC_CACHE =0x01000000 , -SCF_EMULATE_CDB_ASYNC =0x02000000 , -SCF_EMULATE_SYNC_UNMAP =0x04000000 +SCF_CMD_PASSTHROUGH_NOALLOC =0x00000200 , +SCF_SE_CMD_FAILED =0x00000400 , +SCF_SE_LUN_CMD =0x00000800 , +SCF_SE_ALLOW_EOO =0x00001000 , +SCF_SE_DISABLE_ONLINE_CHECK =0x00002000 , +SCF_SENT_CHECK_CONDITION =0x00004000 , +SCF_OVERFLOW_BIT =0x00008000 , +SCF_UNDERFLOW_BIT =0x00010000 , +SCF_SENT_DELAYED_TAS =0x00020000 , +SCF_ALUA_NON_OPTIMIZED =0x00040000 , +SCF_DELAYED_CMD_FROM_SAM_ATTR =0x00080000 , +SCF_PASSTHROUGH_SG_TO_MEM =0x00100000 , +SCF_PASSTHROUGH_CONTIG_TO_SG =0x00200000 , +SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC =0x00400000 , +SCF_EMULATE_SYNC_CACHE =0x00800000 , +SCF_EMULATE_CDB_ASYNC =0x01000000 , +SCF_EMULATE_SYNC_UNMAP =0x02000000 };/* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
@@ -431,8 +430,6 @@ struct se_transport_task {atomic_t transport_lun_stop;spinlock_t t_state_lock;struct completion t_transport_stop_comp; -struct completion t_transport_passthrough_comp; -struct completion t_transport_passthrough_wcomp;struct completion transport_lun_fe_stop_comp;struct completion transport_lun_stop_comp;struct scatterlist *t_tasks_sg_chained;
@@ -527,7 +524,6 @@ struct se_cmd {struct se_device *se_orig_obj_ptr;struct se_lun *se_lun;/* Only used for internal passthrough and legacy TCM fabric modules */ -void *se_fabric_cmd_ptr;struct se_session *se_sess;struct se_tmr_req *se_tmr_req;/* t_task is setup to t_task_backstore in transport_init_se_cmd() */
include/target/target_core_transport.h +0 -4
@@ -181,10 +181,6 @@ extern int transport_generic_handle_data(struct se_cmd *);extern int transport_generic_handle_tmr (struct se_cmd *);extern void __transport_stop_task_timer (struct se_task *,unsigned long *);extern unsigned char transport_asciihex_to_binaryhex (unsigned char val[2 ]); -extern struct se_cmd *transport_allocate_passthrough (unsigned char *,int ,u32 , -void *,u32 ,u32 ,void *); -extern void transport_passthrough_release (struct se_cmd *); -extern int transport_generic_passthrough (struct se_cmd *);extern int transport_generic_map_mem_to_cmd (struct se_cmd *cmd,struct scatterlist *,u32 ,struct scatterlist *,u32 );extern int transport_clear_lun_from_sessions (struct se_lun *);
Signature · 1 line
1.5.6.5
Re: [PATCH 1/4] target-pscsi: query tape blocksize using scsi_execute_req
In reply to Nicholas A. BellingerQuoted 26 lines · Nicholas A. Bellinger
From: Christoph Hellwig <[email protected]>
Use the native Linux scsi execution support instead of the target passthrough support to get the tape blocksize
Signed-off-by Christoph Hellwig <[email protected]>Signed-off-by Nicholas A. Bellinger <[email protected]>--- drivers/target/target_core_pscsi.c | 66 ++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 37 deletions(-)drivers/target/target_core_pscsi.c +7
-0@@ -181,6 +181,33 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)return 1 ; } +static void pscsi_tape_read_blocksize (struct se_device *dev, +struct scsi_device *sdev) +{ +unsigned char cdb[MAX_COMMAND_SIZE ], *buf; + + buf =kzalloc (12 ,GFP_KERNEL ); +if (!buf)
drivers/target/target_core_pscsi.c static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) · line 200
Quoted 10 lines
drivers/target/target_core_pscsi.c +10
-0+return ; + +memset (cdb,0 ,MAX_COMMAND_SIZE ); + cdb[0 ] =MODE_SENSE ; + cdb[4 ] =0x0c ;/* 12 bytes */ + +if (!scsi_execute_req (sdev, cdb,DMA_FROM_DEVICE , buf,12 ,NULL , +HZ ,1 ,NULL )) + goto out_free; +
Hrrrmmm, missed the bugfix for the proper return value of scsi_execute_req() here.
Committed the following incremental patch as 4793c9f04ba.
drivers/target/target_core_pscsi.c +4 -2
@@ -185,6 +185,7 @@ static void pscsi_tape_read_blocksize(struct se_device *dev, struct scsi_device *sdev) {unsigned char cdb[MAX_COMMAND_SIZE ], *buf; +int ret; buf =kzalloc (12 ,GFP_KERNEL );if (!buf)
@@ -194,8 +195,9 @@ static void pscsi_tape_read_blocksize(struct se_device *dev, cdb[0 ] =MODE_SENSE ; cdb[4 ] =0x0c ;/* 12 bytes */ -if (!scsi_execute_req (sdev, cdb,DMA_FROM_DEVICE , buf,12 ,NULL , -HZ ,1 ,NULL )) + ret =scsi_execute_req (sdev, cdb,DMA_FROM_DEVICE , buf,12 ,NULL , +HZ ,1 ,NULL ); +if (ret) goto out_free;/*
Signature · 1 line
1.5.6.5