Merge "EncryptInplace: fsync cryptofd before reporting success" am: e244a15f34 am: 22f226245a

Original change: https://android-review.googlesource.com/c/platform/system/vold/+/1488376

Change-Id: I8e7152cce18b1ed8b5f1265c08e2abb403deef9c
diff --git a/EncryptInplace.cpp b/EncryptInplace.cpp
index 8baed78..057b3ef 100644
--- a/EncryptInplace.cpp
+++ b/EncryptInplace.cpp
@@ -345,6 +345,11 @@
 
     if (success) success &= EncryptPendingData();
 
+    if (success && fsync(cryptofd_) != 0) {
+        PLOG(ERROR) << "Error syncing " << crypto_blkdev_;
+        success = false;
+    }
+
     if (!success) {
         LOG(ERROR) << "In-place encryption of " << DescribeFilesystem() << " failed";
         return false;