@@ -2956,13 +2956,28 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
29562956 __core_scsi3_complete_pro_preempt (dev , pr_reg_n ,
29572957 (preempt_type == PREEMPT_AND_ABORT ) ? & preempt_and_abort_list : NULL ,
29582958 type , scope , preempt_type );
2959-
2960- if (preempt_type == PREEMPT_AND_ABORT )
2961- core_scsi3_release_preempt_and_abort (
2962- & preempt_and_abort_list , pr_reg_n );
29632959 }
2960+
29642961 spin_unlock (& dev -> dev_reservation_lock );
29652962
2963+ /*
2964+ * SPC-4 5.12.11.2.6 Preempting and aborting
2965+ * The actions described in this subclause shall be performed
2966+ * for all I_T nexuses that are registered with the non-zero
2967+ * SERVICE ACTION RESERVATION KEY value, without regard for
2968+ * whether the preempted I_T nexuses hold the persistent
2969+ * reservation. If the SERVICE ACTION RESERVATION KEY field is
2970+ * set to zero and an all registrants persistent reservation is
2971+ * present, the device server shall abort all commands for all
2972+ * registered I_T nexuses.
2973+ */
2974+ if (preempt_type == PREEMPT_AND_ABORT ) {
2975+ core_tmr_lun_reset (dev , NULL , & preempt_and_abort_list ,
2976+ cmd );
2977+ core_scsi3_release_preempt_and_abort (
2978+ & preempt_and_abort_list , pr_reg_n );
2979+ }
2980+
29662981 if (pr_tmpl -> pr_aptpl_active )
29672982 core_scsi3_update_and_write_aptpl (cmd -> se_dev , true);
29682983
@@ -3022,7 +3037,7 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
30223037 if (calling_it_nexus )
30233038 continue ;
30243039
3025- if (pr_reg -> pr_res_key != sa_res_key )
3040+ if (sa_res_key && pr_reg -> pr_res_key != sa_res_key )
30263041 continue ;
30273042
30283043 pr_reg_nacl = pr_reg -> pr_reg_nacl ;
@@ -3425,8 +3440,6 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
34253440 * transport protocols where port names are not required;
34263441 * d) Register the reservation key specified in the SERVICE ACTION
34273442 * RESERVATION KEY field;
3428- * e) Retain the reservation key specified in the SERVICE ACTION
3429- * RESERVATION KEY field and associated information;
34303443 *
34313444 * Also, It is not an error for a REGISTER AND MOVE service action to
34323445 * register an I_T nexus that is already registered with the same
@@ -3448,6 +3461,12 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
34483461 dest_pr_reg = __core_scsi3_locate_pr_reg (dev , dest_node_acl ,
34493462 iport_ptr );
34503463 new_reg = 1 ;
3464+ } else {
3465+ /*
3466+ * e) Retain the reservation key specified in the SERVICE ACTION
3467+ * RESERVATION KEY field and associated information;
3468+ */
3469+ dest_pr_reg -> pr_res_key = sa_res_key ;
34513470 }
34523471 /*
34533472 * f) Release the persistent reservation for the persistent reservation
0 commit comments