vold: Have the fstrim log start and finish times in the event log
bug: 8688454 Change-Id: I5540ab27d3ade2c42ee8fd0de6fbfc1d1e19e36f
This commit is contained in:
parent
e78cd4f33d
commit
bc7d5088f7
1 changed files with 27 additions and 0 deletions
27
fstrim.c
27
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 @@ static void *do_fstrim_filesystems(void *ignored)
|
|||
|
||||
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") ||
|
||||
|
@ -83,6 +106,10 @@ static void *do_fstrim_filesystems(void *ignored)
|
|||
SLOGI("Trimmed %llu bytes on %s\n", range.len, fstab->recs[i].mount_point);
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue