hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
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;
....@@ -526,7 +540,11 @@
526540 struct scatterlist *t_prot_sg;
527541 unsigned int t_prot_nents;
528542 sense_reason_t pi_err;
529
- sector_t bad_sector;
543
+ u64 sense_info;
544
+ /*
545
+ * CPU LIO will execute the cmd on. Defaults to the CPU the cmd is
546
+ * initialized on. Drivers can override.
547
+ */
530548 int cpuid;
531549 };
532550
....@@ -655,26 +673,26 @@
655673 };
656674
657675 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;
676
+ bool emulate_model_alias;
677
+ bool emulate_dpo; /* deprecated */
678
+ bool emulate_fua_write;
679
+ bool emulate_fua_read; /* deprecated */
680
+ bool emulate_write_cache;
681
+ enum target_ua_intlck_ctrl emulate_ua_intlck_ctrl;
682
+ bool emulate_tas;
683
+ bool emulate_tpu;
684
+ bool emulate_tpws;
685
+ bool emulate_caw;
686
+ bool emulate_3pc;
687
+ bool emulate_pr;
670688 enum target_prot_type pi_prot_type;
671689 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;
690
+ bool pi_prot_verify;
691
+ bool enforce_pr_isids;
692
+ bool force_pr_aptpl;
693
+ bool is_nonrot;
694
+ bool emulate_rest_reord;
695
+ bool unmap_zeroes_data;
678696 u32 hw_block_size;
679697 u32 block_size;
680698 u32 hw_max_sectors;
....@@ -733,7 +751,6 @@
733751 struct scsi_port_stats lun_stats;
734752 struct config_group lun_group;
735753 struct se_port_stat_grps port_stat_grps;
736
- struct completion lun_ref_comp;
737754 struct completion lun_shutdown_comp;
738755 struct percpu_ref lun_ref;
739756 struct list_head lun_dev_link;
....@@ -748,6 +765,11 @@
748765 struct config_group scsi_lu_group;
749766 };
750767
768
+struct se_device_queue {
769
+ struct list_head state_list;
770
+ spinlock_t lock;
771
+};
772
+
751773 struct se_device {
752774 /* RELATIVE TARGET PORT IDENTIFER Counter */
753775 u16 dev_rpti_counter;
....@@ -760,6 +782,7 @@
760782 #define DF_USING_UDEV_PATH 0x00000008
761783 #define DF_USING_ALIAS 0x00000010
762784 #define DF_READ_ONLY 0x00000020
785
+ u8 transport_flags;
763786 /* Physical device queue depth */
764787 u32 queue_depth;
765788 /* Used for SPC-2 reservations enforce of ISIDs */
....@@ -780,7 +803,6 @@
780803 atomic_t dev_qf_count;
781804 u32 export_count;
782805 spinlock_t delayed_cmd_lock;
783
- spinlock_t execute_task_lock;
784806 spinlock_t dev_reservation_lock;
785807 unsigned int dev_reservation_flags;
786808 #define DRF_SPC2_RESERVATIONS 0x00000001
....@@ -789,19 +811,17 @@
789811 spinlock_t se_tmr_lock;
790812 spinlock_t qf_cmd_lock;
791813 struct semaphore caw_sem;
792
- /* Used for legacy SPC-2 reservationsa */
793
- struct se_node_acl *dev_reserved_node_acl;
814
+ /* Used for legacy SPC-2 reservations */
815
+ struct se_session *reservation_holder;
794816 /* Used for ALUA Logical Unit Group membership */
795817 struct t10_alua_lu_gp_member *dev_alua_lu_gp_mem;
796818 /* Used for SPC-3 Persistent Reservations */
797819 struct t10_pr_registration *dev_pr_res_holder;
798820 struct list_head dev_sep_list;
799821 struct list_head dev_tmr_list;
800
- struct workqueue_struct *tmr_wq;
801822 struct work_struct qf_work_queue;
802823 struct work_struct delayed_cmd_work;
803824 struct list_head delayed_cmd_list;
804
- struct list_head state_list;
805825 struct list_head qf_cmd_list;
806826 /* Pointer to associated SE HBA */
807827 struct se_hba *se_hba;
....@@ -828,6 +848,9 @@
828848 /* For se_lun->lun_se_dev RCU read-side critical access */
829849 u32 hba_index;
830850 struct rcu_head rcu_head;
851
+ int queue_cnt;
852
+ struct se_device_queue *queues;
853
+ struct mutex lun_reset_mutex;
831854 };
832855
833856 struct se_hba {
....@@ -872,7 +895,6 @@
872895 /* Spinlock for adding/removing sessions */
873896 spinlock_t session_lock;
874897 struct mutex tpg_lun_mutex;
875
- struct list_head se_tpg_node;
876898 /* linked list for initiator ACL list */
877899 struct list_head acl_node_list;
878900 struct hlist_head tpg_lun_hlist;