tcm: Add struct se_dev_limits for subsystem ->create_virtdevice()
Subsystems (2)
PATCH 1/1 tcm: Add struct se_dev_limits for subsystem ->create_virtdevice()
From: Nicholas Bellinger <[email protected]>
This patch adds support for passing a new struct se_dev_limits containing a struct queue_limits into the transport_add_device_to_core_hba() from IBLOCK, FILEIO, PSCSI, RAMDISK and STGT subsystem plugins used to register
TCM storage backstores. The struct se_dev_limits currently contains:
struct se_dev_limits {
/* Max supported SCSI CDB length */
int max_cdb_len;
/* Max supported HW queue depth */
u32 hw_queue_depth;
/* Max supported virtual queue depth */
u32 queue_depth;
/* From include/linux/blkdev.h for the other HW/SW limits. */
struct queue_limits limits;
} ____cacheline_aligned;Once this structure has been populated by the subsystem ->create_virtdevice() call for either A) a real struct block_device and struct request_queue->limits (iblock, pscsi, fileio w/ BD), B) or the virtual defaults limits (fileio w/o BD, rd_dr, rd_mcp) imposed by the subsystem backstore and then passed into transport_add_device_to_core_hba() in TCM Core code.
Quoted 1 line
From inside
transport_add_device_to_core_hba(),se_dev_set_default_attribs()
is passed the new struct se_dev_limits and the v4.0 struct se_dev_attrib values are populated directly from struct se_dev_limits and dev_limits->limits. Using this method allows us to drop these five legacy APIs callers that have been removed all together from target_core_transport.h:struct se_subsystem_api and TCM code:
->get_max_cdb_len() ->get_blocksize() ->get_max_sectors() ->get_queue_depth() ->get_max_queue_depth()
A huge thanks again to hch for his feedback on moving in this direction, and allowing us to drop yet another ~200 LOC and the legacy struct se_subsystem_api callers!!
--- drivers/target/target_core_configfs.c | 4 ++ drivers/target/target_core_device.c | 72 ++++++++++++++------------------ drivers/target/target_core_file.c | 72 +++++++++++--------------------- drivers/target/target_core_iblock.c | 53 +++++++---------------- drivers/target/target_core_pscsi.c | 66 ++++++++--------------------- drivers/target/target_core_rd.c | 58 +++++--------------------- drivers/target/target_core_stgt.c | 45 -------------------- drivers/target/target_core_transport.c | 64 ++++++---------------------- include/target/target_core_base.h | 12 +++++ include/target/target_core_device.h | 2 +- include/target/target_core_transport.h | 25 +---------- 11 files changed, 134 insertions(+), 339 deletions(-)
drivers/target/target_core_configfs.c +4 -0
@@ -751,6 +751,9 @@ SE_DEV_ATTR(emulate_tpws, S_IRUGO | S_IWUSR);DEF_DEV_ATTRIB (enforce_pr_isids);SE_DEV_ATTR (enforce_pr_isids,S_IRUGO |S_IWUSR ); +DEF_DEV_ATTRIB_RO (max_cdb_len); +SE_DEV_ATTR_RO (max_cdb_len); +DEF_DEV_ATTRIB_RO (hw_block_size);SE_DEV_ATTR_RO (hw_block_size);
@@ -799,6 +802,7 @@ static struct configfs_attribute *target_core_dev_attrib_attrs[] = { &target_core_dev_attrib_emulate_tpu.attr, &target_core_dev_attrib_emulate_tpws.attr, &target_core_dev_attrib_enforce_pr_isids.attr, + &target_core_dev_attrib_max_cdb_len.attr, &target_core_dev_attrib_hw_block_size.attr, &target_core_dev_attrib_block_size.attr, &target_core_dev_attrib_hw_max_sectors.attr,
drivers/target/target_core_device.c +31 -41
146 lines not on this page · raw message
drivers/target/target_core_file.c +24 -48
132 lines not on this page · raw message
drivers/target/target_core_iblock.c +17 -36
106 lines not on this page · raw message
drivers/target/target_core_pscsi.c +19 -47
113 lines not on this page · raw message
drivers/target/target_core_rd.c +11 -47
115 lines not on this page · raw message
drivers/target/target_core_stgt.c +0 -45
73 lines not on this page · raw message
drivers/target/target_core_transport.c +13 -51
117 lines not on this page · raw message
include/target/target_core_base.h +12 -0
@@ -744,6 +744,17 @@ struct se_dev_entry {struct list_head ua_list; }____cacheline_aligned ; +struct se_dev_limits { +/* Max supported SCSI CDB length */ +int max_cdb_len; +/* Max supported HW queue depth */ +u32 hw_queue_depth; +/* Max supported virtual queue depth */ +u32 queue_depth; +/* From include/linux/blkdev.h for the other HW/SW limits. */ +struct queue_limits limits; +}____cacheline_aligned ; +struct se_dev_attrib {int emulate_dpo;int emulate_fua_write;
@@ -756,6 +767,7 @@ struct se_dev_attrib {int emulate_reservations;int emulate_alua;int enforce_pr_isids; +int max_cdb_len;u32 hw_block_size;u32 block_size;u32 hw_max_sectors;
include/target/target_core_device.h +1 -1
@@ -36,7 +36,7 @@ extern void se_dev_start(struct se_device *);extern void se_dev_stop (struct se_device *);extern int se_dev_check_online (struct se_device *);extern int se_dev_check_shutdown (struct se_device *); -extern void se_dev_set_default_attribs (struct se_device *); +extern void se_dev_set_default_attribs (struct se_device *,struct se_dev_limits *);extern int se_dev_set_task_timeout (struct se_device *,u32 );extern int se_dev_set_max_unmap_lba_count (struct se_device *,u32 );extern int se_dev_set_max_unmap_block_desc_count (struct se_device *,u32 );
include/target/target_core_transport.h +2 -23
@@ -192,7 +192,8 @@ extern int transport_rescan_evpd_device_ident(struct se_device *);extern struct se_device *transport_add_device_to_core_hba (struct se_hba *,struct se_subsystem_api *,struct se_subsystem_dev *,u32 , -void *,const char *,const char *); +void *,struct se_dev_limits *, +const char *,const char *);extern int transport_generic_activate_device (struct se_device *);extern void transport_generic_deactivate_device (struct se_device *);extern void transport_generic_free_device (struct se_device *);
@@ -521,15 +522,6 @@ struct se_subsystem_api {*/ unsigned char *(*get_cdb)(struct se_task *);/* -* get_max_cdb_len(): Used by subsystems backstoers to signal the -* maximum receivable SCSI CDB size. -*/ -u32 (*get_max_cdb_len)(struct se_device *); -/* -* get_blocksize(): -*/ -u32 (*get_blocksize)(struct se_device *); -/* * get_device_rev(): */ u32 (*get_device_rev)(struct se_device *);
@@ -546,23 +538,10 @@ struct se_subsystem_api {*/ u32 (*get_max_cdbs)(struct se_device *);/* -* get_max_sectors(): -*/ -u32 (*get_max_sectors)(struct se_device *); -/* * Get the sector_t from a subsystem backstore.. */ sector_t (*get_blocks)(struct se_device *);/* -* get_queue_depth(): -* -*/ -u32 (*get_queue_depth)(struct se_device *); -/* -* get_max_queue_depth(): -*/ -u32 (*get_max_queue_depth)(struct se_device *); -/* * do_se_mem_map(): */ int (*do_se_mem_map)(struct se_task *, struct list_head *, void *,
Signature · 1 line
1.5.6.5