target/iblock: Convert to external iblock_backend_dev_attrs
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 28 Nov 2014 03:53:28 +0000 (19:53 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 2 Dec 2014 05:36:02 +0000 (21:36 -0800)
This patch converts IBLOCK 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(iblock) populates iblock_backend_dev_attrs[]

It introduces no functional change for existing IBLOCK device attributes.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_iblock.c

index 5e69d36af1057efd2ddfa665736e5ec3c99143c5..3efff94fbd9788838f565218965d180b78a67604 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
+#include <target/target_core_backend_configfs.h>
 
 #include "target_core_iblock.h"
 
@@ -858,6 +859,41 @@ static bool iblock_get_write_cache(struct se_device *dev)
        return q->flush_flags & REQ_FLUSH;
 }
 
+DEF_TB_DEFAULT_ATTRIBS(iblock);
+
+static struct configfs_attribute *iblock_backend_dev_attrs[] = {
+       &iblock_dev_attrib_emulate_model_alias.attr,
+       &iblock_dev_attrib_emulate_dpo.attr,
+       &iblock_dev_attrib_emulate_fua_write.attr,
+       &iblock_dev_attrib_emulate_fua_read.attr,
+       &iblock_dev_attrib_emulate_write_cache.attr,
+       &iblock_dev_attrib_emulate_ua_intlck_ctrl.attr,
+       &iblock_dev_attrib_emulate_tas.attr,
+       &iblock_dev_attrib_emulate_tpu.attr,
+       &iblock_dev_attrib_emulate_tpws.attr,
+       &iblock_dev_attrib_emulate_caw.attr,
+       &iblock_dev_attrib_emulate_3pc.attr,
+       &iblock_dev_attrib_pi_prot_type.attr,
+       &iblock_dev_attrib_hw_pi_prot_type.attr,
+       &iblock_dev_attrib_pi_prot_format.attr,
+       &iblock_dev_attrib_enforce_pr_isids.attr,
+       &iblock_dev_attrib_is_nonrot.attr,
+       &iblock_dev_attrib_emulate_rest_reord.attr,
+       &iblock_dev_attrib_force_pr_aptpl.attr,
+       &iblock_dev_attrib_hw_block_size.attr,
+       &iblock_dev_attrib_block_size.attr,
+       &iblock_dev_attrib_hw_max_sectors.attr,
+       &iblock_dev_attrib_fabric_max_sectors.attr,
+       &iblock_dev_attrib_optimal_sectors.attr,
+       &iblock_dev_attrib_hw_queue_depth.attr,
+       &iblock_dev_attrib_queue_depth.attr,
+       &iblock_dev_attrib_max_unmap_lba_count.attr,
+       &iblock_dev_attrib_max_unmap_block_desc_count.attr,
+       &iblock_dev_attrib_unmap_granularity.attr,
+       &iblock_dev_attrib_unmap_granularity_alignment.attr,
+       &iblock_dev_attrib_max_write_same_len.attr,
+       NULL,
+};
 
 static struct se_subsystem_api iblock_template = {
        .name                   = "iblock",
@@ -884,6 +920,11 @@ static struct se_subsystem_api iblock_template = {
 
 static int __init iblock_module_init(void)
 {
+       struct target_backend_cits *tbc = &iblock_template.tb_cits;
+
+       target_core_setup_sub_cits(&iblock_template);
+       tbc->tb_dev_attrib_cit.ct_attrs = iblock_backend_dev_attrs;
+
        return transport_subsystem_register(&iblock_template);
 }