@@ -3164,6 +3164,8 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
sense_reason_t ret;
unsigned short rtpi;
unsigned char proto_ident;
+ char *isid = NULL, dest_buf[PR_REG_ISID_ID_LEN];
+ struct se_session *dest_sess = NULL;
if (!se_sess || !se_lun) {
pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n");
@@ -3347,6 +3349,19 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
goto out;
}
+ dest_sess = dest_node_acl->nacl_sess;
+ if (!dest_sess) {
+ pr_err("nacl_sess for dest_node_acl is NULL.\n");
+ atomic_dec_mb(&dest_node_acl->acl_pr_ref_count);
+ dest_node_acl = NULL;
+ ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
+ goto out;
+ }
+ if (dest_tf_ops->sess_get_initiator_sid != NULL) {
+ dest_tf_ops->sess_get_initiator_sid(dest_sess, &dest_buf[0], PR_REG_ISID_LEN);
+ isid = &dest_buf[0];
+ }
+
if (core_scsi3_nodeacl_depend_item(dest_node_acl)) {
pr_err("core_scsi3_nodeacl_depend_item() for"
" dest_node_acl\n");
@@ -3435,6 +3450,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
*/
type = pr_res_holder->pr_res_type;
scope = pr_res_holder->pr_res_type;
+ isid = (iport_ptr) ? iport_ptr : isid;
/*
* c) Associate the reservation key specified in the SERVICE ACTION
* RESERVATION KEY field with the I_T nexus specified as the
@@ -3456,7 +3472,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
* reservation key or a different reservation key.
*/
dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl,
- iport_ptr);
+ isid);
if (!dest_pr_reg) {
struct se_lun *dest_lun = rcu_dereference_check(dest_se_deve->se_lun,
kref_read(&dest_se_deve->pr_kref) != 0);
@@ -3464,15 +3480,19 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
spin_unlock(&dev->dev_reservation_lock);
if (core_scsi3_alloc_registration(cmd->se_dev, dest_node_acl,
dest_lun, dest_se_deve, dest_se_deve->mapped_lun,
- iport_ptr, sa_res_key, 0, aptpl, 2, 1)) {
+ isid, sa_res_key, 0, aptpl, 2, 1)) {
ret = TCM_INVALID_PARAMETER_LIST;
goto out;
}
spin_lock(&dev->dev_reservation_lock);
dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl,
- iport_ptr);
+ isid);
new_reg = 1;
}
+ if (!dest_pr_reg) {
+ ret = TCM_INVALID_PARAMETER_LIST;
+ goto out;
+ }
/*
* f) Release the persistent reservation for the persistent reservation
* holder (i.e., the I_T nexus on which the