diff options
author | Ken Sumrall | 2012-07-23 21:34:00 -0500 |
---|---|---|
committer | Ken Sumrall | 2012-07-24 19:24:04 -0500 |
commit | 5dc5bfefa078f2aded34f85db4613ba91ad49b76 (patch) | |
tree | a3cae17e8b3a7ca70cf1a25735d478e6936fda66 | |
parent | 55b763ff7b779d7ee91f245e0887332db8782afe (diff) | |
download | platform-system-core-5dc5bfefa078f2aded34f85db4613ba91ad49b76.tar.gz platform-system-core-5dc5bfefa078f2aded34f85db4613ba91ad49b76.tar.xz platform-system-core-5dc5bfefa078f2aded34f85db4613ba91ad49b76.zip |
Mount/unmount filesystems before running e2fsckandroid-cts-4.1_r2
This works around a performance problem in the firmware of
some emmc chips.
Change-Id: Ia414b4604d11e47ce9cb3f86ac82602e081bb09e
-rw-r--r-- | fs_mgr/fs_mgr.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c index 0361ab8bc..60aed4237 100644 --- a/fs_mgr/fs_mgr.c +++ b/fs_mgr/fs_mgr.c | |||
@@ -358,13 +358,34 @@ static void free_fstab(struct fstab_rec *fstab) | |||
358 | free(fstab); | 358 | free(fstab); |
359 | } | 359 | } |
360 | 360 | ||
361 | static void check_fs(char *blk_dev, char *type) | 361 | static void check_fs(char *blk_dev, char *type, char *target) |
362 | { | 362 | { |
363 | pid_t pid; | 363 | pid_t pid; |
364 | int status; | 364 | int status; |
365 | int ret; | ||
366 | long tmpmnt_flags = MS_NOATIME | MS_NOEXEC | MS_NOSUID; | ||
367 | char *tmpmnt_opts = "nomblk_io_submit,errors=remount-ro"; | ||
365 | 368 | ||
366 | /* Check for the types of filesystems we know how to check */ | 369 | /* Check for the types of filesystems we know how to check */ |
367 | if (!strcmp(type, "ext2") || !strcmp(type, "ext3") || !strcmp(type, "ext4")) { | 370 | if (!strcmp(type, "ext2") || !strcmp(type, "ext3") || !strcmp(type, "ext4")) { |
371 | /* | ||
372 | * First try to mount and unmount the filesystem. We do this because | ||
373 | * the kernel is more efficient than e2fsck in running the journal and | ||
374 | * processing orphaned inodes, and on at least one device with a | ||
375 | * performance issue in the emmc firmware, it can take e2fsck 2.5 minutes | ||
376 | * to do what the kernel does in about a second. | ||
377 | * | ||
378 | * After mounting and unmounting the filesystem, run e2fsck, and if an | ||
379 | * error is recorded in the filesystem superblock, e2fsck will do a full | ||
380 | * check. Otherwise, it does nothing. If the kernel cannot mount the | ||
381 | * filesytsem due to an error, e2fsck is still run to do a full check | ||
382 | * fix the filesystem. | ||
383 | */ | ||
384 | ret = mount(blk_dev, target, type, tmpmnt_flags, tmpmnt_opts); | ||
385 | if (! ret) { | ||
386 | umount(target); | ||
387 | } | ||
388 | |||
368 | INFO("Running %s on %s\n", E2FSCK_BIN, blk_dev); | 389 | INFO("Running %s on %s\n", E2FSCK_BIN, blk_dev); |
369 | pid = fork(); | 390 | pid = fork(); |
370 | if (pid > 0) { | 391 | if (pid > 0) { |
@@ -434,7 +455,7 @@ int fs_mgr_mount_all(char *fstab_file) | |||
434 | } | 455 | } |
435 | 456 | ||
436 | if (fstab[i].fs_mgr_flags & MF_CHECK) { | 457 | if (fstab[i].fs_mgr_flags & MF_CHECK) { |
437 | check_fs(fstab[i].blk_dev, fstab[i].type); | 458 | check_fs(fstab[i].blk_dev, fstab[i].type, fstab[i].mnt_point); |
438 | } | 459 | } |
439 | 460 | ||
440 | mret = mount(fstab[i].blk_dev, fstab[i].mnt_point, fstab[i].type, | 461 | mret = mount(fstab[i].blk_dev, fstab[i].mnt_point, fstab[i].type, |
@@ -500,7 +521,7 @@ int fs_mgr_do_mount(char *fstab_file, char *n_name, char *n_blk_dev, char *tmp_m | |||
500 | } | 521 | } |
501 | 522 | ||
502 | if (fstab[i].fs_mgr_flags & MF_CHECK) { | 523 | if (fstab[i].fs_mgr_flags & MF_CHECK) { |
503 | check_fs(fstab[i].blk_dev, fstab[i].type); | 524 | check_fs(fstab[i].blk_dev, fstab[i].type, fstab[i].mnt_point); |
504 | } | 525 | } |
505 | 526 | ||
506 | /* Now mount it where requested */ | 527 | /* Now mount it where requested */ |