: Add support for PREEMPT_AND_ABORT SA
PATCH 1/1 : Add support for PREEMPT_AND_ABORT SA
Greetings all,
This patch adds support for the PROUT PREEMPT_AND_ABORT service action to core_scsi3_emulate_pro_preempt() and core_tmr_lun_reset() using existing TAS (TASK_ABORTED status) emulation. The logic assigns the initiator port provided pre-registered reservation key to allocated SCSI Task and Task Management through logical unit ACLs in target_core_mod code.
This patch uses struct list_head preempt_and_abort_list inside of core_scsi3_emulate_pro_preempt() to track PR registrations/reservation data structure t10_pr_registration_t once it has been removed from the se_device_t list, and before they get released back into struct kmem_cache t10_pr_reg_cache in core_scsi3_release_preempt_and_abort().
These patches are made against lio-core-2.6.git/master and tested on v2.6.29 x86 32-bit HVM using sg_persist and sg_request from sg3_utils. The lio-core-2.6.git tree can be found at:
http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=summary
So far, I have been primarily testing the following scenario, which is what linux-cluster userspace in RHEL/CentOS (and everyone else) does with fence_scsi today for their WRITE Exclusive, Registrants Only persistent reservation setup. Here is test setup I am using:
# The same /sys/kernel/config/target/core/$HBA/$DEV Linux LVM object mapped across
# two different LIO-Target iSCSI target ports initiator# lsscsi --transport [3:0:0:0] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.cff3eedbd2fd,t,0x1 /dev/sde [4:0:0:0] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0,t,0x1 /dev/sdf
*) Initiator side using Open/iSCSI:
[ 185.682972] scsi3 : iSCSI Initiator over TCP/IP [ 185.998817] scsi 3:0:0:0: Direct-Access LIO-ORG IBLOCK 3.0 PQ: 0 ANSI: 5 [ 186.009172] sd 3:0:0:0: [sde] 128000 4096-byte hardware sectors (524 MB) [ 186.013274] sd 3:0:0:0: [sde] Write Protect is off [ 186.013286] sd 3:0:0:0: [sde] Mode Sense: 2f 00 00 00 [ 186.034372] sd 3:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 186.045854] sd 3:0:0:0: [sde] 128000 4096-byte hardware sectors (524 MB) [ 186.054955] sd 3:0:0:0: [sde] Write Protect is off [ 186.054967] sd 3:0:0:0: [sde] Mode Sense: 2f 00 00 00 [ 186.072648] sd 3:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 186.073401] sde: unknown partition table [ 186.084108] sd 3:0:0:0: [sde] Attached SCSI disk [ 186.085052] sd 3:0:0:0: Attached scsi generic sg4 type 0 [ 186.316470] alua: device handler registered [ 186.321957] sd 3:0:0:0: alua: supports implicit TPGS [ 186.326881] sd 3:0:0:0: alua: port group 00 rel port 02 [ 186.331445] sd 3:0:0:0: alua: port group 00 state A supports tousNA [ 186.372696] sd 3:0:0:0: alua: port group 00 state A supports tousNA [ 188.204172] scsi4 : iSCSI Initiator over TCP/IP [ 188.481410] scsi 4:0:0:0: Direct-Access LIO-ORG IBLOCK 3.0 PQ: 0 ANSI: 5 [ 188.489828] sd 4:0:0:0: [sdf] 128000 4096-byte hardware sectors (524 MB) [ 188.497081] sd 4:0:0:0: [sdf] Write Protect is off [ 188.497093] sd 4:0:0:0: [sdf] Mode Sense: 2f 00 00 00 [ 188.512344] sd 4:0:0:0: [sdf] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 188.525858] sd 4:0:0:0: [sdf] 128000 4096-byte hardware sectors (524 MB) [ 188.534314] sd 4:0:0:0: [sdf] Write Protect is off [ 188.534325] sd 4:0:0:0: [sdf] Mode Sense: 2f 00 00 00 [ 188.550966] sd 4:0:0:0: [sdf] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 188.557596] sdf: unknown partition table
# Register both ports
initiator# sg_persist --out --register --param-sark=0x1234abcd -Y -v /dev/sde initiator# sg_persist --out --register --param-sark=0x4567ffff -Y -v /dev/sdf # Create a write exclusive, registrants only persistent reservation initiator# sg_persist --out --reserve --param-rk=0x1234abcd --prout-type=5 -v /dev/sde
... Start running READ/WRITE I/O to /dev/sde ...
# Preempt the reservation on /dev/sdf using /dev/sde's reservation key..
initiator# sg_persist --out --preempt-abort --param-rk=0x4567ffff --param-sark=0x1234abcd --prout-type 5 -v /dev/sdf
[ 199.570148] sd 3:0:0:0: reservation conflict [ 205.461349] sd 3:0:0:0: reservation conflict [ 205.462076] sd 3:0:0:0: [sde] Result: hostbyte=DID_OK driverbyte=DRIVER_OK,SUGGEST_OK [ 205.462228] end_request: I/O error, dev sde, sector 384 [ 205.480997] sd 3:0:0:0: reservation conflict [ 205.481013] sd 3:0:0:0: [sde] Result: hostbyte=DID_OK driverbyte=DRIVER_OK,SUGGEST_OK
# Re-Register on the port that has been preempted
initiator# sg_persist --out --register --param-sark=0x1234abcd -Y -v /dev/sde
... Start running READ/WRITE I/O to /dev/sdf ..
# Preempt the reservation on /dev/sde using /dev/sdf's reservation key..
initiator# sg_persist --out --preempt-abort --param-rk=0x1234abcd --param-sark=0x4567ffff --prout-type 5 -v /dev/sde
[ 269.379004] sd 4:0:0:0: reservation conflict [ 269.379021] sd 4:0:0:0: [sdf] Result: hostbyte=DID_OK driverbyte=DRIVER_OK,SUGGEST_OK [ 269.379030] end_request: I/O error, dev sdf, sector 1280 [ 269.414193] sd 4:0:0:0: reservation conflict [ 269.414210] sd 4:0:0:0: [sdf] Result: hostbyte=DID_OK driverbyte=DRIVER_OK,SUGGEST_OK [ 269.414219] end_request: I/O error, dev sdf, sector 1024
and so on..
So far, things are looking good on the lio-core-2.6.git side, however I am able to trigger a BUG() from time to time in Open/iSCSI Initiator when returning include/scsi/scsi.h:SAM_STAT_TASK_ABORTED when TAS=1 in target_core_mod/ConfigFS, but other than that things are looking good with small amounts of outstanding CDBs being preempted and aborted. Sometimes the Open/iSCSI client side does a bus reset (restart the iSCSI session) instead of processing TASK_ABORTED status (which appear to be getting sent from target_core_mod), not sure if this is related to the BUG() that is triggered or not (will CC Open-iSCSI list).
*) Target side using lio-core-2.6.git on v2.6.29:
<SNIP>
SPC-3 PR [iSCSI] Service Action: REGISTER Initiator Node: iqn.1993-08.org.debian:01:2dadf92d0ef
SPC-3 PR [iSCSI] for ALL TCM Subsystem iblock Object Target Port(s)
SPC-3 PR [iSCSI] SA Res Key: 0x000000001234abcd PRgeneration: 0x00000013
SPC-3 PR [iSCSI] Service Action: implict RELEASE cleared reservation holder TYPE: Write Exclusive Access, Registrants Only ALL_TG_PT: 1
SPC-3 PR [iSCSI] RELEASE Node: iqn.1993-08.org.debian:01:2dadf92d0ef
SPC-3 PR [iSCSI] Service Action: UNREGISTER Initiator Node: iqn.1993-08.org.debian:01:2dadf92d0ef
SPC-3 PR [iSCSI] for ALL TCM Subsystem iblock Object Target Port(s)
SPC-3 PR [iSCSI] SA Res Key: 0x000000004567ffff PRgeneration: 0x00000011
[iSCSI]: Allocated UNIT ATTENTION, mapped LUN: 0, ASC: 0x2a, ASCQ: 0x03
SPC-3 PR [iSCSI] Service Action: PREEMPT_AND_ABORT created new reservation holder TYPE: Write Exclusive Access, Registrants Only ALL_TG_PT: 1
SPC-3 PR [iSCSI] PREEMPT_AND_ABORT from Node: iqn.1993-08.org.debian:01:2dadf92d0efLUN_RESET: Preempt starting for [iblock], tas: 1LUN_RESET: Preempt cmd: d3b5a300 task: d3193200 ITT/CmdSN: 0x2b000010/0x00000000, i_state: 1, t_state/def_t_state: 243/0 cdb: 0x2aLUN_RESET: ITT[0x2b000010] - pr_res_key: 0x000000004567ffff t_task_cdbs: 1 t_task_cdbs_left: 1 t_task_cdbs_sent: 0 -- t_transport_active: 0 t_transport_stop: 0 t_transport_sent: 0LUN_RESET: Got t_transport_active = 0 for task: d3193200, t_fe_count: 1 dev: dec3f000LUN_RESET: Preempt for [iblock] Complete
[iSCSI]: Releasing UNIT ATTENTION condition with INTLCK_CTRL: 0, mapped LUN: 0, got CDB: 0x2a reported ASC: 0x2a, ASCQ: 0x03
Conflict for WRITE CDB: 0x2a to Write Exclusive Access, Registrants Only reservation
Conflict for WRITE CDB: 0x2a to Write Exclusive Access, Registrants Only reservation
Conflict for WRITE CDB: 0x2a to Write Exclusive Access, Registrants Only reservation
--- drivers/lio-core/target_core_base.h | 4 + drivers/lio-core/target_core_device.c | 2 + drivers/lio-core/target_core_pr.c | 201 +++++++++++++++++++++--------- drivers/lio-core/target_core_pr.h | 2 + drivers/lio-core/target_core_tmr.c | 164 +++++++++++++++++------- drivers/lio-core/target_core_tmr.h | 3 +- drivers/lio-core/target_core_transport.c | 8 +- 7 files changed, 270 insertions(+), 114 deletions(-)
drivers/lio-core/target_core_base.h +4 -0
@@ -294,6 +294,7 @@ typedef struct t10_pr_registration_s {struct se_dev_entry_s *pr_reg_deve;struct se_lun_s *pr_reg_tg_pt_lun;struct list_head pr_reg_list; +struct list_head pr_reg_abort_list; } t10_pr_registration_t; typedef struct t10_reservation_template_s {
@@ -472,6 +473,8 @@ typedef struct se_cmd_s {u32 iov_data_count;/* Number of iovecs allocated for iscsi_cmd_t->iov_data */ u32 orig_iov_data_count; +/* Persistent Reservation key */ +u64 pr_res_key;atomic_t transport_sent;/* Used for sense data */ void *sense_buffer;
@@ -604,6 +607,7 @@ typedef struct se_dev_entry_s {u32 last_byte_count;u32 total_cmds;u32 total_bytes; +u64 pr_res_key;#ifdef SNMP_SUPPORT u64 creation_time;u32 attach_count;
drivers/lio-core/target_core_device.c +2 -0
@@ -266,6 +266,7 @@ extern int __transport_get_lun_for_cmd( deve->deve_cmds++; se_lun = se_cmd->se_lun = deve->se_lun; + se_cmd->pr_res_key = deve->pr_res_key; se_cmd->orig_fe_lun = unpacked_lun; se_cmd->se_orig_obj_api =SE_LUN (se_cmd)->lun_obj_api; se_cmd->se_orig_obj_ptr =SE_LUN (se_cmd)->lun_type_ptr;
@@ -346,6 +347,7 @@ extern int transport_get_lun_for_tmr(if (deve->lun_flags &TRANSPORT_LUNFLAGS_INITIATOR_ACCESS ) { se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun; dev = se_tmr->tmr_dev = se_lun->se_dev; + se_cmd->pr_res_key = deve->pr_res_key; se_cmd->orig_fe_lun = unpacked_lun; se_cmd->se_orig_obj_api =SE_LUN (se_cmd)->lun_obj_api; se_cmd->se_orig_obj_ptr =SE_LUN (se_cmd)->lun_type_ptr;
drivers/lio-core/target_core_pr.c +139 -62
387 lines not on this page · raw message
drivers/lio-core/target_core_pr.h +2 -0
@@ -46,6 +46,8 @@ extern void core_scsi3_free_pr_reg_from_nacl(struct se_device_s *, struct se_node_acl_s *);extern void core_scsi3_free_all_registrations (struct se_device_s *);extern unsigned char *core_scsi3_pr_dump_type (int ); +extern int core_scsi3_check_cdb_abort_and_preempt (struct list_head *, +struct se_cmd_s *);extern int core_scsi3_emulate_pr (struct se_cmd_s *);extern int core_setup_reservations (struct se_device_s *);
drivers/lio-core/target_core_tmr.c +115 -49
278 lines not on this page · raw message
drivers/lio-core/target_core_tmr.h +2 -1
@@ -37,6 +37,7 @@ extern struct kmem_cache *se_tmr_req_cache;extern struct se_tmr_req_s *core_tmr_alloc_req (struct se_cmd_s *,void *,u8 );extern void core_tmr_release_req (struct se_tmr_req_s *); -extern int core_tmr_lun_reset (struct se_device_s *,struct se_tmr_req_s *); +extern int core_tmr_lun_reset (struct se_device_s *,struct se_tmr_req_s *, +struct list_head *,struct se_cmd_s *);#endif /* TARGET_CORE_TMR_H */
drivers/lio-core/target_core_transport.c +6 -2
@@ -7357,7 +7357,11 @@ EXPORT_SYMBOL(transport_send_check_condition_and_sense);void transport_send_task_abort (se_cmd_t *cmd) { cmd->scsi_status =SAM_STAT_TASK_ABORTED ; - +#if 0 +printk (KERN_INFO "Setting SAM_STAT_TASK_ABORTED status for CDB: 0x%02x," +" ITT: 0x%08x\n" ,T_TASK (cmd)->t_task_cdb[0 ], +CMD_TFO (cmd)->get_task_tag (cmd)); +#endif if (!(cmd->se_cmd_flags &SCF_CMD_PASSTHROUGH ))CMD_TFO (cmd)->queue_status (cmd); }
@@ -7384,7 +7388,7 @@ int transport_generic_do_tmr(se_cmd_t *cmd) tmr->response =TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED ;break ;case LUN_RESET : - ret =core_tmr_lun_reset (dev, tmr); + ret =core_tmr_lun_reset (dev, tmr,NULL ,NULL ); tmr->response = (!ret) ?TMR_FUNCTION_COMPLETE :TMR_FUNCTION_REJECTED ;break ;
Signature · 1 line
1.5.4.1