: Enable PR_*_REGONLY and PR_*_ALLREG logic
PATCH 1/1 : Enable PR_*_REGONLY and PR_*_ALLREG logic
Greetings all,
This patch enables the remaining SPC-3 compliant persistent reservation for PR TYPEs:PR_TYPE_WRITE_EXCLUSIVE_REGONLY, PR_TYPE_EXCLUSIVE_ACCESS_REGONLY, PR_TYPE_WRITE_EXCLUSIVE_ALLREG and PR_TYPE_EXCLUSIVE_ACCESS_ALLREG.
This patch hooks up the CDB restriction logic following spc4r17 for *all* PR TYPEs in core_scsi3_pr_seq_non_holder(). It also enables all PR TYPEs emulation in core_scsi3_emulate_pro_reserve(), For PR OUT, the patch updates core_scsi3_pri_read_reservation() for PR_*_ALL_REG reservations to return zero (following spc4r17).
This patch leaves debug code ON for the restricted, non reservation holding path, so that we can see what CDBs the client side setups are generating for PR bringup. This means that for those folks interested in testing PR_*_ALL_REG types, this will generate alot of dmesg output for non reservation (but registered) initiator ports generation bulk I/O in core_scsi3_pr_seq_non_holder(). The verbose debug output will be disabled once things PR_*_ALL_REG gets a bit more testing.
Also, note that unit attention condition for PR_TYPE_*_REG_ONLY and PR_TYPE_*_ALLREG of ASC type RESERVATION RELEASED is not supported in this patch, and is a WIP.
This patch are made against lio-core-2.6.git/master and tested on v2.6.29-rc8 x86 32-bit HVM. 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
*) Here is the client side setup, sdg and sdk are the same IBLOCK LUN available across two different LIO-Target Endpoints (TargetName+TPGT) using an x86 HVM Open/iSCSI Initiator.
initiator# lsscsi --transport
[0:0:0:0] disk /dev/sda [0:0:1:0] disk /dev/sdb [0:0:2:0] disk /dev/sdc [1:0:0:0] disk /dev/sdd [10:0:0:0] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0,t,0x1 /dev/sdg [10:0:0:1] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0,t,0x1 /dev/sdh [10:0:0:2] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0,t,0x1 /dev/sdi [10:0:0:3] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0,t,0x1 /dev/sdj [12:0:0:0] disk iqn.2003-01.org.linux-iscsi.target.i686:sn.cff3eedbd2fd,t,0x1 /dev/sdk initiator# lsscsi [0:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda [0:0:1:0] disk VMware, VMware Virtual S 1.0 /dev/sdb [0:0:2:0] disk VMware, VMware Virtual S 1.0 /dev/sdc [1:0:0:0] disk ATA VMware Virtual I 0000 /dev/sdd [10:0:0:0] disk LIO-ORG IBLOCK 3.0 /dev/sdg [10:0:0:1] disk VMware, VMware Virtual S 1.0 /dev/sdh [10:0:0:2] disk LIO-ORG RAMDISK-MCP 3.0 /dev/sdi [10:0:0:3] disk LIO-ORG FILEIO 3.0 /dev/sdj [12:0:0:0] disk LIO-ORG IBLOCK 3.0 /dev/sdk
*) Here is what it looks like against sg_persist:
initiator# sg_persist --out --register-ignore --param-sark=0x1234dcba -Y -v /dev/sdg
inquiry cdb: 12 00 00 00 24 00
LIO-ORG IBLOCK 3.0
Peripheral device type: disk
Persistent Reservation Out cmd: 5f 06 00 00 00 00 00 00 18 00 PR out: command (Register and ignore existing key) successful
initiator# sg_persist --out --register-ignore --param-sark=0x5678ffff -Y -v /dev/sdk
inquiry cdb: 12 00 00 00 24 00
LIO-ORG IBLOCK 3.0
Peripheral device type: disk
Persistent Reservation Out cmd: 5f 06 00 00 00 00 00 00 18 00 PR out: command (Register and ignore existing key) successful
initiator# sg_persist --out --reserve --param-rk=0x1234dcba --prout-type=5 -v /dev/sdg
inquiry cdb: 12 00 00 00 24 00
LIO-ORG IBLOCK 3.0
Peripheral device type: disk
Persistent Reservation Out cmd: 5f 01 05 00 00 00 00 00 18 00 PR out: command (Reserve) successful
initiator# sg_persist --in --read-full-status /dev/sdg -v
inquiry cdb: 12 00 00 00 24 00
LIO-ORG IBLOCK 3.0
Peripheral device type: disk
Persistent Reservation In cmd: 5e 03 00 00 00 00 00 20 00 00 PR generation=0x2
Key=0x1234dcba
All target ports bit set
<< Reservation holder >>
scope: LU_SCOPE, type: Write Exclusive, registrants only Transport Id of initiator:
iSCSI world wide unique port id: iqn.1993-08.org.debian:01:2dadf92d0ef
Key=0x5678ffff
All target ports bit set
not reservation holder
Transport Id of initiator:
iSCSI world wide unique port id: iqn.1993-08.org.debian:01:2dadf92d0ef
initiator# sg_persist --in --report-capabilities /dev/sdg -v
inquiry cdb: 12 00 00 00 24 00
LIO-ORG IBLOCK 3.0
Peripheral device type: disk
Persistent Reservation In cmd: 5e 02 00 00 00 00 00 20 00 00 Report capabilities response:
Compatible Reservation Handling(CRH): 0
Specify Initiator Ports Capable(SIP_C): 0
All Target Ports Capable(ATP_C): 1
Persist Through Power Loss Capable(PTPL_C): 0
Type Mask Valid(TMV): 1
Allow commands: 1
Persist Through Power Loss Active(PTPL_A): 0
Support indicated in Type mask:
Write Exclusive, all registrants: 1
Exclusive Access, registrants only: 1
Write Exclusive, registrants only: 1
Exclusive Access: 1
Write Exclusive: 1
Exclusive Access, all registrants: 1
*) cat /sys/kernel/config/target/core/iblock_0/lvm_test0/pr/*
SPC-3 Reservation: iSCSI Initiator: iqn.1993-08.org.debian:01:2dadf92d0ef
SPC-3 Reservation: All Target Ports registration0x00000004
SPC-3 Reservation: iSCSI Target Node Endpoint: iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0 SPC-3 Reservation: Relative Port Identifer Tag: 1 iSCSI Portal Group Tag: 1 iSCSI Logical Unit: 0 SPC-3 PR Registrations:
iSCSI Node: iqn.1993-08.org.debian:01:2dadf92d0ef Key: 0x000000001234dcba PRgen: 0x00000003 iSCSI Node: iqn.1993-08.org.debian:01:2dadf92d0ef Key: 0x000000005678ffff PRgen: 0x00000001 SPC-3 Reservation Type: Write Exclusive Access, Registrants Only
*) dmesg output
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x00 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x25 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x1a for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x1a for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x1a for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x00 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x25 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x1a for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x1a for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x1a for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0xa0 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
PSCSI Status Byte exception at task: df3bf000 CDB: 0x12 Result: 0x08000002
PSCSI Status Byte exception at task: df3bf000 CDB: 0x12 Result: 0x08000002
TARGET_CORE[iSCSI]: Expected Transfer Length: 512 does not match SCSI CDB Length: 4096 for SAM Opcode: 0x28
Failing OVERFLOW/UNDERFLOW for LBA op CDB on non 512-byte sector setup subsystem plugin: rd_mcp
TARGET_CORE[iSCSI]: Expected Transfer Length: 512 does not match SCSI CDB Length: 4096 for SAM Opcode: 0x28
Failing OVERFLOW/UNDERFLOW for LBA op CDB on non 512-byte sector setup subsystem plugin: fileio
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x00 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0xa3 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x00 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0xa3 for NON Write Exclusive Access, Registrants Only reservation holder
TARGET_CORE[iSCSI]: Expected Transfer Length: 512 does not match SCSI CDB Length: 4096 for SAM Opcode: 0x28
Failing OVERFLOW/UNDERFLOW for LBA op CDB on non 512-byte sector setup subsystem plugin: rd_mcp
TARGET_CORE[iSCSI]: Expected Transfer Length: 512 does not match SCSI CDB Length: 4096 for SAM Opcode: 0x28
Failing OVERFLOW/UNDERFLOW for LBA op CDB on non 512-byte sector setup subsystem plugin: fileio
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Allowing CDB: 0x5f for NON Write Exclusive Access, Registrants Only reservation holder
SPC-3 PR [iSCSI] REGISTER_AND_IGNORE_EXISTING_KEY: Changed Reservation Key for iqn.1993-08.org.debian:01:2dadf92d
0ef to: 0x000000005678ffff PRgeneration: 0x00000002
Allowing CDB: 0x28 for Write Exclusive Access, Registrants Only reservation
Conflict for WRITE CDB: 0x2a to Write Exclusive Access, Registrants Only reservation
SPC-3 PR RESERVE: Received res_key: 0x000000001234abcd does not match existing SA REGISTER res_key: 0x000000005678ffff
SPC-3 PR [iSCSI] REGISTER_AND_IGNORE_EXISTING_KEY: Changed Reservation Key for iqn.1993-08.org.debian:01:2dadf92d0ef to: 0x000000001234dcba PRgeneration: 0x00000003 Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Conflict for WRITE CDB: 0x5f to Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x5e for Write Exclusive Access, Registrants Only reservation
Allowing CDB: 0x12 for NON Write Exclusive Access, Registrants Only reservation holder
Conflict for WRITE CDB: 0x5f to Write Exclusive Access, Registrants Only reservation
--- drivers/lio-core/target_core_base.h | 30 ++-- drivers/lio-core/target_core_pr.c | 262 +++++++++++++++++++++--------- drivers/lio-core/target_core_transport.c | 6 +- 3 files changed, 203 insertions(+), 95 deletions(-)
drivers/lio-core/target_core_base.h +15 -15
@@ -279,6 +279,19 @@ typedef enum {struct se_cmd_s ; +typedef struct t10_pr_registration_s { +int pr_reg_all_tg_pt;/* Reservation effects all target ports */ +int pr_res_holder; +int pr_res_type; +int pr_res_scope; +u32 pr_res_generation; +u64 pr_res_key; +struct se_node_acl_s *pr_reg_nacl; +struct se_dev_entry_s *pr_reg_deve; +struct se_lun_s *pr_reg_tg_pt_lun; +struct list_head pr_reg_list; +}t10_pr_registration_t ; + typedef struct t10_reservation_template_s { /* Reservation effects all target ports */ int pr_all_tg_pt;
@@ -288,27 +301,14 @@ typedef struct t10_reservation_template_s {/* Reservation holder when pr_all_tg_pt=1 */ struct se_node_acl_s *pr_res_holder;struct list_head registration_list; -int (*t10_reservation_check)(struct se_cmd_s *); +int (*t10_reservation_check)(struct se_cmd_s *,u32 *);int (*t10_reserve)(struct se_cmd_s *);int (*t10_release)(struct se_cmd_s *); -int (*t10_seq_non_holder)(struct se_cmd_s *,unsigned char *); +int (*t10_seq_non_holder)(struct se_cmd_s *,unsigned char *,u32 );int (*t10_pr_register)(struct se_cmd_s *);int (*t10_pr_clear)(struct se_cmd_s *); }____cacheline_aligned t10_reservation_template_t; -typedef struct t10_pr_registration_s { -int pr_reg_all_tg_pt;/* Reservation effects all target ports */ -int pr_res_holder; -int pr_res_type; -int pr_res_scope; -u32 pr_res_generation; -u64 pr_res_key; -struct se_node_acl_s *pr_reg_nacl; -struct se_dev_entry_s *pr_reg_deve; -struct se_lun_s *pr_reg_tg_pt_lun; -struct list_head pr_reg_list; -}t10_pr_registration_t ; - typedef struct se_queue_req_s { int state; void *queue_se_obj_ptr;
drivers/lio-core/target_core_pr.c +185 -77
414 lines not on this page · raw message
drivers/lio-core/target_core_transport.c +3 -3
@@ -4667,10 +4667,10 @@ static int transport_generic_cmd_sequencer(se_device_t *dev =SE_DEV (cmd);se_subsystem_dev_t *su_dev = dev->se_sub_dev;int ret =0 , sector_ret =0 ; -u32 sectors =0 , size =0 ; +u32 sectors =0 , size =0 , pr_reg_type =0 ; -if (T10_RES (su_dev)->t10_reservation_check (cmd) !=0 ) { -if (T10_RES (su_dev)->t10_seq_non_holder (cmd, cdb) !=0 ) { +if (T10_RES (su_dev)->t10_reservation_check (cmd, &pr_reg_type) !=0 ) { +if (T10_RES (su_dev)->t10_seq_non_holder (cmd, cdb, pr_reg_type) !=0 ) { cmd->transport_wait_for_tasks = &transport_nop_wait_for_tasks;transport_get_maps (cmd);
Signature · 9 lines
1.5.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html