target/pscsi: Convert to external pscsi_backend_dev_attrs
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 28 Nov 2014 05:26:18 +0000 (05:26 +0000)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 2 Dec 2014 05:36:03 +0000 (21:36 -0800)
This patch converts PSCSI 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
for hw_pi_prot_type, hw_block_size, hw_max_sectors, hw_queue_depth populates
pscsi_backend_dev_attrs[]

Only these four hw_* read-only device attributes are exports for PSCSI.

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

index 7c8291f..74873e4 100644 (file)
@@ -44,6 +44,7 @@
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
+#include <target/target_core_backend_configfs.h>
 
 #include "target_core_alua.h"
 #include "target_core_pscsi.h"
@@ -1165,6 +1166,26 @@ static void pscsi_req_done(struct request *req, int uptodate)
        kfree(pt);
 }
 
+DEF_TB_DEV_ATTRIB_RO(pscsi, hw_pi_prot_type);
+TB_DEV_ATTR_RO(pscsi, hw_pi_prot_type);
+
+DEF_TB_DEV_ATTRIB_RO(pscsi, hw_block_size);
+TB_DEV_ATTR_RO(pscsi, hw_block_size);
+
+DEF_TB_DEV_ATTRIB_RO(pscsi, hw_max_sectors);
+TB_DEV_ATTR_RO(pscsi, hw_max_sectors);
+
+DEF_TB_DEV_ATTRIB_RO(pscsi, hw_queue_depth);
+TB_DEV_ATTR_RO(pscsi, hw_queue_depth);
+
+static struct configfs_attribute *pscsi_backend_dev_attrs[] = {
+       &pscsi_dev_attrib_hw_pi_prot_type.attr,
+       &pscsi_dev_attrib_hw_block_size.attr,
+       &pscsi_dev_attrib_hw_max_sectors.attr,
+       &pscsi_dev_attrib_hw_queue_depth.attr,
+       NULL,
+};
+
 static struct se_subsystem_api pscsi_template = {
        .name                   = "pscsi",
        .owner                  = THIS_MODULE,
@@ -1185,6 +1206,11 @@ static struct se_subsystem_api pscsi_template = {
 
 static int __init pscsi_module_init(void)
 {
+       struct target_backend_cits *tbc = &pscsi_template.tb_cits;
+
+       target_core_setup_sub_cits(&pscsi_template);
+       tbc->tb_dev_attrib_cit.ct_attrs = pscsi_backend_dev_attrs;
+
        return transport_subsystem_register(&pscsi_template);
 }