diff options
Diffstat (limited to 'drivers/target/target_core_pr.c')
-rw-r--r-- | drivers/target/target_core_pr.c | 364 |
1 files changed, 182 insertions, 182 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index b662db3a320b..27a7525971b9 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -105,13 +105,13 @@ static int core_scsi2_reservation_check(struct se_cmd *cmd, u32 *pr_reg_type) | |||
105 | } | 105 | } |
106 | if (dev->dev_reserved_node_acl != sess->se_node_acl) { | 106 | if (dev->dev_reserved_node_acl != sess->se_node_acl) { |
107 | spin_unlock(&dev->dev_reservation_lock); | 107 | spin_unlock(&dev->dev_reservation_lock); |
108 | return -1; | 108 | return -EINVAL; |
109 | } | 109 | } |
110 | if (!(dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID)) { | 110 | if (!(dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID)) { |
111 | spin_unlock(&dev->dev_reservation_lock); | 111 | spin_unlock(&dev->dev_reservation_lock); |
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
114 | ret = (dev->dev_res_bin_isid == sess->sess_bin_isid) ? 0 : -1; | 114 | ret = (dev->dev_res_bin_isid == sess->sess_bin_isid) ? 0 : -EINVAL; |
115 | spin_unlock(&dev->dev_reservation_lock); | 115 | spin_unlock(&dev->dev_reservation_lock); |
116 | 116 | ||
117 | return ret; | 117 | return ret; |
@@ -143,8 +143,8 @@ static int core_scsi2_reservation_release(struct se_cmd *cmd) | |||
143 | dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID; | 143 | dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID; |
144 | } | 144 | } |
145 | printk(KERN_INFO "SCSI-2 Released reservation for %s LUN: %u ->" | 145 | printk(KERN_INFO "SCSI-2 Released reservation for %s LUN: %u ->" |
146 | " MAPPED LUN: %u for %s\n", TPG_TFO(tpg)->get_fabric_name(), | 146 | " MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(), |
147 | SE_LUN(cmd)->unpacked_lun, cmd->se_deve->mapped_lun, | 147 | cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun, |
148 | sess->se_node_acl->initiatorname); | 148 | sess->se_node_acl->initiatorname); |
149 | spin_unlock(&dev->dev_reservation_lock); | 149 | spin_unlock(&dev->dev_reservation_lock); |
150 | 150 | ||
@@ -157,8 +157,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
157 | struct se_session *sess = cmd->se_sess; | 157 | struct se_session *sess = cmd->se_sess; |
158 | struct se_portal_group *tpg = sess->se_tpg; | 158 | struct se_portal_group *tpg = sess->se_tpg; |
159 | 159 | ||
160 | if ((T_TASK(cmd)->t_task_cdb[1] & 0x01) && | 160 | if ((cmd->t_task->t_task_cdb[1] & 0x01) && |
161 | (T_TASK(cmd)->t_task_cdb[1] & 0x02)) { | 161 | (cmd->t_task->t_task_cdb[1] & 0x02)) { |
162 | printk(KERN_ERR "LongIO and Obselete Bits set, returning" | 162 | printk(KERN_ERR "LongIO and Obselete Bits set, returning" |
163 | " ILLEGAL_REQUEST\n"); | 163 | " ILLEGAL_REQUEST\n"); |
164 | return PYX_TRANSPORT_ILLEGAL_REQUEST; | 164 | return PYX_TRANSPORT_ILLEGAL_REQUEST; |
@@ -174,12 +174,12 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
174 | if (dev->dev_reserved_node_acl && | 174 | if (dev->dev_reserved_node_acl && |
175 | (dev->dev_reserved_node_acl != sess->se_node_acl)) { | 175 | (dev->dev_reserved_node_acl != sess->se_node_acl)) { |
176 | printk(KERN_ERR "SCSI-2 RESERVATION CONFLIFT for %s fabric\n", | 176 | printk(KERN_ERR "SCSI-2 RESERVATION CONFLIFT for %s fabric\n", |
177 | TPG_TFO(tpg)->get_fabric_name()); | 177 | tpg->se_tpg_tfo->get_fabric_name()); |
178 | printk(KERN_ERR "Original reserver LUN: %u %s\n", | 178 | printk(KERN_ERR "Original reserver LUN: %u %s\n", |
179 | SE_LUN(cmd)->unpacked_lun, | 179 | cmd->se_lun->unpacked_lun, |
180 | dev->dev_reserved_node_acl->initiatorname); | 180 | dev->dev_reserved_node_acl->initiatorname); |
181 | printk(KERN_ERR "Current attempt - LUN: %u -> MAPPED LUN: %u" | 181 | printk(KERN_ERR "Current attempt - LUN: %u -> MAPPED LUN: %u" |
182 | " from %s \n", SE_LUN(cmd)->unpacked_lun, | 182 | " from %s \n", cmd->se_lun->unpacked_lun, |
183 | cmd->se_deve->mapped_lun, | 183 | cmd->se_deve->mapped_lun, |
184 | sess->se_node_acl->initiatorname); | 184 | sess->se_node_acl->initiatorname); |
185 | spin_unlock(&dev->dev_reservation_lock); | 185 | spin_unlock(&dev->dev_reservation_lock); |
@@ -193,8 +193,8 @@ static int core_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
193 | dev->dev_flags |= DF_SPC2_RESERVATIONS_WITH_ISID; | 193 | dev->dev_flags |= DF_SPC2_RESERVATIONS_WITH_ISID; |
194 | } | 194 | } |
195 | printk(KERN_INFO "SCSI-2 Reserved %s LUN: %u -> MAPPED LUN: %u" | 195 | printk(KERN_INFO "SCSI-2 Reserved %s LUN: %u -> MAPPED LUN: %u" |
196 | " for %s\n", TPG_TFO(tpg)->get_fabric_name(), | 196 | " for %s\n", tpg->se_tpg_tfo->get_fabric_name(), |
197 | SE_LUN(cmd)->unpacked_lun, cmd->se_deve->mapped_lun, | 197 | cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun, |
198 | sess->se_node_acl->initiatorname); | 198 | sess->se_node_acl->initiatorname); |
199 | spin_unlock(&dev->dev_reservation_lock); | 199 | spin_unlock(&dev->dev_reservation_lock); |
200 | 200 | ||
@@ -215,9 +215,9 @@ int core_scsi2_emulate_crh(struct se_cmd *cmd) | |||
215 | struct se_session *se_sess = cmd->se_sess; | 215 | struct se_session *se_sess = cmd->se_sess; |
216 | struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; | 216 | struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; |
217 | struct t10_pr_registration *pr_reg; | 217 | struct t10_pr_registration *pr_reg; |
218 | struct t10_reservation_template *pr_tmpl = &su_dev->t10_reservation; | 218 | struct t10_reservation *pr_tmpl = &su_dev->t10_pr; |
219 | unsigned char *cdb = &T_TASK(cmd)->t_task_cdb[0]; | 219 | unsigned char *cdb = &cmd->t_task->t_task_cdb[0]; |
220 | int crh = (T10_RES(su_dev)->res_type == SPC3_PERSISTENT_RESERVATIONS); | 220 | int crh = (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS); |
221 | int conflict = 0; | 221 | int conflict = 0; |
222 | 222 | ||
223 | if (!(se_sess)) | 223 | if (!(se_sess)) |
@@ -307,7 +307,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
307 | u32 pr_reg_type) | 307 | u32 pr_reg_type) |
308 | { | 308 | { |
309 | struct se_dev_entry *se_deve; | 309 | struct se_dev_entry *se_deve; |
310 | struct se_session *se_sess = SE_SESS(cmd); | 310 | struct se_session *se_sess = cmd->se_sess; |
311 | int other_cdb = 0, ignore_reg; | 311 | int other_cdb = 0, ignore_reg; |
312 | int registered_nexus = 0, ret = 1; /* Conflict by default */ | 312 | int registered_nexus = 0, ret = 1; /* Conflict by default */ |
313 | int all_reg = 0, reg_only = 0; /* ALL_REG, REG_ONLY */ | 313 | int all_reg = 0, reg_only = 0; /* ALL_REG, REG_ONLY */ |
@@ -362,7 +362,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
362 | registered_nexus = 1; | 362 | registered_nexus = 1; |
363 | break; | 363 | break; |
364 | default: | 364 | default: |
365 | return -1; | 365 | return -EINVAL; |
366 | } | 366 | } |
367 | /* | 367 | /* |
368 | * Referenced from spc4r17 table 45 for *NON* PR holder access | 368 | * Referenced from spc4r17 table 45 for *NON* PR holder access |
@@ -414,7 +414,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
414 | default: | 414 | default: |
415 | printk(KERN_ERR "Unknown PERSISTENT_RESERVE_OUT service" | 415 | printk(KERN_ERR "Unknown PERSISTENT_RESERVE_OUT service" |
416 | " action: 0x%02x\n", cdb[1] & 0x1f); | 416 | " action: 0x%02x\n", cdb[1] & 0x1f); |
417 | return -1; | 417 | return -EINVAL; |
418 | } | 418 | } |
419 | break; | 419 | break; |
420 | case RELEASE: | 420 | case RELEASE: |
@@ -461,7 +461,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
461 | default: | 461 | default: |
462 | printk(KERN_ERR "Unknown MI Service Action: 0x%02x\n", | 462 | printk(KERN_ERR "Unknown MI Service Action: 0x%02x\n", |
463 | (cdb[1] & 0x1f)); | 463 | (cdb[1] & 0x1f)); |
464 | return -1; | 464 | return -EINVAL; |
465 | } | 465 | } |
466 | break; | 466 | break; |
467 | case ACCESS_CONTROL_IN: | 467 | case ACCESS_CONTROL_IN: |
@@ -549,7 +549,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
549 | 549 | ||
550 | static u32 core_scsi3_pr_generation(struct se_device *dev) | 550 | static u32 core_scsi3_pr_generation(struct se_device *dev) |
551 | { | 551 | { |
552 | struct se_subsystem_dev *su_dev = SU_DEV(dev); | 552 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
553 | u32 prg; | 553 | u32 prg; |
554 | /* | 554 | /* |
555 | * PRGeneration field shall contain the value of a 32-bit wrapping | 555 | * PRGeneration field shall contain the value of a 32-bit wrapping |
@@ -561,7 +561,7 @@ static u32 core_scsi3_pr_generation(struct se_device *dev) | |||
561 | * See spc4r17 section 6.3.12 READ_KEYS service action | 561 | * See spc4r17 section 6.3.12 READ_KEYS service action |
562 | */ | 562 | */ |
563 | spin_lock(&dev->dev_reservation_lock); | 563 | spin_lock(&dev->dev_reservation_lock); |
564 | prg = T10_RES(su_dev)->pr_generation++; | 564 | prg = su_dev->t10_pr.pr_generation++; |
565 | spin_unlock(&dev->dev_reservation_lock); | 565 | spin_unlock(&dev->dev_reservation_lock); |
566 | 566 | ||
567 | return prg; | 567 | return prg; |
@@ -592,14 +592,14 @@ static int core_scsi3_pr_reservation_check( | |||
592 | cmd->pr_res_key = dev->dev_pr_res_holder->pr_res_key; | 592 | cmd->pr_res_key = dev->dev_pr_res_holder->pr_res_key; |
593 | if (dev->dev_pr_res_holder->pr_reg_nacl != sess->se_node_acl) { | 593 | if (dev->dev_pr_res_holder->pr_reg_nacl != sess->se_node_acl) { |
594 | spin_unlock(&dev->dev_reservation_lock); | 594 | spin_unlock(&dev->dev_reservation_lock); |
595 | return -1; | 595 | return -EINVAL; |
596 | } | 596 | } |
597 | if (!(dev->dev_pr_res_holder->isid_present_at_reg)) { | 597 | if (!(dev->dev_pr_res_holder->isid_present_at_reg)) { |
598 | spin_unlock(&dev->dev_reservation_lock); | 598 | spin_unlock(&dev->dev_reservation_lock); |
599 | return 0; | 599 | return 0; |
600 | } | 600 | } |
601 | ret = (dev->dev_pr_res_holder->pr_reg_bin_isid == | 601 | ret = (dev->dev_pr_res_holder->pr_reg_bin_isid == |
602 | sess->sess_bin_isid) ? 0 : -1; | 602 | sess->sess_bin_isid) ? 0 : -EINVAL; |
603 | /* | 603 | /* |
604 | * Use bit in *pr_reg_type to notify ISID mismatch in | 604 | * Use bit in *pr_reg_type to notify ISID mismatch in |
605 | * core_scsi3_pr_seq_non_holder(). | 605 | * core_scsi3_pr_seq_non_holder(). |
@@ -620,7 +620,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( | |||
620 | int all_tg_pt, | 620 | int all_tg_pt, |
621 | int aptpl) | 621 | int aptpl) |
622 | { | 622 | { |
623 | struct se_subsystem_dev *su_dev = SU_DEV(dev); | 623 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
624 | struct t10_pr_registration *pr_reg; | 624 | struct t10_pr_registration *pr_reg; |
625 | 625 | ||
626 | pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_ATOMIC); | 626 | pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_ATOMIC); |
@@ -629,7 +629,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( | |||
629 | return NULL; | 629 | return NULL; |
630 | } | 630 | } |
631 | 631 | ||
632 | pr_reg->pr_aptpl_buf = kzalloc(T10_RES(su_dev)->pr_aptpl_buf_len, | 632 | pr_reg->pr_aptpl_buf = kzalloc(su_dev->t10_pr.pr_aptpl_buf_len, |
633 | GFP_ATOMIC); | 633 | GFP_ATOMIC); |
634 | if (!(pr_reg->pr_aptpl_buf)) { | 634 | if (!(pr_reg->pr_aptpl_buf)) { |
635 | printk(KERN_ERR "Unable to allocate pr_reg->pr_aptpl_buf\n"); | 635 | printk(KERN_ERR "Unable to allocate pr_reg->pr_aptpl_buf\n"); |
@@ -803,7 +803,7 @@ out: | |||
803 | } | 803 | } |
804 | 804 | ||
805 | int core_scsi3_alloc_aptpl_registration( | 805 | int core_scsi3_alloc_aptpl_registration( |
806 | struct t10_reservation_template *pr_tmpl, | 806 | struct t10_reservation *pr_tmpl, |
807 | u64 sa_res_key, | 807 | u64 sa_res_key, |
808 | unsigned char *i_port, | 808 | unsigned char *i_port, |
809 | unsigned char *isid, | 809 | unsigned char *isid, |
@@ -819,13 +819,13 @@ int core_scsi3_alloc_aptpl_registration( | |||
819 | 819 | ||
820 | if (!(i_port) || !(t_port) || !(sa_res_key)) { | 820 | if (!(i_port) || !(t_port) || !(sa_res_key)) { |
821 | printk(KERN_ERR "Illegal parameters for APTPL registration\n"); | 821 | printk(KERN_ERR "Illegal parameters for APTPL registration\n"); |
822 | return -1; | 822 | return -EINVAL; |
823 | } | 823 | } |
824 | 824 | ||
825 | pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_KERNEL); | 825 | pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_KERNEL); |
826 | if (!(pr_reg)) { | 826 | if (!(pr_reg)) { |
827 | printk(KERN_ERR "Unable to allocate struct t10_pr_registration\n"); | 827 | printk(KERN_ERR "Unable to allocate struct t10_pr_registration\n"); |
828 | return -1; | 828 | return -ENOMEM; |
829 | } | 829 | } |
830 | pr_reg->pr_aptpl_buf = kzalloc(pr_tmpl->pr_aptpl_buf_len, GFP_KERNEL); | 830 | pr_reg->pr_aptpl_buf = kzalloc(pr_tmpl->pr_aptpl_buf_len, GFP_KERNEL); |
831 | 831 | ||
@@ -893,11 +893,11 @@ static void core_scsi3_aptpl_reserve( | |||
893 | 893 | ||
894 | printk(KERN_INFO "SPC-3 PR [%s] Service Action: APTPL RESERVE created" | 894 | printk(KERN_INFO "SPC-3 PR [%s] Service Action: APTPL RESERVE created" |
895 | " new reservation holder TYPE: %s ALL_TG_PT: %d\n", | 895 | " new reservation holder TYPE: %s ALL_TG_PT: %d\n", |
896 | TPG_TFO(tpg)->get_fabric_name(), | 896 | tpg->se_tpg_tfo->get_fabric_name(), |
897 | core_scsi3_pr_dump_type(pr_reg->pr_res_type), | 897 | core_scsi3_pr_dump_type(pr_reg->pr_res_type), |
898 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); | 898 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); |
899 | printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n", | 899 | printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n", |
900 | TPG_TFO(tpg)->get_fabric_name(), node_acl->initiatorname, | 900 | tpg->se_tpg_tfo->get_fabric_name(), node_acl->initiatorname, |
901 | (prf_isid) ? &i_buf[0] : ""); | 901 | (prf_isid) ? &i_buf[0] : ""); |
902 | } | 902 | } |
903 | 903 | ||
@@ -913,7 +913,7 @@ static int __core_scsi3_check_aptpl_registration( | |||
913 | struct se_dev_entry *deve) | 913 | struct se_dev_entry *deve) |
914 | { | 914 | { |
915 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | 915 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
916 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 916 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
917 | unsigned char i_port[PR_APTPL_MAX_IPORT_LEN]; | 917 | unsigned char i_port[PR_APTPL_MAX_IPORT_LEN]; |
918 | unsigned char t_port[PR_APTPL_MAX_TPORT_LEN]; | 918 | unsigned char t_port[PR_APTPL_MAX_TPORT_LEN]; |
919 | u16 tpgt; | 919 | u16 tpgt; |
@@ -925,8 +925,8 @@ static int __core_scsi3_check_aptpl_registration( | |||
925 | */ | 925 | */ |
926 | snprintf(i_port, PR_APTPL_MAX_IPORT_LEN, "%s", nacl->initiatorname); | 926 | snprintf(i_port, PR_APTPL_MAX_IPORT_LEN, "%s", nacl->initiatorname); |
927 | snprintf(t_port, PR_APTPL_MAX_TPORT_LEN, "%s", | 927 | snprintf(t_port, PR_APTPL_MAX_TPORT_LEN, "%s", |
928 | TPG_TFO(tpg)->tpg_get_wwn(tpg)); | 928 | tpg->se_tpg_tfo->tpg_get_wwn(tpg)); |
929 | tpgt = TPG_TFO(tpg)->tpg_get_tag(tpg); | 929 | tpgt = tpg->se_tpg_tfo->tpg_get_tag(tpg); |
930 | /* | 930 | /* |
931 | * Look for the matching registrations+reservation from those | 931 | * Look for the matching registrations+reservation from those |
932 | * created from APTPL metadata. Note that multiple registrations | 932 | * created from APTPL metadata. Note that multiple registrations |
@@ -980,11 +980,11 @@ int core_scsi3_check_aptpl_registration( | |||
980 | struct se_lun *lun, | 980 | struct se_lun *lun, |
981 | struct se_lun_acl *lun_acl) | 981 | struct se_lun_acl *lun_acl) |
982 | { | 982 | { |
983 | struct se_subsystem_dev *su_dev = SU_DEV(dev); | 983 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
984 | struct se_node_acl *nacl = lun_acl->se_lun_nacl; | 984 | struct se_node_acl *nacl = lun_acl->se_lun_nacl; |
985 | struct se_dev_entry *deve = &nacl->device_list[lun_acl->mapped_lun]; | 985 | struct se_dev_entry *deve = &nacl->device_list[lun_acl->mapped_lun]; |
986 | 986 | ||
987 | if (T10_RES(su_dev)->res_type != SPC3_PERSISTENT_RESERVATIONS) | 987 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
988 | return 0; | 988 | return 0; |
989 | 989 | ||
990 | return __core_scsi3_check_aptpl_registration(dev, tpg, lun, | 990 | return __core_scsi3_check_aptpl_registration(dev, tpg, lun, |
@@ -1017,7 +1017,7 @@ static void __core_scsi3_dump_registration( | |||
1017 | printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" | 1017 | printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" |
1018 | " Port(s)\n", tfo->get_fabric_name(), | 1018 | " Port(s)\n", tfo->get_fabric_name(), |
1019 | (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", | 1019 | (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", |
1020 | TRANSPORT(dev)->name); | 1020 | dev->transport->name); |
1021 | printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:" | 1021 | printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:" |
1022 | " 0x%08x APTPL: %d\n", tfo->get_fabric_name(), | 1022 | " 0x%08x APTPL: %d\n", tfo->get_fabric_name(), |
1023 | pr_reg->pr_res_key, pr_reg->pr_res_generation, | 1023 | pr_reg->pr_res_key, pr_reg->pr_res_generation, |
@@ -1035,10 +1035,10 @@ static void __core_scsi3_add_registration( | |||
1035 | int register_type, | 1035 | int register_type, |
1036 | int register_move) | 1036 | int register_move) |
1037 | { | 1037 | { |
1038 | struct se_subsystem_dev *su_dev = SU_DEV(dev); | 1038 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
1039 | struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; | 1039 | struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; |
1040 | struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; | 1040 | struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; |
1041 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 1041 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
1042 | 1042 | ||
1043 | /* | 1043 | /* |
1044 | * Increment PRgeneration counter for struct se_device upon a successful | 1044 | * Increment PRgeneration counter for struct se_device upon a successful |
@@ -1050,7 +1050,7 @@ static void __core_scsi3_add_registration( | |||
1050 | * for the REGISTER. | 1050 | * for the REGISTER. |
1051 | */ | 1051 | */ |
1052 | pr_reg->pr_res_generation = (register_move) ? | 1052 | pr_reg->pr_res_generation = (register_move) ? |
1053 | T10_RES(su_dev)->pr_generation++ : | 1053 | su_dev->t10_pr.pr_generation++ : |
1054 | core_scsi3_pr_generation(dev); | 1054 | core_scsi3_pr_generation(dev); |
1055 | 1055 | ||
1056 | spin_lock(&pr_tmpl->registration_lock); | 1056 | spin_lock(&pr_tmpl->registration_lock); |
@@ -1107,7 +1107,7 @@ static int core_scsi3_alloc_registration( | |||
1107 | pr_reg = __core_scsi3_alloc_registration(dev, nacl, deve, isid, | 1107 | pr_reg = __core_scsi3_alloc_registration(dev, nacl, deve, isid, |
1108 | sa_res_key, all_tg_pt, aptpl); | 1108 | sa_res_key, all_tg_pt, aptpl); |
1109 | if (!(pr_reg)) | 1109 | if (!(pr_reg)) |
1110 | return -1; | 1110 | return -EPERM; |
1111 | 1111 | ||
1112 | __core_scsi3_add_registration(dev, nacl, pr_reg, | 1112 | __core_scsi3_add_registration(dev, nacl, pr_reg, |
1113 | register_type, register_move); | 1113 | register_type, register_move); |
@@ -1119,7 +1119,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( | |||
1119 | struct se_node_acl *nacl, | 1119 | struct se_node_acl *nacl, |
1120 | unsigned char *isid) | 1120 | unsigned char *isid) |
1121 | { | 1121 | { |
1122 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 1122 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
1123 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | 1123 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
1124 | struct se_portal_group *tpg; | 1124 | struct se_portal_group *tpg; |
1125 | 1125 | ||
@@ -1143,8 +1143,8 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( | |||
1143 | * SCSI Intiatior TransportID w/ ISIDs is enforced | 1143 | * SCSI Intiatior TransportID w/ ISIDs is enforced |
1144 | * for fabric modules (iSCSI) requiring them. | 1144 | * for fabric modules (iSCSI) requiring them. |
1145 | */ | 1145 | */ |
1146 | if (TPG_TFO(tpg)->sess_get_initiator_sid != NULL) { | 1146 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) { |
1147 | if (DEV_ATTRIB(dev)->enforce_pr_isids) | 1147 | if (dev->se_sub_dev->se_dev_attrib.enforce_pr_isids) |
1148 | continue; | 1148 | continue; |
1149 | } | 1149 | } |
1150 | atomic_inc(&pr_reg->pr_res_holders); | 1150 | atomic_inc(&pr_reg->pr_res_holders); |
@@ -1180,9 +1180,9 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg( | |||
1180 | struct se_portal_group *tpg = nacl->se_tpg; | 1180 | struct se_portal_group *tpg = nacl->se_tpg; |
1181 | unsigned char buf[PR_REG_ISID_LEN], *isid_ptr = NULL; | 1181 | unsigned char buf[PR_REG_ISID_LEN], *isid_ptr = NULL; |
1182 | 1182 | ||
1183 | if (TPG_TFO(tpg)->sess_get_initiator_sid != NULL) { | 1183 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) { |
1184 | memset(&buf[0], 0, PR_REG_ISID_LEN); | 1184 | memset(&buf[0], 0, PR_REG_ISID_LEN); |
1185 | TPG_TFO(tpg)->sess_get_initiator_sid(sess, &buf[0], | 1185 | tpg->se_tpg_tfo->sess_get_initiator_sid(sess, &buf[0], |
1186 | PR_REG_ISID_LEN); | 1186 | PR_REG_ISID_LEN); |
1187 | isid_ptr = &buf[0]; | 1187 | isid_ptr = &buf[0]; |
1188 | } | 1188 | } |
@@ -1240,7 +1240,7 @@ static int core_scsi3_check_implict_release( | |||
1240 | " UNREGISTER while existing reservation with matching" | 1240 | " UNREGISTER while existing reservation with matching" |
1241 | " key 0x%016Lx is present from another SCSI Initiator" | 1241 | " key 0x%016Lx is present from another SCSI Initiator" |
1242 | " Port\n", pr_reg->pr_res_key); | 1242 | " Port\n", pr_reg->pr_res_key); |
1243 | ret = -1; | 1243 | ret = -EPERM; |
1244 | } | 1244 | } |
1245 | spin_unlock(&dev->dev_reservation_lock); | 1245 | spin_unlock(&dev->dev_reservation_lock); |
1246 | 1246 | ||
@@ -1248,7 +1248,7 @@ static int core_scsi3_check_implict_release( | |||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | /* | 1250 | /* |
1251 | * Called with struct t10_reservation_template->registration_lock held. | 1251 | * Called with struct t10_reservation->registration_lock held. |
1252 | */ | 1252 | */ |
1253 | static void __core_scsi3_free_registration( | 1253 | static void __core_scsi3_free_registration( |
1254 | struct se_device *dev, | 1254 | struct se_device *dev, |
@@ -1258,7 +1258,7 @@ static void __core_scsi3_free_registration( | |||
1258 | { | 1258 | { |
1259 | struct target_core_fabric_ops *tfo = | 1259 | struct target_core_fabric_ops *tfo = |
1260 | pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; | 1260 | pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; |
1261 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 1261 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
1262 | char i_buf[PR_REG_ISID_ID_LEN]; | 1262 | char i_buf[PR_REG_ISID_ID_LEN]; |
1263 | int prf_isid; | 1263 | int prf_isid; |
1264 | 1264 | ||
@@ -1296,7 +1296,7 @@ static void __core_scsi3_free_registration( | |||
1296 | printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" | 1296 | printk(KERN_INFO "SPC-3 PR [%s] for %s TCM Subsystem %s Object Target" |
1297 | " Port(s)\n", tfo->get_fabric_name(), | 1297 | " Port(s)\n", tfo->get_fabric_name(), |
1298 | (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", | 1298 | (pr_reg->pr_reg_all_tg_pt) ? "ALL" : "SINGLE", |
1299 | TRANSPORT(dev)->name); | 1299 | dev->transport->name); |
1300 | printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:" | 1300 | printk(KERN_INFO "SPC-3 PR [%s] SA Res Key: 0x%016Lx PRgeneration:" |
1301 | " 0x%08x\n", tfo->get_fabric_name(), pr_reg->pr_res_key, | 1301 | " 0x%08x\n", tfo->get_fabric_name(), pr_reg->pr_res_key, |
1302 | pr_reg->pr_res_generation); | 1302 | pr_reg->pr_res_generation); |
@@ -1319,7 +1319,7 @@ void core_scsi3_free_pr_reg_from_nacl( | |||
1319 | struct se_device *dev, | 1319 | struct se_device *dev, |
1320 | struct se_node_acl *nacl) | 1320 | struct se_node_acl *nacl) |
1321 | { | 1321 | { |
1322 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 1322 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
1323 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; | 1323 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; |
1324 | /* | 1324 | /* |
1325 | * If the passed se_node_acl matches the reservation holder, | 1325 | * If the passed se_node_acl matches the reservation holder, |
@@ -1349,7 +1349,7 @@ void core_scsi3_free_pr_reg_from_nacl( | |||
1349 | void core_scsi3_free_all_registrations( | 1349 | void core_scsi3_free_all_registrations( |
1350 | struct se_device *dev) | 1350 | struct se_device *dev) |
1351 | { | 1351 | { |
1352 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 1352 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
1353 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; | 1353 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; |
1354 | 1354 | ||
1355 | spin_lock(&dev->dev_reservation_lock); | 1355 | spin_lock(&dev->dev_reservation_lock); |
@@ -1381,13 +1381,13 @@ void core_scsi3_free_all_registrations( | |||
1381 | 1381 | ||
1382 | static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg) | 1382 | static int core_scsi3_tpg_depend_item(struct se_portal_group *tpg) |
1383 | { | 1383 | { |
1384 | return configfs_depend_item(TPG_TFO(tpg)->tf_subsys, | 1384 | return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, |
1385 | &tpg->tpg_group.cg_item); | 1385 | &tpg->tpg_group.cg_item); |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) | 1388 | static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) |
1389 | { | 1389 | { |
1390 | configfs_undepend_item(TPG_TFO(tpg)->tf_subsys, | 1390 | configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, |
1391 | &tpg->tpg_group.cg_item); | 1391 | &tpg->tpg_group.cg_item); |
1392 | 1392 | ||
1393 | atomic_dec(&tpg->tpg_pr_ref_count); | 1393 | atomic_dec(&tpg->tpg_pr_ref_count); |
@@ -1401,7 +1401,7 @@ static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl) | |||
1401 | if (nacl->dynamic_node_acl) | 1401 | if (nacl->dynamic_node_acl) |
1402 | return 0; | 1402 | return 0; |
1403 | 1403 | ||
1404 | return configfs_depend_item(TPG_TFO(tpg)->tf_subsys, | 1404 | return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, |
1405 | &nacl->acl_group.cg_item); | 1405 | &nacl->acl_group.cg_item); |
1406 | } | 1406 | } |
1407 | 1407 | ||
@@ -1415,7 +1415,7 @@ static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) | |||
1415 | return; | 1415 | return; |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | configfs_undepend_item(TPG_TFO(tpg)->tf_subsys, | 1418 | configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, |
1419 | &nacl->acl_group.cg_item); | 1419 | &nacl->acl_group.cg_item); |
1420 | 1420 | ||
1421 | atomic_dec(&nacl->acl_pr_ref_count); | 1421 | atomic_dec(&nacl->acl_pr_ref_count); |
@@ -1436,7 +1436,7 @@ static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve) | |||
1436 | nacl = lun_acl->se_lun_nacl; | 1436 | nacl = lun_acl->se_lun_nacl; |
1437 | tpg = nacl->se_tpg; | 1437 | tpg = nacl->se_tpg; |
1438 | 1438 | ||
1439 | return configfs_depend_item(TPG_TFO(tpg)->tf_subsys, | 1439 | return configfs_depend_item(tpg->se_tpg_tfo->tf_subsys, |
1440 | &lun_acl->se_lun_group.cg_item); | 1440 | &lun_acl->se_lun_group.cg_item); |
1441 | } | 1441 | } |
1442 | 1442 | ||
@@ -1456,7 +1456,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) | |||
1456 | nacl = lun_acl->se_lun_nacl; | 1456 | nacl = lun_acl->se_lun_nacl; |
1457 | tpg = nacl->se_tpg; | 1457 | tpg = nacl->se_tpg; |
1458 | 1458 | ||
1459 | configfs_undepend_item(TPG_TFO(tpg)->tf_subsys, | 1459 | configfs_undepend_item(tpg->se_tpg_tfo->tf_subsys, |
1460 | &lun_acl->se_lun_group.cg_item); | 1460 | &lun_acl->se_lun_group.cg_item); |
1461 | 1461 | ||
1462 | atomic_dec(&se_deve->pr_ref_count); | 1462 | atomic_dec(&se_deve->pr_ref_count); |
@@ -1471,10 +1471,10 @@ static int core_scsi3_decode_spec_i_port( | |||
1471 | int all_tg_pt, | 1471 | int all_tg_pt, |
1472 | int aptpl) | 1472 | int aptpl) |
1473 | { | 1473 | { |
1474 | struct se_device *dev = SE_DEV(cmd); | 1474 | struct se_device *dev = cmd->se_lun->lun_se_dev; |
1475 | struct se_port *tmp_port; | 1475 | struct se_port *tmp_port; |
1476 | struct se_portal_group *dest_tpg = NULL, *tmp_tpg; | 1476 | struct se_portal_group *dest_tpg = NULL, *tmp_tpg; |
1477 | struct se_session *se_sess = SE_SESS(cmd); | 1477 | struct se_session *se_sess = cmd->se_sess; |
1478 | struct se_node_acl *dest_node_acl = NULL; | 1478 | struct se_node_acl *dest_node_acl = NULL; |
1479 | struct se_dev_entry *dest_se_deve = NULL, *local_se_deve; | 1479 | struct se_dev_entry *dest_se_deve = NULL, *local_se_deve; |
1480 | struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e; | 1480 | struct t10_pr_registration *dest_pr_reg, *local_pr_reg, *pr_reg_e; |
@@ -1482,7 +1482,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1482 | struct list_head tid_dest_list; | 1482 | struct list_head tid_dest_list; |
1483 | struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp; | 1483 | struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp; |
1484 | struct target_core_fabric_ops *tmp_tf_ops; | 1484 | struct target_core_fabric_ops *tmp_tf_ops; |
1485 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 1485 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
1486 | unsigned char *ptr, *i_str = NULL, proto_ident, tmp_proto_ident; | 1486 | unsigned char *ptr, *i_str = NULL, proto_ident, tmp_proto_ident; |
1487 | char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; | 1487 | char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; |
1488 | u32 tpdl, tid_len = 0; | 1488 | u32 tpdl, tid_len = 0; |
@@ -1509,7 +1509,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1509 | tidh_new->dest_node_acl = se_sess->se_node_acl; | 1509 | tidh_new->dest_node_acl = se_sess->se_node_acl; |
1510 | tidh_new->dest_se_deve = local_se_deve; | 1510 | tidh_new->dest_se_deve = local_se_deve; |
1511 | 1511 | ||
1512 | local_pr_reg = __core_scsi3_alloc_registration(SE_DEV(cmd), | 1512 | local_pr_reg = __core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev, |
1513 | se_sess->se_node_acl, local_se_deve, l_isid, | 1513 | se_sess->se_node_acl, local_se_deve, l_isid, |
1514 | sa_res_key, all_tg_pt, aptpl); | 1514 | sa_res_key, all_tg_pt, aptpl); |
1515 | if (!(local_pr_reg)) { | 1515 | if (!(local_pr_reg)) { |
@@ -1557,7 +1557,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1557 | tmp_tpg = tmp_port->sep_tpg; | 1557 | tmp_tpg = tmp_port->sep_tpg; |
1558 | if (!(tmp_tpg)) | 1558 | if (!(tmp_tpg)) |
1559 | continue; | 1559 | continue; |
1560 | tmp_tf_ops = TPG_TFO(tmp_tpg); | 1560 | tmp_tf_ops = tmp_tpg->se_tpg_tfo; |
1561 | if (!(tmp_tf_ops)) | 1561 | if (!(tmp_tf_ops)) |
1562 | continue; | 1562 | continue; |
1563 | if (!(tmp_tf_ops->get_fabric_proto_ident) || | 1563 | if (!(tmp_tf_ops->get_fabric_proto_ident) || |
@@ -1625,7 +1625,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1625 | dest_tpg = tmp_tpg; | 1625 | dest_tpg = tmp_tpg; |
1626 | printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node:" | 1626 | printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node:" |
1627 | " %s Port RTPI: %hu\n", | 1627 | " %s Port RTPI: %hu\n", |
1628 | TPG_TFO(dest_tpg)->get_fabric_name(), | 1628 | dest_tpg->se_tpg_tfo->get_fabric_name(), |
1629 | dest_node_acl->initiatorname, dest_rtpi); | 1629 | dest_node_acl->initiatorname, dest_rtpi); |
1630 | 1630 | ||
1631 | spin_lock(&dev->se_port_lock); | 1631 | spin_lock(&dev->se_port_lock); |
@@ -1642,7 +1642,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1642 | #if 0 | 1642 | #if 0 |
1643 | printk("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u" | 1643 | printk("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u" |
1644 | " tid_len: %d for %s + %s\n", | 1644 | " tid_len: %d for %s + %s\n", |
1645 | TPG_TFO(dest_tpg)->get_fabric_name(), cmd->data_length, | 1645 | dest_tpg->se_tpg_tfo->get_fabric_name(), cmd->data_length, |
1646 | tpdl, tid_len, i_str, iport_ptr); | 1646 | tpdl, tid_len, i_str, iport_ptr); |
1647 | #endif | 1647 | #endif |
1648 | if (tid_len > tpdl) { | 1648 | if (tid_len > tpdl) { |
@@ -1663,7 +1663,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1663 | if (!(dest_se_deve)) { | 1663 | if (!(dest_se_deve)) { |
1664 | printk(KERN_ERR "Unable to locate %s dest_se_deve" | 1664 | printk(KERN_ERR "Unable to locate %s dest_se_deve" |
1665 | " from destination RTPI: %hu\n", | 1665 | " from destination RTPI: %hu\n", |
1666 | TPG_TFO(dest_tpg)->get_fabric_name(), | 1666 | dest_tpg->se_tpg_tfo->get_fabric_name(), |
1667 | dest_rtpi); | 1667 | dest_rtpi); |
1668 | 1668 | ||
1669 | core_scsi3_nodeacl_undepend_item(dest_node_acl); | 1669 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
@@ -1686,7 +1686,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1686 | #if 0 | 1686 | #if 0 |
1687 | printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node: %s" | 1687 | printk(KERN_INFO "SPC-3 PR SPEC_I_PT: Located %s Node: %s" |
1688 | " dest_se_deve mapped_lun: %u\n", | 1688 | " dest_se_deve mapped_lun: %u\n", |
1689 | TPG_TFO(dest_tpg)->get_fabric_name(), | 1689 | dest_tpg->se_tpg_tfo->get_fabric_name(), |
1690 | dest_node_acl->initiatorname, dest_se_deve->mapped_lun); | 1690 | dest_node_acl->initiatorname, dest_se_deve->mapped_lun); |
1691 | #endif | 1691 | #endif |
1692 | /* | 1692 | /* |
@@ -1741,7 +1741,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1741 | * and then call __core_scsi3_add_registration() in the | 1741 | * and then call __core_scsi3_add_registration() in the |
1742 | * 2nd loop which will never fail. | 1742 | * 2nd loop which will never fail. |
1743 | */ | 1743 | */ |
1744 | dest_pr_reg = __core_scsi3_alloc_registration(SE_DEV(cmd), | 1744 | dest_pr_reg = __core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev, |
1745 | dest_node_acl, dest_se_deve, iport_ptr, | 1745 | dest_node_acl, dest_se_deve, iport_ptr, |
1746 | sa_res_key, all_tg_pt, aptpl); | 1746 | sa_res_key, all_tg_pt, aptpl); |
1747 | if (!(dest_pr_reg)) { | 1747 | if (!(dest_pr_reg)) { |
@@ -1787,12 +1787,12 @@ static int core_scsi3_decode_spec_i_port( | |||
1787 | prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0], | 1787 | prf_isid = core_pr_dump_initiator_port(dest_pr_reg, &i_buf[0], |
1788 | PR_REG_ISID_ID_LEN); | 1788 | PR_REG_ISID_ID_LEN); |
1789 | 1789 | ||
1790 | __core_scsi3_add_registration(SE_DEV(cmd), dest_node_acl, | 1790 | __core_scsi3_add_registration(cmd->se_lun->lun_se_dev, dest_node_acl, |
1791 | dest_pr_reg, 0, 0); | 1791 | dest_pr_reg, 0, 0); |
1792 | 1792 | ||
1793 | printk(KERN_INFO "SPC-3 PR [%s] SPEC_I_PT: Successfully" | 1793 | printk(KERN_INFO "SPC-3 PR [%s] SPEC_I_PT: Successfully" |
1794 | " registered Transport ID for Node: %s%s Mapped LUN:" | 1794 | " registered Transport ID for Node: %s%s Mapped LUN:" |
1795 | " %u\n", TPG_TFO(dest_tpg)->get_fabric_name(), | 1795 | " %u\n", dest_tpg->se_tpg_tfo->get_fabric_name(), |
1796 | dest_node_acl->initiatorname, (prf_isid) ? | 1796 | dest_node_acl->initiatorname, (prf_isid) ? |
1797 | &i_buf[0] : "", dest_se_deve->mapped_lun); | 1797 | &i_buf[0] : "", dest_se_deve->mapped_lun); |
1798 | 1798 | ||
@@ -1855,7 +1855,7 @@ static int __core_scsi3_update_aptpl_buf( | |||
1855 | { | 1855 | { |
1856 | struct se_lun *lun; | 1856 | struct se_lun *lun; |
1857 | struct se_portal_group *tpg; | 1857 | struct se_portal_group *tpg; |
1858 | struct se_subsystem_dev *su_dev = SU_DEV(dev); | 1858 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
1859 | struct t10_pr_registration *pr_reg; | 1859 | struct t10_pr_registration *pr_reg; |
1860 | unsigned char tmp[512], isid_buf[32]; | 1860 | unsigned char tmp[512], isid_buf[32]; |
1861 | ssize_t len = 0; | 1861 | ssize_t len = 0; |
@@ -1873,8 +1873,8 @@ static int __core_scsi3_update_aptpl_buf( | |||
1873 | /* | 1873 | /* |
1874 | * Walk the registration list.. | 1874 | * Walk the registration list.. |
1875 | */ | 1875 | */ |
1876 | spin_lock(&T10_RES(su_dev)->registration_lock); | 1876 | spin_lock(&su_dev->t10_pr.registration_lock); |
1877 | list_for_each_entry(pr_reg, &T10_RES(su_dev)->registration_list, | 1877 | list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list, |
1878 | pr_reg_list) { | 1878 | pr_reg_list) { |
1879 | 1879 | ||
1880 | tmp[0] = '\0'; | 1880 | tmp[0] = '\0'; |
@@ -1900,7 +1900,7 @@ static int __core_scsi3_update_aptpl_buf( | |||
1900 | "res_holder=1\nres_type=%02x\n" | 1900 | "res_holder=1\nres_type=%02x\n" |
1901 | "res_scope=%02x\nres_all_tg_pt=%d\n" | 1901 | "res_scope=%02x\nres_all_tg_pt=%d\n" |
1902 | "mapped_lun=%u\n", reg_count, | 1902 | "mapped_lun=%u\n", reg_count, |
1903 | TPG_TFO(tpg)->get_fabric_name(), | 1903 | tpg->se_tpg_tfo->get_fabric_name(), |
1904 | pr_reg->pr_reg_nacl->initiatorname, isid_buf, | 1904 | pr_reg->pr_reg_nacl->initiatorname, isid_buf, |
1905 | pr_reg->pr_res_key, pr_reg->pr_res_type, | 1905 | pr_reg->pr_res_key, pr_reg->pr_res_type, |
1906 | pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt, | 1906 | pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt, |
@@ -1910,7 +1910,7 @@ static int __core_scsi3_update_aptpl_buf( | |||
1910 | "initiator_fabric=%s\ninitiator_node=%s\n%s" | 1910 | "initiator_fabric=%s\ninitiator_node=%s\n%s" |
1911 | "sa_res_key=%llu\nres_holder=0\n" | 1911 | "sa_res_key=%llu\nres_holder=0\n" |
1912 | "res_all_tg_pt=%d\nmapped_lun=%u\n", | 1912 | "res_all_tg_pt=%d\nmapped_lun=%u\n", |
1913 | reg_count, TPG_TFO(tpg)->get_fabric_name(), | 1913 | reg_count, tpg->se_tpg_tfo->get_fabric_name(), |
1914 | pr_reg->pr_reg_nacl->initiatorname, isid_buf, | 1914 | pr_reg->pr_reg_nacl->initiatorname, isid_buf, |
1915 | pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt, | 1915 | pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt, |
1916 | pr_reg->pr_res_mapped_lun); | 1916 | pr_reg->pr_res_mapped_lun); |
@@ -1919,8 +1919,8 @@ static int __core_scsi3_update_aptpl_buf( | |||
1919 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { | 1919 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { |
1920 | printk(KERN_ERR "Unable to update renaming" | 1920 | printk(KERN_ERR "Unable to update renaming" |
1921 | " APTPL metadata\n"); | 1921 | " APTPL metadata\n"); |
1922 | spin_unlock(&T10_RES(su_dev)->registration_lock); | 1922 | spin_unlock(&su_dev->t10_pr.registration_lock); |
1923 | return -1; | 1923 | return -EMSGSIZE; |
1924 | } | 1924 | } |
1925 | len += sprintf(buf+len, "%s", tmp); | 1925 | len += sprintf(buf+len, "%s", tmp); |
1926 | 1926 | ||
@@ -1929,21 +1929,21 @@ static int __core_scsi3_update_aptpl_buf( | |||
1929 | */ | 1929 | */ |
1930 | snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n" | 1930 | snprintf(tmp, 512, "target_fabric=%s\ntarget_node=%s\n" |
1931 | "tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%u\nPR_REG_END:" | 1931 | "tpgt=%hu\nport_rtpi=%hu\ntarget_lun=%u\nPR_REG_END:" |
1932 | " %d\n", TPG_TFO(tpg)->get_fabric_name(), | 1932 | " %d\n", tpg->se_tpg_tfo->get_fabric_name(), |
1933 | TPG_TFO(tpg)->tpg_get_wwn(tpg), | 1933 | tpg->se_tpg_tfo->tpg_get_wwn(tpg), |
1934 | TPG_TFO(tpg)->tpg_get_tag(tpg), | 1934 | tpg->se_tpg_tfo->tpg_get_tag(tpg), |
1935 | lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count); | 1935 | lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count); |
1936 | 1936 | ||
1937 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { | 1937 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { |
1938 | printk(KERN_ERR "Unable to update renaming" | 1938 | printk(KERN_ERR "Unable to update renaming" |
1939 | " APTPL metadata\n"); | 1939 | " APTPL metadata\n"); |
1940 | spin_unlock(&T10_RES(su_dev)->registration_lock); | 1940 | spin_unlock(&su_dev->t10_pr.registration_lock); |
1941 | return -1; | 1941 | return -EMSGSIZE; |
1942 | } | 1942 | } |
1943 | len += sprintf(buf+len, "%s", tmp); | 1943 | len += sprintf(buf+len, "%s", tmp); |
1944 | reg_count++; | 1944 | reg_count++; |
1945 | } | 1945 | } |
1946 | spin_unlock(&T10_RES(su_dev)->registration_lock); | 1946 | spin_unlock(&su_dev->t10_pr.registration_lock); |
1947 | 1947 | ||
1948 | if (!(reg_count)) | 1948 | if (!(reg_count)) |
1949 | len += sprintf(buf+len, "No Registrations or Reservations"); | 1949 | len += sprintf(buf+len, "No Registrations or Reservations"); |
@@ -1975,7 +1975,7 @@ static int __core_scsi3_write_aptpl_to_file( | |||
1975 | unsigned char *buf, | 1975 | unsigned char *buf, |
1976 | u32 pr_aptpl_buf_len) | 1976 | u32 pr_aptpl_buf_len) |
1977 | { | 1977 | { |
1978 | struct t10_wwn *wwn = &SU_DEV(dev)->t10_wwn; | 1978 | struct t10_wwn *wwn = &dev->se_sub_dev->t10_wwn; |
1979 | struct file *file; | 1979 | struct file *file; |
1980 | struct iovec iov[1]; | 1980 | struct iovec iov[1]; |
1981 | mm_segment_t old_fs; | 1981 | mm_segment_t old_fs; |
@@ -1989,7 +1989,7 @@ static int __core_scsi3_write_aptpl_to_file( | |||
1989 | if (strlen(&wwn->unit_serial[0]) >= 512) { | 1989 | if (strlen(&wwn->unit_serial[0]) >= 512) { |
1990 | printk(KERN_ERR "WWN value for struct se_device does not fit" | 1990 | printk(KERN_ERR "WWN value for struct se_device does not fit" |
1991 | " into path buffer\n"); | 1991 | " into path buffer\n"); |
1992 | return -1; | 1992 | return -EMSGSIZE; |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | snprintf(path, 512, "/var/target/pr/aptpl_%s", &wwn->unit_serial[0]); | 1995 | snprintf(path, 512, "/var/target/pr/aptpl_%s", &wwn->unit_serial[0]); |
@@ -1997,7 +1997,7 @@ static int __core_scsi3_write_aptpl_to_file( | |||
1997 | if (IS_ERR(file) || !file || !file->f_dentry) { | 1997 | if (IS_ERR(file) || !file || !file->f_dentry) { |
1998 | printk(KERN_ERR "filp_open(%s) for APTPL metadata" | 1998 | printk(KERN_ERR "filp_open(%s) for APTPL metadata" |
1999 | " failed\n", path); | 1999 | " failed\n", path); |
2000 | return -1; | 2000 | return (PTR_ERR(file) < 0 ? PTR_ERR(file) : -ENOENT); |
2001 | } | 2001 | } |
2002 | 2002 | ||
2003 | iov[0].iov_base = &buf[0]; | 2003 | iov[0].iov_base = &buf[0]; |
@@ -2014,7 +2014,7 @@ static int __core_scsi3_write_aptpl_to_file( | |||
2014 | if (ret < 0) { | 2014 | if (ret < 0) { |
2015 | printk("Error writing APTPL metadata file: %s\n", path); | 2015 | printk("Error writing APTPL metadata file: %s\n", path); |
2016 | filp_close(file, NULL); | 2016 | filp_close(file, NULL); |
2017 | return -1; | 2017 | return -EIO; |
2018 | } | 2018 | } |
2019 | filp_close(file, NULL); | 2019 | filp_close(file, NULL); |
2020 | 2020 | ||
@@ -2049,14 +2049,14 @@ static int core_scsi3_update_and_write_aptpl( | |||
2049 | ret = core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len, | 2049 | ret = core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len, |
2050 | clear_aptpl_metadata); | 2050 | clear_aptpl_metadata); |
2051 | if (ret != 0) | 2051 | if (ret != 0) |
2052 | return -1; | 2052 | return ret; |
2053 | /* | 2053 | /* |
2054 | * __core_scsi3_write_aptpl_to_file() will call strlen() | 2054 | * __core_scsi3_write_aptpl_to_file() will call strlen() |
2055 | * on the passed buf to determine pr_aptpl_buf_len. | 2055 | * on the passed buf to determine pr_aptpl_buf_len. |
2056 | */ | 2056 | */ |
2057 | ret = __core_scsi3_write_aptpl_to_file(dev, buf, 0); | 2057 | ret = __core_scsi3_write_aptpl_to_file(dev, buf, 0); |
2058 | if (ret != 0) | 2058 | if (ret != 0) |
2059 | return -1; | 2059 | return ret; |
2060 | 2060 | ||
2061 | return ret; | 2061 | return ret; |
2062 | } | 2062 | } |
@@ -2070,13 +2070,13 @@ static int core_scsi3_emulate_pro_register( | |||
2070 | int spec_i_pt, | 2070 | int spec_i_pt, |
2071 | int ignore_key) | 2071 | int ignore_key) |
2072 | { | 2072 | { |
2073 | struct se_session *se_sess = SE_SESS(cmd); | 2073 | struct se_session *se_sess = cmd->se_sess; |
2074 | struct se_device *dev = SE_DEV(cmd); | 2074 | struct se_device *dev = cmd->se_lun->lun_se_dev; |
2075 | struct se_dev_entry *se_deve; | 2075 | struct se_dev_entry *se_deve; |
2076 | struct se_lun *se_lun = SE_LUN(cmd); | 2076 | struct se_lun *se_lun = cmd->se_lun; |
2077 | struct se_portal_group *se_tpg; | 2077 | struct se_portal_group *se_tpg; |
2078 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; | 2078 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; |
2079 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 2079 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
2080 | /* Used for APTPL metadata w/ UNREGISTER */ | 2080 | /* Used for APTPL metadata w/ UNREGISTER */ |
2081 | unsigned char *pr_aptpl_buf = NULL; | 2081 | unsigned char *pr_aptpl_buf = NULL; |
2082 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; | 2082 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; |
@@ -2089,9 +2089,9 @@ static int core_scsi3_emulate_pro_register( | |||
2089 | se_tpg = se_sess->se_tpg; | 2089 | se_tpg = se_sess->se_tpg; |
2090 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 2090 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
2091 | 2091 | ||
2092 | if (TPG_TFO(se_tpg)->sess_get_initiator_sid != NULL) { | 2092 | if (se_tpg->se_tpg_tfo->sess_get_initiator_sid) { |
2093 | memset(&isid_buf[0], 0, PR_REG_ISID_LEN); | 2093 | memset(&isid_buf[0], 0, PR_REG_ISID_LEN); |
2094 | TPG_TFO(se_tpg)->sess_get_initiator_sid(se_sess, &isid_buf[0], | 2094 | se_tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, &isid_buf[0], |
2095 | PR_REG_ISID_LEN); | 2095 | PR_REG_ISID_LEN); |
2096 | isid_ptr = &isid_buf[0]; | 2096 | isid_ptr = &isid_buf[0]; |
2097 | } | 2097 | } |
@@ -2117,7 +2117,7 @@ static int core_scsi3_emulate_pro_register( | |||
2117 | * Port Endpoint that the PRO was received from on the | 2117 | * Port Endpoint that the PRO was received from on the |
2118 | * Logical Unit of the SCSI device server. | 2118 | * Logical Unit of the SCSI device server. |
2119 | */ | 2119 | */ |
2120 | ret = core_scsi3_alloc_registration(SE_DEV(cmd), | 2120 | ret = core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev, |
2121 | se_sess->se_node_acl, se_deve, isid_ptr, | 2121 | se_sess->se_node_acl, se_deve, isid_ptr, |
2122 | sa_res_key, all_tg_pt, aptpl, | 2122 | sa_res_key, all_tg_pt, aptpl, |
2123 | ignore_key, 0); | 2123 | ignore_key, 0); |
@@ -2145,7 +2145,7 @@ static int core_scsi3_emulate_pro_register( | |||
2145 | */ | 2145 | */ |
2146 | if (!(aptpl)) { | 2146 | if (!(aptpl)) { |
2147 | pr_tmpl->pr_aptpl_active = 0; | 2147 | pr_tmpl->pr_aptpl_active = 0; |
2148 | core_scsi3_update_and_write_aptpl(SE_DEV(cmd), NULL, 0); | 2148 | core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0); |
2149 | printk("SPC-3 PR: Set APTPL Bit Deactivated for" | 2149 | printk("SPC-3 PR: Set APTPL Bit Deactivated for" |
2150 | " REGISTER\n"); | 2150 | " REGISTER\n"); |
2151 | return 0; | 2151 | return 0; |
@@ -2155,10 +2155,10 @@ static int core_scsi3_emulate_pro_register( | |||
2155 | * update the APTPL metadata information using its | 2155 | * update the APTPL metadata information using its |
2156 | * preallocated *pr_reg->pr_aptpl_buf. | 2156 | * preallocated *pr_reg->pr_aptpl_buf. |
2157 | */ | 2157 | */ |
2158 | pr_reg = core_scsi3_locate_pr_reg(SE_DEV(cmd), | 2158 | pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, |
2159 | se_sess->se_node_acl, se_sess); | 2159 | se_sess->se_node_acl, se_sess); |
2160 | 2160 | ||
2161 | ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), | 2161 | ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, |
2162 | &pr_reg->pr_aptpl_buf[0], | 2162 | &pr_reg->pr_aptpl_buf[0], |
2163 | pr_tmpl->pr_aptpl_buf_len); | 2163 | pr_tmpl->pr_aptpl_buf_len); |
2164 | if (!(ret)) { | 2164 | if (!(ret)) { |
@@ -2223,7 +2223,7 @@ static int core_scsi3_emulate_pro_register( | |||
2223 | */ | 2223 | */ |
2224 | if (!(sa_res_key)) { | 2224 | if (!(sa_res_key)) { |
2225 | pr_holder = core_scsi3_check_implict_release( | 2225 | pr_holder = core_scsi3_check_implict_release( |
2226 | SE_DEV(cmd), pr_reg); | 2226 | cmd->se_lun->lun_se_dev, pr_reg); |
2227 | if (pr_holder < 0) { | 2227 | if (pr_holder < 0) { |
2228 | kfree(pr_aptpl_buf); | 2228 | kfree(pr_aptpl_buf); |
2229 | core_scsi3_put_pr_reg(pr_reg); | 2229 | core_scsi3_put_pr_reg(pr_reg); |
@@ -2260,7 +2260,7 @@ static int core_scsi3_emulate_pro_register( | |||
2260 | /* | 2260 | /* |
2261 | * Release the calling I_T Nexus registration now.. | 2261 | * Release the calling I_T Nexus registration now.. |
2262 | */ | 2262 | */ |
2263 | __core_scsi3_free_registration(SE_DEV(cmd), pr_reg, | 2263 | __core_scsi3_free_registration(cmd->se_lun->lun_se_dev, pr_reg, |
2264 | NULL, 1); | 2264 | NULL, 1); |
2265 | /* | 2265 | /* |
2266 | * From spc4r17, section 5.7.11.3 Unregistering | 2266 | * From spc4r17, section 5.7.11.3 Unregistering |
@@ -2315,11 +2315,11 @@ static int core_scsi3_emulate_pro_register( | |||
2315 | * READ_KEYS service action. | 2315 | * READ_KEYS service action. |
2316 | */ | 2316 | */ |
2317 | pr_reg->pr_res_generation = core_scsi3_pr_generation( | 2317 | pr_reg->pr_res_generation = core_scsi3_pr_generation( |
2318 | SE_DEV(cmd)); | 2318 | cmd->se_lun->lun_se_dev); |
2319 | pr_reg->pr_res_key = sa_res_key; | 2319 | pr_reg->pr_res_key = sa_res_key; |
2320 | printk("SPC-3 PR [%s] REGISTER%s: Changed Reservation" | 2320 | printk("SPC-3 PR [%s] REGISTER%s: Changed Reservation" |
2321 | " Key for %s to: 0x%016Lx PRgeneration:" | 2321 | " Key for %s to: 0x%016Lx PRgeneration:" |
2322 | " 0x%08x\n", CMD_TFO(cmd)->get_fabric_name(), | 2322 | " 0x%08x\n", cmd->se_tfo->get_fabric_name(), |
2323 | (ignore_key) ? "_AND_IGNORE_EXISTING_KEY" : "", | 2323 | (ignore_key) ? "_AND_IGNORE_EXISTING_KEY" : "", |
2324 | pr_reg->pr_reg_nacl->initiatorname, | 2324 | pr_reg->pr_reg_nacl->initiatorname, |
2325 | pr_reg->pr_res_key, pr_reg->pr_res_generation); | 2325 | pr_reg->pr_res_key, pr_reg->pr_res_generation); |
@@ -2378,12 +2378,12 @@ static int core_scsi3_pro_reserve( | |||
2378 | int scope, | 2378 | int scope, |
2379 | u64 res_key) | 2379 | u64 res_key) |
2380 | { | 2380 | { |
2381 | struct se_session *se_sess = SE_SESS(cmd); | 2381 | struct se_session *se_sess = cmd->se_sess; |
2382 | struct se_dev_entry *se_deve; | 2382 | struct se_dev_entry *se_deve; |
2383 | struct se_lun *se_lun = SE_LUN(cmd); | 2383 | struct se_lun *se_lun = cmd->se_lun; |
2384 | struct se_portal_group *se_tpg; | 2384 | struct se_portal_group *se_tpg; |
2385 | struct t10_pr_registration *pr_reg, *pr_res_holder; | 2385 | struct t10_pr_registration *pr_reg, *pr_res_holder; |
2386 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 2386 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
2387 | char i_buf[PR_REG_ISID_ID_LEN]; | 2387 | char i_buf[PR_REG_ISID_ID_LEN]; |
2388 | int ret, prf_isid; | 2388 | int ret, prf_isid; |
2389 | 2389 | ||
@@ -2398,7 +2398,7 @@ static int core_scsi3_pro_reserve( | |||
2398 | /* | 2398 | /* |
2399 | * Locate the existing *pr_reg via struct se_node_acl pointers | 2399 | * Locate the existing *pr_reg via struct se_node_acl pointers |
2400 | */ | 2400 | */ |
2401 | pr_reg = core_scsi3_locate_pr_reg(SE_DEV(cmd), se_sess->se_node_acl, | 2401 | pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl, |
2402 | se_sess); | 2402 | se_sess); |
2403 | if (!(pr_reg)) { | 2403 | if (!(pr_reg)) { |
2404 | printk(KERN_ERR "SPC-3 PR: Unable to locate" | 2404 | printk(KERN_ERR "SPC-3 PR: Unable to locate" |
@@ -2459,9 +2459,9 @@ static int core_scsi3_pro_reserve( | |||
2459 | printk(KERN_ERR "SPC-3 PR: Attempted RESERVE from" | 2459 | printk(KERN_ERR "SPC-3 PR: Attempted RESERVE from" |
2460 | " [%s]: %s while reservation already held by" | 2460 | " [%s]: %s while reservation already held by" |
2461 | " [%s]: %s, returning RESERVATION_CONFLICT\n", | 2461 | " [%s]: %s, returning RESERVATION_CONFLICT\n", |
2462 | CMD_TFO(cmd)->get_fabric_name(), | 2462 | cmd->se_tfo->get_fabric_name(), |
2463 | se_sess->se_node_acl->initiatorname, | 2463 | se_sess->se_node_acl->initiatorname, |
2464 | TPG_TFO(pr_res_nacl->se_tpg)->get_fabric_name(), | 2464 | pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), |
2465 | pr_res_holder->pr_reg_nacl->initiatorname); | 2465 | pr_res_holder->pr_reg_nacl->initiatorname); |
2466 | 2466 | ||
2467 | spin_unlock(&dev->dev_reservation_lock); | 2467 | spin_unlock(&dev->dev_reservation_lock); |
@@ -2482,9 +2482,9 @@ static int core_scsi3_pro_reserve( | |||
2482 | " [%s]: %s trying to change TYPE and/or SCOPE," | 2482 | " [%s]: %s trying to change TYPE and/or SCOPE," |
2483 | " while reservation already held by [%s]: %s," | 2483 | " while reservation already held by [%s]: %s," |
2484 | " returning RESERVATION_CONFLICT\n", | 2484 | " returning RESERVATION_CONFLICT\n", |
2485 | CMD_TFO(cmd)->get_fabric_name(), | 2485 | cmd->se_tfo->get_fabric_name(), |
2486 | se_sess->se_node_acl->initiatorname, | 2486 | se_sess->se_node_acl->initiatorname, |
2487 | TPG_TFO(pr_res_nacl->se_tpg)->get_fabric_name(), | 2487 | pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), |
2488 | pr_res_holder->pr_reg_nacl->initiatorname); | 2488 | pr_res_holder->pr_reg_nacl->initiatorname); |
2489 | 2489 | ||
2490 | spin_unlock(&dev->dev_reservation_lock); | 2490 | spin_unlock(&dev->dev_reservation_lock); |
@@ -2518,16 +2518,16 @@ static int core_scsi3_pro_reserve( | |||
2518 | 2518 | ||
2519 | printk(KERN_INFO "SPC-3 PR [%s] Service Action: RESERVE created new" | 2519 | printk(KERN_INFO "SPC-3 PR [%s] Service Action: RESERVE created new" |
2520 | " reservation holder TYPE: %s ALL_TG_PT: %d\n", | 2520 | " reservation holder TYPE: %s ALL_TG_PT: %d\n", |
2521 | CMD_TFO(cmd)->get_fabric_name(), core_scsi3_pr_dump_type(type), | 2521 | cmd->se_tfo->get_fabric_name(), core_scsi3_pr_dump_type(type), |
2522 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); | 2522 | (pr_reg->pr_reg_all_tg_pt) ? 1 : 0); |
2523 | printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n", | 2523 | printk(KERN_INFO "SPC-3 PR [%s] RESERVE Node: %s%s\n", |
2524 | CMD_TFO(cmd)->get_fabric_name(), | 2524 | cmd->se_tfo->get_fabric_name(), |
2525 | se_sess->se_node_acl->initiatorname, | 2525 | se_sess->se_node_acl->initiatorname, |
2526 | (prf_isid) ? &i_buf[0] : ""); | 2526 | (prf_isid) ? &i_buf[0] : ""); |
2527 | spin_unlock(&dev->dev_reservation_lock); | 2527 | spin_unlock(&dev->dev_reservation_lock); |
2528 | 2528 | ||
2529 | if (pr_tmpl->pr_aptpl_active) { | 2529 | if (pr_tmpl->pr_aptpl_active) { |
2530 | ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), | 2530 | ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, |
2531 | &pr_reg->pr_aptpl_buf[0], | 2531 | &pr_reg->pr_aptpl_buf[0], |
2532 | pr_tmpl->pr_aptpl_buf_len); | 2532 | pr_tmpl->pr_aptpl_buf_len); |
2533 | if (!(ret)) | 2533 | if (!(ret)) |
@@ -2608,10 +2608,10 @@ static int core_scsi3_emulate_pro_release( | |||
2608 | u64 res_key) | 2608 | u64 res_key) |
2609 | { | 2609 | { |
2610 | struct se_device *dev = cmd->se_dev; | 2610 | struct se_device *dev = cmd->se_dev; |
2611 | struct se_session *se_sess = SE_SESS(cmd); | 2611 | struct se_session *se_sess = cmd->se_sess; |
2612 | struct se_lun *se_lun = SE_LUN(cmd); | 2612 | struct se_lun *se_lun = cmd->se_lun; |
2613 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_res_holder; | 2613 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_res_holder; |
2614 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 2614 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
2615 | int ret, all_reg = 0; | 2615 | int ret, all_reg = 0; |
2616 | 2616 | ||
2617 | if (!(se_sess) || !(se_lun)) { | 2617 | if (!(se_sess) || !(se_lun)) { |
@@ -2698,9 +2698,9 @@ static int core_scsi3_emulate_pro_release( | |||
2698 | " reservation from [%s]: %s with different TYPE " | 2698 | " reservation from [%s]: %s with different TYPE " |
2699 | "and/or SCOPE while reservation already held by" | 2699 | "and/or SCOPE while reservation already held by" |
2700 | " [%s]: %s, returning RESERVATION_CONFLICT\n", | 2700 | " [%s]: %s, returning RESERVATION_CONFLICT\n", |
2701 | CMD_TFO(cmd)->get_fabric_name(), | 2701 | cmd->se_tfo->get_fabric_name(), |
2702 | se_sess->se_node_acl->initiatorname, | 2702 | se_sess->se_node_acl->initiatorname, |
2703 | TPG_TFO(pr_res_nacl->se_tpg)->get_fabric_name(), | 2703 | pr_res_nacl->se_tpg->se_tpg_tfo->get_fabric_name(), |
2704 | pr_res_holder->pr_reg_nacl->initiatorname); | 2704 | pr_res_holder->pr_reg_nacl->initiatorname); |
2705 | 2705 | ||
2706 | spin_unlock(&dev->dev_reservation_lock); | 2706 | spin_unlock(&dev->dev_reservation_lock); |
@@ -2758,7 +2758,7 @@ static int core_scsi3_emulate_pro_release( | |||
2758 | 2758 | ||
2759 | write_aptpl: | 2759 | write_aptpl: |
2760 | if (pr_tmpl->pr_aptpl_active) { | 2760 | if (pr_tmpl->pr_aptpl_active) { |
2761 | ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), | 2761 | ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, |
2762 | &pr_reg->pr_aptpl_buf[0], | 2762 | &pr_reg->pr_aptpl_buf[0], |
2763 | pr_tmpl->pr_aptpl_buf_len); | 2763 | pr_tmpl->pr_aptpl_buf_len); |
2764 | if (!(ret)) | 2764 | if (!(ret)) |
@@ -2775,15 +2775,15 @@ static int core_scsi3_emulate_pro_clear( | |||
2775 | { | 2775 | { |
2776 | struct se_device *dev = cmd->se_dev; | 2776 | struct se_device *dev = cmd->se_dev; |
2777 | struct se_node_acl *pr_reg_nacl; | 2777 | struct se_node_acl *pr_reg_nacl; |
2778 | struct se_session *se_sess = SE_SESS(cmd); | 2778 | struct se_session *se_sess = cmd->se_sess; |
2779 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 2779 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
2780 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; | 2780 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; |
2781 | u32 pr_res_mapped_lun = 0; | 2781 | u32 pr_res_mapped_lun = 0; |
2782 | int calling_it_nexus = 0; | 2782 | int calling_it_nexus = 0; |
2783 | /* | 2783 | /* |
2784 | * Locate the existing *pr_reg via struct se_node_acl pointers | 2784 | * Locate the existing *pr_reg via struct se_node_acl pointers |
2785 | */ | 2785 | */ |
2786 | pr_reg_n = core_scsi3_locate_pr_reg(SE_DEV(cmd), | 2786 | pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, |
2787 | se_sess->se_node_acl, se_sess); | 2787 | se_sess->se_node_acl, se_sess); |
2788 | if (!(pr_reg_n)) { | 2788 | if (!(pr_reg_n)) { |
2789 | printk(KERN_ERR "SPC-3 PR: Unable to locate" | 2789 | printk(KERN_ERR "SPC-3 PR: Unable to locate" |
@@ -2846,10 +2846,10 @@ static int core_scsi3_emulate_pro_clear( | |||
2846 | spin_unlock(&pr_tmpl->registration_lock); | 2846 | spin_unlock(&pr_tmpl->registration_lock); |
2847 | 2847 | ||
2848 | printk(KERN_INFO "SPC-3 PR [%s] Service Action: CLEAR complete\n", | 2848 | printk(KERN_INFO "SPC-3 PR [%s] Service Action: CLEAR complete\n", |
2849 | CMD_TFO(cmd)->get_fabric_name()); | 2849 | cmd->se_tfo->get_fabric_name()); |
2850 | 2850 | ||
2851 | if (pr_tmpl->pr_aptpl_active) { | 2851 | if (pr_tmpl->pr_aptpl_active) { |
2852 | core_scsi3_update_and_write_aptpl(SE_DEV(cmd), NULL, 0); | 2852 | core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0); |
2853 | printk(KERN_INFO "SPC-3 PR: Updated APTPL metadata" | 2853 | printk(KERN_INFO "SPC-3 PR: Updated APTPL metadata" |
2854 | " for CLEAR\n"); | 2854 | " for CLEAR\n"); |
2855 | } | 2855 | } |
@@ -2954,13 +2954,13 @@ static int core_scsi3_pro_preempt( | |||
2954 | u64 sa_res_key, | 2954 | u64 sa_res_key, |
2955 | int abort) | 2955 | int abort) |
2956 | { | 2956 | { |
2957 | struct se_device *dev = SE_DEV(cmd); | 2957 | struct se_device *dev = cmd->se_lun->lun_se_dev; |
2958 | struct se_dev_entry *se_deve; | 2958 | struct se_dev_entry *se_deve; |
2959 | struct se_node_acl *pr_reg_nacl; | 2959 | struct se_node_acl *pr_reg_nacl; |
2960 | struct se_session *se_sess = SE_SESS(cmd); | 2960 | struct se_session *se_sess = cmd->se_sess; |
2961 | struct list_head preempt_and_abort_list; | 2961 | struct list_head preempt_and_abort_list; |
2962 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; | 2962 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; |
2963 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 2963 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
2964 | u32 pr_res_mapped_lun = 0; | 2964 | u32 pr_res_mapped_lun = 0; |
2965 | int all_reg = 0, calling_it_nexus = 0, released_regs = 0; | 2965 | int all_reg = 0, calling_it_nexus = 0, released_regs = 0; |
2966 | int prh_type = 0, prh_scope = 0, ret; | 2966 | int prh_type = 0, prh_scope = 0, ret; |
@@ -2969,7 +2969,7 @@ static int core_scsi3_pro_preempt( | |||
2969 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2969 | return PYX_TRANSPORT_LU_COMM_FAILURE; |
2970 | 2970 | ||
2971 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 2971 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
2972 | pr_reg_n = core_scsi3_locate_pr_reg(SE_DEV(cmd), se_sess->se_node_acl, | 2972 | pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl, |
2973 | se_sess); | 2973 | se_sess); |
2974 | if (!(pr_reg_n)) { | 2974 | if (!(pr_reg_n)) { |
2975 | printk(KERN_ERR "SPC-3 PR: Unable to locate" | 2975 | printk(KERN_ERR "SPC-3 PR: Unable to locate" |
@@ -3111,7 +3111,7 @@ static int core_scsi3_pro_preempt( | |||
3111 | spin_unlock(&dev->dev_reservation_lock); | 3111 | spin_unlock(&dev->dev_reservation_lock); |
3112 | 3112 | ||
3113 | if (pr_tmpl->pr_aptpl_active) { | 3113 | if (pr_tmpl->pr_aptpl_active) { |
3114 | ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), | 3114 | ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, |
3115 | &pr_reg_n->pr_aptpl_buf[0], | 3115 | &pr_reg_n->pr_aptpl_buf[0], |
3116 | pr_tmpl->pr_aptpl_buf_len); | 3116 | pr_tmpl->pr_aptpl_buf_len); |
3117 | if (!(ret)) | 3117 | if (!(ret)) |
@@ -3121,7 +3121,7 @@ static int core_scsi3_pro_preempt( | |||
3121 | } | 3121 | } |
3122 | 3122 | ||
3123 | core_scsi3_put_pr_reg(pr_reg_n); | 3123 | core_scsi3_put_pr_reg(pr_reg_n); |
3124 | core_scsi3_pr_generation(SE_DEV(cmd)); | 3124 | core_scsi3_pr_generation(cmd->se_lun->lun_se_dev); |
3125 | return 0; | 3125 | return 0; |
3126 | } | 3126 | } |
3127 | /* | 3127 | /* |
@@ -3247,7 +3247,7 @@ static int core_scsi3_pro_preempt( | |||
3247 | } | 3247 | } |
3248 | 3248 | ||
3249 | if (pr_tmpl->pr_aptpl_active) { | 3249 | if (pr_tmpl->pr_aptpl_active) { |
3250 | ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), | 3250 | ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, |
3251 | &pr_reg_n->pr_aptpl_buf[0], | 3251 | &pr_reg_n->pr_aptpl_buf[0], |
3252 | pr_tmpl->pr_aptpl_buf_len); | 3252 | pr_tmpl->pr_aptpl_buf_len); |
3253 | if (!(ret)) | 3253 | if (!(ret)) |
@@ -3256,7 +3256,7 @@ static int core_scsi3_pro_preempt( | |||
3256 | } | 3256 | } |
3257 | 3257 | ||
3258 | core_scsi3_put_pr_reg(pr_reg_n); | 3258 | core_scsi3_put_pr_reg(pr_reg_n); |
3259 | core_scsi3_pr_generation(SE_DEV(cmd)); | 3259 | core_scsi3_pr_generation(cmd->se_lun->lun_se_dev); |
3260 | return 0; | 3260 | return 0; |
3261 | } | 3261 | } |
3262 | 3262 | ||
@@ -3297,17 +3297,17 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3297 | int aptpl, | 3297 | int aptpl, |
3298 | int unreg) | 3298 | int unreg) |
3299 | { | 3299 | { |
3300 | struct se_session *se_sess = SE_SESS(cmd); | 3300 | struct se_session *se_sess = cmd->se_sess; |
3301 | struct se_device *dev = SE_DEV(cmd); | 3301 | struct se_device *dev = cmd->se_lun->lun_se_dev; |
3302 | struct se_dev_entry *se_deve, *dest_se_deve = NULL; | 3302 | struct se_dev_entry *se_deve, *dest_se_deve = NULL; |
3303 | struct se_lun *se_lun = SE_LUN(cmd); | 3303 | struct se_lun *se_lun = cmd->se_lun; |
3304 | struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL; | 3304 | struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL; |
3305 | struct se_port *se_port; | 3305 | struct se_port *se_port; |
3306 | struct se_portal_group *se_tpg, *dest_se_tpg = NULL; | 3306 | struct se_portal_group *se_tpg, *dest_se_tpg = NULL; |
3307 | struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops; | 3307 | struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops; |
3308 | struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg; | 3308 | struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg; |
3309 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 3309 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
3310 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 3310 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
3311 | unsigned char *initiator_str; | 3311 | unsigned char *initiator_str; |
3312 | char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; | 3312 | char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; |
3313 | u32 tid_len, tmp_tid_len; | 3313 | u32 tid_len, tmp_tid_len; |
@@ -3322,7 +3322,7 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3322 | memset(dest_iport, 0, 64); | 3322 | memset(dest_iport, 0, 64); |
3323 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); | 3323 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); |
3324 | se_tpg = se_sess->se_tpg; | 3324 | se_tpg = se_sess->se_tpg; |
3325 | tf_ops = TPG_TFO(se_tpg); | 3325 | tf_ops = se_tpg->se_tpg_tfo; |
3326 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 3326 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
3327 | /* | 3327 | /* |
3328 | * Follow logic from spc4r17 Section 5.7.8, Table 50 -- | 3328 | * Follow logic from spc4r17 Section 5.7.8, Table 50 -- |
@@ -3330,7 +3330,7 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3330 | * | 3330 | * |
3331 | * Locate the existing *pr_reg via struct se_node_acl pointers | 3331 | * Locate the existing *pr_reg via struct se_node_acl pointers |
3332 | */ | 3332 | */ |
3333 | pr_reg = core_scsi3_locate_pr_reg(SE_DEV(cmd), se_sess->se_node_acl, | 3333 | pr_reg = core_scsi3_locate_pr_reg(cmd->se_lun->lun_se_dev, se_sess->se_node_acl, |
3334 | se_sess); | 3334 | se_sess); |
3335 | if (!(pr_reg)) { | 3335 | if (!(pr_reg)) { |
3336 | printk(KERN_ERR "SPC-3 PR: Unable to locate PR_REGISTERED" | 3336 | printk(KERN_ERR "SPC-3 PR: Unable to locate PR_REGISTERED" |
@@ -3384,7 +3384,7 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3384 | dest_se_tpg = se_port->sep_tpg; | 3384 | dest_se_tpg = se_port->sep_tpg; |
3385 | if (!(dest_se_tpg)) | 3385 | if (!(dest_se_tpg)) |
3386 | continue; | 3386 | continue; |
3387 | dest_tf_ops = TPG_TFO(dest_se_tpg); | 3387 | dest_tf_ops = dest_se_tpg->se_tpg_tfo; |
3388 | if (!(dest_tf_ops)) | 3388 | if (!(dest_tf_ops)) |
3389 | continue; | 3389 | continue; |
3390 | 3390 | ||
@@ -3612,7 +3612,7 @@ after_iport_check: | |||
3612 | dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl, | 3612 | dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl, |
3613 | iport_ptr); | 3613 | iport_ptr); |
3614 | if (!(dest_pr_reg)) { | 3614 | if (!(dest_pr_reg)) { |
3615 | ret = core_scsi3_alloc_registration(SE_DEV(cmd), | 3615 | ret = core_scsi3_alloc_registration(cmd->se_lun->lun_se_dev, |
3616 | dest_node_acl, dest_se_deve, iport_ptr, | 3616 | dest_node_acl, dest_se_deve, iport_ptr, |
3617 | sa_res_key, 0, aptpl, 2, 1); | 3617 | sa_res_key, 0, aptpl, 2, 1); |
3618 | if (ret != 0) { | 3618 | if (ret != 0) { |
@@ -3683,12 +3683,12 @@ after_iport_check: | |||
3683 | */ | 3683 | */ |
3684 | if (!(aptpl)) { | 3684 | if (!(aptpl)) { |
3685 | pr_tmpl->pr_aptpl_active = 0; | 3685 | pr_tmpl->pr_aptpl_active = 0; |
3686 | core_scsi3_update_and_write_aptpl(SE_DEV(cmd), NULL, 0); | 3686 | core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, NULL, 0); |
3687 | printk("SPC-3 PR: Set APTPL Bit Deactivated for" | 3687 | printk("SPC-3 PR: Set APTPL Bit Deactivated for" |
3688 | " REGISTER_AND_MOVE\n"); | 3688 | " REGISTER_AND_MOVE\n"); |
3689 | } else { | 3689 | } else { |
3690 | pr_tmpl->pr_aptpl_active = 1; | 3690 | pr_tmpl->pr_aptpl_active = 1; |
3691 | ret = core_scsi3_update_and_write_aptpl(SE_DEV(cmd), | 3691 | ret = core_scsi3_update_and_write_aptpl(cmd->se_lun->lun_se_dev, |
3692 | &dest_pr_reg->pr_aptpl_buf[0], | 3692 | &dest_pr_reg->pr_aptpl_buf[0], |
3693 | pr_tmpl->pr_aptpl_buf_len); | 3693 | pr_tmpl->pr_aptpl_buf_len); |
3694 | if (!(ret)) | 3694 | if (!(ret)) |
@@ -3723,7 +3723,7 @@ static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb) | |||
3723 | */ | 3723 | */ |
3724 | static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) | 3724 | static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) |
3725 | { | 3725 | { |
3726 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 3726 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
3727 | u64 res_key, sa_res_key; | 3727 | u64 res_key, sa_res_key; |
3728 | int sa, scope, type, aptpl; | 3728 | int sa, scope, type, aptpl; |
3729 | int spec_i_pt = 0, all_tg_pt = 0, unreg = 0; | 3729 | int spec_i_pt = 0, all_tg_pt = 0, unreg = 0; |
@@ -3731,7 +3731,7 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) | |||
3731 | * FIXME: A NULL struct se_session pointer means an this is not coming from | 3731 | * FIXME: A NULL struct se_session pointer means an this is not coming from |
3732 | * a $FABRIC_MOD's nexus, but from internal passthrough ops. | 3732 | * a $FABRIC_MOD's nexus, but from internal passthrough ops. |
3733 | */ | 3733 | */ |
3734 | if (!(SE_SESS(cmd))) | 3734 | if (!(cmd->se_sess)) |
3735 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 3735 | return PYX_TRANSPORT_LU_COMM_FAILURE; |
3736 | 3736 | ||
3737 | if (cmd->data_length < 24) { | 3737 | if (cmd->data_length < 24) { |
@@ -3827,10 +3827,10 @@ static int core_scsi3_emulate_pr_out(struct se_cmd *cmd, unsigned char *cdb) | |||
3827 | */ | 3827 | */ |
3828 | static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | 3828 | static int core_scsi3_pri_read_keys(struct se_cmd *cmd) |
3829 | { | 3829 | { |
3830 | struct se_device *se_dev = SE_DEV(cmd); | 3830 | struct se_device *se_dev = cmd->se_lun->lun_se_dev; |
3831 | struct se_subsystem_dev *su_dev = SU_DEV(se_dev); | 3831 | struct se_subsystem_dev *su_dev = se_dev->se_sub_dev; |
3832 | struct t10_pr_registration *pr_reg; | 3832 | struct t10_pr_registration *pr_reg; |
3833 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 3833 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
3834 | u32 add_len = 0, off = 8; | 3834 | u32 add_len = 0, off = 8; |
3835 | 3835 | ||
3836 | if (cmd->data_length < 8) { | 3836 | if (cmd->data_length < 8) { |
@@ -3839,13 +3839,13 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
3839 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 3839 | return PYX_TRANSPORT_INVALID_CDB_FIELD; |
3840 | } | 3840 | } |
3841 | 3841 | ||
3842 | buf[0] = ((T10_RES(su_dev)->pr_generation >> 24) & 0xff); | 3842 | buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); |
3843 | buf[1] = ((T10_RES(su_dev)->pr_generation >> 16) & 0xff); | 3843 | buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); |
3844 | buf[2] = ((T10_RES(su_dev)->pr_generation >> 8) & 0xff); | 3844 | buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); |
3845 | buf[3] = (T10_RES(su_dev)->pr_generation & 0xff); | 3845 | buf[3] = (su_dev->t10_pr.pr_generation & 0xff); |
3846 | 3846 | ||
3847 | spin_lock(&T10_RES(su_dev)->registration_lock); | 3847 | spin_lock(&su_dev->t10_pr.registration_lock); |
3848 | list_for_each_entry(pr_reg, &T10_RES(su_dev)->registration_list, | 3848 | list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list, |
3849 | pr_reg_list) { | 3849 | pr_reg_list) { |
3850 | /* | 3850 | /* |
3851 | * Check for overflow of 8byte PRI READ_KEYS payload and | 3851 | * Check for overflow of 8byte PRI READ_KEYS payload and |
@@ -3865,7 +3865,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
3865 | 3865 | ||
3866 | add_len += 8; | 3866 | add_len += 8; |
3867 | } | 3867 | } |
3868 | spin_unlock(&T10_RES(su_dev)->registration_lock); | 3868 | spin_unlock(&su_dev->t10_pr.registration_lock); |
3869 | 3869 | ||
3870 | buf[4] = ((add_len >> 24) & 0xff); | 3870 | buf[4] = ((add_len >> 24) & 0xff); |
3871 | buf[5] = ((add_len >> 16) & 0xff); | 3871 | buf[5] = ((add_len >> 16) & 0xff); |
@@ -3882,10 +3882,10 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
3882 | */ | 3882 | */ |
3883 | static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | 3883 | static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) |
3884 | { | 3884 | { |
3885 | struct se_device *se_dev = SE_DEV(cmd); | 3885 | struct se_device *se_dev = cmd->se_lun->lun_se_dev; |
3886 | struct se_subsystem_dev *su_dev = SU_DEV(se_dev); | 3886 | struct se_subsystem_dev *su_dev = se_dev->se_sub_dev; |
3887 | struct t10_pr_registration *pr_reg; | 3887 | struct t10_pr_registration *pr_reg; |
3888 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 3888 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
3889 | u64 pr_res_key; | 3889 | u64 pr_res_key; |
3890 | u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */ | 3890 | u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */ |
3891 | 3891 | ||
@@ -3895,10 +3895,10 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | |||
3895 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 3895 | return PYX_TRANSPORT_INVALID_CDB_FIELD; |
3896 | } | 3896 | } |
3897 | 3897 | ||
3898 | buf[0] = ((T10_RES(su_dev)->pr_generation >> 24) & 0xff); | 3898 | buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); |
3899 | buf[1] = ((T10_RES(su_dev)->pr_generation >> 16) & 0xff); | 3899 | buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); |
3900 | buf[2] = ((T10_RES(su_dev)->pr_generation >> 8) & 0xff); | 3900 | buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); |
3901 | buf[3] = (T10_RES(su_dev)->pr_generation & 0xff); | 3901 | buf[3] = (su_dev->t10_pr.pr_generation & 0xff); |
3902 | 3902 | ||
3903 | spin_lock(&se_dev->dev_reservation_lock); | 3903 | spin_lock(&se_dev->dev_reservation_lock); |
3904 | pr_reg = se_dev->dev_pr_res_holder; | 3904 | pr_reg = se_dev->dev_pr_res_holder; |
@@ -3963,9 +3963,9 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | |||
3963 | */ | 3963 | */ |
3964 | static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) | 3964 | static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) |
3965 | { | 3965 | { |
3966 | struct se_device *dev = SE_DEV(cmd); | 3966 | struct se_device *dev = cmd->se_lun->lun_se_dev; |
3967 | struct t10_reservation_template *pr_tmpl = &SU_DEV(dev)->t10_reservation; | 3967 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; |
3968 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 3968 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
3969 | u16 add_len = 8; /* Hardcoded to 8. */ | 3969 | u16 add_len = 8; /* Hardcoded to 8. */ |
3970 | 3970 | ||
3971 | if (cmd->data_length < 6) { | 3971 | if (cmd->data_length < 6) { |
@@ -4014,13 +4014,13 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) | |||
4014 | */ | 4014 | */ |
4015 | static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | 4015 | static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) |
4016 | { | 4016 | { |
4017 | struct se_device *se_dev = SE_DEV(cmd); | 4017 | struct se_device *se_dev = cmd->se_lun->lun_se_dev; |
4018 | struct se_node_acl *se_nacl; | 4018 | struct se_node_acl *se_nacl; |
4019 | struct se_subsystem_dev *su_dev = SU_DEV(se_dev); | 4019 | struct se_subsystem_dev *su_dev = se_dev->se_sub_dev; |
4020 | struct se_portal_group *se_tpg; | 4020 | struct se_portal_group *se_tpg; |
4021 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | 4021 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
4022 | struct t10_reservation_template *pr_tmpl = &SU_DEV(se_dev)->t10_reservation; | 4022 | struct t10_reservation *pr_tmpl = &se_dev->se_sub_dev->t10_pr; |
4023 | unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf; | 4023 | unsigned char *buf = (unsigned char *)cmd->t_task->t_task_buf; |
4024 | u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len; | 4024 | u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len; |
4025 | u32 off = 8; /* off into first Full Status descriptor */ | 4025 | u32 off = 8; /* off into first Full Status descriptor */ |
4026 | int format_code = 0; | 4026 | int format_code = 0; |
@@ -4031,10 +4031,10 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | |||
4031 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 4031 | return PYX_TRANSPORT_INVALID_CDB_FIELD; |
4032 | } | 4032 | } |
4033 | 4033 | ||
4034 | buf[0] = ((T10_RES(su_dev)->pr_generation >> 24) & 0xff); | 4034 | buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); |
4035 | buf[1] = ((T10_RES(su_dev)->pr_generation >> 16) & 0xff); | 4035 | buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); |
4036 | buf[2] = ((T10_RES(su_dev)->pr_generation >> 8) & 0xff); | 4036 | buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); |
4037 | buf[3] = (T10_RES(su_dev)->pr_generation & 0xff); | 4037 | buf[3] = (su_dev->t10_pr.pr_generation & 0xff); |
4038 | 4038 | ||
4039 | spin_lock(&pr_tmpl->registration_lock); | 4039 | spin_lock(&pr_tmpl->registration_lock); |
4040 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, | 4040 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, |
@@ -4051,7 +4051,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | |||
4051 | * Determine expected length of $FABRIC_MOD specific | 4051 | * Determine expected length of $FABRIC_MOD specific |
4052 | * TransportID full status descriptor.. | 4052 | * TransportID full status descriptor.. |
4053 | */ | 4053 | */ |
4054 | exp_desc_len = TPG_TFO(se_tpg)->tpg_get_pr_transport_id_len( | 4054 | exp_desc_len = se_tpg->se_tpg_tfo->tpg_get_pr_transport_id_len( |
4055 | se_tpg, se_nacl, pr_reg, &format_code); | 4055 | se_tpg, se_nacl, pr_reg, &format_code); |
4056 | 4056 | ||
4057 | if ((exp_desc_len + add_len) > cmd->data_length) { | 4057 | if ((exp_desc_len + add_len) > cmd->data_length) { |
@@ -4116,7 +4116,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | |||
4116 | /* | 4116 | /* |
4117 | * Now, have the $FABRIC_MOD fill in the protocol identifier | 4117 | * Now, have the $FABRIC_MOD fill in the protocol identifier |
4118 | */ | 4118 | */ |
4119 | desc_len = TPG_TFO(se_tpg)->tpg_get_pr_transport_id(se_tpg, | 4119 | desc_len = se_tpg->se_tpg_tfo->tpg_get_pr_transport_id(se_tpg, |
4120 | se_nacl, pr_reg, &format_code, &buf[off+4]); | 4120 | se_nacl, pr_reg, &format_code, &buf[off+4]); |
4121 | 4121 | ||
4122 | spin_lock(&pr_tmpl->registration_lock); | 4122 | spin_lock(&pr_tmpl->registration_lock); |
@@ -4174,7 +4174,7 @@ static int core_scsi3_emulate_pr_in(struct se_cmd *cmd, unsigned char *cdb) | |||
4174 | 4174 | ||
4175 | int core_scsi3_emulate_pr(struct se_cmd *cmd) | 4175 | int core_scsi3_emulate_pr(struct se_cmd *cmd) |
4176 | { | 4176 | { |
4177 | unsigned char *cdb = &T_TASK(cmd)->t_task_cdb[0]; | 4177 | unsigned char *cdb = &cmd->t_task->t_task_cdb[0]; |
4178 | struct se_device *dev = cmd->se_dev; | 4178 | struct se_device *dev = cmd->se_dev; |
4179 | /* | 4179 | /* |
4180 | * Following spc2r20 5.5.1 Reservations overview: | 4180 | * Following spc2r20 5.5.1 Reservations overview: |
@@ -4213,39 +4213,39 @@ static int core_pt_seq_non_holder( | |||
4213 | int core_setup_reservations(struct se_device *dev, int force_pt) | 4213 | int core_setup_reservations(struct se_device *dev, int force_pt) |
4214 | { | 4214 | { |
4215 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | 4215 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; |
4216 | struct t10_reservation_template *rest = &su_dev->t10_reservation; | 4216 | struct t10_reservation *rest = &su_dev->t10_pr; |
4217 | /* | 4217 | /* |
4218 | * If this device is from Target_Core_Mod/pSCSI, use the reservations | 4218 | * If this device is from Target_Core_Mod/pSCSI, use the reservations |
4219 | * of the Underlying SCSI hardware. In Linux/SCSI terms, this can | 4219 | * of the Underlying SCSI hardware. In Linux/SCSI terms, this can |
4220 | * cause a problem because libata and some SATA RAID HBAs appear | 4220 | * cause a problem because libata and some SATA RAID HBAs appear |
4221 | * under Linux/SCSI, but to emulate reservations themselves. | 4221 | * under Linux/SCSI, but to emulate reservations themselves. |
4222 | */ | 4222 | */ |
4223 | if (((TRANSPORT(dev)->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) && | 4223 | if (((dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) && |
4224 | !(DEV_ATTRIB(dev)->emulate_reservations)) || force_pt) { | 4224 | !(dev->se_sub_dev->se_dev_attrib.emulate_reservations)) || force_pt) { |
4225 | rest->res_type = SPC_PASSTHROUGH; | 4225 | rest->res_type = SPC_PASSTHROUGH; |
4226 | rest->pr_ops.t10_reservation_check = &core_pt_reservation_check; | 4226 | rest->pr_ops.t10_reservation_check = &core_pt_reservation_check; |
4227 | rest->pr_ops.t10_seq_non_holder = &core_pt_seq_non_holder; | 4227 | rest->pr_ops.t10_seq_non_holder = &core_pt_seq_non_holder; |
4228 | printk(KERN_INFO "%s: Using SPC_PASSTHROUGH, no reservation" | 4228 | printk(KERN_INFO "%s: Using SPC_PASSTHROUGH, no reservation" |
4229 | " emulation\n", TRANSPORT(dev)->name); | 4229 | " emulation\n", dev->transport->name); |
4230 | return 0; | 4230 | return 0; |
4231 | } | 4231 | } |
4232 | /* | 4232 | /* |
4233 | * If SPC-3 or above is reported by real or emulated struct se_device, | 4233 | * If SPC-3 or above is reported by real or emulated struct se_device, |
4234 | * use emulated Persistent Reservations. | 4234 | * use emulated Persistent Reservations. |
4235 | */ | 4235 | */ |
4236 | if (TRANSPORT(dev)->get_device_rev(dev) >= SCSI_3) { | 4236 | if (dev->transport->get_device_rev(dev) >= SCSI_3) { |
4237 | rest->res_type = SPC3_PERSISTENT_RESERVATIONS; | 4237 | rest->res_type = SPC3_PERSISTENT_RESERVATIONS; |
4238 | rest->pr_ops.t10_reservation_check = &core_scsi3_pr_reservation_check; | 4238 | rest->pr_ops.t10_reservation_check = &core_scsi3_pr_reservation_check; |
4239 | rest->pr_ops.t10_seq_non_holder = &core_scsi3_pr_seq_non_holder; | 4239 | rest->pr_ops.t10_seq_non_holder = &core_scsi3_pr_seq_non_holder; |
4240 | printk(KERN_INFO "%s: Using SPC3_PERSISTENT_RESERVATIONS" | 4240 | printk(KERN_INFO "%s: Using SPC3_PERSISTENT_RESERVATIONS" |
4241 | " emulation\n", TRANSPORT(dev)->name); | 4241 | " emulation\n", dev->transport->name); |
4242 | } else { | 4242 | } else { |
4243 | rest->res_type = SPC2_RESERVATIONS; | 4243 | rest->res_type = SPC2_RESERVATIONS; |
4244 | rest->pr_ops.t10_reservation_check = &core_scsi2_reservation_check; | 4244 | rest->pr_ops.t10_reservation_check = &core_scsi2_reservation_check; |
4245 | rest->pr_ops.t10_seq_non_holder = | 4245 | rest->pr_ops.t10_seq_non_holder = |
4246 | &core_scsi2_reservation_seq_non_holder; | 4246 | &core_scsi2_reservation_seq_non_holder; |
4247 | printk(KERN_INFO "%s: Using SPC2_RESERVATIONS emulation\n", | 4247 | printk(KERN_INFO "%s: Using SPC2_RESERVATIONS emulation\n", |
4248 | TRANSPORT(dev)->name); | 4248 | dev->transport->name); |
4249 | } | 4249 | } |
4250 | 4250 | ||
4251 | return 0; | 4251 | return 0; |