Merge 930a384ea14b8c1aeee8881d63e92a8a3a090013 on remote branch

Change-Id: I43dc8c7b1891a7b3ac001541e01013a32a2865c6
diff --git a/EncryptInplace.cpp b/EncryptInplace.cpp
index 14277a4..87c59a5 100644
--- a/EncryptInplace.cpp
+++ b/EncryptInplace.cpp
@@ -205,9 +205,16 @@
         data->count = 0;
 
         for (block = 0; block < block_count; block++) {
-            int used = (aux_info.bg_desc[i].bg_flags & EXT4_BG_BLOCK_UNINIT)
-                           ? 0
-                           : bitmap_get_bit(block_bitmap, block);
+            int used;
+
+            if (aux_info.bg_desc[i].bg_flags & EXT4_BG_BLOCK_UNINIT) {
+                // In block groups with an uninitialized block bitmap, we only
+                // need to encrypt the backup superblock (if one is present).
+                used = (ext4_bg_has_super_block(i) && block < 1 + aux_info.bg_desc_blocks);
+            } else {
+                used = bitmap_get_bit(block_bitmap, block);
+            }
+
             update_progress(data, used);
             if (used) {
                 if (data->count == 0) {