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

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

Change-Id: I10ff2f5cccf00fbd3cbac93059ce7f069911e9c4
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;