diff options
author | Kent Overstreet <kmo@daterainc.com> | 2014-02-25 20:34:21 -0500 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-03-18 15:22:35 -0400 |
commit | 15754020524a56517df082799f07de880f4b29e2 (patch) | |
tree | 1577f69ab2606e08c4c88ef8d1986a2a25835be9 | |
parent | 7159b1ad3dded9da040b5c608acf3d52d50f661e (diff) |
bcache: Improve priority_stats
Break down data into clean data/dirty data/metadata.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
-rw-r--r-- | drivers/md/bcache/sysfs.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index d8458d477a12..662b9484ed5e 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c | |||
@@ -761,7 +761,9 @@ SHOW(__bch_cache) | |||
761 | int cmp(const void *l, const void *r) | 761 | int cmp(const void *l, const void *r) |
762 | { return *((uint16_t *) r) - *((uint16_t *) l); } | 762 | { return *((uint16_t *) r) - *((uint16_t *) l); } |
763 | 763 | ||
764 | size_t n = ca->sb.nbuckets, i, unused, btree; | 764 | struct bucket *b; |
765 | size_t n = ca->sb.nbuckets, i; | ||
766 | size_t unused = 0, available = 0, dirty = 0, meta = 0; | ||
765 | uint64_t sum = 0; | 767 | uint64_t sum = 0; |
766 | /* Compute 31 quantiles */ | 768 | /* Compute 31 quantiles */ |
767 | uint16_t q[31], *p, *cached; | 769 | uint16_t q[31], *p, *cached; |
@@ -772,6 +774,17 @@ SHOW(__bch_cache) | |||
772 | return -ENOMEM; | 774 | return -ENOMEM; |
773 | 775 | ||
774 | mutex_lock(&ca->set->bucket_lock); | 776 | mutex_lock(&ca->set->bucket_lock); |
777 | for_each_bucket(b, ca) { | ||
778 | if (!GC_SECTORS_USED(b)) | ||
779 | unused++; | ||
780 | if (GC_MARK(b) == GC_MARK_RECLAIMABLE) | ||
781 | available++; | ||
782 | if (GC_MARK(b) == GC_MARK_DIRTY) | ||
783 | dirty++; | ||
784 | if (GC_MARK(b) == GC_MARK_METADATA) | ||
785 | meta++; | ||
786 | } | ||
787 | |||
775 | for (i = ca->sb.first_bucket; i < n; i++) | 788 | for (i = ca->sb.first_bucket; i < n; i++) |
776 | p[i] = ca->buckets[i].prio; | 789 | p[i] = ca->buckets[i].prio; |
777 | mutex_unlock(&ca->set->bucket_lock); | 790 | mutex_unlock(&ca->set->bucket_lock); |
@@ -786,10 +799,7 @@ SHOW(__bch_cache) | |||
786 | 799 | ||
787 | while (cached < p + n && | 800 | while (cached < p + n && |
788 | *cached == BTREE_PRIO) | 801 | *cached == BTREE_PRIO) |
789 | cached++; | 802 | cached++, n--; |
790 | |||
791 | btree = cached - p; | ||
792 | n -= btree; | ||
793 | 803 | ||
794 | for (i = 0; i < n; i++) | 804 | for (i = 0; i < n; i++) |
795 | sum += INITIAL_PRIO - cached[i]; | 805 | sum += INITIAL_PRIO - cached[i]; |
@@ -805,12 +815,16 @@ SHOW(__bch_cache) | |||
805 | 815 | ||
806 | ret = scnprintf(buf, PAGE_SIZE, | 816 | ret = scnprintf(buf, PAGE_SIZE, |
807 | "Unused: %zu%%\n" | 817 | "Unused: %zu%%\n" |
818 | "Clean: %zu%%\n" | ||
819 | "Dirty: %zu%%\n" | ||
808 | "Metadata: %zu%%\n" | 820 | "Metadata: %zu%%\n" |
809 | "Average: %llu\n" | 821 | "Average: %llu\n" |
810 | "Sectors per Q: %zu\n" | 822 | "Sectors per Q: %zu\n" |
811 | "Quantiles: [", | 823 | "Quantiles: [", |
812 | unused * 100 / (size_t) ca->sb.nbuckets, | 824 | unused * 100 / (size_t) ca->sb.nbuckets, |
813 | btree * 100 / (size_t) ca->sb.nbuckets, sum, | 825 | available * 100 / (size_t) ca->sb.nbuckets, |
826 | dirty * 100 / (size_t) ca->sb.nbuckets, | ||
827 | meta * 100 / (size_t) ca->sb.nbuckets, sum, | ||
814 | n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1)); | 828 | n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1)); |
815 | 829 | ||
816 | for (i = 0; i < ARRAY_SIZE(q); i++) | 830 | for (i = 0; i < ARRAY_SIZE(q); i++) |