]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - block/blk-cgroup.h
blkcg: implement blkg_[rw]stat_recursive_sum() and blkg_[rw]stat_merge()
[karo-tx-linux.git] / block / blk-cgroup.h
index 586c0ac3309acf32e32095def288d60f1ebcf176..f2b292925ccda3a2e8301eec4924e5fac989a354 100644 (file)
@@ -164,6 +164,10 @@ u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off);
 u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
                       int off);
 
+u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off);
+struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd,
+                                            int off);
+
 struct blkg_conf_ctx {
        struct gendisk                  *disk;
        struct blkcg_gq                 *blkg;
@@ -413,6 +417,18 @@ static inline void blkg_stat_reset(struct blkg_stat *stat)
        stat->cnt = 0;
 }
 
+/**
+ * blkg_stat_merge - merge a blkg_stat into another
+ * @to: the destination blkg_stat
+ * @from: the source
+ *
+ * Add @from's count to @to.
+ */
+static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
+{
+       blkg_stat_add(to, blkg_stat_read(from));
+}
+
 /**
  * blkg_rwstat_add - add a value to a blkg_rwstat
  * @rwstat: target blkg_rwstat
@@ -484,6 +500,25 @@ static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
        memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
 }
 
+/**
+ * blkg_rwstat_merge - merge a blkg_rwstat into another
+ * @to: the destination blkg_rwstat
+ * @from: the source
+ *
+ * Add @from's counts to @to.
+ */
+static inline void blkg_rwstat_merge(struct blkg_rwstat *to,
+                                    struct blkg_rwstat *from)
+{
+       struct blkg_rwstat v = blkg_rwstat_read(from);
+       int i;
+
+       u64_stats_update_begin(&to->syncp);
+       for (i = 0; i < BLKG_RWSTAT_NR; i++)
+               to->cnt[i] += v.cnt[i];
+       u64_stats_update_end(&to->syncp);
+}
+
 #else  /* CONFIG_BLK_CGROUP */
 
 struct cgroup;