hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/target/target_core_base.h
....@@ -46,6 +46,10 @@
4646 /* Used by transport_get_inquiry_vpd_device_ident() */
4747 #define INQUIRY_VPD_DEVICE_IDENTIFIER_LEN 254
4848
49
+#define INQUIRY_VENDOR_LEN 8
50
+#define INQUIRY_MODEL_LEN 16
51
+#define INQUIRY_REVISION_LEN 4
52
+
4953 /* Attempts before moving from SHORT to LONG */
5054 #define PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD 3
5155 #define PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT 3 /* In milliseconds */
....@@ -70,8 +74,6 @@
7074 #define DA_EMULATE_MODEL_ALIAS 0
7175 /* Emulation for WriteCache and SYNCHRONIZE_CACHE */
7276 #define DA_EMULATE_WRITE_CACHE 0
73
-/* Emulation for UNIT ATTENTION Interlock Control */
74
-#define DA_EMULATE_UA_INTLLCK_CTRL 0
7577 /* Emulation for TASK_ABORTED status (TAS) by default */
7678 #define DA_EMULATE_TAS 1
7779 /* Emulation for Thin Provisioning UNMAP using block/blk-lib.c:blkdev_issue_discard() */
....@@ -87,6 +89,8 @@
8789 #define DA_EMULATE_3PC 1
8890 /* No Emulation for PSCSI by default */
8991 #define DA_EMULATE_ALUA 0
92
+/* Emulate SCSI2 RESERVE/RELEASE and Persistent Reservations by default */
93
+#define DA_EMULATE_PR 1
9094 /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
9195 #define DA_ENFORCE_PR_ISIDS 1
9296 /* Force SPC-3 PR Activate Persistence across Target Power Loss */
....@@ -134,11 +138,9 @@
134138 SCF_SENT_CHECK_CONDITION = 0x00000800,
135139 SCF_OVERFLOW_BIT = 0x00001000,
136140 SCF_UNDERFLOW_BIT = 0x00002000,
137
- SCF_SEND_DELAYED_TAS = 0x00004000,
138141 SCF_ALUA_NON_OPTIMIZED = 0x00008000,
139142 SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000,
140143 SCF_COMPARE_AND_WRITE = 0x00080000,
141
- SCF_COMPARE_AND_WRITE_POST = 0x00100000,
142144 SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC = 0x00200000,
143145 SCF_ACK_KREF = 0x00400000,
144146 SCF_USE_CPUID = 0x00800000,
....@@ -205,6 +207,7 @@
205207 TMR_LUN_RESET = 5,
206208 TMR_TARGET_WARM_RESET = 6,
207209 TMR_TARGET_COLD_RESET = 7,
210
+ TMR_LUN_RESET_PRO = 0x80,
208211 TMR_UNKNOWN = 0xff,
209212 };
210213
....@@ -315,9 +318,13 @@
315318 };
316319
317320 struct t10_wwn {
318
- char vendor[8];
319
- char model[16];
320
- char revision[4];
321
+ /*
322
+ * SCSI left aligned strings may not be null terminated. +1 to ensure a
323
+ * null terminator is always present.
324
+ */
325
+ char vendor[INQUIRY_VENDOR_LEN + 1];
326
+ char model[INQUIRY_MODEL_LEN + 1];
327
+ char revision[INQUIRY_REVISION_LEN + 1];
321328 char unit_serial[INQUIRY_VPD_SERIAL_LEN];
322329 spinlock_t t10_vpd_lock;
323330 struct se_device *t10_dev;
....@@ -425,6 +432,13 @@
425432 TARGET_DIF_TYPE3_PROT,
426433 };
427434
435
+/* Emulation for UNIT ATTENTION Interlock Control */
436
+enum target_ua_intlck_ctrl {
437
+ TARGET_UA_INTLCK_CTRL_CLEAR = 0,
438
+ TARGET_UA_INTLCK_CTRL_NO_CLEAR = 1,
439
+ TARGET_UA_INTLCK_CTRL_ESTABLISH_UA = 2,
440
+};
441
+
428442 enum target_core_dif_check {
429443 TARGET_DIF_CHECK_GUARD = 0x1 << 0,
430444 TARGET_DIF_CHECK_APPTAG = 0x1 << 1,
....@@ -475,7 +489,8 @@
475489 struct se_session *se_sess;
476490 struct se_tmr_req *se_tmr_req;
477491 struct list_head se_cmd_list;
478
- struct completion *compl;
492
+ struct completion *free_compl;
493
+ struct completion *abrt_compl;
479494 const struct target_core_fabric_ops *se_tfo;
480495 sense_reason_t (*execute_cmd)(struct se_cmd *);
481496 sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool, int *);
....@@ -493,7 +508,6 @@
493508 #define CMD_T_STOP (1 << 5)
494509 #define CMD_T_TAS (1 << 10)
495510 #define CMD_T_FABRIC_STOP (1 << 11)
496
-#define CMD_T_PRE_EXECUTE (1 << 12)
497511 spinlock_t t_state_lock;
498512 struct kref cmd_kref;
499513 struct completion t_transport_stop_comp;
....@@ -655,26 +669,26 @@
655669 };
656670
657671 struct se_dev_attrib {
658
- int emulate_model_alias;
659
- int emulate_dpo;
660
- int emulate_fua_write;
661
- int emulate_fua_read;
662
- int emulate_write_cache;
663
- int emulate_ua_intlck_ctrl;
664
- int emulate_tas;
665
- int emulate_tpu;
666
- int emulate_tpws;
667
- int emulate_caw;
668
- int emulate_3pc;
669
- int pi_prot_format;
672
+ bool emulate_model_alias;
673
+ bool emulate_dpo; /* deprecated */
674
+ bool emulate_fua_write;
675
+ bool emulate_fua_read; /* deprecated */
676
+ bool emulate_write_cache;
677
+ enum target_ua_intlck_ctrl emulate_ua_intlck_ctrl;
678
+ bool emulate_tas;
679
+ bool emulate_tpu;
680
+ bool emulate_tpws;
681
+ bool emulate_caw;
682
+ bool emulate_3pc;
683
+ bool emulate_pr;
670684 enum target_prot_type pi_prot_type;
671685 enum target_prot_type hw_pi_prot_type;
672
- int pi_prot_verify;
673
- int enforce_pr_isids;
674
- int force_pr_aptpl;
675
- int is_nonrot;
676
- int emulate_rest_reord;
677
- int unmap_zeroes_data;
686
+ bool pi_prot_verify;
687
+ bool enforce_pr_isids;
688
+ bool force_pr_aptpl;
689
+ bool is_nonrot;
690
+ bool emulate_rest_reord;
691
+ bool unmap_zeroes_data;
678692 u32 hw_block_size;
679693 u32 block_size;
680694 u32 hw_max_sectors;
....@@ -733,7 +747,6 @@
733747 struct scsi_port_stats lun_stats;
734748 struct config_group lun_group;
735749 struct se_port_stat_grps port_stat_grps;
736
- struct completion lun_ref_comp;
737750 struct completion lun_shutdown_comp;
738751 struct percpu_ref lun_ref;
739752 struct list_head lun_dev_link;
....@@ -760,6 +773,7 @@
760773 #define DF_USING_UDEV_PATH 0x00000008
761774 #define DF_USING_ALIAS 0x00000010
762775 #define DF_READ_ONLY 0x00000020
776
+ u8 transport_flags;
763777 /* Physical device queue depth */
764778 u32 queue_depth;
765779 /* Used for SPC-2 reservations enforce of ISIDs */
....@@ -789,15 +803,14 @@
789803 spinlock_t se_tmr_lock;
790804 spinlock_t qf_cmd_lock;
791805 struct semaphore caw_sem;
792
- /* Used for legacy SPC-2 reservationsa */
793
- struct se_node_acl *dev_reserved_node_acl;
806
+ /* Used for legacy SPC-2 reservations */
807
+ struct se_session *reservation_holder;
794808 /* Used for ALUA Logical Unit Group membership */
795809 struct t10_alua_lu_gp_member *dev_alua_lu_gp_mem;
796810 /* Used for SPC-3 Persistent Reservations */
797811 struct t10_pr_registration *dev_pr_res_holder;
798812 struct list_head dev_sep_list;
799813 struct list_head dev_tmr_list;
800
- struct workqueue_struct *tmr_wq;
801814 struct work_struct qf_work_queue;
802815 struct work_struct delayed_cmd_work;
803816 struct list_head delayed_cmd_list;
....@@ -872,7 +885,6 @@
872885 /* Spinlock for adding/removing sessions */
873886 spinlock_t session_lock;
874887 struct mutex tpg_lun_mutex;
875
- struct list_head se_tpg_node;
876888 /* linked list for initiator ACL list */
877889 struct list_head acl_node_list;
878890 struct hlist_head tpg_lun_hlist;