aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Goldstein <amir@cellrox.com>2014-08-04 19:29:32 +0300
committerRom Lemarchand <romlem@google.com>2015-08-20 19:06:44 -0700
commitb54e887e201ff194c3561949cad5a5557ce85069 (patch)
tree51c7365bafdf7bafb1cb747a871e7206a9b35969
parent2f6805e0d78d0575da74a7386e50de3c5eda39e9 (diff)
sysrq: Emergency Remount R/O in reverse order
This change fixes a problem where reboot on Android panics the kernel almost every time when file systems are mounted over loop devices. Android reboot command does: - sync - echo u > /proc/sysrq-trigger - syscall_reboot The problem is with sysrq emergency remount R/O trying to remount-ro in wrong order. since /data is re-mounted ro before loop devices, loop device remount-ro fails to flush the journal and panics the kernel: EXT4-fs (loop0): Remounting filesystem read-only EXT4-fs (loop0): previous I/O error to superblock detected loop: Write error at byte offset 0, length 4096. Buffer I/O error on device loop0, logical block 0 lost page write due to I/O error on loop0 Kernel panic - not syncing: EXT4-fs panic from previous error The fix is quite simple. In do_emergency_remount(), use list_for_each_entry_reverse() on sb list instead of list_for_each_entry(). It makes a lot of sense to umount the file systems in reverse order in which they were added to sb list. Change-Id: I4370e39b5873bd16ade5d5f9ddb2704beb02a2bb Signed-off-by: Amir Goldstein <amir@cellrox.com> Acked-by: Oren Laadan <orenl@cellrox.com>
-rw-r--r--fs/super.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/super.c b/fs/super.c
index 80d5cf2ca765..2e69def2167a 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -758,7 +758,7 @@ static void do_emergency_remount(struct work_struct *work)
struct super_block *sb, *p = NULL;
spin_lock(&sb_lock);
- list_for_each_entry(sb, &super_blocks, s_list) {
+ list_for_each_entry_reverse(sb, &super_blocks, s_list) {
if (hlist_unhashed(&sb->s_instances))
continue;
sb->s_count++;