Skip to content

Commit 93ce58d

Browse files
author
Mark Salyzyn
committed
fs_mgr: overlayfs: check if scratch device is ext4 dedupe
Do not attempt to mount scratch r/w if it is ext4 dedupe, this causes too much noise and troubling but innocuous error reports. Assumption is we normally try f2fs first on all devices, we only try ext4 first if we do not have f2fs tools, or if the existing filesystem is ext4. That said, we only have to check if it is ext4 dedupe during the first mount attempt, the fallback mount attempt for ext4 is unlikely to need this checking. Changes the output report for a retrofit DAP device from: $ adb remount Disabling verity for /system [libfs_mgr]superblock s_max_mnt_count:65535,/dev/block/by-name/system_b [libfs_mgr]check_fs(): mount(/dev/block/by-name/system_b,/mnt/scratch,ext4)=-1: Invalid argument [libfs_mgr]Running /system/bin/e2fsck on /dev/block/sda6 [libfs_mgr]__mount(source=/dev/block/by-name/system_b,target=/mnt/scratch,type=ext4)=-1: Invalid argument [libfs_mgr]Running /system/bin/fsck.f2fs -a /dev/block/sda6 [libfs_mgr]__mount(source=/dev/block/by-name/system_b,target=/mnt/scratch,type=f2fs)=0: Success Using overlayfs for /system . . . To the more pleasant: $ adb $BL1 remount Disabling verity for /system [libfs_mgr]superblock s_max_mnt_count:65535,/dev/block/by-name/system_b [libfs_mgr]__mount(source=/dev/block/by-name/system_b,target=/mnt/scratch,type=ext4)=0: Success [libfs_mgr]umount(/mnt/scratch) [libfs_mgr]Running /system/bin/fsck.f2fs -a /dev/block/sda6 [libfs_mgr]__mount(source=/dev/block/by-name/system_b,target=/mnt/scratch,type=f2fs)=0: Success Using overlayfs for /system . . . Signed-off-by: Mark Salyzyn <[email protected]> Test: adb-remount-test.sh Change-Id: Ic8c642912b1bafe0b4210c69c99a1d89fa20f204
1 parent c9a69b1 commit 93ce58d

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)