OSDN Git Service

Add visible logs about fstrim run for block based checkpoints
authorSandeep Patil <sspatil@google.com>
Mon, 15 Apr 2019 15:45:27 +0000 (08:45 -0700)
committerSandeep Patil <sspatil@google.com>
Wed, 17 Apr 2019 19:55:58 +0000 (12:55 -0700)
Bug: 120095226
Test: Tested by forcing /data/system/last-fstrim last modified time back
      2 years & manually trigger checkpoint using 'vdc checkpoint startCheckpoint 1'

Change-Id: I0cb8b6a85ae787e1ba2cdd7998a46942ca69760f
Merged-In: I0cb8b6a85ae787e1ba2cdd7998a46942ca69760f
Signed-off-by: Sandeep Patil <sspatil@google.com>
Checkpoint.cpp

index e784c91..19c1f3c 100644 (file)
@@ -17,6 +17,7 @@
 #define LOG_TAG "Checkpoint"
 #include "Checkpoint.h"
 #include "VoldUtil.h"
+#include "VolumeManager.h"
 
 #include <fstream>
 #include <list>
@@ -337,10 +338,14 @@ Status cp_prepareCheckpoint() {
 
             struct fstrim_range range = {};
             range.len = ULLONG_MAX;
+            nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
             if (ioctl(fd, FITRIM, &range)) {
                 PLOG(ERROR) << "Failed to trim " << mount_rec.mount_point;
                 continue;
             }
+            nsecs_t time = systemTime(SYSTEM_TIME_BOOTTIME) - start;
+            LOG(INFO) << "Trimmed " << range.len << " bytes on " << mount_rec.mount_point << " in "
+                      << nanoseconds_to_milliseconds(time) << "ms for checkpoint";
 
             setBowState(mount_rec.blk_device, "1");
         }