target/rd: Convert to external rd_mcp_backend_dev_attrs

This patch converts RAMDISK to use an external set of device attributes,
and utilizes target_core_backend_configfs.h macros to generate a default
set of configfs extended-attr handlers.

It calls target_core_setup_sub_cits() to setup the initial config_item_type
based on existing target_core_configfs.c defaults, and using configfs_attribute
generated by DEF_TB_DEFAULT_ATTRIBS(rc_mcp) populates rd_mcp_backend_dev_attrs[]

It introduces no functional change for existing RD_MCP device attributes.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
Nicholas Bellinger 2014-11-28 05:06:10 +00:00
parent b23204970a
commit 03a627457e

View File

@ -34,6 +34,7 @@
#include <target/target_core_base.h>
#include <target/target_core_backend.h>
#include <target/target_core_backend_configfs.h>
#include "target_core_rd.h"
@ -632,6 +633,42 @@ rd_parse_cdb(struct se_cmd *cmd)
return sbc_parse_cdb(cmd, &rd_sbc_ops);
}
DEF_TB_DEFAULT_ATTRIBS(rd_mcp);
static struct configfs_attribute *rd_mcp_backend_dev_attrs[] = {
&rd_mcp_dev_attrib_emulate_model_alias.attr,
&rd_mcp_dev_attrib_emulate_dpo.attr,
&rd_mcp_dev_attrib_emulate_fua_write.attr,
&rd_mcp_dev_attrib_emulate_fua_read.attr,
&rd_mcp_dev_attrib_emulate_write_cache.attr,
&rd_mcp_dev_attrib_emulate_ua_intlck_ctrl.attr,
&rd_mcp_dev_attrib_emulate_tas.attr,
&rd_mcp_dev_attrib_emulate_tpu.attr,
&rd_mcp_dev_attrib_emulate_tpws.attr,
&rd_mcp_dev_attrib_emulate_caw.attr,
&rd_mcp_dev_attrib_emulate_3pc.attr,
&rd_mcp_dev_attrib_pi_prot_type.attr,
&rd_mcp_dev_attrib_hw_pi_prot_type.attr,
&rd_mcp_dev_attrib_pi_prot_format.attr,
&rd_mcp_dev_attrib_enforce_pr_isids.attr,
&rd_mcp_dev_attrib_is_nonrot.attr,
&rd_mcp_dev_attrib_emulate_rest_reord.attr,
&rd_mcp_dev_attrib_force_pr_aptpl.attr,
&rd_mcp_dev_attrib_hw_block_size.attr,
&rd_mcp_dev_attrib_block_size.attr,
&rd_mcp_dev_attrib_hw_max_sectors.attr,
&rd_mcp_dev_attrib_fabric_max_sectors.attr,
&rd_mcp_dev_attrib_optimal_sectors.attr,
&rd_mcp_dev_attrib_hw_queue_depth.attr,
&rd_mcp_dev_attrib_queue_depth.attr,
&rd_mcp_dev_attrib_max_unmap_lba_count.attr,
&rd_mcp_dev_attrib_max_unmap_block_desc_count.attr,
&rd_mcp_dev_attrib_unmap_granularity.attr,
&rd_mcp_dev_attrib_unmap_granularity_alignment.attr,
&rd_mcp_dev_attrib_max_write_same_len.attr,
NULL,
};
static struct se_subsystem_api rd_mcp_template = {
.name = "rd_mcp",
.inquiry_prod = "RAMDISK-MCP",
@ -653,8 +690,12 @@ static struct se_subsystem_api rd_mcp_template = {
int __init rd_module_init(void)
{
struct target_backend_cits *tbc = &rd_mcp_template.tb_cits;
int ret;
target_core_setup_sub_cits(&rd_mcp_template);
tbc->tb_dev_attrib_cit.ct_attrs = rd_mcp_backend_dev_attrs;
ret = transport_subsystem_register(&rd_mcp_template);
if (ret < 0) {
return ret;