Skip to content

Commit a22e74c

Browse files
Treehugger RobotGerrit Code Review
Treehugger Robot
authored and
Gerrit Code Review
committed
Merge "fs_mgr: overlayfs: check if scratch device is ext4 dedupe"
2 parents 949f453 + 93ce58d commit a22e74c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

fs_mgr/fs_mgr_overlayfs.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,15 +809,26 @@ bool fs_mgr_overlayfs_mount_scratch(const std::string& device_path, const std::s
809809
entry.fs_type = mnt_type;
810810
if ((mnt_type == "f2fs") && !f2fs) entry.fs_type = "ext4";
811811
if ((mnt_type == "ext4") && !ext4) entry.fs_type = "f2fs";
812-
entry.flags = MS_NOATIME;
813-
if (readonly) {
814-
entry.flags |= MS_RDONLY;
815-
} else {
812+
entry.flags = MS_NOATIME | MS_RDONLY;
813+
auto mounted = true;
814+
if (!readonly) {
815+
if (entry.fs_type == "ext4") {
816+
// check if ext4 de-dupe
817+
entry.flags |= MS_RDONLY;
818+
auto save_errno = errno;
819+
mounted = fs_mgr_do_mount_one(entry) == 0;
820+
if (mounted) {
821+
mounted = !fs_mgr_has_shared_blocks(entry.mount_point, entry.blk_device);
822+
fs_mgr_overlayfs_umount_scratch();
823+
}
824+
errno = save_errno;
825+
}
826+
entry.flags &= ~MS_RDONLY;
816827
fs_mgr_set_blk_ro(device_path, false);
817828
}
818829
entry.fs_mgr_flags.check = true;
819830
auto save_errno = errno;
820-
auto mounted = fs_mgr_do_mount_one(entry) == 0;
831+
if (mounted) mounted = fs_mgr_do_mount_one(entry) == 0;
821832
if (!mounted) {
822833
if ((entry.fs_type == "f2fs") && ext4) {
823834
entry.fs_type = "ext4";

0 commit comments

Comments
 (0)