aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_configfs.c
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2011-03-14 07:06:11 -0400
committerJames Bottomley <James.Bottomley@suse.de>2011-03-23 12:36:50 -0400
commit12d233842987d9972957419e427987b94f7bd7b4 (patch)
treeb3d08872b37f08aac3a9ec66e3fef49fbedb0f19 /drivers/target/target_core_configfs.c
parent15fb48cc40be170423fe8ddd17666aa6175315e3 (diff)
[SCSI] target: add initial statistics
This patch adds a target_core_mib.c statistics conversion for backend context struct se_subsystem_dev + struct se_device config_group based statistics in target_core_device.c using CONFIGFS_EATTR() based struct config_item_types from target_core_stat.c code. The conversion from backend /proc/scsi_target/mib/ context output to configfs default groups+attributes include scsi_dev, scsi_lu, and scsi_tgt_dev output from within individual: /sys/kernel/config/target/core/$HBA/DEV/ The legacy procfs output now appear as individual configfs attributes under: *) $HBA/$DEV/statistics/scsi_dev: |-- indx |-- inst |-- ports `-- role *) $HBA/$DEV/statistics/scsi_lu: |-- creation_time |-- dev |-- dev_type |-- full_stat |-- hs_num_cmds |-- indx |-- inst |-- lu_name |-- lun |-- num_cmds |-- prod |-- read_mbytes |-- resets |-- rev |-- state_bit |-- status |-- vend `-- write_mbytes *) $HBA/$DEV/statistics/scsi_tgt_dev: |-- indx |-- inst |-- non_access_lus |-- num_lus |-- resets `-- status The conversion from backend /proc/scsi_target/mib/ context output to configfs default groups+attributes include scsi_port, scsi_tgt_port and scsi_transport output from within individual: /sys/kernel/config/target/fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/ The legacy procfs output now appear as individual configfs attributes under: *) fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/scsi_port |-- busy_count |-- dev |-- indx |-- inst `-- role *) fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/scsi_tgt_port |-- dev |-- hs_in_cmds |-- in_cmds |-- indx |-- inst |-- name |-- port_index |-- read_mbytes `-- write_mbytes *) fabric/$WWN/tpgt_$TPGT/lun/lun_$LUN_ID/statistics/scsi_transport |-- dev_name |-- device |-- indx `-- inst The conversion from backend /proc/scsi_target/mib/ context output to configfs default groups+attributes include scsi_att_intr_port and scsi_auth_intr output from within individual: /sys/kernel/config/target/fabric/$WWN/tpgt_$TPGT/acls/$INITIATOR_WWN/lun_$LUN_ID/statistics/ The legacy procfs output now appear as individual configfs attributes under: *) acls/$INITIATOR_WWN/lun_$LUN_ID/statistics/scsi_att_intr_port |-- dev |-- indx |-- inst |-- port |-- port_auth_indx `-- port_ident *) acls/$INITIATOR_WWN/lun_$LUN_ID/statistics/scsi_auth_intr |-- att_count |-- creation_time |-- dev |-- dev_or_port |-- hs_num_cmds |-- indx |-- inst |-- intr_name |-- map_indx |-- num_cmds |-- port |-- read_mbytes |-- row_status `-- write_mbytes Also, this includes adding struct target_fabric_configfs_template-> tfc_wwn_fabric_stats_cit and ->tfc_tpg_nacl_stat_cit respectively for use during target_core_fabric_configfs.c:target_fabric_setup_cits() Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/target/target_core_configfs.c')
-rw-r--r--drivers/target/target_core_configfs.c76
1 files changed, 66 insertions, 10 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index a38fec4acceb..a5f44a6e6e1d 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * This file contains ConfigFS logic for the Generic Target Engine project. 4 * This file contains ConfigFS logic for the Generic Target Engine project.
5 * 5 *
6 * Copyright (c) 2008-2010 Rising Tide Systems 6 * Copyright (c) 2008-2011 Rising Tide Systems
7 * Copyright (c) 2008-2010 Linux-iSCSI.org 7 * Copyright (c) 2008-2011 Linux-iSCSI.org
8 * 8 *
9 * Nicholas A. Bellinger <nab@kernel.org> 9 * Nicholas A. Bellinger <nab@kernel.org>
10 * 10 *
@@ -50,6 +50,7 @@
50#include "target_core_hba.h" 50#include "target_core_hba.h"
51#include "target_core_pr.h" 51#include "target_core_pr.h"
52#include "target_core_rd.h" 52#include "target_core_rd.h"
53#include "target_core_stat.h"
53 54
54static struct list_head g_tf_list; 55static struct list_head g_tf_list;
55static struct mutex g_tf_lock; 56static struct mutex g_tf_lock;
@@ -2709,6 +2710,34 @@ static struct config_item_type target_core_alua_cit = {
2709 2710
2710/* End functions for struct config_item_type target_core_alua_cit */ 2711/* End functions for struct config_item_type target_core_alua_cit */
2711 2712
2713/* Start functions for struct config_item_type target_core_stat_cit */
2714
2715static struct config_group *target_core_stat_mkdir(
2716 struct config_group *group,
2717 const char *name)
2718{
2719 return ERR_PTR(-ENOSYS);
2720}
2721
2722static void target_core_stat_rmdir(
2723 struct config_group *group,
2724 struct config_item *item)
2725{
2726 return;
2727}
2728
2729static struct configfs_group_operations target_core_stat_group_ops = {
2730 .make_group = &target_core_stat_mkdir,
2731 .drop_item = &target_core_stat_rmdir,
2732};
2733
2734static struct config_item_type target_core_stat_cit = {
2735 .ct_group_ops = &target_core_stat_group_ops,
2736 .ct_owner = THIS_MODULE,
2737};
2738
2739/* End functions for struct config_item_type target_core_stat_cit */
2740
2712/* Start functions for struct config_item_type target_core_hba_cit */ 2741/* Start functions for struct config_item_type target_core_hba_cit */
2713 2742
2714static struct config_group *target_core_make_subdev( 2743static struct config_group *target_core_make_subdev(
@@ -2721,10 +2750,12 @@ static struct config_group *target_core_make_subdev(
2721 struct config_item *hba_ci = &group->cg_item; 2750 struct config_item *hba_ci = &group->cg_item;
2722 struct se_hba *hba = item_to_hba(hba_ci); 2751 struct se_hba *hba = item_to_hba(hba_ci);
2723 struct config_group *dev_cg = NULL, *tg_pt_gp_cg = NULL; 2752 struct config_group *dev_cg = NULL, *tg_pt_gp_cg = NULL;
2753 struct config_group *dev_stat_grp = NULL;
2754 int errno = -ENOMEM, ret;
2724 2755
2725 if (mutex_lock_interruptible(&hba->hba_access_mutex)) 2756 ret = mutex_lock_interruptible(&hba->hba_access_mutex);
2726 return NULL; 2757 if (ret)
2727 2758 return ERR_PTR(ret);
2728 /* 2759 /*
2729 * Locate the struct se_subsystem_api from parent's struct se_hba. 2760 * Locate the struct se_subsystem_api from parent's struct se_hba.
2730 */ 2761 */
@@ -2754,7 +2785,7 @@ static struct config_group *target_core_make_subdev(
2754 se_dev->se_dev_hba = hba; 2785 se_dev->se_dev_hba = hba;
2755 dev_cg = &se_dev->se_dev_group; 2786 dev_cg = &se_dev->se_dev_group;
2756 2787
2757 dev_cg->default_groups = kzalloc(sizeof(struct config_group) * 6, 2788 dev_cg->default_groups = kzalloc(sizeof(struct config_group) * 7,
2758 GFP_KERNEL); 2789 GFP_KERNEL);
2759 if (!(dev_cg->default_groups)) 2790 if (!(dev_cg->default_groups))
2760 goto out; 2791 goto out;
@@ -2786,13 +2817,17 @@ static struct config_group *target_core_make_subdev(
2786 &target_core_dev_wwn_cit); 2817 &target_core_dev_wwn_cit);
2787 config_group_init_type_name(&se_dev->t10_alua.alua_tg_pt_gps_group, 2818 config_group_init_type_name(&se_dev->t10_alua.alua_tg_pt_gps_group,
2788 "alua", &target_core_alua_tg_pt_gps_cit); 2819 "alua", &target_core_alua_tg_pt_gps_cit);
2820 config_group_init_type_name(&se_dev->dev_stat_grps.stat_group,
2821 "statistics", &target_core_stat_cit);
2822
2789 dev_cg->default_groups[0] = &se_dev->se_dev_attrib.da_group; 2823 dev_cg->default_groups[0] = &se_dev->se_dev_attrib.da_group;
2790 dev_cg->default_groups[1] = &se_dev->se_dev_pr_group; 2824 dev_cg->default_groups[1] = &se_dev->se_dev_pr_group;
2791 dev_cg->default_groups[2] = &se_dev->t10_wwn.t10_wwn_group; 2825 dev_cg->default_groups[2] = &se_dev->t10_wwn.t10_wwn_group;
2792 dev_cg->default_groups[3] = &se_dev->t10_alua.alua_tg_pt_gps_group; 2826 dev_cg->default_groups[3] = &se_dev->t10_alua.alua_tg_pt_gps_group;
2793 dev_cg->default_groups[4] = NULL; 2827 dev_cg->default_groups[4] = &se_dev->dev_stat_grps.stat_group;
2828 dev_cg->default_groups[5] = NULL;
2794 /* 2829 /*
2795 * Add core/$HBA/$DEV/alua/tg_pt_gps/default_tg_pt_gp 2830 * Add core/$HBA/$DEV/alua/default_tg_pt_gp
2796 */ 2831 */
2797 tg_pt_gp = core_alua_allocate_tg_pt_gp(se_dev, "default_tg_pt_gp", 1); 2832 tg_pt_gp = core_alua_allocate_tg_pt_gp(se_dev, "default_tg_pt_gp", 1);
2798 if (!(tg_pt_gp)) 2833 if (!(tg_pt_gp))
@@ -2812,6 +2847,17 @@ static struct config_group *target_core_make_subdev(
2812 tg_pt_gp_cg->default_groups[0] = &tg_pt_gp->tg_pt_gp_group; 2847 tg_pt_gp_cg->default_groups[0] = &tg_pt_gp->tg_pt_gp_group;
2813 tg_pt_gp_cg->default_groups[1] = NULL; 2848 tg_pt_gp_cg->default_groups[1] = NULL;
2814 T10_ALUA(se_dev)->default_tg_pt_gp = tg_pt_gp; 2849 T10_ALUA(se_dev)->default_tg_pt_gp = tg_pt_gp;
2850 /*
2851 * Add core/$HBA/$DEV/statistics/ default groups
2852 */
2853 dev_stat_grp = &DEV_STAT_GRP(se_dev)->stat_group;
2854 dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 4,
2855 GFP_KERNEL);
2856 if (!dev_stat_grp->default_groups) {
2857 printk(KERN_ERR "Unable to allocate dev_stat_grp->default_groups\n");
2858 goto out;
2859 }
2860 target_stat_setup_dev_default_groups(se_dev);
2815 2861
2816 printk(KERN_INFO "Target_Core_ConfigFS: Allocated struct se_subsystem_dev:" 2862 printk(KERN_INFO "Target_Core_ConfigFS: Allocated struct se_subsystem_dev:"
2817 " %p se_dev_su_ptr: %p\n", se_dev, se_dev->se_dev_su_ptr); 2863 " %p se_dev_su_ptr: %p\n", se_dev, se_dev->se_dev_su_ptr);
@@ -2823,6 +2869,8 @@ out:
2823 core_alua_free_tg_pt_gp(T10_ALUA(se_dev)->default_tg_pt_gp); 2869 core_alua_free_tg_pt_gp(T10_ALUA(se_dev)->default_tg_pt_gp);
2824 T10_ALUA(se_dev)->default_tg_pt_gp = NULL; 2870 T10_ALUA(se_dev)->default_tg_pt_gp = NULL;
2825 } 2871 }
2872 if (dev_stat_grp)
2873 kfree(dev_stat_grp->default_groups);
2826 if (tg_pt_gp_cg) 2874 if (tg_pt_gp_cg)
2827 kfree(tg_pt_gp_cg->default_groups); 2875 kfree(tg_pt_gp_cg->default_groups);
2828 if (dev_cg) 2876 if (dev_cg)
@@ -2832,7 +2880,7 @@ out:
2832 kfree(se_dev); 2880 kfree(se_dev);
2833unlock: 2881unlock:
2834 mutex_unlock(&hba->hba_access_mutex); 2882 mutex_unlock(&hba->hba_access_mutex);
2835 return NULL; 2883 return ERR_PTR(errno);
2836} 2884}
2837 2885
2838static void target_core_drop_subdev( 2886static void target_core_drop_subdev(
@@ -2844,7 +2892,7 @@ static void target_core_drop_subdev(
2844 struct se_hba *hba; 2892 struct se_hba *hba;
2845 struct se_subsystem_api *t; 2893 struct se_subsystem_api *t;
2846 struct config_item *df_item; 2894 struct config_item *df_item;
2847 struct config_group *dev_cg, *tg_pt_gp_cg; 2895 struct config_group *dev_cg, *tg_pt_gp_cg, *dev_stat_grp;
2848 int i; 2896 int i;
2849 2897
2850 hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item); 2898 hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item);
@@ -2856,6 +2904,14 @@ static void target_core_drop_subdev(
2856 list_del(&se_dev->g_se_dev_list); 2904 list_del(&se_dev->g_se_dev_list);
2857 spin_unlock(&se_global->g_device_lock); 2905 spin_unlock(&se_global->g_device_lock);
2858 2906
2907 dev_stat_grp = &DEV_STAT_GRP(se_dev)->stat_group;
2908 for (i = 0; dev_stat_grp->default_groups[i]; i++) {
2909 df_item = &dev_stat_grp->default_groups[i]->cg_item;
2910 dev_stat_grp->default_groups[i] = NULL;
2911 config_item_put(df_item);
2912 }
2913 kfree(dev_stat_grp->default_groups);
2914
2859 tg_pt_gp_cg = &T10_ALUA(se_dev)->alua_tg_pt_gps_group; 2915 tg_pt_gp_cg = &T10_ALUA(se_dev)->alua_tg_pt_gps_group;
2860 for (i = 0; tg_pt_gp_cg->default_groups[i]; i++) { 2916 for (i = 0; tg_pt_gp_cg->default_groups[i]; i++) {
2861 df_item = &tg_pt_gp_cg->default_groups[i]->cg_item; 2917 df_item = &tg_pt_gp_cg->default_groups[i]->cg_item;