dovecot-2.2: lib-fs: Added fs_stats_get_read/write_usecs()

dovecot at dovecot.org dovecot at dovecot.org
Thu Nov 19 12:47:56 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/fac18fa49f2d
changeset: 19399:fac18fa49f2d
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Nov 19 14:46:54 2015 +0200
description:
lib-fs: Added fs_stats_get_read/write_usecs()
These can be easily used to sum up all the timings for read and write
categories.

diffstat:

 src/lib-fs/fs-api.c |  18 ++++++++++++++++++
 src/lib-fs/fs-api.h |   4 ++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diffs (37 lines):

diff -r cd347fd1791a -r fac18fa49f2d src/lib-fs/fs-api.c
--- a/src/lib-fs/fs-api.c	Wed Nov 18 21:06:17 2015 +0200
+++ b/src/lib-fs/fs-api.c	Thu Nov 19 14:46:54 2015 +0200
@@ -987,3 +987,21 @@
 	fs_set_error(fs, "Asynchronous operation in progress");
 	errno = EAGAIN;
 }
+
+uint64_t fs_stats_get_read_usecs(const struct fs_stats *stats)
+{
+	return timing_get_sum(stats->timings[FS_OP_METADATA]) +
+		timing_get_sum(stats->timings[FS_OP_PREFETCH]) +
+		timing_get_sum(stats->timings[FS_OP_READ]) +
+		timing_get_sum(stats->timings[FS_OP_EXISTS]) +
+		timing_get_sum(stats->timings[FS_OP_STAT]) +
+		timing_get_sum(stats->timings[FS_OP_ITER]);
+}
+
+uint64_t fs_stats_get_write_usecs(const struct fs_stats *stats)
+{
+	return timing_get_sum(stats->timings[FS_OP_WRITE]) +
+		timing_get_sum(stats->timings[FS_OP_COPY]) +
+		timing_get_sum(stats->timings[FS_OP_DELETE]);
+}
+
diff -r cd347fd1791a -r fac18fa49f2d src/lib-fs/fs-api.h
--- a/src/lib-fs/fs-api.h	Wed Nov 18 21:06:17 2015 +0200
+++ b/src/lib-fs/fs-api.h	Thu Nov 19 14:46:54 2015 +0200
@@ -333,4 +333,8 @@
    filesystem whose stats you want to see. */
 const struct fs_stats *fs_get_stats(struct fs *fs);
 
+/* Helper functions to count number of usecs for read/write operations. */
+uint64_t fs_stats_get_read_usecs(const struct fs_stats *stats);
+uint64_t fs_stats_get_write_usecs(const struct fs_stats *stats);
+
 #endif


More information about the dovecot-cvs mailing list