Possibility to reset SGV pools statistic added
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Fri, 23 Oct 2009 17:55:37 +0000 (17:55 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Fri, 23 Oct 2009 17:55:37 +0000 (17:55 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1261 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scst/src/scst_mem.c
scst/src/scst_mem.h
scst/src/scst_sysfs.c

index 8a3bac3..23be97a 100644 (file)
@@ -1800,6 +1800,35 @@ ssize_t sgv_sysfs_stat_show(struct kobject *kobj,
        return res;
 }
 
+ssize_t sgv_sysfs_stat_reset(struct kobject *kobj,
+       struct kobj_attribute *attr, const char *buf, size_t count)
+{
+       struct sgv_pool *pool;
+       int i;
+
+       TRACE_ENTRY();
+
+       pool = container_of(kobj, struct sgv_pool, sgv_kobj);
+
+       for (i = 0; i < SGV_POOL_ELEMENTS; i++) {
+               atomic_set(&pool->cache_acc[i].hit_alloc, 0);
+               atomic_set(&pool->cache_acc[i].total_alloc, 0);
+               atomic_set(&pool->cache_acc[i].merged, 0);
+       }
+
+       atomic_set(&pool->big_pages, 0);
+       atomic_set(&pool->big_merged, 0);
+       atomic_set(&pool->big_alloc, 0);
+       atomic_set(&pool->other_pages, 0);
+       atomic_set(&pool->other_merged, 0);
+       atomic_set(&pool->other_alloc, 0);
+
+       PRINT_INFO("Statistics for SGV pool %s resetted", pool->name);
+
+       TRACE_EXIT_RES(count);
+       return count;
+}
+
 ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj,
        struct kobj_attribute *attr, char *buf)
 {
@@ -1829,4 +1858,19 @@ ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj,
        return res;
 }
 
+ssize_t sgv_sysfs_global_stat_reset(struct kobject *kobj,
+       struct kobj_attribute *attr, const char *buf, size_t count)
+{
+       TRACE_ENTRY();
+
+       atomic_set(&sgv_releases_on_hiwmk, 0);
+       atomic_set(&sgv_releases_on_hiwmk_failed, 0);
+       atomic_set(&sgv_other_total_alloc, 0);
+
+       PRINT_INFO("%s", "Global SGV pool statistics resetted");
+
+       TRACE_EXIT_RES(count);
+       return count;
+}
+
 #endif /* CONFIG_SCST_PROC */
index 56c16e5..36bbd73 100644 (file)
@@ -133,8 +133,12 @@ int sgv_procinfo_show(struct seq_file *seq, void *v);
 #else
 ssize_t sgv_sysfs_stat_show(struct kobject *kobj,
        struct kobj_attribute *attr, char *buf);
+ssize_t sgv_sysfs_stat_reset(struct kobject *kobj,
+       struct kobj_attribute *attr, const char *buf, size_t count);
 ssize_t sgv_sysfs_global_stat_show(struct kobject *kobj,
        struct kobj_attribute *attr, char *buf);
+ssize_t sgv_sysfs_global_stat_reset(struct kobject *kobj,
+       struct kobj_attribute *attr, const char *buf, size_t count);
 #endif
 
 void scst_sgv_pool_use_norm(struct scst_tgt_dev *tgt_dev);
index 67e43ca..7bf56f2 100644 (file)
@@ -1045,7 +1045,8 @@ out_remove_acg_dev:
  */
 
 static struct kobj_attribute sgv_stat_attr =
-       __ATTR(stats, S_IRUGO, sgv_sysfs_stat_show, NULL);
+       __ATTR(stats, S_IRUGO | S_IWUSR, sgv_sysfs_stat_show,
+               sgv_sysfs_stat_reset);
 
 static struct attribute *sgv_attrs[] = {
        &sgv_stat_attr.attr,
@@ -1104,7 +1105,8 @@ void scst_sgv_sysfs_put(struct sgv_pool *pool)
 }
 
 static struct kobj_attribute sgv_global_stat_attr =
-       __ATTR(global_stats, S_IRUGO, sgv_sysfs_global_stat_show, NULL);
+       __ATTR(global_stats, S_IRUGO | S_IWUSR, sgv_sysfs_global_stat_show,
+               sgv_sysfs_global_stat_reset);
 
 static struct attribute *sgv_default_attrs[] = {
        &sgv_global_stat_attr.attr,