path: root/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
diff options
authorKotresh HR <>2016-04-29 17:45:31 +0530
committerVenky Shankar <>2016-05-01 21:33:33 -0700
commitdb468e4361315a91aaeeaa14ff7e6b448e2c8599 (patch)
tree750ecfe27bdb68275f1fe0de134942291fbad290 /xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
parent3c01660f63a32e53395e9af13f33ee5439932cdf (diff)
features/bitrot: Introduce scrubber monitor thread
The patch does following changes. 1. Introduce scrubber monitor thread. 2. Move scrub status related APIs to separate file and make part of libbitrot library. Problem: Earlier, each child of the scrubber was maintaining the state machine and hence there was no way to track the start and end time of scrubbing as each brick has it's own start and end time. Also each brick was maintaining it's own timer wheel instance. It was also not possible to get scrubbed files count per session as we could not get last child which finishes scrubbing to reset it to zero. Solution: Introduce scrubber monitor thread. It does following. 1. Maintains the scrubber state machine. Earlier each child had it's own state machine. Now, only monitor maintains on behalf of all it's children. 2. Maintains the timer wheel instance. Earlier each child had it's own timer wheel instance. Now, only monitor maintains on behalf of all it's children. As a result, we can track the scrub statistics easily and correctly. Change-Id: Ic6e34ffa57984bd7a5ee81f4e263342bc1d9b302 BUG: 1329211 Signed-off-by: Kotresh HR <> Reviewed-on: Smoke: Gluster Build System <> NetBSD-regression: NetBSD Build System <> CentOS-regression: Gluster Build System <> Reviewed-by: Venky Shankar <>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h')
1 files changed, 46 insertions, 0 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
new file mode 100644
index 0000000..694ba0a
--- /dev/null
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
@@ -0,0 +1,46 @@
+ Copyright (c) 2016 Red Hat, Inc. <>
+ This file is part of GlusterFS.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+#include <stdint.h>
+#include <sys/time.h>
+#include <pthread.h>
+struct br_scrub_stats {
+ uint64_t scrubbed_files; /* Total number of scrubbed file */
+ uint64_t unsigned_files; /* Total number of unsigned file */
+ uint64_t scrub_duration; /* Duration of last scrub */
+ char last_scrub_time[1024]; /*last scrub completion time */
+ struct timeval scrub_start_tv; /* Scrubbing starting time*/
+ struct timeval scrub_end_tv; /* Scrubbing finishing time */
+ pthread_mutex_t lock;
+typedef struct br_scrub_stats br_scrub_stats_t;
+br_inc_unsigned_file_count (br_scrub_stats_t *scrub_stat);
+br_inc_scrubbed_file (br_scrub_stats_t *scrub_stat);
+br_update_scrub_start_time (br_scrub_stats_t *scrub_stat, struct timeval *tv);
+br_update_scrub_finish_time (br_scrub_stats_t *scrub_stat, char *timestr,
+ struct timeval *tv);
+#endif /* __BIT_ROT_SCRUB_STATUS_H__ */