am bc7d5088: vold: Have the fstrim log start and finish times in the event log
* commit 'bc7d5088f7f7cbd097f99d2f6d015e2c0a73cacb':
vold: Have the fstrim log start and finish times in the event log
diff --git a/fstrim.c b/fstrim.c
index dd0a1af..73705f9 100644
--- a/fstrim.c
+++ b/fstrim.c
@@ -22,14 +22,34 @@
#include <string.h>
#include <limits.h>
#include <linux/fs.h>
+#include <time.h>
#include <fs_mgr.h>
#include <pthread.h>
#define LOG_TAG "fstrim"
#include "cutils/log.h"
#include "hardware_legacy/power.h"
+/* These numbers must match what the MountService specified in
+ * frameworks/base/services/java/com/android/server/EventLogTags.logtags
+ */
+#define LOG_FSTRIM_START 2755
+#define LOG_FSTRIM_FINISH 2756
+
#define FSTRIM_WAKELOCK "dofstrim"
+static unsigned long long get_boot_time_ms(void)
+{
+ struct timespec t;
+ unsigned long long time_ms;
+
+ t.tv_sec = 0;
+ t.tv_nsec = 0;
+ clock_gettime(CLOCK_BOOTTIME, &t);
+ time_ms = (t.tv_sec * 1000LL) + (t.tv_nsec / 1000000);
+
+ return time_ms;
+}
+
static void *do_fstrim_filesystems(void *ignored)
{
int i;
@@ -41,6 +61,9 @@
SLOGI("Starting fstrim work...\n");
+ /* Log the start time in the event log */
+ LOG_EVENT_LONG(LOG_FSTRIM_START, get_boot_time_ms());
+
for (i = 0; i < fstab->num_entries; i++) {
/* Skip raw partitions */
if (!strcmp(fstab->recs[i].fs_type, "emmc") ||
@@ -84,6 +107,10 @@
}
close(fd);
}
+
+ /* Log the finish time in the event log */
+ LOG_EVENT_LONG(LOG_FSTRIM_FINISH, get_boot_time_ms());
+
SLOGI("Finished fstrim work.\n");
/* Release the wakelock that let us work */