Merge "Break vold dependency on keystore utilities."
diff --git a/Android.bp b/Android.bp
index cc015bf..aca6493 100644
--- a/Android.bp
+++ b/Android.bp
@@ -64,9 +64,7 @@
     defaults: ["vold_default_flags"],
 
     srcs: [
-        "binder/android/os/IVold.aidl",
-        "binder/android/os/IVoldListener.aidl",
-        "binder/android/os/IVoldTaskListener.aidl",
+        ":vold_aidl",
     ],
     shared_libs: [
         "libbinder",
@@ -79,6 +77,11 @@
     },
 }
 
+cc_library_headers {
+    name: "libvold_headers",
+    export_include_dirs: ["."],
+}
+
 // Static library factored out to support testing
 cc_library_static {
     name: "libvold",
@@ -123,6 +126,16 @@
         "model/VolumeBase.cpp",
         "secontext.cpp",
     ],
+    product_variables: {
+        arc: {
+            exclude_srcs: [
+                "model/ObbVolume.cpp",
+            ],
+            static_libs: [
+                "libarcobbvolume",
+            ],
+        },
+    },
 }
 
 cc_binary {
@@ -134,6 +147,13 @@
 
     srcs: ["main.cpp"],
     static_libs: ["libvold"],
+    product_variables: {
+        arc: {
+            static_libs: [
+                "libarcobbvolume",
+            ]
+        },
+    },
     init_rc: ["vold.rc"],
 
     required: [
@@ -187,4 +207,13 @@
     ],
 }
 
+filegroup {
+    name: "vold_aidl",
+    srcs: [
+        "binder/android/os/IVold.aidl",
+        "binder/android/os/IVoldListener.aidl",
+        "binder/android/os/IVoldTaskListener.aidl",
+    ],
+}
+
 subdirs = ["tests"]
diff --git a/Benchmark.cpp b/Benchmark.cpp
index 63b4dd3..dfe3366 100644
--- a/Benchmark.cpp
+++ b/Benchmark.cpp
@@ -18,8 +18,10 @@
 #include "BenchmarkGen.h"
 #include "VolumeManager.h"
 
+#include <android-base/chrono_utils.h>
 #include <android-base/file.h>
 #include <android-base/logging.h>
+
 #include <cutils/iosched_policy.h>
 #include <hardware_legacy/power.h>
 #include <private/android_filesystem_config.h>
@@ -30,18 +32,65 @@
 #include <sys/resource.h>
 #include <unistd.h>
 
-#define ENABLE_DROP_CACHES 1
-
 using android::base::ReadFileToString;
 using android::base::WriteStringToFile;
 
 namespace android {
 namespace vold {
 
+// Benchmark currently uses chdir(), which means we can only
+// safely run one at a time.
+static std::mutex kBenchmarkLock;
+
 static const char* kWakeLock = "Benchmark";
 
+// Reasonable cards are able to complete the create/run stages
+// in under 20 seconds.
+constexpr auto kTimeout = 20s;
+
+// RAII class for boosting device performance during benchmarks.
+class PerformanceBoost {
+private:
+    int orig_prio;
+    int orig_ioprio;
+    IoSchedClass orig_clazz;
+
+public:
+    PerformanceBoost() {
+        errno = 0;
+        orig_prio = getpriority(PRIO_PROCESS, 0);
+        if (errno != 0) {
+            PLOG(WARNING) << "Failed to getpriority";
+            orig_prio = 0;
+        }
+        if (setpriority(PRIO_PROCESS, 0, -10) != 0) {
+            PLOG(WARNING) << "Failed to setpriority";
+        }
+        if (android_get_ioprio(0, &orig_clazz, &orig_ioprio)) {
+            PLOG(WARNING) << "Failed to android_get_ioprio";
+            orig_ioprio = 0;
+            orig_clazz = IoSchedClass_NONE;
+        }
+        if (android_set_ioprio(0, IoSchedClass_RT, 0)) {
+            PLOG(WARNING) << "Failed to android_set_ioprio";
+        }
+    }
+
+    ~PerformanceBoost() {
+        if (android_set_ioprio(0, orig_clazz, orig_ioprio)) {
+            PLOG(WARNING) << "Failed to android_set_ioprio";
+        }
+        if (setpriority(PRIO_PROCESS, 0, orig_prio) != 0) {
+            PLOG(WARNING) << "Failed to setpriority";
+        }
+    }
+};
+
 static status_t benchmarkInternal(const std::string& rootPath,
+        const android::sp<android::os::IVoldTaskListener>& listener,
         android::os::PersistableBundle* extras) {
+    status_t res = 0;
+
     auto path = rootPath;
     path += "/misc";
     if (android::vold::PrepareDir(path, 01771, AID_SYSTEM, AID_MISC)) {
@@ -56,28 +105,6 @@
         return -1;
     }
 
-    errno = 0;
-    int orig_prio = getpriority(PRIO_PROCESS, 0);
-    if (errno != 0) {
-        PLOG(ERROR) << "Failed to getpriority";
-        return -1;
-    }
-    if (setpriority(PRIO_PROCESS, 0, -10) != 0) {
-        PLOG(ERROR) << "Failed to setpriority";
-        return -1;
-    }
-
-    IoSchedClass orig_clazz = IoSchedClass_NONE;
-    int orig_ioprio = 0;
-    if (android_get_ioprio(0, &orig_clazz, &orig_ioprio)) {
-        PLOG(ERROR) << "Failed to android_get_ioprio";
-        return -1;
-    }
-    if (android_set_ioprio(0, IoSchedClass_RT, 0)) {
-        PLOG(ERROR) << "Failed to android_set_ioprio";
-        return -1;
-    }
-
     char orig_cwd[PATH_MAX];
     if (getcwd(orig_cwd, PATH_MAX) == NULL) {
         PLOG(ERROR) << "Failed getcwd";
@@ -90,66 +117,76 @@
 
     sync();
 
-    LOG(INFO) << "Benchmarking " << path;
-    nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
+    extras->putString(String16("path"), String16(path.c_str()));
+    extras->putString(String16("ident"), String16(BenchmarkIdent().c_str()));
 
-    BenchmarkCreate();
-    sync();
-    nsecs_t create = systemTime(SYSTEM_TIME_BOOTTIME);
-
-#if ENABLE_DROP_CACHES
-    LOG(VERBOSE) << "Before drop_caches";
-    if (!WriteStringToFile("3", "/proc/sys/vm/drop_caches")) {
-        PLOG(ERROR) << "Failed to drop_caches";
+    // Always create
+    {
+        android::base::Timer timer;
+        LOG(INFO) << "Creating " << path;
+        res |= BenchmarkCreate([&](int progress) -> bool {
+            if (listener) {
+                listener->onStatus(progress, *extras);
+            }
+            return (timer.duration() < kTimeout);
+        });
+        sync();
+        if (res == OK) extras->putLong(String16("create"), timer.duration().count());
     }
-    LOG(VERBOSE) << "After drop_caches";
-#endif
-    nsecs_t drop = systemTime(SYSTEM_TIME_BOOTTIME);
 
-    BenchmarkRun();
-    sync();
-    nsecs_t run = systemTime(SYSTEM_TIME_BOOTTIME);
+    // Only drop when we haven't aborted
+    if (res == OK) {
+        android::base::Timer timer;
+        LOG(VERBOSE) << "Before drop_caches";
+        if (!WriteStringToFile("3", "/proc/sys/vm/drop_caches")) {
+            PLOG(ERROR) << "Failed to drop_caches";
+            res = -1;
+        }
+        LOG(VERBOSE) << "After drop_caches";
+        sync();
+        if (res == OK) extras->putLong(String16("drop"), timer.duration().count());
+    }
 
-    BenchmarkDestroy();
-    sync();
-    nsecs_t destroy = systemTime(SYSTEM_TIME_BOOTTIME);
+    // Only run when we haven't aborted
+    if (res == OK) {
+        android::base::Timer timer;
+        LOG(INFO) << "Running " << path;
+        res |= BenchmarkRun([&](int progress) -> bool {
+            if (listener) {
+                listener->onStatus(progress, *extras);
+            }
+            return (timer.duration() < kTimeout);
+        });
+        sync();
+        if (res == OK) extras->putLong(String16("run"), timer.duration().count());
+    }
+
+    // Always destroy
+    {
+        android::base::Timer timer;
+        LOG(INFO) << "Destroying " << path;
+        res |= BenchmarkDestroy();
+        sync();
+        if (res == OK) extras->putLong(String16("destroy"), timer.duration().count());
+    }
 
     if (chdir(orig_cwd) != 0) {
         PLOG(ERROR) << "Failed to chdir";
-    }
-    if (android_set_ioprio(0, orig_clazz, orig_ioprio)) {
-        PLOG(ERROR) << "Failed to android_set_ioprio";
-    }
-    if (setpriority(PRIO_PROCESS, 0, orig_prio) != 0) {
-        PLOG(ERROR) << "Failed to setpriority";
+        return -1;
     }
 
-    nsecs_t create_d = create - start;
-    nsecs_t drop_d = drop - create;
-    nsecs_t run_d = run - drop;
-    nsecs_t destroy_d = destroy - run;
-
-    LOG(INFO) << "create took " << nanoseconds_to_milliseconds(create_d) << "ms";
-    LOG(INFO) << "drop took " << nanoseconds_to_milliseconds(drop_d) << "ms";
-    LOG(INFO) << "run took " << nanoseconds_to_milliseconds(run_d) << "ms";
-    LOG(INFO) << "destroy took " << nanoseconds_to_milliseconds(destroy_d) << "ms";
-
-    extras->putString(String16("path"), String16(path.c_str()));
-    extras->putString(String16("ident"), String16(BenchmarkIdent().c_str()));
-    extras->putLong(String16("create"), create_d);
-    extras->putLong(String16("drop"), drop_d);
-    extras->putLong(String16("run"), run_d);
-    extras->putLong(String16("destroy"), destroy_d);
-
-    return 0;
+    return res;
 }
 
 void Benchmark(const std::string& path,
         const android::sp<android::os::IVoldTaskListener>& listener) {
+    std::lock_guard<std::mutex> lock(kBenchmarkLock);
     acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
 
+    PerformanceBoost boost;
     android::os::PersistableBundle extras;
-    status_t res = benchmarkInternal(path, &extras);
+
+    status_t res = benchmarkInternal(path, listener, &extras);
     if (listener) {
         listener->onFinished(res, extras);
     }
diff --git a/BenchmarkGen.h b/BenchmarkGen.h
index cd95aae..a1bf718 100644
--- a/BenchmarkGen.h
+++ b/BenchmarkGen.h
@@ -29,6 +29,7 @@
 #include <fcntl.h>
 
 #include <algorithm>
+#include <functional>
 #include <string>
 
 #include <Utils.h>
@@ -36,10 +37,11 @@
 namespace android {
 namespace vold {
 
-static status_t BenchmarkRun() {
+static status_t BenchmarkRun(std::function<bool(int)> checkpoint) {
+
 
 char* buf = (char*) malloc(1048576);
-int  t3433f17 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
+int t3433f17 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(lseek(t3433f17, 0, SEEK_END));
 TEMP_FAILURE_RETRY(lseek(t3433f17, 38891199, SEEK_SET));
 TEMP_FAILURE_RETRY(read(t3433f17, buf, 65557));
@@ -50,7 +52,7 @@
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 30, 37276895));
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 14, 37276925));
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 914520, 37273600)); // mmap2
-int  t3433f18 = TEMP_FAILURE_RETRY(open("file1", O_RDONLY|O_LARGEFILE));
+int t3433f18 = TEMP_FAILURE_RETRY(open("file1", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(pread(t3433f18, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3433f18, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3433f18, buf, 4096, 0)); // mmap2
@@ -211,8 +213,8 @@
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 30, 32521955));
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 45, 32521985));
 TEMP_FAILURE_RETRY(pread(t3433f17, buf, 6350, 32518144)); // mmap2
-int  t3450f18 = TEMP_FAILURE_RETRY(open("file11", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
-int  t3450f22 = TEMP_FAILURE_RETRY(open("file12", O_RDONLY|O_LARGEFILE));
+int t3450f18 = TEMP_FAILURE_RETRY(open("file11", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3450f22 = TEMP_FAILURE_RETRY(open("file12", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3450f22, buf, 1));
 close(t3450f22);
 t3450f22 = TEMP_FAILURE_RETRY(open("file13", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
@@ -224,7 +226,7 @@
 TEMP_FAILURE_RETRY(fsync(t3450f22));
 close(t3450f22);
 close(t3450f18);
-int  t3454f26 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3454f26 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(lseek(t3454f26, 0, SEEK_END));
 TEMP_FAILURE_RETRY(lseek(t3454f26, 38891199, SEEK_SET));
 TEMP_FAILURE_RETRY(read(t3454f26, buf, 65557));
@@ -236,7 +238,7 @@
 TEMP_FAILURE_RETRY(read(t3454f26, buf, 65557));
 TEMP_FAILURE_RETRY(pread(t3454f26, buf, 769726, 38187008)); // mmap2
 close(t3454f26);
-int  t3455f17 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
+int t3455f17 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(lseek(t3455f17, 0, SEEK_END));
 TEMP_FAILURE_RETRY(lseek(t3455f17, 38891199, SEEK_SET));
 TEMP_FAILURE_RETRY(read(t3455f17, buf, 65557));
@@ -247,10 +249,10 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 37276895));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 14, 37276925));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 914520, 37273600)); // mmap2
-int  t3454f29 = TEMP_FAILURE_RETRY(open("file16", O_RDONLY|O_LARGEFILE));
+int t3454f29 = TEMP_FAILURE_RETRY(open("file16", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(pread(t3454f29, buf, 14048, 0)); // mmap2
 close(t3454f29);
-int  t3455f18 = TEMP_FAILURE_RETRY(open("file1", O_RDONLY|O_LARGEFILE));
+int t3455f18 = TEMP_FAILURE_RETRY(open("file1", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4096, 0)); // mmap2
@@ -277,6 +279,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 1048576, 0)); // mmap2
 close(t3455f18);
 t3455f18 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE));
+if (!checkpoint(52)) return -1;
 TEMP_FAILURE_RETRY(read(t3455f18, buf, 4));
 TEMP_FAILURE_RETRY(lseek(t3455f18, 0, SEEK_SET));
 TEMP_FAILURE_RETRY(lseek(t3455f18, 0, SEEK_END));
@@ -397,7 +400,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 3513185));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 46, 3513215));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3262, 3510272)); // mmap2
-int  t3455f19 = TEMP_FAILURE_RETRY(open("file12", O_RDONLY|O_LARGEFILE));
+int t3455f19 = TEMP_FAILURE_RETRY(open("file12", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3455f19, buf, 1));
 close(t3455f19);
 t3455f19 = TEMP_FAILURE_RETRY(open("file13", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
@@ -415,9 +418,9 @@
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 13748, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f18, buf, 4196, 12288)); // mmap2
 close(t3455f18);
-int  t3483f20 = TEMP_FAILURE_RETRY(open("file17", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3483f20 = TEMP_FAILURE_RETRY(open("file17", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 100, 0));
-int  t3483f21 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3483f21 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3483f21, buf, 1, 0));
 close(t3483f21);
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 0));
@@ -440,7 +443,7 @@
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 16384));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 12288));
-int  t3483f22 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3483f22 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3483f22, buf, 1, 0));
 close(t3483f22);
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 16, 24));
@@ -467,9 +470,9 @@
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 49152));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 139264));
 TEMP_FAILURE_RETRY(pread(t3483f20, buf, 4096, 172032));
-int  t3483f25 = TEMP_FAILURE_RETRY(open("file19", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3483f25 = TEMP_FAILURE_RETRY(open("file19", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 100, 0));
-int  t3483f26 = TEMP_FAILURE_RETRY(open("file20", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3483f26 = TEMP_FAILURE_RETRY(open("file20", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3483f26, buf, 1, 0));
 close(t3483f26);
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 0));
@@ -492,7 +495,7 @@
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 16384));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 12288));
-int  t3483f27 = TEMP_FAILURE_RETRY(open("file20", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3483f27 = TEMP_FAILURE_RETRY(open("file20", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3483f27, buf, 1, 0));
 close(t3483f27);
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 16, 24));
@@ -533,6 +536,7 @@
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 69632));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 81920));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 90112));
+if (!checkpoint(55)) return -1;
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 102400));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 114688));
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 4096, 131072));
@@ -541,16 +545,16 @@
 TEMP_FAILURE_RETRY(pread(t3483f27, buf, 1, 0));
 close(t3483f27);
 TEMP_FAILURE_RETRY(pread(t3483f25, buf, 16, 24));
-int  t3498f30 = TEMP_FAILURE_RETRY(open("file21", O_RDONLY|O_LARGEFILE));
+int t3498f30 = TEMP_FAILURE_RETRY(open("file21", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3498f30, buf, 16384));
 close(t3498f30);
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 278721));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 19, 278751));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 25119, 278528)); // mmap2
-int  t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f30 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f30, buf, 1, 0));
 close(t3499f30);
-int  t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
+int t3499f31 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4096, 516));
@@ -595,7 +599,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f30));
 close(t3499f30);
-int  t3500f30 = TEMP_FAILURE_RETRY(open("file23", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3500f30 = TEMP_FAILURE_RETRY(open("file23", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3500f30, buf, 52, 0));
 TEMP_FAILURE_RETRY(pread(t3500f30, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3500f30, buf, 27898, 0)); // mmap2
@@ -631,7 +635,7 @@
 TEMP_FAILURE_RETRY(pread(t3500f30, buf, 1048576, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3500f30, buf, 122564, 3059712)); // mmap2
 close(t3500f30);
-int  t3502f30 = TEMP_FAILURE_RETRY(open("file29", O_RDONLY|O_LARGEFILE));
+int t3502f30 = TEMP_FAILURE_RETRY(open("file29", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3502f30, buf, 1));
 TEMP_FAILURE_RETRY(read(t3502f30, buf, 4));
 TEMP_FAILURE_RETRY(read(t3502f30, buf, 1));
@@ -776,6 +780,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2073, 32759808)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 32273035));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 37, 32273065));
+if (!checkpoint(58)) return -1;
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1692, 32272384)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34612102));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 38, 34612132));
@@ -802,7 +807,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f31, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f31));
-int  t3499f32 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f32 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f32));
 close(t3499f32);
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 12, 0));
@@ -837,9 +842,9 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f31, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f31));
 close(t3499f31);
-int  t3492f31 = TEMP_FAILURE_RETRY(open("file30", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3492f31 = TEMP_FAILURE_RETRY(open("file30", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 100, 0));
-int  t3492f32 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f32 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f32, buf, 1, 0));
 close(t3492f32);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 4096, 0));
@@ -865,7 +870,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1005, 35635200)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 4096, 16384));
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 4096, 12288));
-int  t3492f33 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f33 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f33, buf, 1, 0));
 close(t3492f33);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
@@ -899,7 +904,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f30, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f30));
-int  t3499f34 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f34 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f34));
 close(t3499f34);
 TEMP_FAILURE_RETRY(pwrite(t3499f30, buf, 12, 0));
@@ -1001,6 +1006,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 43, 35474168));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3682, 35471360)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34394223));
+if (!checkpoint(61)) return -1;
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 41, 34394253));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 481, 34394112)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 32648704));
@@ -1034,19 +1040,19 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 36096678));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 29, 36096708));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3292, 36093952)); // mmap2
-int  t3509f41 = TEMP_FAILURE_RETRY(open("file33", O_RDONLY|O_LARGEFILE));
-int  t3492f42 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3509f41 = TEMP_FAILURE_RETRY(open("file33", O_RDONLY|O_LARGEFILE));
+int t3492f42 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f42, buf, 1, 0));
 close(t3492f42);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 4096, 53248));
-int  t3499f42 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f42 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f42, buf, 1, 0));
 close(t3499f42);
 TEMP_FAILURE_RETRY(read(t3509f41, buf, 8192));
 TEMP_FAILURE_RETRY(read(t3509f41, buf, 8091));
 close(t3509f41);
-int  t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f41, buf, 1, 0));
 close(t3499f41);
 t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -1103,10 +1109,10 @@
 t3499f41 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f41, buf, 1, 0));
 close(t3499f41);
-int  t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 1, 0));
 close(t3499f40);
-int  t3492f40 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f40 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f40, buf, 1, 0));
 close(t3492f40);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
@@ -1192,7 +1198,7 @@
 t3499f40 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 1, 0));
 close(t3499f40);
-int  t3492f41 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f41 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f41, buf, 1, 0));
 close(t3492f41);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
@@ -1223,6 +1229,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 12824));
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4096, 12828));
+if (!checkpoint(64)) return -1;
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f40));
@@ -1253,7 +1260,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f40, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f40));
-int  t3508f42 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3508f42 = TEMP_FAILURE_RETRY(open("file0", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(lseek(t3508f42, 0, SEEK_END));
 TEMP_FAILURE_RETRY(lseek(t3508f42, 38891199, SEEK_SET));
 TEMP_FAILURE_RETRY(read(t3508f42, buf, 65557));
@@ -1265,7 +1272,7 @@
 TEMP_FAILURE_RETRY(read(t3508f42, buf, 65557));
 TEMP_FAILURE_RETRY(pread(t3508f42, buf, 769726, 38187008)); // mmap2
 close(t3508f42);
-int  t3499f43 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f43 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f43));
 close(t3499f43);
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 12, 0));
@@ -1273,10 +1280,10 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f40, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f40));
 close(t3499f40);
-int  t3508f40 = TEMP_FAILURE_RETRY(open("file16", O_RDONLY|O_LARGEFILE));
+int t3508f40 = TEMP_FAILURE_RETRY(open("file16", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(pread(t3508f40, buf, 14048, 0)); // mmap2
 close(t3508f40);
-int  t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f33, buf, 1, 0));
 close(t3499f33);
 t3499f33 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -1295,7 +1302,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f33, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f33));
-int  t3499f39 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f39 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f39));
 close(t3499f39);
 TEMP_FAILURE_RETRY(pwrite(t3499f33, buf, 12, 0));
@@ -1336,7 +1343,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35448800));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 31, 35448830));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2408, 35446784)); // mmap2
-int  t3519f33 = TEMP_FAILURE_RETRY(open("file34", O_RDONLY|O_LARGEFILE));
+int t3519f33 = TEMP_FAILURE_RETRY(open("file34", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3519f33, buf, 1422));
 TEMP_FAILURE_RETRY(read(t3519f33, buf, 1));
 close(t3519f33);
@@ -1436,11 +1443,11 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 29897692));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 34, 29897722));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1809, 29896704)); // mmap2
-int  t3523f49 = TEMP_FAILURE_RETRY(open("file33", O_RDONLY|O_LARGEFILE));
+int t3523f49 = TEMP_FAILURE_RETRY(open("file33", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3523f49, buf, 8192));
 TEMP_FAILURE_RETRY(read(t3523f49, buf, 8091));
 close(t3523f49);
-int  t3455f50 = TEMP_FAILURE_RETRY(open("file7", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3455f50 = TEMP_FAILURE_RETRY(open("file7", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 close(t3455f50);
 t3455f50 = TEMP_FAILURE_RETRY(open("file35", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3455f50, buf, 52, 0));
@@ -1452,6 +1459,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f50, buf, 52, 0));
 TEMP_FAILURE_RETRY(pread(t3455f50, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f50, buf, 187587, 0)); // mmap2
+if (!checkpoint(67)) return -1;
 TEMP_FAILURE_RETRY(pread(t3455f50, buf, 4128, 188416)); // mmap2
 close(t3455f50);
 t3455f50 = TEMP_FAILURE_RETRY(open("file24", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@@ -1471,7 +1479,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 29922405));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 45, 29922435));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1962, 29921280)); // mmap2
-int  t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f50, buf, 1, 0));
 close(t3499f50);
 t3499f50 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -1490,7 +1498,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f50, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f50));
-int  t3499f52 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f52 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f52));
 close(t3499f52);
 TEMP_FAILURE_RETRY(pwrite(t3499f50, buf, 12, 0));
@@ -1534,7 +1542,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 33255456));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 43, 33255486));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 795, 33255424)); // mmap2
-int  t3492f52 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f52 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f52, buf, 1, 0));
 close(t3492f52);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
@@ -1594,8 +1602,8 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35513539));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 37, 35513569));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1673, 35512320)); // mmap2
-int  t3526f50 = TEMP_FAILURE_RETRY(open("file39", O_RDONLY|O_LARGEFILE));
-int  t3526f52 = TEMP_FAILURE_RETRY(open("file40", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3526f50 = TEMP_FAILURE_RETRY(open("file39", O_RDONLY|O_LARGEFILE));
+int t3526f52 = TEMP_FAILURE_RETRY(open("file40", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3526f52, buf, 52, 0));
 TEMP_FAILURE_RETRY(pread(t3526f52, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3526f52, buf, 1584, 0)); // mmap2
@@ -1619,7 +1627,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 32575657));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 49, 32575687));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 451, 32575488)); // mmap2
-int  t3519f50 = TEMP_FAILURE_RETRY(open("file41", O_RDONLY|O_LARGEFILE));
+int t3519f50 = TEMP_FAILURE_RETRY(open("file41", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3519f50, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3519f50, buf, 16384));
 close(t3519f50);
@@ -1632,7 +1640,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 29920348));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 42, 29920378));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 5221, 29917184)); // mmap2
-int  t3527f50 = TEMP_FAILURE_RETRY(open("file42", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3527f50 = TEMP_FAILURE_RETRY(open("file42", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3527f50, buf, 52, 0));
 TEMP_FAILURE_RETRY(pread(t3527f50, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 32567874));
@@ -1652,7 +1660,7 @@
 TEMP_FAILURE_RETRY(read(t3519f50, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3519f50, buf, 16384));
 close(t3519f50);
-int  t3492f50 = TEMP_FAILURE_RETRY(open("file44", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f50 = TEMP_FAILURE_RETRY(open("file44", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f50, buf, 52, 0));
 TEMP_FAILURE_RETRY(pread(t3492f50, buf, 4096, 0)); // mmap2
 TEMP_FAILURE_RETRY(pread(t3492f50, buf, 10313, 0)); // mmap2
@@ -1666,23 +1674,23 @@
 TEMP_FAILURE_RETRY(read(t3526f52, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3526f52, buf, 16384));
 close(t3526f52);
-int  t3532f53 = TEMP_FAILURE_RETRY(open("file47", O_RDONLY|O_LARGEFILE));
+int t3532f53 = TEMP_FAILURE_RETRY(open("file47", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3532f53, buf, 16384));
-int  t3533f47 = TEMP_FAILURE_RETRY(open("file48", O_RDONLY|O_LARGEFILE));
+int t3533f47 = TEMP_FAILURE_RETRY(open("file48", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3532f53, buf, 16384));
 close(t3532f53);
 TEMP_FAILURE_RETRY(read(t3533f47, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3533f47, buf, 16384));
 close(t3533f47);
-int  t3519f43 = TEMP_FAILURE_RETRY(open("file49", O_RDONLY|O_LARGEFILE));
+int t3519f43 = TEMP_FAILURE_RETRY(open("file49", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3519f43, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3519f43, buf, 16384));
 close(t3519f43);
-int  t3532f43 = TEMP_FAILURE_RETRY(open("file50", O_RDONLY|O_LARGEFILE));
+int t3532f43 = TEMP_FAILURE_RETRY(open("file50", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3532f43, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3532f43, buf, 16384));
 close(t3532f43);
-int  t3533f43 = TEMP_FAILURE_RETRY(open("file51", O_RDONLY|O_LARGEFILE));
+int t3533f43 = TEMP_FAILURE_RETRY(open("file51", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3533f43, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3533f43, buf, 16384));
 close(t3533f43);
@@ -1695,10 +1703,11 @@
 TEMP_FAILURE_RETRY(read(t3532f53, buf, 16384));
 close(t3519f43);
 close(t3532f53);
-int  t3492f57 = TEMP_FAILURE_RETRY(open("file54", O_RDONLY|O_LARGEFILE));
+int t3492f57 = TEMP_FAILURE_RETRY(open("file54", O_RDONLY|O_LARGEFILE));
+if (!checkpoint(70)) return -1;
 TEMP_FAILURE_RETRY(read(t3492f57, buf, 39938));
 close(t3492f57);
-int  t3492f61 = TEMP_FAILURE_RETRY(open("file55", O_RDONLY|O_LARGEFILE));
+int t3492f61 = TEMP_FAILURE_RETRY(open("file55", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3492f61, buf, 8192));
 TEMP_FAILURE_RETRY(read(t3492f61, buf, 8192));
 close(t3492f61);
@@ -1793,7 +1802,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 28977951));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 48, 28977981));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3292, 28975104)); // mmap2
-int  t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f55, buf, 1, 0));
 close(t3499f55);
 t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -1812,7 +1821,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f55, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f55));
-int  t3499f56 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f56 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f56));
 close(t3499f56);
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 12, 0));
@@ -1820,14 +1829,14 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f55));
 close(t3499f55);
-int  t3505f55 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f55 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f55, buf, 1, 0));
 close(t3505f55);
-int  t3519f55 = TEMP_FAILURE_RETRY(open("file57", O_RDONLY|O_LARGEFILE));
+int t3519f55 = TEMP_FAILURE_RETRY(open("file57", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3519f55, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3519f55, buf, 16384));
 close(t3519f55);
-int  t3532f55 = TEMP_FAILURE_RETRY(open("file58", O_RDONLY|O_LARGEFILE));
+int t3532f55 = TEMP_FAILURE_RETRY(open("file58", O_RDONLY|O_LARGEFILE));
 t3499f56 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f56, buf, 1, 0));
 close(t3499f56);
@@ -1835,7 +1844,7 @@
 TEMP_FAILURE_RETRY(read(t3532f55, buf, 16384));
 close(t3532f55);
 t3499f55 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
-int  t3505f56 = TEMP_FAILURE_RETRY(open("file59", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3505f56 = TEMP_FAILURE_RETRY(open("file59", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
@@ -1848,7 +1857,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f55, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f55));
-int  t3499f59 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f59 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f59));
 close(t3499f59);
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 12, 0));
@@ -1856,11 +1865,11 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f55));
 close(t3499f55);
-int  t3533f55 = TEMP_FAILURE_RETRY(open("file60", O_RDONLY|O_LARGEFILE));
+int t3533f55 = TEMP_FAILURE_RETRY(open("file60", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3533f55, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3533f55, buf, 16384));
 close(t3533f55);
-int  t3499f58 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f58 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f58, buf, 1, 0));
 close(t3499f58);
 t3499f58 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -1928,6 +1937,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 516));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 4612));
+if (!checkpoint(73)) return -1;
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 4616));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4096, 4620));
 TEMP_FAILURE_RETRY(pwrite(t3499f55, buf, 4, 8716));
@@ -2026,7 +2036,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4, 12824));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4096, 12828));
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4, 16924));
-int  t3499f62 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f62 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f62, buf, 1, 0));
 close(t3499f62);
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 4, 16928));
@@ -2048,7 +2058,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f62, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f62));
-int  t3499f68 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f68 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f68));
 close(t3499f68);
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 12, 0));
@@ -2058,7 +2068,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f62));
 close(t3499f62);
-int  t3505f62 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f62 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3505f62));
 close(t3505f62);
 TEMP_FAILURE_RETRY(pwrite(t3505f56, buf, 12, 0));
@@ -2069,11 +2079,11 @@
 t3505f56 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f56, buf, 1, 0));
 close(t3505f56);
-int  t3533f56 = TEMP_FAILURE_RETRY(open("file61", O_RDONLY|O_LARGEFILE));
+int t3533f56 = TEMP_FAILURE_RETRY(open("file61", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3533f56, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3533f56, buf, 16384));
 close(t3533f56);
-int  t3532f56 = TEMP_FAILURE_RETRY(open("file62", O_RDONLY|O_LARGEFILE));
+int t3532f56 = TEMP_FAILURE_RETRY(open("file62", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3532f56, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3532f56, buf, 16384));
 close(t3532f56);
@@ -2130,7 +2140,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 29935078));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 50, 29935108));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1983, 29933568)); // mmap2
-int  t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f66, buf, 1, 0));
 close(t3499f66);
 t3499f66 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2142,7 +2152,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4096, 4620));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4, 8716));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 36467015));
-int  t3532f68 = TEMP_FAILURE_RETRY(open("file64", O_RDONLY|O_LARGEFILE));
+int t3532f68 = TEMP_FAILURE_RETRY(open("file64", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 41, 36467045));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4, 8720));
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4096, 8724));
@@ -2152,13 +2162,14 @@
 TEMP_FAILURE_RETRY(fdatasync(t3499f66));
 TEMP_FAILURE_RETRY(read(t3532f68, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3532f68, buf, 16384));
-int  t3499f73 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f73 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(read(t3532f68, buf, 16384));
 TEMP_FAILURE_RETRY(fdatasync(t3499f73));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34267550));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 49, 34267580));
 close(t3499f73);
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 12, 0));
+if (!checkpoint(76)) return -1;
 close(t3532f68);
 TEMP_FAILURE_RETRY(fdatasync(t3499f66));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 722, 34267136)); // mmap2
@@ -2180,11 +2191,11 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35513539));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 37, 35513569));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 1673, 35512320)); // mmap2
-int  t3532f61 = TEMP_FAILURE_RETRY(open("file65", O_RDONLY|O_LARGEFILE));
+int t3532f61 = TEMP_FAILURE_RETRY(open("file65", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3532f61, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3532f61, buf, 16384));
 close(t3532f61);
-int  t3533f61 = TEMP_FAILURE_RETRY(open("file66", O_RDONLY|O_LARGEFILE));
+int t3533f61 = TEMP_FAILURE_RETRY(open("file66", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3533f61, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3533f61, buf, 16384));
 close(t3533f61);
@@ -2212,7 +2223,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f62, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f62));
-int  t3499f61 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f61 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f61));
 close(t3499f61);
 TEMP_FAILURE_RETRY(pwrite(t3499f62, buf, 12, 0));
@@ -2228,11 +2239,11 @@
 TEMP_FAILURE_RETRY(read(t3533f61, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3533f61, buf, 16384));
 close(t3533f61);
-int  t3519f61 = TEMP_FAILURE_RETRY(open("file71", O_RDONLY|O_LARGEFILE));
+int t3519f61 = TEMP_FAILURE_RETRY(open("file71", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3519f61, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3519f61, buf, 16384));
 close(t3519f61);
-int  t3499f80 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f80 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f80, buf, 1, 0));
 close(t3499f80);
 t3499f80 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2248,7 +2259,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f80, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f80, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f80));
-int  t3499f81 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f81 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f81));
 close(t3499f81);
 TEMP_FAILURE_RETRY(pwrite(t3499f80, buf, 12, 0));
@@ -2283,7 +2294,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34957756));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 29, 34957786));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3273, 34955264)); // mmap2
-int  t3519f68 = TEMP_FAILURE_RETRY(open("file72", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f68 = TEMP_FAILURE_RETRY(open("file72", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f68);
 t3519f68 = TEMP_FAILURE_RETRY(open("file73", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f68);
@@ -2305,7 +2316,7 @@
 close(t3519f68);
 t3519f68 = TEMP_FAILURE_RETRY(open("file82", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f68);
-int  t3519f70 = TEMP_FAILURE_RETRY(open("file83", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f70 = TEMP_FAILURE_RETRY(open("file83", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f70);
 t3519f68 = TEMP_FAILURE_RETRY(open("file84", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f68);
@@ -2330,12 +2341,12 @@
 t3519f70 = TEMP_FAILURE_RETRY(open("file94", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f70);
 t3519f70 = TEMP_FAILURE_RETRY(open("file95", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
-int  t3492f72 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f72 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f72, buf, 1, 0));
 close(t3492f72);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
 close(t3519f70);
-int  t3492f70 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3492f70 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3492f70, buf, 1, 0));
 close(t3492f70);
 TEMP_FAILURE_RETRY(pread(t3492f31, buf, 16, 24));
@@ -2367,15 +2378,15 @@
 close(t3519f68);
 t3519f68 = TEMP_FAILURE_RETRY(open("file109", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f68);
-int  t3519f72 = TEMP_FAILURE_RETRY(open("file110", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f72 = TEMP_FAILURE_RETRY(open("file110", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f72);
-int  t3519f80 = TEMP_FAILURE_RETRY(open("file111", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f80 = TEMP_FAILURE_RETRY(open("file111", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f80);
-int  t3519f81 = TEMP_FAILURE_RETRY(open("file112", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f81 = TEMP_FAILURE_RETRY(open("file112", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f81);
 t3519f81 = TEMP_FAILURE_RETRY(open("file113", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f81);
-int  t3519f76 = TEMP_FAILURE_RETRY(open("file114", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f76 = TEMP_FAILURE_RETRY(open("file114", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f76);
 t3519f70 = TEMP_FAILURE_RETRY(open("file115", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f70);
@@ -2383,7 +2394,7 @@
 close(t3519f70);
 t3519f70 = TEMP_FAILURE_RETRY(open("file117", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f70);
-int  t3519f67 = TEMP_FAILURE_RETRY(open("file118", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3519f67 = TEMP_FAILURE_RETRY(open("file118", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f67);
 t3519f67 = TEMP_FAILURE_RETRY(open("file119", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f67);
@@ -2396,6 +2407,7 @@
 t3519f67 = TEMP_FAILURE_RETRY(open("file123", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f67);
 t3519f67 = TEMP_FAILURE_RETRY(open("file124", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+if (!checkpoint(79)) return -1;
 close(t3519f67);
 t3519f67 = TEMP_FAILURE_RETRY(open("file125", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3519f67);
@@ -2405,8 +2417,8 @@
 close(t3519f67);
 t3519f70 = TEMP_FAILURE_RETRY(open("file128", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3519f70);
-int  t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
-int  t3519f75 = TEMP_FAILURE_RETRY(open("file128", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3519f75 = TEMP_FAILURE_RETRY(open("file128", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 close(t3526f70);
 t3526f70 = TEMP_FAILURE_RETRY(open("file129", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3519f75, buf, 2991));
@@ -2415,7 +2427,7 @@
 close(t3526f70);
 t3519f67 = TEMP_FAILURE_RETRY(open("file130", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3519f67, buf, 16384));
-int  t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f72, buf, 1, 0));
 close(t3499f72);
 TEMP_FAILURE_RETRY(read(t3519f67, buf, 16384));
@@ -2433,7 +2445,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f72, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f72));
-int  t3499f67 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f67 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f67));
 close(t3499f67);
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 12, 0));
@@ -2446,7 +2458,7 @@
 t3526f70 = TEMP_FAILURE_RETRY(open("file131", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f70, buf, 4622));
 close(t3526f70);
-int  t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f72);
 t3526f72 = TEMP_FAILURE_RETRY(open("file132", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f72, buf, 16384));
@@ -2454,10 +2466,10 @@
 close(t3526f72);
 t3526f70 = TEMP_FAILURE_RETRY(open("file133", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f70);
-int  t3526f75 = TEMP_FAILURE_RETRY(open("file133", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3526f75 = TEMP_FAILURE_RETRY(open("file133", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f75, buf, 13332));
 close(t3526f75);
-int  t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f70, buf, 1, 0));
 close(t3495f70);
 t3495f70 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2473,7 +2485,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3495f70, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3495f70));
-int  t3495f75 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3495f75 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3495f75));
 close(t3495f75);
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 12, 0));
@@ -2481,9 +2493,9 @@
 TEMP_FAILURE_RETRY(pwrite(t3495f70, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3495f70));
 close(t3495f70);
-int  t3526f93 = TEMP_FAILURE_RETRY(open("file134", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3526f93 = TEMP_FAILURE_RETRY(open("file134", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f93);
-int  t3526f88 = TEMP_FAILURE_RETRY(open("file134", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3526f88 = TEMP_FAILURE_RETRY(open("file134", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f88, buf, 15056));
 close(t3526f88);
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34433108));
@@ -2511,7 +2523,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3495f75, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3495f75, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3495f75));
-int  t3495f86 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3495f86 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3495f86));
 close(t3495f86);
 TEMP_FAILURE_RETRY(pwrite(t3495f75, buf, 12, 0));
@@ -2519,7 +2531,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3495f75, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3495f75));
 close(t3495f75);
-int  t3499f74 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f74 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f74, buf, 1, 0));
 close(t3499f74);
 t3499f74 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2535,7 +2547,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f74, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f74));
-int  t3499f75 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f75 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f75));
 close(t3499f75);
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 12, 0));
@@ -2543,18 +2555,18 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f74, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f74));
 close(t3499f74);
-int  t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f64);
 t3526f64 = TEMP_FAILURE_RETRY(open("file135", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f64, buf, 16384));
 TEMP_FAILURE_RETRY(write(t3526f64, buf, 4873));
 close(t3526f64);
-int  t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f90);
 t3526f90 = TEMP_FAILURE_RETRY(open("file136", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 4199));
 close(t3526f90);
-int  t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35511105));
@@ -2579,7 +2591,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f90));
-int  t3499f92 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f92 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f92));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35513993));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 34, 35514023));
@@ -2620,6 +2632,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f90));
 close(t3499f90);
+if (!checkpoint(82)) return -1;
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
@@ -2644,17 +2657,17 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f90));
 close(t3499f90);
-int  t3495f72 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3495f72 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f72, buf, 1, 0));
 close(t3495f72);
-int  t3499f84 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f84 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f84, buf, 1, 0));
 close(t3499f84);
 t3499f72 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4096, 516));
-int  t3495f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
+int t3495f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 4612));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4, 4616));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 4096, 4620));
@@ -2667,7 +2680,7 @@
 TEMP_FAILURE_RETRY(pread(t3499f72, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f72));
 TEMP_FAILURE_RETRY(pwrite(t3495f84, buf, 4096, 516));
-int  t3499f88 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f88 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f88));
 TEMP_FAILURE_RETRY(pwrite(t3495f84, buf, 4, 4612));
 TEMP_FAILURE_RETRY(pwrite(t3495f84, buf, 4, 4616));
@@ -2683,7 +2696,7 @@
 TEMP_FAILURE_RETRY(fdatasync(t3495f84));
 TEMP_FAILURE_RETRY(pwrite(t3499f72, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f72));
-int  t3495f88 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3495f88 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 31156572));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 58, 31156602));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3099, 31154176)); // mmap2
@@ -2698,7 +2711,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34907552));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 39, 34907582));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2551, 34906112)); // mmap2
-int  t3495f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3495f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3495f66, buf, 1, 0));
 close(t3495f66);
 t3495f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2738,7 +2751,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f66, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f66));
-int  t3499f70 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f70 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f70));
 close(t3499f70);
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 12, 0));
@@ -2746,11 +2759,11 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f66, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f66));
 close(t3499f66);
-int  t3526f66 = TEMP_FAILURE_RETRY(open("file137", O_RDONLY|O_LARGEFILE));
+int t3526f66 = TEMP_FAILURE_RETRY(open("file137", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3526f66, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3526f66, buf, 16384));
 close(t3526f66);
-int  t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f66, buf, 1, 0));
 close(t3505f66);
 t3505f66 = TEMP_FAILURE_RETRY(open("file138", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
@@ -2786,7 +2799,7 @@
 TEMP_FAILURE_RETRY(fdatasync(t3495f70));
 close(t3495f70);
 TEMP_FAILURE_RETRY(write(t3505f66, buf, 10592));
-int  t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f70);
 t3533f70 = TEMP_FAILURE_RETRY(open("file140", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3533f70, buf, 4042));
@@ -2796,7 +2809,7 @@
 t3533f70 = TEMP_FAILURE_RETRY(open("file141", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f70);
 t3526f70 = TEMP_FAILURE_RETRY(open("file142", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
-int  t3533f72 = TEMP_FAILURE_RETRY(open("file141", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3533f72 = TEMP_FAILURE_RETRY(open("file141", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 close(t3526f70);
 t3526f70 = TEMP_FAILURE_RETRY(open("file142", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f70, buf, 5057));
@@ -2838,6 +2851,7 @@
 close(t3505f66);
 t3505f66 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 512, 0));
+if (!checkpoint(85)) return -1;
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4096, 516));
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 4612));
@@ -2858,7 +2872,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 4, 25132));
 TEMP_FAILURE_RETRY(pread(t3505f66, buf, 8, 25600));
 TEMP_FAILURE_RETRY(fdatasync(t3505f66));
-int  t3505f70 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f70 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3505f70));
 close(t3505f70);
 TEMP_FAILURE_RETRY(pwrite(t3505f66, buf, 12, 0));
@@ -2923,7 +2937,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34261624));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 49, 34261654));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2993, 34258944)); // mmap2
-int  t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f91);
 t3533f91 = TEMP_FAILURE_RETRY(open("file143", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 31210525));
@@ -2932,7 +2946,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3673, 31207424)); // mmap2
 TEMP_FAILURE_RETRY(write(t3533f91, buf, 2024));
 close(t3533f91);
-int  t3499f91 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f91 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f91, buf, 1, 0));
 close(t3499f91);
 t3499f91 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2948,7 +2962,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f91, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f91, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f91));
-int  t3499f93 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f93 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f93));
 close(t3499f93);
 TEMP_FAILURE_RETRY(pwrite(t3499f91, buf, 12, 0));
@@ -2956,7 +2970,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f91, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f91));
 close(t3499f91);
-int  t3505f84 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f84 = TEMP_FAILURE_RETRY(open("file31", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f84, buf, 1, 0));
 close(t3505f84);
 t3505f84 = TEMP_FAILURE_RETRY(open("file31", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -2972,7 +2986,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3505f84, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3505f84));
-int  t3505f90 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f90 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3505f90));
 close(t3505f90);
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 12, 0));
@@ -2980,41 +2994,41 @@
 TEMP_FAILURE_RETRY(pwrite(t3505f84, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3505f84));
 close(t3505f84);
-int  t3533f102 = TEMP_FAILURE_RETRY(open("file144", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3533f102 = TEMP_FAILURE_RETRY(open("file144", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f102);
 t3533f72 = TEMP_FAILURE_RETRY(open("file144", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3533f72, buf, 5550));
 close(t3533f72);
-int  t3526f84 = TEMP_FAILURE_RETRY(open("file145", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3526f84 = TEMP_FAILURE_RETRY(open("file145", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f84);
-int  t3526f101 = TEMP_FAILURE_RETRY(open("file145", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3526f101 = TEMP_FAILURE_RETRY(open("file145", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f101, buf, 3612));
 close(t3526f101);
 t3526f90 = TEMP_FAILURE_RETRY(open("file146", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f90);
 t3526f90 = TEMP_FAILURE_RETRY(open("file146", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 5414));
-int  t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f96);
 t3533f96 = TEMP_FAILURE_RETRY(open("file147", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 close(t3526f90);
 TEMP_FAILURE_RETRY(write(t3533f96, buf, 3834));
 close(t3533f96);
-int  t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3519f90);
 t3519f90 = TEMP_FAILURE_RETRY(open("file148", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3519f90, buf, 3461));
-int  t3526f96 = TEMP_FAILURE_RETRY(open("file149", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3526f96 = TEMP_FAILURE_RETRY(open("file149", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3526f96);
 close(t3519f90);
 t3526f90 = TEMP_FAILURE_RETRY(open("file149", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 16384));
 TEMP_FAILURE_RETRY(write(t3526f90, buf, 12766));
 close(t3526f90);
-int  t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f90);
 t3533f90 = TEMP_FAILURE_RETRY(open("file150", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
-int  t3505f96 = TEMP_FAILURE_RETRY(open("file151", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3505f96 = TEMP_FAILURE_RETRY(open("file151", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 100, 0));
 TEMP_FAILURE_RETRY(write(t3533f90, buf, 10056));
 close(t3533f90);
@@ -3036,7 +3050,7 @@
 close(t3505f90);
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 16, 24));
 t3505f90 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
-int  t3533f99 = TEMP_FAILURE_RETRY(open("file153", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
+int t3533f99 = TEMP_FAILURE_RETRY(open("file153", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600));
 close(t3533f99);
 TEMP_FAILURE_RETRY(pread(t3505f90, buf, 1, 0));
 close(t3505f90);
@@ -3046,7 +3060,7 @@
 close(t3533f90);
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 4096, 16384));
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 4096, 12288));
-int  t3505f99 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f99 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f99, buf, 1, 0));
 close(t3505f99);
 TEMP_FAILURE_RETRY(pread(t3505f96, buf, 16, 24));
@@ -3066,6 +3080,7 @@
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 1, 0));
 close(t3499f90);
+if (!checkpoint(88)) return -1;
 t3499f90 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 512));
@@ -3079,7 +3094,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f90, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f90));
-int  t3499f97 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f97 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f97));
 close(t3499f97);
 TEMP_FAILURE_RETRY(pwrite(t3499f90, buf, 12, 0));
@@ -3114,7 +3129,7 @@
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34438470));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 63, 34438500));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 3681, 34435072)); // mmap2
-int  t3576f95 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3576f95 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3576f95, buf, 1, 0));
 close(t3576f95);
 t3499f92 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@@ -3136,7 +3151,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f92, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f92));
-int  t3499f95 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f95 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f95));
 close(t3499f95);
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 12, 0));
@@ -3174,7 +3189,7 @@
 t3576f95 = TEMP_FAILURE_RETRY(open("file152", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3576f95, buf, 1, 0));
 close(t3576f95);
-int  t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 1, 0));
 close(t3499f100);
 t3499f100 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -3190,7 +3205,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f100));
-int  t3499f106 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f106 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f106));
 close(t3499f106);
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 12, 0));
@@ -3217,7 +3232,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 4, 16924));
 TEMP_FAILURE_RETRY(pread(t3499f100, buf, 8, 17408));
 TEMP_FAILURE_RETRY(fdatasync(t3499f100));
-int  t3499f105 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f105 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f105));
 close(t3499f105);
 TEMP_FAILURE_RETRY(pwrite(t3499f100, buf, 12, 0));
@@ -3278,11 +3293,12 @@
 close(t3499f100);
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 35636928));
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 60, 35636958));
+if (!checkpoint(91)) return -1;
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 2062, 35635200)); // mmap2
 t3499f84 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f84, buf, 1, 0));
 close(t3499f84);
-int  t3499f27 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
+int t3499f27 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f27, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f27, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f27, buf, 4096, 516));
@@ -3360,9 +3376,9 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f92, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f92));
 close(t3499f92);
-int  t3545f92 = TEMP_FAILURE_RETRY(open("file154", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3545f92 = TEMP_FAILURE_RETRY(open("file154", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 100, 0));
-int  t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f97, buf, 1, 0));
 close(t3545f97);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 4096, 0));
@@ -3392,7 +3408,7 @@
 TEMP_FAILURE_RETRY(read(t3545f97, buf, 8));
 TEMP_FAILURE_RETRY(read(t3545f97, buf, 1));
 close(t3545f97);
-int  t3545f100 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f100 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f100, buf, 1, 0));
 close(t3545f100);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
@@ -3427,11 +3443,11 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f97));
 close(t3545f97);
-int  t3545f104 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f104 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f104, buf, 1, 0));
 close(t3545f104);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-int  t3545f29 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f29 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f29, buf, 1, 0));
 close(t3545f29);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
@@ -3460,7 +3476,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f97, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f97));
 close(t3545f97);
-int  t3575f29 = TEMP_FAILURE_RETRY(open("file16", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0));
+int t3575f29 = TEMP_FAILURE_RETRY(open("file16", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0));
 TEMP_FAILURE_RETRY(write(t3575f29, buf, 17344));
 close(t3575f29);
 t3545f97 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@@ -3496,7 +3512,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f29));
 close(t3545f29);
-int  t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f26, buf, 1, 0));
 close(t3499f26);
 t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -3514,6 +3530,7 @@
 TEMP_FAILURE_RETRY(fdatasync(t3499f26));
 t3499f97 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f97));
+if (!checkpoint(93)) return -1;
 close(t3499f97);
 TEMP_FAILURE_RETRY(pwrite(t3499f26, buf, 12, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f26));
@@ -3523,7 +3540,7 @@
 t3499f26 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f26, buf, 1, 0));
 close(t3499f26);
-int  t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
+int t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 4096, 516));
@@ -3548,7 +3565,7 @@
 TEMP_FAILURE_RETRY(pread(t3545f97, buf, 1, 0));
 close(t3545f97);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-int  t3545f90 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f90 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f90, buf, 1, 0));
 close(t3545f90);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
@@ -3594,13 +3611,13 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f29, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f29));
 close(t3545f29);
-int  t3545f84 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f84 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f84, buf, 1, 0));
 close(t3545f84);
 TEMP_FAILURE_RETRY(pread(t3545f92, buf, 16, 24));
-int  t3584f84 = TEMP_FAILURE_RETRY(open("file157", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3584f84 = TEMP_FAILURE_RETRY(open("file157", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 100, 0));
-int  t3584f90 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3584f90 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3584f90, buf, 1, 0));
 close(t3584f90);
 t3545f90 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
@@ -3619,13 +3636,13 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 4, 8720));
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 4096, 8724));
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 4, 12820));
-int  t3584f99 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3584f99 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f90, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3545f90));
 TEMP_FAILURE_RETRY(pread(t3584f99, buf, 1, 0));
 close(t3584f99);
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 16, 24));
-int  t3545f99 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f99 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3545f99));
 close(t3545f99);
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 12, 0));
@@ -3637,16 +3654,16 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f90, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f90));
 close(t3545f90);
-int  t3584f29 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3584f29 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3584f29, buf, 1, 0));
 close(t3584f29);
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 4096, 8192));
-int  t3584f27 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3584f27 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3584f27, buf, 1, 0));
 close(t3584f27);
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 16, 24));
-int  t3545f95 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3545f95 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 t3584f99 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3545f95, buf, 1, 0));
 TEMP_FAILURE_RETRY(pread(t3584f99, buf, 1, 0));
@@ -3665,7 +3682,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4, 4616));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4096, 4620));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4, 8716));
-int  t3584f95 = TEMP_FAILURE_RETRY(open("file159", O_RDONLY|O_LARGEFILE));
+int t3584f95 = TEMP_FAILURE_RETRY(open("file159", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3584f95, buf, 8));
 TEMP_FAILURE_RETRY(read(t3584f95, buf, 1));
 close(t3584f95);
@@ -3679,7 +3696,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4, 16928));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4096, 16932));
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 4, 21028));
-int  t3584f101 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3584f101 = TEMP_FAILURE_RETRY(open("file158", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3584f101, buf, 1, 0));
 close(t3584f101);
 TEMP_FAILURE_RETRY(pread(t3584f84, buf, 16, 24));
@@ -3722,7 +3739,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3545f99, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3545f99));
 close(t3545f99);
-int  t3581f99 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3581f99 = TEMP_FAILURE_RETRY(open("file155", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3581f99, buf, 1, 0));
 close(t3581f99);
 TEMP_FAILURE_RETRY(pread(t3455f17, buf, 30, 34970937));
@@ -3760,6 +3777,7 @@
 t3526f90 = TEMP_FAILURE_RETRY(open("file162", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
+if (!checkpoint(96)) return -1;
 close(t3526f90);
 t3526f90 = TEMP_FAILURE_RETRY(open("file163", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
@@ -3773,20 +3791,20 @@
 TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
 TEMP_FAILURE_RETRY(read(t3526f90, buf, 16384));
 close(t3526f90);
-int  t3586f102 = TEMP_FAILURE_RETRY(open("file166", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3586f102 = TEMP_FAILURE_RETRY(open("file166", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3586f102);
-int  t3586f97 = TEMP_FAILURE_RETRY(open("file167", O_RDONLY|O_LARGEFILE));
+int t3586f97 = TEMP_FAILURE_RETRY(open("file167", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3586f97, buf, 8192));
 TEMP_FAILURE_RETRY(read(t3586f97, buf, 8192));
 close(t3586f97);
-int  t3587f95 = TEMP_FAILURE_RETRY(open("file168", O_RDONLY|O_LARGEFILE));
+int t3587f95 = TEMP_FAILURE_RETRY(open("file168", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3587f95, buf, 16384));
 close(t3587f95);
 t3499f28 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f28, buf, 1, 0));
 close(t3499f28);
-int  t3496f28 = TEMP_FAILURE_RETRY(open("file169", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
-int  t3499f103 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
+int t3496f28 = TEMP_FAILURE_RETRY(open("file169", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600));
+int t3499f103 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
 TEMP_FAILURE_RETRY(pwrite(t3499f103, buf, 512, 0));
 TEMP_FAILURE_RETRY(pwrite(t3499f103, buf, 4, 512));
 TEMP_FAILURE_RETRY(pwrite(t3499f103, buf, 4096, 516));
@@ -3835,9 +3853,9 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f28, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f28));
 close(t3499f28);
-int  t3541f103 = TEMP_FAILURE_RETRY(open("file170", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3541f103 = TEMP_FAILURE_RETRY(open("file170", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3541f103, buf, 100, 0));
-int  t3541f105 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3541f105 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3541f105, buf, 1, 0));
 close(t3541f105);
 TEMP_FAILURE_RETRY(pread(t3541f103, buf, 4096, 0));
@@ -3864,12 +3882,12 @@
 TEMP_FAILURE_RETRY(read(t3541f105, buf, 8));
 TEMP_FAILURE_RETRY(read(t3541f105, buf, 1));
 close(t3541f105);
-int  t3541f106 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3541f106 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3541f106, buf, 1, 0));
 close(t3541f106);
 TEMP_FAILURE_RETRY(pread(t3541f103, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3541f103, buf, 4096, 20480));
-int  t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f107, buf, 1, 0));
 close(t3499f107);
 t3499f107 = TEMP_FAILURE_RETRY(open("file18", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0660));
@@ -3885,7 +3903,7 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f107, buf, 4, 12820));
 TEMP_FAILURE_RETRY(pread(t3499f107, buf, 8, 13312));
 TEMP_FAILURE_RETRY(fdatasync(t3499f107));
-int  t3499f108 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3499f108 = TEMP_FAILURE_RETRY(open("file22", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(fdatasync(t3499f108));
 close(t3499f108);
 TEMP_FAILURE_RETRY(pwrite(t3499f107, buf, 12, 0));
@@ -3917,16 +3935,16 @@
 TEMP_FAILURE_RETRY(pwrite(t3499f105, buf, 28, 0));
 TEMP_FAILURE_RETRY(fdatasync(t3499f105));
 close(t3499f105);
-int  t3505f106 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3505f106 = TEMP_FAILURE_RETRY(open("file171", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3505f106, buf, 1, 0));
 close(t3505f106);
-int  t3540f107 = TEMP_FAILURE_RETRY(open("file173", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3540f107 = TEMP_FAILURE_RETRY(open("file173", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3540f107, buf, 100, 0));
-int  t3540f108 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3540f108 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3540f108, buf, 1, 0));
 close(t3540f108);
 TEMP_FAILURE_RETRY(pread(t3540f107, buf, 4096, 0));
-int  t3540f105 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3540f105 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3540f105, buf, 1, 0));
 close(t3540f105);
 TEMP_FAILURE_RETRY(pread(t3540f107, buf, 16, 24));
@@ -3949,7 +3967,7 @@
 TEMP_FAILURE_RETRY(read(t3540f105, buf, 8));
 TEMP_FAILURE_RETRY(read(t3540f105, buf, 1));
 close(t3540f105);
-int  t3540f106 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3540f106 = TEMP_FAILURE_RETRY(open("file174", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3540f106, buf, 1, 0));
 close(t3540f106);
 TEMP_FAILURE_RETRY(pread(t3540f107, buf, 16, 24));
@@ -3963,14 +3981,14 @@
 TEMP_FAILURE_RETRY(pread(t3540f106, buf, 1, 0));
 close(t3540f106);
 TEMP_FAILURE_RETRY(pread(t3540f107, buf, 16, 24));
-int  t3496f105 = TEMP_FAILURE_RETRY(open("file176", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
+int t3496f105 = TEMP_FAILURE_RETRY(open("file176", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC));
 close(t3496f105);
 t3499f108 = TEMP_FAILURE_RETRY(open("file18", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3499f108, buf, 1, 0));
 close(t3499f108);
-int  t3597f108 = TEMP_FAILURE_RETRY(open("file177", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
+int t3597f108 = TEMP_FAILURE_RETRY(open("file177", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600));
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 100, 0));
-int  t3597f109 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3597f109 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3597f109, buf, 1, 0));
 close(t3597f109);
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 0));
@@ -3987,27 +4005,28 @@
 TEMP_FAILURE_RETRY(pread(t3597f109, buf, 1, 0));
 close(t3597f109);
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 16, 24));
-int  t3540f109 = TEMP_FAILURE_RETRY(open("file179", O_RDONLY|O_LARGEFILE));
+int t3540f109 = TEMP_FAILURE_RETRY(open("file179", O_RDONLY|O_LARGEFILE));
 TEMP_FAILURE_RETRY(read(t3540f109, buf, 4000));
-int  t3597f110 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3597f110 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3597f110, buf, 1, 0));
 close(t3597f110);
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 16, 24));
 close(t3540f109);
+if (!checkpoint(99)) return -1;
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 16384));
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 12288));
 t3597f109 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3597f109, buf, 1, 0));
 close(t3597f109);
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 16, 24));
-int  t3597f111 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3597f111 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3597f111, buf, 1, 0));
 close(t3597f111);
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 16, 24));
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 24576));
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 20480));
 TEMP_FAILURE_RETRY(pread(t3597f108, buf, 4096, 57344));
-int  t3598f111 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
+int t3598f111 = TEMP_FAILURE_RETRY(open("file178", O_RDONLY|O_LARGEFILE|O_CLOEXEC));
 TEMP_FAILURE_RETRY(pread(t3598f111, buf, 1, 0));
 close(t3598f111);
 close(t3540f107);
@@ -4054,7 +4073,7 @@
     return OK;
 }
 
-static status_t BenchmarkCreate() {
+static status_t BenchmarkCreate(std::function<bool(int)> checkpoint) {
 status_t res = 0;
 res |= CreateFile("stub", 0);
 
@@ -4069,6 +4088,7 @@
 res |= CreateFile("file76", 0);
 res |= CreateFile("file140", 4042);
 res |= CreateFile("file80", 0);
+if (!checkpoint(3)) return -1;
 res |= CreateFile("file139", 49152);
 res |= CreateFile("file50", 32768);
 res |= CreateFile("file179", 4000);
@@ -4081,6 +4101,7 @@
 res |= CreateFile("file72", 0);
 res |= CreateFile("file55", 16384);
 res |= CreateFile("file54", 39938);
+if (!checkpoint(6)) return -1;
 res |= CreateFile("file129", 3974);
 res |= CreateFile("file107", 0);
 res |= CreateFile("file95", 0);
@@ -4093,6 +4114,7 @@
 res |= CreateFile("file40", 4172);
 res |= CreateFile("file20", 1);
 res |= CreateFile("file151", 499712);
+if (!checkpoint(10)) return -1;
 res |= CreateFile("file106", 0);
 res |= CreateFile("file159", 9);
 res |= CreateFile("file47", 32768);
@@ -4105,6 +4127,7 @@
 res |= CreateFile("file148", 3461);
 res |= CreateFile("file7", 794976);
 res |= CreateFile("file68", 32768);
+if (!checkpoint(13)) return -1;
 res |= CreateFile("file109", 0);
 res |= CreateFile("file142", 5057);
 res |= CreateFile("file147", 3834);
@@ -4117,6 +4140,7 @@
 res |= CreateFile("file79", 0);
 res |= CreateFile("file65", 32768);
 res |= CreateFile("file135", 21257);
+if (!checkpoint(16)) return -1;
 res |= CreateFile("file124", 0);
 res |= CreateFile("file87", 0);
 res |= CreateFile("file64", 49152);
@@ -4129,6 +4153,7 @@
 res |= CreateFile("file163", 32768);
 res |= CreateFile("file67", 32768);
 res |= CreateFile("file155", 21512);
+if (!checkpoint(20)) return -1;
 res |= CreateFile("file156", 9);
 res |= CreateFile("file23", 28700);
 res |= CreateFile("file61", 32768);
@@ -4141,6 +4166,7 @@
 res |= CreateFile("file57", 32768);
 res |= CreateFile("file104", 0);
 res |= CreateFile("file113", 0);
+if (!checkpoint(23)) return -1;
 res |= CreateFile("file99", 0);
 res |= CreateFile("file120", 0);
 res |= CreateFile("file154", 73728);
@@ -4153,6 +4179,7 @@
 res |= CreateFile("file91", 0);
 res |= CreateFile("file158", 1);
 res |= CreateFile("file174", 1);
+if (!checkpoint(26)) return -1;
 res |= CreateFile("file48", 32768);
 res |= CreateFile("file33", 32566);
 res |= CreateFile("file83", 0);
@@ -4165,6 +4192,7 @@
 res |= CreateFile("file164", 32768);
 res |= CreateFile("file36", 192544);
 res |= CreateFile("file6", 4636);
+if (!checkpoint(30)) return -1;
 res |= CreateFile("file10", 16484);
 res |= CreateFile("file150", 10056);
 res |= CreateFile("file62", 32768);
@@ -4177,6 +4205,7 @@
 res |= CreateFile("file103", 0);
 res |= CreateFile("file26", 28676);
 res |= CreateFile("file46", 32768);
+if (!checkpoint(33)) return -1;
 res |= CreateFile("file60", 32768);
 res |= CreateFile("file162", 32768);
 res |= CreateFile("file25", 32872);
@@ -4189,6 +4218,7 @@
 res |= CreateFile("file37", 159752);
 res |= CreateFile("file73", 0);
 res |= CreateFile("file71", 32768);
+if (!checkpoint(36)) return -1;
 res |= CreateFile("file98", 0);
 res |= CreateFile("file74", 0);
 res |= CreateFile("file93", 0);
@@ -4201,6 +4231,7 @@
 res |= CreateFile("file132", 23233);
 res |= CreateFile("file92", 0);
 res |= CreateFile("file11", 0);
+if (!checkpoint(40)) return -1;
 res |= CreateFile("file86", 0);
 res |= CreateFile("file22", 0);
 res |= CreateFile("file56", 16384);
@@ -4213,6 +4244,7 @@
 res |= CreateFile("file116", 0);
 res |= CreateFile("file29", 1035);
 res |= CreateFile("file35", 118788);
+if (!checkpoint(43)) return -1;
 res |= CreateFile("file170", 24576);
 res |= CreateFile("file30", 98304);
 res |= CreateFile("file14", 0);
@@ -4225,6 +4257,7 @@
 res |= CreateFile("file134", 15056);
 res |= CreateFile("file31", 25608);
 res |= CreateFile("file97", 0);
+if (!checkpoint(46)) return -1;
 res |= CreateFile("file84", 0);
 res |= CreateFile("file114", 0);
 res |= CreateFile("file88", 0);
@@ -4237,6 +4270,7 @@
 res |= CreateFile("file169", 11354);
 res |= CreateFile("file166", 0);
 res |= CreateFile("file49", 32768);
+if (!checkpoint(50)) return -1;
 res |= CreateFile("file177", 61440);
 
 return res;
diff --git a/IdleMaint.cpp b/IdleMaint.cpp
index ed6374f..62086cd 100644
--- a/IdleMaint.cpp
+++ b/IdleMaint.cpp
@@ -17,7 +17,12 @@
 #include "IdleMaint.h"
 #include "Utils.h"
 #include "VolumeManager.h"
+#include "model/PrivateVolume.h"
 
+#include <thread>
+
+#include <android-base/chrono_utils.h>
+#include <android-base/file.h>
 #include <android-base/stringprintf.h>
 #include <android-base/logging.h>
 #include <fs_mgr.h>
@@ -31,26 +36,60 @@
 #include <sys/wait.h>
 #include <fcntl.h>
 
+using android::base::Basename;
+using android::base::ReadFileToString;
+using android::base::Realpath;
 using android::base::StringPrintf;
+using android::base::Timer;
+using android::base::WriteStringToFile;
 
 namespace android {
 namespace vold {
 
-static const char* kWakeLock = "IdleMaint";
+enum class PathTypes {
+    kMountPoint = 1,
+    kBlkDevice,
+};
 
-static void addFromVolumeManager(std::list<std::string>* paths) {
+enum class IdleMaintStats {
+    kStopped = 1,
+    kRunning,
+    kAbort,
+};
+
+static const char* kWakeLock = "IdleMaint";
+static const int DIRTY_SEGMENTS_THRESHOLD = 100;
+static const int GC_TIMEOUT_SEC = 480;
+
+static IdleMaintStats idle_maint_stat(IdleMaintStats::kStopped);
+static std::condition_variable cv_abort, cv_stop;
+static std::mutex cv_m;
+
+static void addFromVolumeManager(std::list<std::string>* paths,
+                                 PathTypes path_type) {
     VolumeManager* vm = VolumeManager::Instance();
     std::list<std::string> privateIds;
     vm->listVolumes(VolumeBase::Type::kPrivate, privateIds);
     for (const auto& id : privateIds) {
-        auto vol = vm->findVolume(id);
+        PrivateVolume* vol = static_cast<PrivateVolume*>(vm->findVolume(id).get());
         if (vol != nullptr && vol->getState() == VolumeBase::State::kMounted) {
-            paths->push_back(vol->getPath());
+            if (path_type == PathTypes::kMountPoint) {
+                paths->push_back(vol->getPath());
+            } else if (path_type == PathTypes::kBlkDevice) {
+                std::string gc_path;
+                const std::string& fs_type = vol->getFsType();
+                if (fs_type == "f2fs" &&
+                    Realpath(vol->getRawDevPath(), &gc_path)) {
+                    paths->push_back(std::string("/sys/fs/") + fs_type +
+                                     "/" + Basename(gc_path));
+                }
+            }
+
         }
     }
 }
 
-static void addFromFstab(std::list<std::string>* paths) {
+static void addFromFstab(std::list<std::string>* paths, PathTypes path_type) {
     std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
                                                                fs_mgr_free_fstab);
     struct fstab_rec *prev_rec = NULL;
@@ -79,7 +118,17 @@
             continue;
         }
 
-        paths->push_back(fstab->recs[i].mount_point);
+        if (path_type == PathTypes::kMountPoint) {
+            paths->push_back(fstab->recs[i].mount_point);
+        } else if (path_type == PathTypes::kBlkDevice) {
+            std::string gc_path;
+            if (std::string(fstab->recs[i].fs_type) == "f2fs" &&
+                Realpath(fstab->recs[i].blk_device, &gc_path)) {
+                paths->push_back(std::string("/sys/fs/") + fstab->recs[i].fs_type +
+                                 "/" + Basename(gc_path));
+            }
+        }
+
         prev_rec = &fstab->recs[i];
     }
 }
@@ -89,8 +138,8 @@
 
     // Collect both fstab and vold volumes
     std::list<std::string> paths;
-    addFromFstab(&paths);
-    addFromVolumeManager(&paths);
+    addFromFstab(&paths, PathTypes::kMountPoint);
+    addFromVolumeManager(&paths, PathTypes::kMountPoint);
 
     for (const auto& path : paths) {
         LOG(DEBUG) << "Starting trim of " << path;
@@ -138,5 +187,136 @@
     release_wake_lock(kWakeLock);
 }
 
+static bool waitForGc(const std::list<std::string>& paths) {
+    std::unique_lock<std::mutex> lk(cv_m, std::defer_lock);
+    bool stop = false, aborted = false;
+    Timer timer;
+
+    while (!stop && !aborted) {
+        stop = true;
+        for (const auto& path : paths) {
+            std::string dirty_segments;
+            if (!ReadFileToString(path + "/dirty_segments", &dirty_segments)) {
+                PLOG(WARNING) << "Reading dirty_segments failed in " << path;
+                continue;
+            }
+            if (std::stoi(dirty_segments) > DIRTY_SEGMENTS_THRESHOLD) {
+                stop = false;
+                break;
+            }
+        }
+
+        if (stop) break;
+
+        if (timer.duration() >= std::chrono::seconds(GC_TIMEOUT_SEC)) {
+            LOG(WARNING) << "GC timeout";
+            break;
+        }
+
+        lk.lock();
+        aborted = cv_abort.wait_for(lk, 10s, []{
+            return idle_maint_stat == IdleMaintStats::kAbort;});
+        lk.unlock();
+    }
+
+    return aborted;
+}
+
+static int startGc(const std::list<std::string>& paths) {
+    for (const auto& path : paths) {
+        LOG(DEBUG) << "Start GC on " << path;
+        if (!WriteStringToFile("1", path + "/gc_urgent")) {
+            PLOG(WARNING) << "Start GC failed on " << path;
+        }
+    }
+    return android::OK;
+}
+
+static int stopGc(const std::list<std::string>& paths) {
+    for (const auto& path : paths) {
+        LOG(DEBUG) << "Stop GC on " << path;
+        if (!WriteStringToFile("0", path + "/gc_urgent")) {
+            PLOG(WARNING) << "Stop GC failed on " << path;
+        }
+    }
+    return android::OK;
+}
+
+int RunIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener) {
+    std::unique_lock<std::mutex> lk(cv_m);
+    if (idle_maint_stat != IdleMaintStats::kStopped) {
+        LOG(DEBUG) << "idle maintenance is already running";
+        if (listener) {
+            android::os::PersistableBundle extras;
+            listener->onFinished(0, extras);
+        }
+        return android::OK;
+    }
+    idle_maint_stat = IdleMaintStats::kRunning;
+    lk.unlock();
+
+    LOG(DEBUG) << "idle maintenance started";
+
+    acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
+
+    std::list<std::string> paths;
+    addFromFstab(&paths, PathTypes::kBlkDevice);
+    addFromVolumeManager(&paths, PathTypes::kBlkDevice);
+
+    startGc(paths);
+
+    bool gc_aborted = waitForGc(paths);
+
+    stopGc(paths);
+
+    lk.lock();
+    idle_maint_stat = IdleMaintStats::kStopped;
+    lk.unlock();
+
+    cv_stop.notify_one();
+
+    if (!gc_aborted) {
+        Trim(nullptr);
+    }
+
+    if (listener) {
+        android::os::PersistableBundle extras;
+        listener->onFinished(0, extras);
+    }
+
+    LOG(DEBUG) << "idle maintenance completed";
+
+    release_wake_lock(kWakeLock);
+
+    return android::OK;
+}
+
+int AbortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener) {
+    acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
+
+    std::unique_lock<std::mutex> lk(cv_m);
+    if (idle_maint_stat != IdleMaintStats::kStopped) {
+        idle_maint_stat = IdleMaintStats::kAbort;
+        lk.unlock();
+        cv_abort.notify_one();
+        lk.lock();
+        LOG(DEBUG) << "aborting idle maintenance";
+        cv_stop.wait(lk, []{
+            return idle_maint_stat == IdleMaintStats::kStopped;});
+    }
+    lk.unlock();
+
+    if (listener) {
+        android::os::PersistableBundle extras;
+        listener->onFinished(0, extras);
+    }
+
+    release_wake_lock(kWakeLock);
+
+    LOG(DEBUG) << "idle maintenance stopped";
+
+    return android::OK;
+}
+
 }  // namespace vold
 }  // namespace android
diff --git a/IdleMaint.h b/IdleMaint.h
index 38dadfb..e043db4 100644
--- a/IdleMaint.h
+++ b/IdleMaint.h
@@ -23,6 +23,8 @@
 namespace vold {
 
 void Trim(const android::sp<android::os::IVoldTaskListener>& listener);
+int RunIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
+int AbortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
 
 }  // namespace vold
 }  // namespace android
diff --git a/KeyStorage.cpp b/KeyStorage.cpp
index 7e1d4a7..2f6aa1a 100644
--- a/KeyStorage.cpp
+++ b/KeyStorage.cpp
@@ -35,6 +35,7 @@
 
 #include <android-base/file.h>
 #include <android-base/logging.h>
+#include <android-base/unique_fd.h>
 
 #include <cutils/properties.h>
 
@@ -153,10 +154,29 @@
 }
 
 static bool writeStringToFile(const std::string& payload, const std::string& filename) {
-    if (!android::base::WriteStringToFile(payload, filename)) {
-        PLOG(ERROR) << "Failed to write to " << filename;
+    android::base::unique_fd fd(TEMP_FAILURE_RETRY(
+        open(filename.c_str(), O_WRONLY | O_CREAT | O_NOFOLLOW | O_TRUNC | O_CLOEXEC, 0666)));
+    if (fd == -1) {
+        PLOG(ERROR) << "Failed to open " << filename;
         return false;
     }
+    if (!android::base::WriteStringToFd(payload, fd)) {
+        PLOG(ERROR) << "Failed to write to " << filename;
+        unlink(filename.c_str());
+        return false;
+    }
+    // fsync as close won't guarantee flush data
+    // see close(2), fsync(2) and b/68901441
+    if (fsync(fd) == -1) {
+        if (errno == EROFS || errno == EINVAL) {
+            PLOG(WARNING) << "Skip fsync " << filename
+                          << " on a file system does not support synchronization";
+        } else {
+            PLOG(ERROR) << "Failed to fsync " << filename;
+            unlink(filename.c_str());
+            return false;
+        }
+    }
     return true;
 }
 
diff --git a/Keymaster.cpp b/Keymaster.cpp
index e2e21e8..e32d598 100644
--- a/Keymaster.cpp
+++ b/Keymaster.cpp
@@ -204,71 +204,83 @@
     return dev.isSecure();
 }
 
-int keymaster_create_key_for_cryptfs_scrypt(uint32_t rsa_key_size,
-                                            uint64_t rsa_exponent,
-                                            uint32_t ratelimit,
-                                            uint8_t* key_buffer,
-                                            uint32_t key_buffer_size,
-                                            uint32_t* key_out_size)
-{
-    Keymaster dev;
-    std::string key;
-    if (!dev) {
-        LOG(ERROR) << "Failed to initiate keymaster session";
-        return -1;
+static bool write_string_to_buf(const std::string& towrite, uint8_t* buffer, uint32_t buffer_size,
+                                uint32_t* out_size) {
+    if (!buffer || !out_size) {
+        LOG(ERROR) << "Missing target pointers";
+        return false;
     }
-    if (!key_buffer || !key_out_size) {
-        LOG(ERROR) << __FILE__ << ":" << __LINE__ << ":Invalid argument";
-        return -1;
+    *out_size = towrite.size();
+    if (buffer_size < towrite.size()) {
+        LOG(ERROR) << "Buffer too small " << buffer_size << " < " << towrite.size();
+        return false;
     }
+    memset(buffer, '\0', buffer_size);
+    std::copy(towrite.begin(), towrite.end(), buffer);
+    return true;
+}
+
+static AuthorizationSet keyParams(uint32_t rsa_key_size, uint64_t rsa_exponent, uint32_t ratelimit) {
+    return AuthorizationSetBuilder()
+        .Authorization(TAG_ALGORITHM, Algorithm::RSA)
+        .Authorization(TAG_KEY_SIZE, rsa_key_size)
+        .Authorization(TAG_RSA_PUBLIC_EXPONENT, rsa_exponent)
+        .Authorization(TAG_PURPOSE, KeyPurpose::SIGN)
+        .Authorization(TAG_PADDING, PaddingMode::NONE)
+        .Authorization(TAG_DIGEST, Digest::NONE)
+        .Authorization(TAG_BLOB_USAGE_REQUIREMENTS, KeyBlobUsageRequirements::STANDALONE)
+        .Authorization(TAG_NO_AUTH_REQUIRED)
+        .Authorization(TAG_MIN_SECONDS_BETWEEN_OPS, ratelimit);
+}
+
+int keymaster_create_key_for_cryptfs_scrypt(uint32_t rsa_key_size, uint64_t rsa_exponent,
+                                            uint32_t ratelimit, uint8_t* key_buffer,
+                                            uint32_t key_buffer_size, uint32_t* key_out_size) {
     if (key_out_size) {
         *key_out_size = 0;
     }
-
-    auto paramBuilder = AuthorizationSetBuilder()
-                            .Authorization(TAG_ALGORITHM, Algorithm::RSA)
-                            .Authorization(TAG_KEY_SIZE, rsa_key_size)
-                            .Authorization(TAG_RSA_PUBLIC_EXPONENT, rsa_exponent)
-                            .Authorization(TAG_PURPOSE, KeyPurpose::SIGN)
-                            .Authorization(TAG_PADDING, PaddingMode::NONE)
-                            .Authorization(TAG_DIGEST, Digest::NONE)
-                            .Authorization(TAG_BLOB_USAGE_REQUIREMENTS,
-                                    KeyBlobUsageRequirements::STANDALONE)
-                            .Authorization(TAG_NO_AUTH_REQUIRED)
-                            .Authorization(TAG_MIN_SECONDS_BETWEEN_OPS, ratelimit);
-
-    if (!dev.generateKey(paramBuilder, &key)) {
-        return -1;
-    }
-
-    if (key_out_size) {
-        *key_out_size = key.size();
-    }
-
-    if (key_buffer_size < key.size()) {
-        return -1;
-    }
-
-    std::copy(key.data(), key.data() + key.size(), key_buffer);
-    return 0;
-}
-
-int keymaster_sign_object_for_cryptfs_scrypt(const uint8_t* key_blob,
-                                             size_t key_blob_size,
-                                             uint32_t ratelimit,
-                                             const uint8_t* object,
-                                             const size_t object_size,
-                                             uint8_t** signature_buffer,
-                                             size_t* signature_buffer_size)
-{
     Keymaster dev;
     if (!dev) {
         LOG(ERROR) << "Failed to initiate keymaster session";
         return -1;
     }
+    std::string key;
+    if (!dev.generateKey(keyParams(rsa_key_size, rsa_exponent, ratelimit), &key)) return -1;
+    if (!write_string_to_buf(key, key_buffer, key_buffer_size, key_out_size)) return -1;
+    return 0;
+}
+
+int keymaster_upgrade_key_for_cryptfs_scrypt(uint32_t rsa_key_size, uint64_t rsa_exponent,
+                                             uint32_t ratelimit, const uint8_t* key_blob,
+                                             size_t key_blob_size, uint8_t* key_buffer,
+                                             uint32_t key_buffer_size, uint32_t* key_out_size) {
+    if (key_out_size) {
+        *key_out_size = 0;
+    }
+    Keymaster dev;
+    if (!dev) {
+        LOG(ERROR) << "Failed to initiate keymaster session";
+        return -1;
+    }
+    std::string old_key(reinterpret_cast<const char*>(key_blob), key_blob_size);
+    std::string new_key;
+    if (!dev.upgradeKey(old_key, keyParams(rsa_key_size, rsa_exponent, ratelimit), &new_key))
+        return -1;
+    if (!write_string_to_buf(new_key, key_buffer, key_buffer_size, key_out_size)) return -1;
+    return 0;
+}
+
+KeymasterSignResult keymaster_sign_object_for_cryptfs_scrypt(
+    const uint8_t* key_blob, size_t key_blob_size, uint32_t ratelimit, const uint8_t* object,
+    const size_t object_size, uint8_t** signature_buffer, size_t* signature_buffer_size) {
+    Keymaster dev;
+    if (!dev) {
+        LOG(ERROR) << "Failed to initiate keymaster session";
+        return KeymasterSignResult::error;
+    }
     if (!key_blob || !object || !signature_buffer || !signature_buffer_size) {
         LOG(ERROR) << __FILE__ << ":" << __LINE__ << ":Invalid argument";
-        return -1;
+        return KeymasterSignResult::error;
     }
 
     AuthorizationSet outParams;
@@ -289,28 +301,33 @@
         } else break;
     }
 
+    if (op.errorCode() == ErrorCode::KEY_REQUIRES_UPGRADE) {
+        LOG(ERROR) << "Keymaster key requires upgrade";
+        return KeymasterSignResult::upgrade;
+    }
+
     if (op.errorCode() != ErrorCode::OK) {
         LOG(ERROR) << "Error starting keymaster signature transaction: " << int32_t(op.errorCode());
-        return -1;
+        return KeymasterSignResult::error;
     }
 
     if (!op.updateCompletely(input, &output)) {
         LOG(ERROR) << "Error sending data to keymaster signature transaction: "
                    << uint32_t(op.errorCode());
-        return -1;
+        return KeymasterSignResult::error;
     }
 
     if (!op.finish(&output)) {
         LOG(ERROR) << "Error finalizing keymaster signature transaction: " << int32_t(op.errorCode());
-        return -1;
+        return KeymasterSignResult::error;
     }
 
     *signature_buffer = reinterpret_cast<uint8_t*>(malloc(output.size()));
     if (*signature_buffer == nullptr) {
         LOG(ERROR) << "Error allocation buffer for keymaster signature";
-        return -1;
+        return KeymasterSignResult::error;
     }
     *signature_buffer_size = output.size();
     std::copy(output.data(), output.data() + output.size(), *signature_buffer);
-    return 0;
+    return KeymasterSignResult::ok;
 }
diff --git a/Keymaster.h b/Keymaster.h
index 34fe59c..6ed5276 100644
--- a/Keymaster.h
+++ b/Keymaster.h
@@ -137,6 +137,14 @@
  * key.
  */
 
+/* Return values for keymaster_sign_object_for_cryptfs_scrypt */
+
+enum class KeymasterSignResult {
+    ok = 0,
+    error = -1,
+    upgrade = -2,
+};
+
 int keymaster_compatibility_cryptfs_scrypt();
 int keymaster_create_key_for_cryptfs_scrypt(uint32_t rsa_key_size,
                                             uint64_t rsa_exponent,
@@ -145,13 +153,14 @@
                                             uint32_t key_buffer_size,
                                             uint32_t* key_out_size);
 
-int keymaster_sign_object_for_cryptfs_scrypt(const uint8_t* key_blob,
-                                             size_t key_blob_size,
-                                             uint32_t ratelimit,
-                                             const uint8_t* object,
-                                             const size_t object_size,
-                                             uint8_t** signature_buffer,
-                                             size_t* signature_buffer_size);
+int keymaster_upgrade_key_for_cryptfs_scrypt(uint32_t rsa_key_size, uint64_t rsa_exponent,
+                                             uint32_t ratelimit, const uint8_t* key_blob,
+                                             size_t key_blob_size, uint8_t* key_buffer,
+                                             uint32_t key_buffer_size, uint32_t* key_out_size);
+
+KeymasterSignResult keymaster_sign_object_for_cryptfs_scrypt(
+    const uint8_t* key_blob, size_t key_blob_size, uint32_t ratelimit, const uint8_t* object,
+    const size_t object_size, uint8_t** signature_buffer, size_t* signature_buffer_size);
 
 
 #endif
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index d7a6576..9d8b990 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -285,6 +285,13 @@
     return translate(VolumeManager::Instance()->onUserStopped(userId));
 }
 
+binder::Status VoldNativeService::onSecureKeyguardStateChanged(bool isShowing) {
+    ENFORCE_UID(AID_SYSTEM);
+    ACQUIRE_LOCK;
+
+    return translate(VolumeManager::Instance()->onSecureKeyguardStateChanged(isShowing));
+}
+
 binder::Status VoldNativeService::partition(const std::string& diskId, int32_t partitionType,
         int32_t ratio) {
     ENFORCE_UID(AID_SYSTEM);
@@ -481,6 +488,28 @@
     return ok();
 }
 
+binder::Status VoldNativeService::runIdleMaint(
+        const android::sp<android::os::IVoldTaskListener>& listener) {
+    ENFORCE_UID(AID_SYSTEM);
+    ACQUIRE_LOCK;
+
+    std::thread([=]() {
+        android::vold::RunIdleMaint(listener);
+    }).detach();
+    return ok();
+}
+
+binder::Status VoldNativeService::abortIdleMaint(
+        const android::sp<android::os::IVoldTaskListener>& listener) {
+    ENFORCE_UID(AID_SYSTEM);
+    ACQUIRE_LOCK;
+
+    std::thread([=]() {
+        android::vold::AbortIdleMaint(listener);
+    }).detach();
+    return ok();
+}
+
 binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
         android::base::unique_fd* _aidl_return) {
     ENFORCE_UID(AID_SYSTEM);
diff --git a/VoldNativeService.h b/VoldNativeService.h
index 7ca72e5..1359d90 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -43,6 +43,8 @@
     binder::Status onUserStarted(int32_t userId);
     binder::Status onUserStopped(int32_t userId);
 
+    binder::Status onSecureKeyguardStateChanged(bool isShowing);
+
     binder::Status partition(const std::string& diskId, int32_t partitionType, int32_t ratio);
     binder::Status forgetPartition(const std::string& partGuid, const std::string& fsUuid);
 
@@ -66,6 +68,10 @@
 
     binder::Status fstrim(int32_t fstrimFlags,
             const android::sp<android::os::IVoldTaskListener>& listener);
+    binder::Status runIdleMaint(
+            const android::sp<android::os::IVoldTaskListener>& listener);
+    binder::Status abortIdleMaint(
+            const android::sp<android::os::IVoldTaskListener>& listener);
 
     binder::Status mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
             android::base::unique_fd* _aidl_return);
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index e078c0d..0936ed0 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -90,6 +90,9 @@
 VolumeManager::VolumeManager() {
     mDebug = false;
     mNextObbId = 0;
+    // For security reasons, assume that a secure keyguard is
+    // showing until we hear otherwise
+    mSecureKeyguardShowing = true;
 }
 
 VolumeManager::~VolumeManager() {
@@ -116,23 +119,13 @@
 
             auto disk = new android::vold::Disk("virtual", buf.st_rdev, "virtual",
                     android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
-            disk->create();
             mVirtualDisk = std::shared_ptr<android::vold::Disk>(disk);
-            mDisks.push_back(mVirtualDisk);
+            handleDiskAdded(mVirtualDisk);
         }
     } else {
         if (mVirtualDisk != nullptr) {
             dev_t device = mVirtualDisk->getDevice();
-
-            auto i = mDisks.begin();
-            while (i != mDisks.end()) {
-                if ((*i)->getDevice() == device) {
-                    (*i)->destroy();
-                    i = mDisks.erase(i);
-                } else {
-                    ++i;
-                }
-            }
+            handleDiskRemoved(device);
 
             Loop::destroyByDevice(mVirtualDiskPath.c_str());
             mVirtualDisk = nullptr;
@@ -217,8 +210,7 @@
 
                 auto disk = new android::vold::Disk(eventPath, device,
                         source->getNickname(), flags);
-                disk->create();
-                mDisks.push_back(std::shared_ptr<android::vold::Disk>(disk));
+                handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
                 break;
             }
         }
@@ -226,24 +218,11 @@
     }
     case NetlinkEvent::Action::kChange: {
         LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
-        for (const auto& disk : mDisks) {
-            if (disk->getDevice() == device) {
-                disk->readMetadata();
-                disk->readPartitions();
-            }
-        }
+        handleDiskChanged(device);
         break;
     }
     case NetlinkEvent::Action::kRemove: {
-        auto i = mDisks.begin();
-        while (i != mDisks.end()) {
-            if ((*i)->getDevice() == device) {
-                (*i)->destroy();
-                i = mDisks.erase(i);
-            } else {
-                ++i;
-            }
-        }
+        handleDiskRemoved(device);
         break;
     }
     default: {
@@ -253,6 +232,51 @@
     }
 }
 
+void VolumeManager::handleDiskAdded(const std::shared_ptr<android::vold::Disk>& disk) {
+    // For security reasons, if secure keyguard is showing, wait
+    // until the user unlocks the device to actually touch it
+    if (mSecureKeyguardShowing) {
+        LOG(INFO) << "Found disk at " << disk->getEventPath()
+                << " but delaying scan due to secure keyguard";
+        mPendingDisks.push_back(disk);
+    } else {
+        disk->create();
+        mDisks.push_back(disk);
+    }
+}
+
+void VolumeManager::handleDiskChanged(dev_t device) {
+    for (const auto& disk : mDisks) {
+        if (disk->getDevice() == device) {
+            disk->readMetadata();
+            disk->readPartitions();
+        }
+    }
+
+    // For security reasons, we ignore all pending disks, since
+    // we'll scan them once the device is unlocked
+}
+
+void VolumeManager::handleDiskRemoved(dev_t device) {
+    auto i = mDisks.begin();
+    while (i != mDisks.end()) {
+        if ((*i)->getDevice() == device) {
+            (*i)->destroy();
+            i = mDisks.erase(i);
+        } else {
+            ++i;
+        }
+    }
+    auto j = mPendingDisks.begin();
+    while (j != mPendingDisks.end()) {
+        if ((*j)->getDevice() == device) {
+            j = mPendingDisks.erase(j);
+        } else {
+            ++j;
+        }
+    }
+}
+
 void VolumeManager::addDiskSource(const std::shared_ptr<DiskSource>& diskSource) {
     std::lock_guard<std::mutex> lock(mLock);
     mDiskSources.push_back(diskSource);
@@ -367,6 +391,20 @@
     return 0;
 }
 
+int VolumeManager::onSecureKeyguardStateChanged(bool isShowing) {
+    mSecureKeyguardShowing = isShowing;
+    if (!mSecureKeyguardShowing) {
+        // Now that secure keyguard has been dismissed, process
+        // any pending disks
+        for (const auto& disk : mPendingDisks) {
+            disk->create();
+            mDisks.push_back(disk);
+        }
+        mPendingDisks.clear();
+    }
+    return 0;
+}
+
 int VolumeManager::setPrimary(const std::shared_ptr<android::vold::VolumeBase>& vol) {
     mPrimary = vol;
     for (userid_t userId : mStartedUsers) {
@@ -554,6 +592,7 @@
         disk->destroy();
     }
     mDisks.clear();
+    mPendingDisks.clear();
     android::vold::sSleepOnUnmount = true;
     return 0;
 }
diff --git a/VolumeManager.h b/VolumeManager.h
index 5baa7ce..fb455d8 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -94,6 +94,8 @@
     int onUserStarted(userid_t userId);
     int onUserStopped(userid_t userId);
 
+    int onSecureKeyguardStateChanged(bool isShowing);
+
     int setPrimary(const std::shared_ptr<android::vold::VolumeBase>& vol);
 
     int remountUid(uid_t uid, const std::string& mode);
@@ -132,6 +134,10 @@
 
     int linkPrimary(userid_t userId);
 
+    void handleDiskAdded(const std::shared_ptr<android::vold::Disk>& disk);
+    void handleDiskChanged(dev_t device);
+    void handleDiskRemoved(dev_t device);
+
     std::mutex mLock;
     std::mutex mCryptLock;
 
@@ -139,6 +145,7 @@
 
     std::list<std::shared_ptr<DiskSource>> mDiskSources;
     std::list<std::shared_ptr<android::vold::Disk>> mDisks;
+    std::list<std::shared_ptr<android::vold::Disk>> mPendingDisks;
     std::list<std::shared_ptr<android::vold::VolumeBase>> mObbVolumes;
 
     std::unordered_map<userid_t, int> mAddedUsers;
@@ -150,6 +157,7 @@
     std::shared_ptr<android::vold::VolumeBase> mPrimary;
 
     int mNextObbId;
+    bool mSecureKeyguardShowing;
 };
 
 #endif
diff --git a/bench/benchgen.py b/bench/benchgen.py
index c852169..f119804 100644
--- a/bench/benchgen.py
+++ b/bench/benchgen.py
@@ -157,6 +157,7 @@
 #include <fcntl.h>
 
 #include <algorithm>
+#include <functional>
 #include <string>
 
 #include <Utils.h>
@@ -164,7 +165,8 @@
 namespace android {
 namespace vold {
 
-static status_t BenchmarkRun() {
+static status_t BenchmarkRun(std::function<bool(int)> checkpoint) {
+
 """
 
     print >>bench, "char* buf = (char*) malloc(%d);" % (bufsize)
@@ -175,13 +177,19 @@
     events = sorted(events, key=lambda e: e.time)
     active = set()
     defined = set()
+    i = 0
+    total = len(events)
     for e in events:
+        i += 1
+        if i % 256 == 0:
+            print >>bench, "if (!checkpoint(%d)) return -1;" % (50 + ((i * 50) / total))
+
         if e.call == "openat":
             fd, f, handle = extract_file(e, e.ret)
             if f:
                 active.add(handle)
                 if handle not in defined:
-                    print >>bench, "int ",
+                    print >>bench, "int",
                     defined.add(handle)
                 create_mode = ''
                 if 'O_CREAT' in e.args[2]:
@@ -297,11 +305,17 @@
     return OK;
 }
 
-static status_t BenchmarkCreate() {
+static status_t BenchmarkCreate(std::function<bool(int)> checkpoint) {
 status_t res = 0;
 res |= CreateFile("stub", 0);
 """
+    i = 0
+    total = len(files.values())
     for f in files.values():
+        i += 1
+        if i % 12 == 0:
+            print >>bench, "if (!checkpoint(%d)) return -1;" % ((i * 50) / total)
+
         print >>bench, 'res |= CreateFile("file%s", %d);' % (f.ident, f.size)
 
     print >>bench, """
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index 5d182c9..d073be2 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -33,6 +33,8 @@
     void onUserStarted(int userId);
     void onUserStopped(int userId);
 
+    void onSecureKeyguardStateChanged(boolean isShowing);
+
     void partition(@utf8InCpp String diskId, int partitionType, int ratio);
     void forgetPartition(@utf8InCpp String partGuid, @utf8InCpp String fsUuid);
 
@@ -54,6 +56,8 @@
     void destroyObb(@utf8InCpp String volId);
 
     void fstrim(int fstrimFlags, IVoldTaskListener listener);
+    void runIdleMaint(IVoldTaskListener listener);
+    void abortIdleMaint(IVoldTaskListener listener);
 
     FileDescriptor mountAppFuse(int uid, int pid, int mountId);
     void unmountAppFuse(int uid, int pid, int mountId);
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 7302c44..af7fda3 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -96,6 +96,8 @@
 #define RETRY_MOUNT_ATTEMPTS 10
 #define RETRY_MOUNT_DELAY_SECONDS 1
 
+static int put_crypt_ftr_and_key(struct crypt_mnt_ftr* crypt_ftr);
+
 static unsigned char saved_master_key[KEY_LEN_BYTES];
 static char *saved_mount_point;
 static int  master_key_saved = 0;
@@ -120,7 +122,7 @@
             &ftr->keymaster_blob_size);
     if (rc) {
         if (ftr->keymaster_blob_size > KEYMASTER_BLOB_SIZE) {
-            SLOGE("Keymaster key blob to large)");
+            SLOGE("Keymaster key blob too large");
             ftr->keymaster_blob_size = 0;
         }
         SLOGE("Failed to generate keypair");
@@ -169,8 +171,31 @@
             SLOGE("Unknown KDF type %d", ftr->kdf_type);
             return -1;
     }
-    return keymaster_sign_object_for_cryptfs_scrypt(ftr->keymaster_blob, ftr->keymaster_blob_size,
-            KEYMASTER_CRYPTFS_RATE_LIMIT, to_sign, to_sign_size, signature, signature_size);
+    for (;;) {
+        auto result = keymaster_sign_object_for_cryptfs_scrypt(
+            ftr->keymaster_blob, ftr->keymaster_blob_size, KEYMASTER_CRYPTFS_RATE_LIMIT, to_sign,
+            to_sign_size, signature, signature_size);
+        switch (result) {
+            case KeymasterSignResult::ok:
+                return 0;
+            case KeymasterSignResult::upgrade:
+                break;
+            default:
+                return -1;
+        }
+        SLOGD("Upgrading key");
+        if (keymaster_upgrade_key_for_cryptfs_scrypt(
+                RSA_KEY_SIZE, RSA_EXPONENT, KEYMASTER_CRYPTFS_RATE_LIMIT, ftr->keymaster_blob,
+                ftr->keymaster_blob_size, ftr->keymaster_blob, KEYMASTER_BLOB_SIZE,
+                &ftr->keymaster_blob_size) != 0) {
+            SLOGE("Failed to upgrade key");
+            return -1;
+        }
+        if (put_crypt_ftr_and_key(ftr) != 0) {
+            SLOGE("Failed to write upgraded key to disk");
+        }
+        SLOGD("Key upgraded successfully");
+    }
 }
 
 /* Store password when userdata is successfully decrypted and mounted.
@@ -1925,16 +1950,19 @@
               args[0], args[1], args[2], args[3], args[4], args[5]);
     } else if (type == F2FS_FS) {
         args[0] = "/system/bin/make_f2fs";
-        args[1] = "-t";
+        args[1] = "-f";
         args[2] = "-d1";
-        args[3] = "-f";
-        args[4] = "-O encrypt";
-        args[5] = crypto_blkdev;
+        args[3] = "-O";
+        args[4] = "encrypt";
+        args[5] = "-O";
+        args[6] = "quota";
+        args[7] = crypto_blkdev;
         snprintf(size_str, sizeof(size_str), "%" PRId64, size);
-        args[6] = size_str;
-        num_args = 7;
-        SLOGI("Making empty filesystem with command %s %s %s %s %s %s %s\n",
-              args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+        args[8] = size_str;
+        num_args = 9;
+        SLOGI("Making empty filesystem with command %s %s %s %s %s %s %s %s %s\n",
+              args[0], args[1], args[2], args[3], args[4], args[5],
+              args[6], args[7], args[8]);
     } else {
         SLOGE("cryptfs_enable_wipe(): unknown filesystem type %d\n", type);
         return -1;
diff --git a/fs/F2fs.cpp b/fs/F2fs.cpp
index 0d12b07..56369d5 100644
--- a/fs/F2fs.cpp
+++ b/fs/F2fs.cpp
@@ -18,7 +18,9 @@
 #include "Utils.h"
 
 #include <android-base/logging.h>
+#include <android-base/properties.h>
 #include <android-base/stringprintf.h>
+#include <ext4_utils/ext4_crypt.h>
 
 #include <vector>
 #include <string>
@@ -72,8 +74,19 @@
 status_t Format(const std::string& source) {
     std::vector<std::string> cmd;
     cmd.push_back(kMkfsPath);
-    cmd.push_back(source);
 
+    cmd.push_back("-f");
+    cmd.push_back("-d1");
+
+    if (android::base::GetBoolProperty("vold.has_quota", false)) {
+        cmd.push_back("-O");
+        cmd.push_back("quota");
+    }
+    if (e4crypt_is_native()) {
+        cmd.push_back("-O");
+        cmd.push_back("encrypt");
+    }
+    cmd.push_back(source);
     return ForkExecvp(cmd);
 }
 
diff --git a/model/Disk.cpp b/model/Disk.cpp
index 14de74f..b42f215 100644
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -51,7 +51,8 @@
 static const char* kSgdiskToken = " \t\n";
 
 static const char* kSysfsLoopMaxMinors = "/sys/module/loop/parameters/max_part";
-static const char* kSysfsMmcMaxMinors = "/sys/module/mmcblk/parameters/perdev_minors";
+static const char* kSysfsMmcMaxMinorsDeprecated = "/sys/module/mmcblk/parameters/perdev_minors";
+static const char* kSysfsMmcMaxMinors = "/sys/module/mmc_block/parameters/perdev_minors";
 
 static const unsigned int kMajorBlockLoop = 7;
 static const unsigned int kMajorBlockScsiA = 8;
@@ -563,7 +564,8 @@
     case kMajorBlockMmc: {
         // Per Documentation/devices.txt this is dynamic
         std::string tmp;
-        if (!ReadFileToString(kSysfsMmcMaxMinors, &tmp)) {
+        if (!ReadFileToString(kSysfsMmcMaxMinors, &tmp) &&
+                !ReadFileToString(kSysfsMmcMaxMinorsDeprecated, &tmp)) {
             LOG(ERROR) << "Failed to read max minors";
             return -errno;
         }
diff --git a/model/PrivateVolume.h b/model/PrivateVolume.h
index 95b718d..9508671 100644
--- a/model/PrivateVolume.h
+++ b/model/PrivateVolume.h
@@ -39,6 +39,8 @@
 public:
     PrivateVolume(dev_t device, const std::string& keyRaw);
     virtual ~PrivateVolume();
+    const std::string& getFsType() { return mFsType; };
+    const std::string& getRawDevPath() { return mRawDevPath; };
 
 protected:
     status_t doCreate() override;
diff --git a/tests/CryptfsScryptHidlizationEquivalence_test.cpp b/tests/CryptfsScryptHidlizationEquivalence_test.cpp
index 3a6c029..2905af2 100644
--- a/tests/CryptfsScryptHidlizationEquivalence_test.cpp
+++ b/tests/CryptfsScryptHidlizationEquivalence_test.cpp
@@ -433,8 +433,11 @@
             SLOGE("Unknown KDF type %d", ftr->kdf_type);
             return -1;
     }
-    return keymaster_sign_object_for_cryptfs_scrypt(ftr->keymaster_blob, ftr->keymaster_blob_size,
-            KEYMASTER_CRYPTFS_RATE_LIMIT, to_sign, to_sign_size, signature, signature_size);
+    if (keymaster_sign_object_for_cryptfs_scrypt(
+            ftr->keymaster_blob, ftr->keymaster_blob_size, KEYMASTER_CRYPTFS_RATE_LIMIT, to_sign,
+            to_sign_size, signature, signature_size) != KeymasterSignResult::ok)
+        return -1;
+    return 0;
 }
 
 namespace android {