diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-15 17:25:10 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-15 17:25:10 -0500 |
| commit | 5bd665f28db2b04a8d6fe277342479906fc60b62 (patch) | |
| tree | 4f9f63120fed3a61b44bbb7ec4ebaaa4dc4fc571 /include | |
| parent | 115b1cc2ef0f43ecb42bdbf55f06e9d2231d5a7e (diff) | |
| parent | 79e62fc3827bd437c304c1810f36896fc1e717b1 (diff) | |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull target updates from Nicholas Bellinger:
"It has been a very busy development cycle this time around in target
land, with the highlights including:
- Kill struct se_subsystem_dev, in favor of direct se_device usage
(hch)
- Simplify reservations code by combining SPC-3 + SCSI-2 support for
virtual backends only (hch)
- Simplify ALUA code for virtual only backends, and remove left over
abstractions (hch)
- Pass sense_reason_t as return value for I/O submission path (hch)
- Refactor MODE_SENSE emulation to allow for easier addition of new
mode pages. (roland)
- Add emulation of MODE_SELECT (roland)
- Fix bug in handling of ExpStatSN wrap-around (steve)
- Fix bug in TMR ABORT_TASK lookup in qla2xxx target (steve)
- Add WRITE_SAME w/ UNMAP=0 support for IBLOCK backends (nab)
- Convert ib_srpt to use modern target_submit_cmd caller + drop
legacy ioctx->kref usage (nab)
- Convert ib_srpt to use modern target_submit_tmr caller (nab)
- Add link_magic for fabric allow_link destination target_items for
symlinks within target_core_fabric_configfs.c code (nab)
- Allocate pointers in instead of full structs for
config_group->default_groups (sebastian)
- Fix 32-bit highmem breakage for FILEIO (sebastian)
All told, hch was able to shave off another ~1K LOC by killing the
se_subsystem_dev abstraction, along with a number of PR + ALUA
simplifications. Also, a nice patch by Roland is the refactoring of
MODE_SENSE handling, along with the addition of initial MODE_SELECT
emulation support for virtual backends.
Sebastian found a long-standing issue wrt to allocation of full
config_group instead of pointers for config_group->default_group[]
setup in a number of areas, which ends up saving memory with big
configurations. He also managed to fix another long-standing BUG wrt
to broken 32-bit highmem support within the FILEIO backend driver.
Thank you again to everyone who contributed this round!"
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (50 commits)
target/iscsi_target: Add NodeACL tags for initiator group support
target/tcm_fc: fix the lockdep warning due to inconsistent lock state
sbp-target: fix error path in sbp_make_tpg()
sbp-target: use simple assignment in tgt_agent_rw_agent_state()
iscsi-target: use kstrdup() for iscsi_param
target/file: merge fd_do_readv() and fd_do_writev()
target/file: Fix 32-bit highmem breakage for SGL -> iovec mapping
target: Add link_magic for fabric allow_link destination target_items
ib_srpt: Convert TMR path to target_submit_tmr
ib_srpt: Convert I/O path to target_submit_cmd + drop legacy ioctx->kref
target: Make spc_get_write_same_sectors return sector_t
target/configfs: use kmalloc() instead of kzalloc() for default groups
target/configfs: allocate only 6 slots for dev_cg->default_groups
target/configfs: allocate pointers instead of full struct for default_groups
target: update error handling for sbc_setup_write_same()
iscsit: use GFP_ATOMIC under spin lock
iscsi_target: Remove redundant null check before kfree
target/iblock: Forward declare bio helpers
target: Clean up flow in transport_check_aborted_status()
target: Clean up logic in transport_put_cmd()
...
Diffstat (limited to 'include')
| -rw-r--r-- | include/target/target_core_backend.h | 49 | ||||
| -rw-r--r-- | include/target/target_core_base.h | 212 | ||||
| -rw-r--r-- | include/target/target_core_fabric.h | 15 |
3 files changed, 93 insertions, 183 deletions
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 2acd54018b64..507910992c59 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h | |||
| @@ -9,6 +9,8 @@ struct se_subsystem_api { | |||
| 9 | struct list_head sub_api_list; | 9 | struct list_head sub_api_list; |
| 10 | 10 | ||
| 11 | char name[16]; | 11 | char name[16]; |
| 12 | char inquiry_prod[16]; | ||
| 13 | char inquiry_rev[4]; | ||
| 12 | struct module *owner; | 14 | struct module *owner; |
| 13 | 15 | ||
| 14 | u8 transport_type; | 16 | u8 transport_type; |
| @@ -16,46 +18,45 @@ struct se_subsystem_api { | |||
| 16 | int (*attach_hba)(struct se_hba *, u32); | 18 | int (*attach_hba)(struct se_hba *, u32); |
| 17 | void (*detach_hba)(struct se_hba *); | 19 | void (*detach_hba)(struct se_hba *); |
| 18 | int (*pmode_enable_hba)(struct se_hba *, unsigned long); | 20 | int (*pmode_enable_hba)(struct se_hba *, unsigned long); |
| 19 | void *(*allocate_virtdevice)(struct se_hba *, const char *); | 21 | |
| 20 | struct se_device *(*create_virtdevice)(struct se_hba *, | 22 | struct se_device *(*alloc_device)(struct se_hba *, const char *); |
| 21 | struct se_subsystem_dev *, void *); | 23 | int (*configure_device)(struct se_device *); |
| 22 | void (*free_device)(void *); | 24 | void (*free_device)(struct se_device *device); |
| 25 | |||
| 26 | ssize_t (*set_configfs_dev_params)(struct se_device *, | ||
| 27 | const char *, ssize_t); | ||
| 28 | ssize_t (*show_configfs_dev_params)(struct se_device *, char *); | ||
| 29 | |||
| 23 | void (*transport_complete)(struct se_cmd *cmd, | 30 | void (*transport_complete)(struct se_cmd *cmd, |
| 24 | struct scatterlist *, | 31 | struct scatterlist *, |
| 25 | unsigned char *); | 32 | unsigned char *); |
| 26 | 33 | ||
| 27 | int (*parse_cdb)(struct se_cmd *cmd); | 34 | sense_reason_t (*parse_cdb)(struct se_cmd *cmd); |
| 28 | ssize_t (*check_configfs_dev_params)(struct se_hba *, | ||
| 29 | struct se_subsystem_dev *); | ||
| 30 | ssize_t (*set_configfs_dev_params)(struct se_hba *, | ||
| 31 | struct se_subsystem_dev *, const char *, ssize_t); | ||
| 32 | ssize_t (*show_configfs_dev_params)(struct se_hba *, | ||
| 33 | struct se_subsystem_dev *, char *); | ||
| 34 | u32 (*get_device_rev)(struct se_device *); | ||
| 35 | u32 (*get_device_type)(struct se_device *); | 35 | u32 (*get_device_type)(struct se_device *); |
| 36 | sector_t (*get_blocks)(struct se_device *); | 36 | sector_t (*get_blocks)(struct se_device *); |
| 37 | unsigned char *(*get_sense_buffer)(struct se_cmd *); | 37 | unsigned char *(*get_sense_buffer)(struct se_cmd *); |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | struct spc_ops { | 40 | struct sbc_ops { |
| 41 | int (*execute_rw)(struct se_cmd *cmd); | 41 | sense_reason_t (*execute_rw)(struct se_cmd *cmd); |
| 42 | int (*execute_sync_cache)(struct se_cmd *cmd); | 42 | sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd); |
| 43 | int (*execute_write_same)(struct se_cmd *cmd); | 43 | sense_reason_t (*execute_write_same)(struct se_cmd *cmd); |
| 44 | int (*execute_unmap)(struct se_cmd *cmd); | 44 | sense_reason_t (*execute_write_same_unmap)(struct se_cmd *cmd); |
| 45 | sense_reason_t (*execute_unmap)(struct se_cmd *cmd); | ||
| 45 | }; | 46 | }; |
| 46 | 47 | ||
| 47 | int transport_subsystem_register(struct se_subsystem_api *); | 48 | int transport_subsystem_register(struct se_subsystem_api *); |
| 48 | void transport_subsystem_release(struct se_subsystem_api *); | 49 | void transport_subsystem_release(struct se_subsystem_api *); |
| 49 | 50 | ||
| 50 | struct se_device *transport_add_device_to_core_hba(struct se_hba *, | ||
| 51 | struct se_subsystem_api *, struct se_subsystem_dev *, u32, | ||
| 52 | void *, struct se_dev_limits *, const char *, const char *); | ||
| 53 | |||
| 54 | void target_complete_cmd(struct se_cmd *, u8); | 51 | void target_complete_cmd(struct se_cmd *, u8); |
| 55 | 52 | ||
| 56 | int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops); | 53 | sense_reason_t spc_parse_cdb(struct se_cmd *cmd, unsigned int *size); |
| 57 | int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size); | 54 | sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd); |
| 58 | int spc_get_write_same_sectors(struct se_cmd *cmd); | 55 | sector_t spc_get_write_same_sectors(struct se_cmd *cmd); |
| 56 | |||
| 57 | sense_reason_t sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops); | ||
| 58 | u32 sbc_get_device_rev(struct se_device *dev); | ||
| 59 | u32 sbc_get_device_type(struct se_device *dev); | ||
| 59 | 60 | ||
| 60 | void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *); | 61 | void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *); |
| 61 | int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *); | 62 | int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *); |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 5be89373ceac..7cae2360221e 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
| @@ -62,20 +62,6 @@ | |||
| 62 | 62 | ||
| 63 | #define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */ | 63 | #define PYX_TRANSPORT_STATUS_INTERVAL 5 /* In seconds */ |
| 64 | 64 | ||
| 65 | /* | ||
| 66 | * struct se_subsystem_dev->su_dev_flags | ||
| 67 | */ | ||
| 68 | #define SDF_FIRMWARE_VPD_UNIT_SERIAL 0x00000001 | ||
| 69 | #define SDF_EMULATED_VPD_UNIT_SERIAL 0x00000002 | ||
| 70 | #define SDF_USING_UDEV_PATH 0x00000004 | ||
| 71 | #define SDF_USING_ALIAS 0x00000008 | ||
| 72 | |||
| 73 | /* | ||
| 74 | * struct se_device->dev_flags | ||
| 75 | */ | ||
| 76 | #define DF_SPC2_RESERVATIONS 0x00000001 | ||
| 77 | #define DF_SPC2_RESERVATIONS_WITH_ISID 0x00000002 | ||
| 78 | |||
| 79 | /* struct se_dev_attrib sanity values */ | 65 | /* struct se_dev_attrib sanity values */ |
| 80 | /* Default max_unmap_lba_count */ | 66 | /* Default max_unmap_lba_count */ |
| 81 | #define DA_MAX_UNMAP_LBA_COUNT 0 | 67 | #define DA_MAX_UNMAP_LBA_COUNT 0 |
| @@ -85,6 +71,8 @@ | |||
| 85 | #define DA_UNMAP_GRANULARITY_DEFAULT 0 | 71 | #define DA_UNMAP_GRANULARITY_DEFAULT 0 |
| 86 | /* Default unmap_granularity_alignment */ | 72 | /* Default unmap_granularity_alignment */ |
| 87 | #define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0 | 73 | #define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 0 |
| 74 | /* Default max_write_same_len, disabled by default */ | ||
| 75 | #define DA_MAX_WRITE_SAME_LEN 0 | ||
| 88 | /* Default max transfer length */ | 76 | /* Default max transfer length */ |
| 89 | #define DA_FABRIC_MAX_SECTORS 8192 | 77 | #define DA_FABRIC_MAX_SECTORS 8192 |
| 90 | /* Emulation for Direct Page Out */ | 78 | /* Emulation for Direct Page Out */ |
| @@ -107,8 +95,6 @@ | |||
| 107 | */ | 95 | */ |
| 108 | #define DA_EMULATE_TPWS 0 | 96 | #define DA_EMULATE_TPWS 0 |
| 109 | /* No Emulation for PSCSI by default */ | 97 | /* No Emulation for PSCSI by default */ |
| 110 | #define DA_EMULATE_RESERVATIONS 0 | ||
| 111 | /* No Emulation for PSCSI by default */ | ||
| 112 | #define DA_EMULATE_ALUA 0 | 98 | #define DA_EMULATE_ALUA 0 |
| 113 | /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */ | 99 | /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */ |
| 114 | #define DA_ENFORCE_PR_ISIDS 1 | 100 | #define DA_ENFORCE_PR_ISIDS 1 |
| @@ -160,8 +146,6 @@ enum se_cmd_flags_table { | |||
| 160 | SCF_EMULATED_TASK_SENSE = 0x00000004, | 146 | SCF_EMULATED_TASK_SENSE = 0x00000004, |
| 161 | SCF_SCSI_DATA_CDB = 0x00000008, | 147 | SCF_SCSI_DATA_CDB = 0x00000008, |
| 162 | SCF_SCSI_TMR_CDB = 0x00000010, | 148 | SCF_SCSI_TMR_CDB = 0x00000010, |
| 163 | SCF_SCSI_CDB_EXCEPTION = 0x00000020, | ||
| 164 | SCF_SCSI_RESERVATION_CONFLICT = 0x00000040, | ||
| 165 | SCF_FUA = 0x00000080, | 149 | SCF_FUA = 0x00000080, |
| 166 | SCF_SE_LUN_CMD = 0x00000100, | 150 | SCF_SE_LUN_CMD = 0x00000100, |
| 167 | SCF_BIDI = 0x00000400, | 151 | SCF_BIDI = 0x00000400, |
| @@ -182,38 +166,33 @@ enum transport_lunflags_table { | |||
| 182 | TRANSPORT_LUNFLAGS_READ_WRITE = 0x04, | 166 | TRANSPORT_LUNFLAGS_READ_WRITE = 0x04, |
| 183 | }; | 167 | }; |
| 184 | 168 | ||
| 185 | /* struct se_device->dev_status */ | ||
| 186 | enum transport_device_status_table { | ||
| 187 | TRANSPORT_DEVICE_ACTIVATED = 0x01, | ||
| 188 | TRANSPORT_DEVICE_DEACTIVATED = 0x02, | ||
| 189 | TRANSPORT_DEVICE_QUEUE_FULL = 0x04, | ||
| 190 | TRANSPORT_DEVICE_SHUTDOWN = 0x08, | ||
| 191 | TRANSPORT_DEVICE_OFFLINE_ACTIVATED = 0x10, | ||
| 192 | TRANSPORT_DEVICE_OFFLINE_DEACTIVATED = 0x20, | ||
| 193 | }; | ||
| 194 | |||
| 195 | /* | 169 | /* |
| 196 | * Used by transport_send_check_condition_and_sense() and se_cmd->scsi_sense_reason | 170 | * Used by transport_send_check_condition_and_sense() |
| 197 | * to signal which ASC/ASCQ sense payload should be built. | 171 | * to signal which ASC/ASCQ sense payload should be built. |
| 198 | */ | 172 | */ |
| 173 | typedef unsigned __bitwise__ sense_reason_t; | ||
| 174 | |||
| 199 | enum tcm_sense_reason_table { | 175 | enum tcm_sense_reason_table { |
| 200 | TCM_NON_EXISTENT_LUN = 0x01, | 176 | #define R(x) (__force sense_reason_t )(x) |
| 201 | TCM_UNSUPPORTED_SCSI_OPCODE = 0x02, | 177 | TCM_NON_EXISTENT_LUN = R(0x01), |
| 202 | TCM_INCORRECT_AMOUNT_OF_DATA = 0x03, | 178 | TCM_UNSUPPORTED_SCSI_OPCODE = R(0x02), |
| 203 | TCM_UNEXPECTED_UNSOLICITED_DATA = 0x04, | 179 | TCM_INCORRECT_AMOUNT_OF_DATA = R(0x03), |
| 204 | TCM_SERVICE_CRC_ERROR = 0x05, | 180 | TCM_UNEXPECTED_UNSOLICITED_DATA = R(0x04), |
| 205 | TCM_SNACK_REJECTED = 0x06, | 181 | TCM_SERVICE_CRC_ERROR = R(0x05), |
| 206 | TCM_SECTOR_COUNT_TOO_MANY = 0x07, | 182 | TCM_SNACK_REJECTED = R(0x06), |
| 207 | TCM_INVALID_CDB_FIELD = 0x08, | 183 | TCM_SECTOR_COUNT_TOO_MANY = R(0x07), |
| 208 | TCM_INVALID_PARAMETER_LIST = 0x09, | 184 | TCM_INVALID_CDB_FIELD = R(0x08), |
| 209 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = 0x0a, | 185 | TCM_INVALID_PARAMETER_LIST = R(0x09), |
| 210 | TCM_UNKNOWN_MODE_PAGE = 0x0b, | 186 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE = R(0x0a), |
| 211 | TCM_WRITE_PROTECTED = 0x0c, | 187 | TCM_UNKNOWN_MODE_PAGE = R(0x0b), |
| 212 | TCM_CHECK_CONDITION_ABORT_CMD = 0x0d, | 188 | TCM_WRITE_PROTECTED = R(0x0c), |
| 213 | TCM_CHECK_CONDITION_UNIT_ATTENTION = 0x0e, | 189 | TCM_CHECK_CONDITION_ABORT_CMD = R(0x0d), |
| 214 | TCM_CHECK_CONDITION_NOT_READY = 0x0f, | 190 | TCM_CHECK_CONDITION_UNIT_ATTENTION = R(0x0e), |
| 215 | TCM_RESERVATION_CONFLICT = 0x10, | 191 | TCM_CHECK_CONDITION_NOT_READY = R(0x0f), |
| 216 | TCM_ADDRESS_OUT_OF_RANGE = 0x11, | 192 | TCM_RESERVATION_CONFLICT = R(0x10), |
| 193 | TCM_ADDRESS_OUT_OF_RANGE = R(0x11), | ||
| 194 | TCM_OUT_OF_RESOURCES = R(0x12), | ||
| 195 | #undef R | ||
| 217 | }; | 196 | }; |
| 218 | 197 | ||
| 219 | enum target_sc_flags_table { | 198 | enum target_sc_flags_table { |
| @@ -246,30 +225,6 @@ enum tcm_tmrsp_table { | |||
| 246 | TMR_FUNCTION_REJECTED = 255, | 225 | TMR_FUNCTION_REJECTED = 255, |
| 247 | }; | 226 | }; |
| 248 | 227 | ||
| 249 | struct se_obj { | ||
| 250 | atomic_t obj_access_count; | ||
| 251 | }; | ||
| 252 | |||
| 253 | /* | ||
| 254 | * Used by TCM Core internally to signal if ALUA emulation is enabled or | ||
| 255 | * disabled, or running in with TCM/pSCSI passthrough mode | ||
| 256 | */ | ||
| 257 | typedef enum { | ||
| 258 | SPC_ALUA_PASSTHROUGH, | ||
| 259 | SPC2_ALUA_DISABLED, | ||
| 260 | SPC3_ALUA_EMULATED | ||
| 261 | } t10_alua_index_t; | ||
| 262 | |||
| 263 | /* | ||
| 264 | * Used by TCM Core internally to signal if SAM Task Attribute emulation | ||
| 265 | * is enabled or disabled, or running in with TCM/pSCSI passthrough mode | ||
| 266 | */ | ||
| 267 | typedef enum { | ||
| 268 | SAM_TASK_ATTR_PASSTHROUGH, | ||
| 269 | SAM_TASK_ATTR_UNTAGGED, | ||
| 270 | SAM_TASK_ATTR_EMULATED | ||
| 271 | } t10_task_attr_index_t; | ||
| 272 | |||
| 273 | /* | 228 | /* |
| 274 | * Used for target SCSI statistics | 229 | * Used for target SCSI statistics |
| 275 | */ | 230 | */ |
| @@ -283,17 +238,15 @@ typedef enum { | |||
| 283 | struct se_cmd; | 238 | struct se_cmd; |
| 284 | 239 | ||
| 285 | struct t10_alua { | 240 | struct t10_alua { |
| 286 | t10_alua_index_t alua_type; | ||
| 287 | /* ALUA Target Port Group ID */ | 241 | /* ALUA Target Port Group ID */ |
| 288 | u16 alua_tg_pt_gps_counter; | 242 | u16 alua_tg_pt_gps_counter; |
| 289 | u32 alua_tg_pt_gps_count; | 243 | u32 alua_tg_pt_gps_count; |
| 290 | spinlock_t tg_pt_gps_lock; | 244 | spinlock_t tg_pt_gps_lock; |
| 291 | struct se_subsystem_dev *t10_sub_dev; | 245 | struct se_device *t10_dev; |
| 292 | /* Used for default ALUA Target Port Group */ | 246 | /* Used for default ALUA Target Port Group */ |
| 293 | struct t10_alua_tg_pt_gp *default_tg_pt_gp; | 247 | struct t10_alua_tg_pt_gp *default_tg_pt_gp; |
| 294 | /* Used for default ALUA Target Port Group ConfigFS group */ | 248 | /* Used for default ALUA Target Port Group ConfigFS group */ |
| 295 | struct config_group alua_tg_pt_gps_group; | 249 | struct config_group alua_tg_pt_gps_group; |
| 296 | int (*alua_state_check)(struct se_cmd *, unsigned char *, u8 *); | ||
| 297 | struct list_head tg_pt_gps_list; | 250 | struct list_head tg_pt_gps_list; |
| 298 | }; | 251 | }; |
| 299 | 252 | ||
| @@ -335,7 +288,7 @@ struct t10_alua_tg_pt_gp { | |||
| 335 | atomic_t tg_pt_gp_ref_cnt; | 288 | atomic_t tg_pt_gp_ref_cnt; |
| 336 | spinlock_t tg_pt_gp_lock; | 289 | spinlock_t tg_pt_gp_lock; |
| 337 | struct mutex tg_pt_gp_md_mutex; | 290 | struct mutex tg_pt_gp_md_mutex; |
| 338 | struct se_subsystem_dev *tg_pt_gp_su_dev; | 291 | struct se_device *tg_pt_gp_dev; |
| 339 | struct config_group tg_pt_gp_group; | 292 | struct config_group tg_pt_gp_group; |
| 340 | struct list_head tg_pt_gp_list; | 293 | struct list_head tg_pt_gp_list; |
| 341 | struct list_head tg_pt_gp_mem_list; | 294 | struct list_head tg_pt_gp_mem_list; |
| @@ -366,23 +319,11 @@ struct t10_wwn { | |||
| 366 | char revision[4]; | 319 | char revision[4]; |
| 367 | char unit_serial[INQUIRY_VPD_SERIAL_LEN]; | 320 | char unit_serial[INQUIRY_VPD_SERIAL_LEN]; |
| 368 | spinlock_t t10_vpd_lock; | 321 | spinlock_t t10_vpd_lock; |
| 369 | struct se_subsystem_dev *t10_sub_dev; | 322 | struct se_device *t10_dev; |
| 370 | struct config_group t10_wwn_group; | 323 | struct config_group t10_wwn_group; |
| 371 | struct list_head t10_vpd_list; | 324 | struct list_head t10_vpd_list; |
| 372 | }; | 325 | }; |
| 373 | 326 | ||
| 374 | |||
| 375 | /* | ||
| 376 | * Used by TCM Core internally to signal if >= SPC-3 persistent reservations | ||
| 377 | * emulation is enabled or disabled, or running in with TCM/pSCSI passthrough | ||
| 378 | * mode | ||
| 379 | */ | ||
| 380 | typedef enum { | ||
| 381 | SPC_PASSTHROUGH, | ||
| 382 | SPC2_RESERVATIONS, | ||
| 383 | SPC3_PERSISTENT_RESERVATIONS | ||
| 384 | } t10_reservations_index_t; | ||
| 385 | |||
| 386 | struct t10_pr_registration { | 327 | struct t10_pr_registration { |
| 387 | /* Used for fabrics that contain WWN+ISID */ | 328 | /* Used for fabrics that contain WWN+ISID */ |
| 388 | #define PR_REG_ISID_LEN 16 | 329 | #define PR_REG_ISID_LEN 16 |
| @@ -424,18 +365,6 @@ struct t10_pr_registration { | |||
| 424 | struct list_head pr_reg_atp_mem_list; | 365 | struct list_head pr_reg_atp_mem_list; |
| 425 | }; | 366 | }; |
| 426 | 367 | ||
| 427 | /* | ||
| 428 | * This set of function pointer ops is set based upon SPC3_PERSISTENT_RESERVATIONS, | ||
| 429 | * SPC2_RESERVATIONS or SPC_PASSTHROUGH in drivers/target/target_core_pr.c: | ||
| 430 | * core_setup_reservations() | ||
| 431 | */ | ||
| 432 | struct t10_reservation_ops { | ||
| 433 | int (*t10_reservation_check)(struct se_cmd *, u32 *); | ||
| 434 | int (*t10_seq_non_holder)(struct se_cmd *, unsigned char *, u32); | ||
| 435 | int (*t10_pr_register)(struct se_cmd *); | ||
| 436 | int (*t10_pr_clear)(struct se_cmd *); | ||
| 437 | }; | ||
| 438 | |||
| 439 | struct t10_reservation { | 368 | struct t10_reservation { |
| 440 | /* Reservation effects all target ports */ | 369 | /* Reservation effects all target ports */ |
| 441 | int pr_all_tg_pt; | 370 | int pr_all_tg_pt; |
| @@ -446,7 +375,6 @@ struct t10_reservation { | |||
| 446 | #define PR_APTPL_BUF_LEN 8192 | 375 | #define PR_APTPL_BUF_LEN 8192 |
| 447 | u32 pr_aptpl_buf_len; | 376 | u32 pr_aptpl_buf_len; |
| 448 | u32 pr_generation; | 377 | u32 pr_generation; |
| 449 | t10_reservations_index_t res_type; | ||
| 450 | spinlock_t registration_lock; | 378 | spinlock_t registration_lock; |
| 451 | spinlock_t aptpl_reg_lock; | 379 | spinlock_t aptpl_reg_lock; |
| 452 | /* | 380 | /* |
| @@ -462,7 +390,6 @@ struct t10_reservation { | |||
| 462 | struct se_node_acl *pr_res_holder; | 390 | struct se_node_acl *pr_res_holder; |
| 463 | struct list_head registration_list; | 391 | struct list_head registration_list; |
| 464 | struct list_head aptpl_reg_list; | 392 | struct list_head aptpl_reg_list; |
| 465 | struct t10_reservation_ops pr_ops; | ||
| 466 | }; | 393 | }; |
| 467 | 394 | ||
| 468 | struct se_tmr_req { | 395 | struct se_tmr_req { |
| @@ -485,7 +412,6 @@ struct se_cmd { | |||
| 485 | u8 scsi_status; | 412 | u8 scsi_status; |
| 486 | u8 scsi_asc; | 413 | u8 scsi_asc; |
| 487 | u8 scsi_ascq; | 414 | u8 scsi_ascq; |
| 488 | u8 scsi_sense_reason; | ||
| 489 | u16 scsi_sense_length; | 415 | u16 scsi_sense_length; |
| 490 | /* Delay for ALUA Active/NonOptimized state access in milliseconds */ | 416 | /* Delay for ALUA Active/NonOptimized state access in milliseconds */ |
| 491 | int alua_nonop_delay; | 417 | int alua_nonop_delay; |
| @@ -523,7 +449,7 @@ struct se_cmd { | |||
| 523 | struct completion cmd_wait_comp; | 449 | struct completion cmd_wait_comp; |
| 524 | struct kref cmd_kref; | 450 | struct kref cmd_kref; |
| 525 | struct target_core_fabric_ops *se_tfo; | 451 | struct target_core_fabric_ops *se_tfo; |
| 526 | int (*execute_cmd)(struct se_cmd *); | 452 | sense_reason_t (*execute_cmd)(struct se_cmd *); |
| 527 | void (*transport_complete_callback)(struct se_cmd *); | 453 | void (*transport_complete_callback)(struct se_cmd *); |
| 528 | 454 | ||
| 529 | unsigned char *t_task_cdb; | 455 | unsigned char *t_task_cdb; |
| @@ -581,6 +507,8 @@ struct se_node_acl { | |||
| 581 | bool acl_stop:1; | 507 | bool acl_stop:1; |
| 582 | u32 queue_depth; | 508 | u32 queue_depth; |
| 583 | u32 acl_index; | 509 | u32 acl_index; |
| 510 | #define MAX_ACL_TAG_SIZE 64 | ||
| 511 | char acl_tag[MAX_ACL_TAG_SIZE]; | ||
| 584 | u64 num_cmds; | 512 | u64 num_cmds; |
| 585 | u64 read_bytes; | 513 | u64 read_bytes; |
| 586 | u64 write_bytes; | 514 | u64 write_bytes; |
| @@ -662,15 +590,6 @@ struct se_dev_entry { | |||
| 662 | struct list_head ua_list; | 590 | struct list_head ua_list; |
| 663 | }; | 591 | }; |
| 664 | 592 | ||
| 665 | struct se_dev_limits { | ||
| 666 | /* Max supported HW queue depth */ | ||
| 667 | u32 hw_queue_depth; | ||
| 668 | /* Max supported virtual queue depth */ | ||
| 669 | u32 queue_depth; | ||
| 670 | /* From include/linux/blkdev.h for the other HW/SW limits. */ | ||
| 671 | struct queue_limits limits; | ||
| 672 | }; | ||
| 673 | |||
| 674 | struct se_dev_attrib { | 593 | struct se_dev_attrib { |
| 675 | int emulate_dpo; | 594 | int emulate_dpo; |
| 676 | int emulate_fua_write; | 595 | int emulate_fua_write; |
| @@ -680,8 +599,6 @@ struct se_dev_attrib { | |||
| 680 | int emulate_tas; | 599 | int emulate_tas; |
| 681 | int emulate_tpu; | 600 | int emulate_tpu; |
| 682 | int emulate_tpws; | 601 | int emulate_tpws; |
| 683 | int emulate_reservations; | ||
| 684 | int emulate_alua; | ||
| 685 | int enforce_pr_isids; | 602 | int enforce_pr_isids; |
| 686 | int is_nonrot; | 603 | int is_nonrot; |
| 687 | int emulate_rest_reord; | 604 | int emulate_rest_reord; |
| @@ -696,7 +613,8 @@ struct se_dev_attrib { | |||
| 696 | u32 max_unmap_block_desc_count; | 613 | u32 max_unmap_block_desc_count; |
| 697 | u32 unmap_granularity; | 614 | u32 unmap_granularity; |
| 698 | u32 unmap_granularity_alignment; | 615 | u32 unmap_granularity_alignment; |
| 699 | struct se_subsystem_dev *da_sub_dev; | 616 | u32 max_write_same_len; |
| 617 | struct se_device *da_dev; | ||
| 700 | struct config_group da_group; | 618 | struct config_group da_group; |
| 701 | }; | 619 | }; |
| 702 | 620 | ||
| @@ -707,48 +625,25 @@ struct se_dev_stat_grps { | |||
| 707 | struct config_group scsi_lu_group; | 625 | struct config_group scsi_lu_group; |
| 708 | }; | 626 | }; |
| 709 | 627 | ||
| 710 | struct se_subsystem_dev { | ||
| 711 | /* Used for struct se_subsystem_dev-->se_dev_alias, must be less than PAGE_SIZE */ | ||
| 712 | #define SE_DEV_ALIAS_LEN 512 | ||
| 713 | unsigned char se_dev_alias[SE_DEV_ALIAS_LEN]; | ||
| 714 | /* Used for struct se_subsystem_dev->se_dev_udev_path[], must be less than PAGE_SIZE */ | ||
| 715 | #define SE_UDEV_PATH_LEN 512 | ||
| 716 | unsigned char se_dev_udev_path[SE_UDEV_PATH_LEN]; | ||
| 717 | u32 su_dev_flags; | ||
| 718 | struct se_hba *se_dev_hba; | ||
| 719 | struct se_device *se_dev_ptr; | ||
| 720 | struct se_dev_attrib se_dev_attrib; | ||
| 721 | /* T10 Asymmetric Logical Unit Assignment for Target Ports */ | ||
| 722 | struct t10_alua t10_alua; | ||
| 723 | /* T10 Inquiry and VPD WWN Information */ | ||
| 724 | struct t10_wwn t10_wwn; | ||
| 725 | /* T10 SPC-2 + SPC-3 Reservations */ | ||
| 726 | struct t10_reservation t10_pr; | ||
| 727 | spinlock_t se_dev_lock; | ||
| 728 | void *se_dev_su_ptr; | ||
| 729 | struct config_group se_dev_group; | ||
| 730 | /* For T10 Reservations */ | ||
| 731 | struct config_group se_dev_pr_group; | ||
| 732 | /* For target_core_stat.c groups */ | ||
| 733 | struct se_dev_stat_grps dev_stat_grps; | ||
| 734 | }; | ||
| 735 | |||
| 736 | struct se_device { | 628 | struct se_device { |
| 629 | #define SE_DEV_LINK_MAGIC 0xfeeddeef | ||
| 630 | u32 dev_link_magic; | ||
| 737 | /* RELATIVE TARGET PORT IDENTIFER Counter */ | 631 | /* RELATIVE TARGET PORT IDENTIFER Counter */ |
| 738 | u16 dev_rpti_counter; | 632 | u16 dev_rpti_counter; |
| 739 | /* Used for SAM Task Attribute ordering */ | 633 | /* Used for SAM Task Attribute ordering */ |
| 740 | u32 dev_cur_ordered_id; | 634 | u32 dev_cur_ordered_id; |
| 741 | u32 dev_flags; | 635 | u32 dev_flags; |
| 636 | #define DF_CONFIGURED 0x00000001 | ||
| 637 | #define DF_FIRMWARE_VPD_UNIT_SERIAL 0x00000002 | ||
| 638 | #define DF_EMULATED_VPD_UNIT_SERIAL 0x00000004 | ||
| 639 | #define DF_USING_UDEV_PATH 0x00000008 | ||
| 640 | #define DF_USING_ALIAS 0x00000010 | ||
| 742 | u32 dev_port_count; | 641 | u32 dev_port_count; |
| 743 | /* See transport_device_status_table */ | ||
| 744 | u32 dev_status; | ||
| 745 | /* Physical device queue depth */ | 642 | /* Physical device queue depth */ |
| 746 | u32 queue_depth; | 643 | u32 queue_depth; |
| 747 | /* Used for SPC-2 reservations enforce of ISIDs */ | 644 | /* Used for SPC-2 reservations enforce of ISIDs */ |
| 748 | u64 dev_res_bin_isid; | 645 | u64 dev_res_bin_isid; |
| 749 | t10_task_attr_index_t dev_task_attr_type; | ||
| 750 | /* Pointer to transport specific device structure */ | 646 | /* Pointer to transport specific device structure */ |
| 751 | void *dev_ptr; | ||
| 752 | u32 dev_index; | 647 | u32 dev_index; |
| 753 | u64 creation_time; | 648 | u64 creation_time; |
| 754 | u32 num_resets; | 649 | u32 num_resets; |
| @@ -761,13 +656,13 @@ struct se_device { | |||
| 761 | atomic_t dev_ordered_id; | 656 | atomic_t dev_ordered_id; |
| 762 | atomic_t dev_ordered_sync; | 657 | atomic_t dev_ordered_sync; |
| 763 | atomic_t dev_qf_count; | 658 | atomic_t dev_qf_count; |
| 764 | struct se_obj dev_obj; | 659 | int export_count; |
| 765 | struct se_obj dev_access_obj; | ||
| 766 | struct se_obj dev_export_obj; | ||
| 767 | spinlock_t delayed_cmd_lock; | 660 | spinlock_t delayed_cmd_lock; |
| 768 | spinlock_t execute_task_lock; | 661 | spinlock_t execute_task_lock; |
| 769 | spinlock_t dev_reservation_lock; | 662 | spinlock_t dev_reservation_lock; |
| 770 | spinlock_t dev_status_lock; | 663 | unsigned int dev_reservation_flags; |
| 664 | #define DRF_SPC2_RESERVATIONS 0x00000001 | ||
| 665 | #define DRF_SPC2_RESERVATIONS_WITH_ISID 0x00000002 | ||
| 771 | spinlock_t se_port_lock; | 666 | spinlock_t se_port_lock; |
| 772 | spinlock_t se_tmr_lock; | 667 | spinlock_t se_tmr_lock; |
| 773 | spinlock_t qf_cmd_lock; | 668 | spinlock_t qf_cmd_lock; |
| @@ -786,7 +681,20 @@ struct se_device { | |||
| 786 | struct list_head qf_cmd_list; | 681 | struct list_head qf_cmd_list; |
| 787 | /* Pointer to associated SE HBA */ | 682 | /* Pointer to associated SE HBA */ |
| 788 | struct se_hba *se_hba; | 683 | struct se_hba *se_hba; |
| 789 | struct se_subsystem_dev *se_sub_dev; | 684 | /* T10 Inquiry and VPD WWN Information */ |
| 685 | struct t10_wwn t10_wwn; | ||
| 686 | /* T10 Asymmetric Logical Unit Assignment for Target Ports */ | ||
| 687 | struct t10_alua t10_alua; | ||
| 688 | /* T10 SPC-2 + SPC-3 Reservations */ | ||
| 689 | struct t10_reservation t10_pr; | ||
| 690 | struct se_dev_attrib dev_attrib; | ||
| 691 | struct config_group dev_group; | ||
| 692 | struct config_group dev_pr_group; | ||
| 693 | struct se_dev_stat_grps dev_stat_grps; | ||
| 694 | #define SE_DEV_ALIAS_LEN 512 /* must be less than PAGE_SIZE */ | ||
| 695 | unsigned char dev_alias[SE_DEV_ALIAS_LEN]; | ||
| 696 | #define SE_UDEV_PATH_LEN 512 /* must be less than PAGE_SIZE */ | ||
| 697 | unsigned char udev_path[SE_UDEV_PATH_LEN]; | ||
| 790 | /* Pointer to template of function pointers for transport */ | 698 | /* Pointer to template of function pointers for transport */ |
| 791 | struct se_subsystem_api *transport; | 699 | struct se_subsystem_api *transport; |
| 792 | /* Linked list for struct se_hba struct se_device list */ | 700 | /* Linked list for struct se_hba struct se_device list */ |
| @@ -803,8 +711,6 @@ struct se_hba { | |||
| 803 | u32 hba_index; | 711 | u32 hba_index; |
| 804 | /* Pointer to transport specific host structure. */ | 712 | /* Pointer to transport specific host structure. */ |
| 805 | void *hba_ptr; | 713 | void *hba_ptr; |
| 806 | /* Linked list for struct se_device */ | ||
| 807 | struct list_head hba_dev_list; | ||
| 808 | struct list_head hba_node; | 714 | struct list_head hba_node; |
| 809 | spinlock_t device_lock; | 715 | spinlock_t device_lock; |
| 810 | struct config_group hba_group; | 716 | struct config_group hba_group; |
| @@ -820,6 +726,8 @@ struct se_port_stat_grps { | |||
| 820 | }; | 726 | }; |
| 821 | 727 | ||
| 822 | struct se_lun { | 728 | struct se_lun { |
| 729 | #define SE_LUN_LINK_MAGIC 0xffff7771 | ||
| 730 | u32 lun_link_magic; | ||
| 823 | /* See transport_lun_status_table */ | 731 | /* See transport_lun_status_table */ |
| 824 | enum transport_lun_status_table lun_status; | 732 | enum transport_lun_status_table lun_status; |
| 825 | u32 lun_access; | 733 | u32 lun_access; |
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 81ddb4ae6c3f..aaa1ee6ab391 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h | |||
| @@ -98,8 +98,8 @@ void transport_deregister_session(struct se_session *); | |||
| 98 | 98 | ||
| 99 | void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *, | 99 | void transport_init_se_cmd(struct se_cmd *, struct target_core_fabric_ops *, |
| 100 | struct se_session *, u32, int, int, unsigned char *); | 100 | struct se_session *, u32, int, int, unsigned char *); |
| 101 | int transport_lookup_cmd_lun(struct se_cmd *, u32); | 101 | sense_reason_t transport_lookup_cmd_lun(struct se_cmd *, u32); |
| 102 | int target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *); | 102 | sense_reason_t target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *); |
| 103 | int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *, | 103 | int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *, |
| 104 | unsigned char *, unsigned char *, u32, u32, int, int, int, | 104 | unsigned char *, unsigned char *, u32, u32, int, int, int, |
| 105 | struct scatterlist *, u32, struct scatterlist *, u32); | 105 | struct scatterlist *, u32, struct scatterlist *, u32); |
| @@ -110,9 +110,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, | |||
| 110 | void *fabric_tmr_ptr, unsigned char tm_type, | 110 | void *fabric_tmr_ptr, unsigned char tm_type, |
| 111 | gfp_t, unsigned int, int); | 111 | gfp_t, unsigned int, int); |
| 112 | int transport_handle_cdb_direct(struct se_cmd *); | 112 | int transport_handle_cdb_direct(struct se_cmd *); |
| 113 | int transport_generic_map_mem_to_cmd(struct se_cmd *cmd, | 113 | sense_reason_t transport_generic_new_cmd(struct se_cmd *); |
| 114 | struct scatterlist *, u32, struct scatterlist *, u32); | ||
| 115 | int transport_generic_new_cmd(struct se_cmd *); | ||
| 116 | 114 | ||
| 117 | void target_execute_cmd(struct se_cmd *cmd); | 115 | void target_execute_cmd(struct se_cmd *cmd); |
| 118 | 116 | ||
| @@ -120,7 +118,8 @@ void transport_generic_free_cmd(struct se_cmd *, int); | |||
| 120 | 118 | ||
| 121 | bool transport_wait_for_tasks(struct se_cmd *); | 119 | bool transport_wait_for_tasks(struct se_cmd *); |
| 122 | int transport_check_aborted_status(struct se_cmd *, int); | 120 | int transport_check_aborted_status(struct se_cmd *, int); |
| 123 | int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); | 121 | int transport_send_check_condition_and_sense(struct se_cmd *, |
| 122 | sense_reason_t, int); | ||
| 124 | 123 | ||
| 125 | int target_put_sess_cmd(struct se_session *, struct se_cmd *); | 124 | int target_put_sess_cmd(struct se_session *, struct se_cmd *); |
| 126 | void target_sess_cmd_list_set_waiting(struct se_session *); | 125 | void target_sess_cmd_list_set_waiting(struct se_session *); |
| @@ -131,7 +130,7 @@ int core_alua_check_nonop_delay(struct se_cmd *); | |||
| 131 | int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); | 130 | int core_tmr_alloc_req(struct se_cmd *, void *, u8, gfp_t); |
| 132 | void core_tmr_release_req(struct se_tmr_req *); | 131 | void core_tmr_release_req(struct se_tmr_req *); |
| 133 | int transport_generic_handle_tmr(struct se_cmd *); | 132 | int transport_generic_handle_tmr(struct se_cmd *); |
| 134 | void transport_generic_request_failure(struct se_cmd *); | 133 | void transport_generic_request_failure(struct se_cmd *, sense_reason_t); |
| 135 | int transport_lookup_tmr_lun(struct se_cmd *, u32); | 134 | int transport_lookup_tmr_lun(struct se_cmd *, u32); |
| 136 | 135 | ||
| 137 | struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *, | 136 | struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *, |
| @@ -143,6 +142,8 @@ int core_tpg_del_initiator_node_acl(struct se_portal_group *, | |||
| 143 | struct se_node_acl *, int); | 142 | struct se_node_acl *, int); |
| 144 | int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *, | 143 | int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *, |
| 145 | unsigned char *, u32, int); | 144 | unsigned char *, u32, int); |
| 145 | int core_tpg_set_initiator_node_tag(struct se_portal_group *, | ||
| 146 | struct se_node_acl *, const char *); | ||
| 146 | int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *, | 147 | int core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *, |
| 147 | struct se_portal_group *, void *, int); | 148 | struct se_portal_group *, void *, int); |
| 148 | int core_tpg_deregister(struct se_portal_group *); | 149 | int core_tpg_deregister(struct se_portal_group *); |
