fs/drop_caches.c: avoid softlockups in drop_pagecache_sb()
commit9c72acbe4940e1a542336daf9be2ca6493788e67
authorJan Kara <jack@suse.cz>
Fri, 1 Feb 2019 22:21:23 +0000 (1 14:21 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:03:18 +0000 (13 14:03 -0700)
tree6e137be0ed7635021c75b1e073ba37dc102e51b8
parent8d5b25551442ea58b129fb9a0a1c439894ceec0f
fs/drop_caches.c: avoid softlockups in drop_pagecache_sb()

[ Upstream commit c27d82f52f75fc9d8d9d40d120d2a96fdeeada5e ]

When superblock has lots of inodes without any pagecache (like is the
case for /proc), drop_pagecache_sb() will iterate through all of them
without dropping sb->s_inode_list_lock which can lead to softlockups
(one of our customers hit this).

Fix the problem by going to the slow path and doing cond_resched() in
case the process needs rescheduling.

Link: http://lkml.kernel.org/r/20190114085343.15011-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/drop_caches.c