linux/fs
Amir Goldstein 3cd879a2e4 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>
(cherry picked from commit 334cc257d864f112b64fb885be908e6cdd644c08)
2015-10-27 16:36:15 +08:00
..
9p 9p: don't leave a half-initialized inode sitting around 2015-08-03 09:29:47 -07:00
adfs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
affs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
afs rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
autofs4 move d_rcu from overlapping d_child to overlapping d_alias 2015-04-29 10:34:00 +02:00
befs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
bfs fs: Limit sys_mount to only request filesystem modules. 2013-03-03 19:36:31 -08:00
btrfs This is the 3.10.92 stable release 2015-10-27 14:09:58 +08:00
cachefiles lift sb_start_write() out of ->write() 2013-04-09 14:12:56 -04:00
ceph move d_rcu from overlapping d_child to overlapping d_alias 2015-04-29 10:34:00 +02:00
cifs This is the 3.10.92 stable release 2015-10-27 14:09:58 +08:00
coda Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
configfs configfs: fix race between dentry put and lookup 2013-11-29 11:11:53 -08:00
cramfs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
debugfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
devpts Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
dlm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
ecryptfs Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
efivarfs efivarfs: Never return ENOENT from firmware again 2013-05-13 20:12:10 +01:00
efs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
exofs ore: Fix wrong math in allocation of per device BIO 2014-02-13 13:48:00 -08:00
exportfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
ext2 Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
ext3 Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
ext4 Merge tag 'lsk-v3.10-15.09-android' 2015-09-28 19:16:34 +08:00
f2fs lsk-v3.10-15.03-android release 2015-04-02 09:25:21 +08:00
fat fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
freevxfs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
fscache fs/fscache/stats.c: fix memory leak 2013-04-29 15:54:27 -07:00
fuse Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-08-14 09:55:00 -07:00
gfs2 Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
hfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-10-14 13:41:57 -07:00
hfsplus Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-10-14 13:41:57 -07:00
hostfs hostfs: use kmalloc instead of kzalloc 2013-05-04 15:48:45 -04:00
hpfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-10-14 13:41:57 -07:00
hppfs rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
hugetlbfs cope with potentially long ->d_dname() output for shmem/hugetlb 2014-04-23 17:03:01 -07:00
isofs isofs: Fix unchecked printing of ER records 2015-01-08 09:58:15 -08:00
jbd rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
jbd2 jbd2: fix ocfs2 corrupt when updating journal superblock fails 2015-08-03 09:29:43 -07:00
jffs2 Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
jfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
lockd LOCKD: Fix a race when initialising nlmsvc_timeout 2015-01-27 07:52:33 -08:00
logfs block: Remove bi_idx references 2013-03-23 14:15:31 -07:00
minix fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
ncpfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
nfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-10-14 13:41:57 -07:00
nfs_common nfs_common: Update the translation between nfsv3 acls linux posix acls 2013-02-13 06:15:14 -08:00
nfsd Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
nilfs2 Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-21 10:02:28 +08:00
nls rk: temp revert rk change 2013-11-08 21:33:42 +08:00
notify fsnotify: fix oops in fsnotify_clear_marks_by_group_flags() 2015-08-16 20:51:35 -07:00
ntfs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
ocfs2 Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-09-14 14:16:21 -07:00
omfs fs, omfs: add NULL terminator in the end up the token list 2015-06-05 23:19:54 -07:00
openpromfs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
proc Merge tag 'lsk-v3.10-15.05-android' into develop-3.10 2015-06-02 11:25:34 +08:00
pstore pstore: pmsg: return -ENOMEM on vmalloc failure 2015-10-27 16:36:01 +08:00
qnx4 fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
qnx6 fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
quota quota: provide interface for readding allocated space into reserved space 2015-01-29 17:40:57 -08:00
ramfs rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
reiserfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-05-12 15:18:24 +08:00
romfs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
squashfs Squashfs: Add LZ4 compression configuration option 2015-03-04 11:27:29 -08:00
sysfs sysfs: add sysfs_create/remove_groups() 2015-09-01 11:11:27 +08:00
sysv Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
ubifs Merge branch 'linaro-android-3.10-lsk' of 2015-03-16 15:52:47 +08:00
udf This is the 3.10.92 stable release 2015-10-27 14:09:58 +08:00
ufs fs: push sync_filesystem() down to the file system's remount_fs() 2015-03-04 11:26:46 -08:00
xfs Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-08-14 09:55:00 -07:00
aio.c aio: fix kernel memory disclosure in io_getevents() introduced in v3.10 2014-06-30 20:09:45 -07:00
anon_inodes.c get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero 2013-02-26 02:46:11 -05:00
attr.c fs,userns: Change inode_capable to capable_wrt_inode_uidgid 2014-06-16 13:42:52 -07:00
bad_inode.c
binfmt_aout.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
binfmt_elf_fdpic.c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2013-05-02 10:16:16 -07:00
binfmt_elf.c fs/binfmt_elf.c:load_elf_binary(): return -EINVAL on zero-length mappings 2015-06-05 23:20:00 -07:00
binfmt_em86.c
binfmt_flat.c new helper: read_code() 2013-04-29 15:40:23 -04:00
binfmt_misc.c rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
binfmt_script.c rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
binfmt_som.c
bio-integrity.c bio-integrity: Fix bio_integrity_verify segment start bug 2014-03-23 21:38:21 -07:00
bio.c block: Fix bio_copy_data() 2013-10-05 07:13:09 -07:00
block_dev.c direct-io: only inc/dec inode->i_dio_count for file systems 2015-07-10 13:17:35 +08:00
buffer.c vfs: fix data corruption when blocksize < pagesize for mmaped data 2014-11-14 08:47:54 -08:00
char_dev.c
compat_binfmt_elf.c binfmt_elf: add ELF_HWCAP2 to compat auxv entries 2014-09-11 17:21:24 +00:00
compat_ioctl.c rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
compat.c [readdir] constify ->actor 2015-03-04 11:19:34 -08:00
coredump.c fs: if a coredump already exists, unlink and recreate with O_EXCL 2015-10-01 12:07:32 +02:00
coredump.h
dcache.c dcache: Handle escaped paths in prepend_path 2015-10-22 14:37:52 -07:00
dcookies.c fs/compat: fix lookup_dcookie() parameter handling 2014-02-13 13:48:00 -08:00
direct-io.c direct-io: only inc/dec inode->i_dio_count for file systems 2015-07-10 13:17:35 +08:00
drop_caches.c
eventfd.c
eventpoll.c epoll: drop EPOLLWAKEUP if PM_SLEEP is disabled 2013-11-25 11:05:09 -08:00
exec.c Merge branch 'linux-linaro-lsk-v3.10' into linux-linaro-lsk-v3.10-android 2015-08-14 09:55:00 -07:00
fcntl.c new helper: file_inode(file) 2013-02-22 23:31:31 -05:00
fhandle.c vfs: read file_handle only once in handle_to_path 2015-06-05 23:20:00 -07:00
file_table.c get rid of s_files and files_lock 2015-07-03 19:48:08 -07:00
file.c fs/file.c:fdtable: avoid triggering OOMs from alloc_fdmem 2014-02-22 12:41:25 -08:00
filesystems.c fs: Limit sys_mount to only request filesystem modules. 2013-03-03 19:36:31 -08:00
fs_struct.c constify path_get/path_put and fs_struct.c stuff 2013-03-01 23:51:07 -05:00
fs-writeback.c Merge branch 'linux-linaro-lsk' into linux-linaro-lsk-android 2015-01-16 22:07:03 +00:00
generic_acl.c
inode.c Merge tag 'lsk-v3.10-15.09-android' 2015-09-28 19:16:34 +08:00
internal.h get rid of s_files and files_lock 2015-07-03 19:48:08 -07:00
ioctl.c new helper: file_inode(file) 2013-02-22 23:31:31 -05:00
ioprio.c block: Fix computation of merged request priority 2014-11-21 09:22:53 -08:00
Kconfig rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
Kconfig.binfmt fs: make binfmt support for #! scripts modular and removable 2013-04-30 17:04:04 -07:00
libfs.c move d_rcu from overlapping d_child to overlapping d_alias 2015-04-29 10:34:00 +02:00
locks.c locks: allow __break_lease to sleep even when break_time is 0 2014-05-13 13:59:44 +02:00
Makefile rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
mbcache.c
mount.h vfs: Is mounted should be testing mnt_ns for NULL or error. 2014-02-06 11:08:16 -08:00
mpage.c
namei.c vfs: Test for and handle paths that are unreachable from their mnt_root 2015-10-22 14:37:52 -07:00
namespace.c umount: Disallow unprivileged mount force 2015-01-08 09:58:16 -08:00
no-block.c
open.c get rid of s_files and files_lock 2015-07-03 19:48:08 -07:00
pipe.c pipe: iovec: Fix memory corruption when retrying atomic copy as non-atomic 2015-06-29 12:08:34 -07:00
pnode.c vfs: Fix invalid ida_remove() call 2013-05-31 15:16:33 -04:00
pnode.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
posix_acl.c posix_acl: handle NULL ACL in posix_acl_equiv_mode 2014-06-07 13:25:33 -07:00
proc_namespace.c
read_write.c fs/compat: fix parameter handling for compat readv/writev syscalls 2014-02-13 13:48:00 -08:00
readdir.c [readdir] constify ->actor 2015-03-04 11:19:34 -08:00
select.c select: use freezable blocking call 2013-07-01 15:45:28 -07:00
seq_file.c Merge remote-tracking branch 'lsk/v3.10/topic/aosp' into linux-linaro-lsk-android 2014-09-08 12:05:48 +01:00
signalfd.c signalfd: fix information leak in signalfd_copyinfo 2015-08-16 20:51:42 -07:00
splice.c splice: Apply generic position and size checks to each write 2015-04-29 10:33:57 +02:00
stack.c
stat.c quota: provide interface for readding allocated space into reserved space 2015-01-29 17:40:57 -08:00
statfs.c rk: revert 20f3d0b+v3.0.66 to v3.0 2013-11-08 21:34:05 +08:00
super.c sysrq: Emergency Remount R/O in reverse order 2015-10-27 16:36:15 +08:00
sync.c teach SYSCALL_DEFINE<n> how to deal with long long/unsigned long long 2013-03-03 22:46:22 -05:00
timerfd.c timerfd: support CLOCK_BOOTTIME clock 2013-12-13 23:04:58 +00:00
utimes.c
xattr_acl.c
xattr.c