: Add per-device attribute 'enforce_pr_isids'
Subsystems (2)
PATCH 4/4 : Add per-device attribute 'enforce_pr_isids'
From: Nicholas Bellinger <[email protected]>
This patch adds a per-device configfs attribute for enforce persistent reservation ISIDs at:
/sys/kernel/config/target/core/$HBA/$DEV/attrib/enforce_pr_isids
By default this is '1', which means that ISID matching for PR operations will be strictly enforced in target_core_pr.c:__core_scsi3_locate_pr_reg() This means that an SCSI Initiator Port using ISIDs for TransportIDs must supply the same ISID in order to access an existing PR registration or reservation, otherwise the SCSI Initiator Port will be expected to perform a new PR registration.
When this attribute is disabled with '0', PR registrations created without an ISID (from ALL_TG_PT=1 and SPEC_I_PT=1 TransportIDs for example) will be allowed to match in __core_scsi3_locate_pr_reg(), allowing for a level of compatibility with persistent reservation consumers w/o using ISID aware TransportIDs.
This attribute may end up going away at some point, but it is useful now for supporting all possible persistent reservation scenarios.
--- drivers/target/target_core_configfs.c | 4 ++++ drivers/target/target_core_device.c | 12 ++++++++++++ include/target/target_core_device.h | 1 + include/target/target_core_transport.h | 2 ++ 4 files changed, 19 insertions(+), 0 deletions(-)
drivers/target/target_core_configfs.c +4 -0
@@ -527,6 +527,9 @@ SE_DEV_ATTR(emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR);DEF_DEV_ATTRIB (emulate_tas);SE_DEV_ATTR (emulate_tas,S_IRUGO |S_IWUSR ); +DEF_DEV_ATTRIB (enforce_pr_isids); +SE_DEV_ATTR (enforce_pr_isids,S_IRUGO |S_IWUSR ); +DEF_DEV_ATTRIB_RO (hw_block_size);SE_DEV_ATTR_RO (hw_block_size);
@@ -553,6 +556,7 @@ CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib_s, da_group);static struct configfs_attribute *target_core_dev_attrib_attrs[] = { &target_core_dev_attrib_emulate_ua_intlck_ctrl.attr, &target_core_dev_attrib_emulate_tas.attr, + &target_core_dev_attrib_enforce_pr_isids.attr, &target_core_dev_attrib_hw_block_size.attr, &target_core_dev_attrib_block_size.attr, &target_core_dev_attrib_hw_max_sectors.attr,
drivers/target/target_core_device.c +12 -0
@@ -1003,6 +1003,7 @@ void se_dev_set_default_attribs(se_device_t *dev)DEV_ATTRIB (dev)->emulate_tas =DA_EMULATE_TAS ;DEV_ATTRIB (dev)->emulate_reservations =DA_EMULATE_RESERVATIONS ;DEV_ATTRIB (dev)->emulate_alua =DA_EMULATE_ALUA ; +DEV_ATTRIB (dev)->enforce_pr_isids =DA_ENFORCE_PR_ISIDS ;/* * block_size is based on subsystem plugin dependent requirements. */
@@ -1089,6 +1090,17 @@ int se_dev_set_emulate_tas(se_device_t *dev, int flag)return 0 ; } +int se_dev_set_enforce_pr_isids (se_device_t *dev,int flag) +{ +if ((flag !=0 ) && (flag !=1 )) { +printk (KERN_ERR "Illegal value %d\n" , flag); +return -1 ; + } +DEV_ATTRIB (dev)->enforce_pr_isids = flag; +printk (KERN_INFO "dev[%p]: SE Device enforce_pr_isids bit: %s\n" , dev, + (DEV_ATTRIB (dev)->enforce_pr_isids) ?"Enabled" :"Disabled" ); +return 0 ; +}/* * Note, this can only be called on unexported SE Device Object. */
include/target/target_core_device.h +1 -0
@@ -63,6 +63,7 @@ extern void se_dev_set_default_attribs(se_device_t *);extern int se_dev_set_task_timeout (se_device_t *,u32 );extern int se_dev_set_emulate_ua_intlck_ctrl (se_device_t *,int );extern int se_dev_set_emulate_tas (se_device_t *,int ); +extern int se_dev_set_enforce_pr_isids (se_device_t *,int );extern int se_dev_set_queue_depth (se_device_t *,u32 );extern int se_dev_set_max_sectors (se_device_t *,u32 );extern int se_dev_set_block_size (se_device_t *,u32 );
include/target/target_core_transport.h +2 -0
@@ -109,6 +109,8 @@#define DA_EMULATE_RESERVATIONS 0/* No Emulation for PSCSI by default */ #define DA_EMULATE_ALUA 0 +/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */ +#define DA_ENFORCE_PR_ISIDS 1#define DA_STATUS_MAX_SECTORS_MIN 16#define DA_STATUS_MAX_SECTORS_MAX 8192
Signature · 1 line
1.5.6.5