summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2015-02-05 16:02:42 -0800
committerNick Kralevich <nnk@google.com>2015-02-05 20:50:22 -0800
commit7294eb6cae4b201c481b2a171d042c56b810b8b3 (patch)
treefb5e6bc18315e187ddc2c4035ee47db74d38d4ed
parentf52338fe1e8f74123a895db591d6a2a53061a2b1 (diff)
downloadsystem_core-7294eb6cae4b201c481b2a171d042c56b810b8b3.zip
system_core-7294eb6cae4b201c481b2a171d042c56b810b8b3.tar.gz
system_core-7294eb6cae4b201c481b2a171d042c56b810b8b3.tar.bz2
fs_mgr: error check umount calls / add retry logic
Don't silently ignore umount errors. At a minimum, log them. Add strerror(errno) to another umount call, to make sure we get some actionable data. check_fs: try 5 times umounting the filesystem. It appears that the umount is failing, perhaps because some service is opening the file on the device or other error. Try unmounting it multiple times in case it's a transient problem and we can recover. Bug: 19199624 Bug: 19156134 Change-Id: I7213eb52d55116fb2419a36494d26d5e159981a7
-rw-r--r--fs_mgr/fs_mgr.c16
-rw-r--r--fs_mgr/fs_mgr_priv.h1
2 files changed, 14 insertions, 3 deletions
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c
index fa52d16..a1391e0 100644
--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -119,7 +119,17 @@ static void check_fs(char *blk_device, char *fs_type, char *target)
ret = mount(blk_device, target, fs_type, tmpmnt_flags, tmpmnt_opts);
INFO("%s(): mount(%s,%s,%s)=%d\n", __func__, blk_device, target, fs_type, ret);
if (!ret) {
- umount(target);
+ int i;
+ for (i = 0; i < 5; i++) {
+ // Try to umount 5 times before continuing on.
+ // Should we try rebooting if all attempts fail?
+ int result = umount(target);
+ if (result == 0) {
+ break;
+ }
+ ERROR("%s(): umount(%s)=%d: %s\n", __func__, target, result, strerror(errno));
+ sleep(1);
+ }
}
/*
@@ -488,8 +498,8 @@ int fs_mgr_mount_all(struct fstab *fstab)
encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
}
} else {
- INFO("Could not umount %s - allow continue unencrypted\n",
- fstab->recs[attempted_idx].mount_point);
+ WARNING("Could not umount %s (%s) - allow continue unencrypted\n",
+ fstab->recs[attempted_idx].mount_point, strerror(errno));
continue;
}
}
diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h
index 34938fa..4ba6f92 100644
--- a/fs_mgr/fs_mgr_priv.h
+++ b/fs_mgr/fs_mgr_priv.h
@@ -21,6 +21,7 @@
#include <fs_mgr.h>
#define INFO(x...) KLOG_INFO("fs_mgr", x)
+#define WARNING(x...) KLOG_WARNING("fs_mgr", x)
#define ERROR(x...) KLOG_ERROR("fs_mgr", x)
#define CRYPTO_TMPFS_OPTIONS "size=256m,mode=0771,uid=1000,gid=1000"