From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Eric Sandeen <sandeen@redhat.com>, Jan Kara <jack@suse.cz>,
Al Viro <viro@zeniv.linux.org.uk>,
Sasha Levin <sashal@kernel.org>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 44/57] fs: avoid softlockups in s_inodes iterators
Date: Fri, 27 Dec 2019 13:02:09 -0500 [thread overview]
Message-ID: <20191227180222.7076-44-sashal@kernel.org> (raw)
In-Reply-To: <20191227180222.7076-1-sashal@kernel.org>
From: Eric Sandeen <sandeen@redhat.com>
[ Upstream commit 04646aebd30b99f2cfa0182435a2ec252fcb16d0 ]
Anything that walks all inodes on sb->s_inodes list without rescheduling
risks softlockups.
Previous efforts were made in 2 functions, see:
c27d82f fs/drop_caches.c: avoid softlockups in drop_pagecache_sb()
ac05fbb inode: don't softlockup when evicting inodes
but there hasn't been an audit of all walkers, so do that now. This
also consistently moves the cond_resched() calls to the bottom of each
loop in cases where it already exists.
One loop remains: remove_dquot_ref(), because I'm not quite sure how
to deal with that one w/o taking the i_lock.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/drop_caches.c | 2 +-
fs/inode.c | 7 +++++++
fs/notify/fsnotify.c | 1 +
fs/quota/dquot.c | 1 +
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d31b6c72b476..dc1a1d5d825b 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -35,11 +35,11 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
spin_unlock(&inode->i_lock);
spin_unlock(&sb->s_inode_list_lock);
- cond_resched();
invalidate_mapping_pages(inode->i_mapping, 0, -1);
iput(toput_inode);
toput_inode = inode;
+ cond_resched();
spin_lock(&sb->s_inode_list_lock);
}
spin_unlock(&sb->s_inode_list_lock);
diff --git a/fs/inode.c b/fs/inode.c
index 76f7535fe754..d2a700c5efce 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -656,6 +656,7 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
struct inode *inode, *next;
LIST_HEAD(dispose);
+again:
spin_lock(&sb->s_inode_list_lock);
list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
spin_lock(&inode->i_lock);
@@ -678,6 +679,12 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
inode_lru_list_del(inode);
spin_unlock(&inode->i_lock);
list_add(&inode->i_lru, &dispose);
+ if (need_resched()) {
+ spin_unlock(&sb->s_inode_list_lock);
+ cond_resched();
+ dispose_list(&dispose);
+ goto again;
+ }
}
spin_unlock(&sb->s_inode_list_lock);
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 506da82ff3f1..a308f7a7e577 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -90,6 +90,7 @@ void fsnotify_unmount_inodes(struct super_block *sb)
iput_inode = inode;
+ cond_resched();
spin_lock(&sb->s_inode_list_lock);
}
spin_unlock(&sb->s_inode_list_lock);
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 3254c90fd899..70098903b45d 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -976,6 +976,7 @@ static int add_dquot_ref(struct super_block *sb, int type)
* later.
*/
old_inode = inode;
+ cond_resched();
spin_lock(&sb->s_inode_list_lock);
}
spin_unlock(&sb->s_inode_list_lock);
--
2.20.1
next prev parent reply other threads:[~2019-12-27 18:04 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-27 18:01 [PATCH AUTOSEL 4.14 01/57] mwifiex: fix possible heap overflow in mwifiex_process_country_ie() Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 02/57] locking/spinlock/debug: Fix various data races Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 03/57] netfilter: ctnetlink: netns exit must wait for callbacks Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 04/57] mwifiex: Fix heap overflow in mmwifiex_process_tdls_action_frame() Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 05/57] libtraceevent: Fix lib installation with O= Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 06/57] x86/efi: Update e820 with reserved EFI boot services data to fix kexec breakage Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 07/57] netfilter: nf_queue: enqueue skbs with NULL dst Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 08/57] efi/gop: Return EFI_NOT_FOUND if there are no usable GOPs Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 09/57] efi/gop: Return EFI_SUCCESS if a usable GOP was found Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 10/57] efi/gop: Fix memory leak in __gop_query32/64() Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 11/57] ARM: vexpress: Set-up shared OPP table instead of individual for each CPU Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 12/57] netfilter: uapi: Avoid undefined left-shift in xt_sctp.h Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 13/57] netfilter: nf_tables: validate NFT_SET_ELEM_INTERVAL_END Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 14/57] netfilter: bridge: make sure to pull arp header in br_nf_forward_arp() Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 15/57] ARM: dts: Cygnus: Fix MDIO node address/size cells Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 16/57] spi: spi-cavium-thunderx: Add missing pci_release_regions() Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 17/57] af_packet: set defaule value for tmo Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 18/57] fjes: fix missed check in fjes_acpi_add Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 19/57] ASoC: topology: Check return value for soc_tplg_pcm_create() Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 20/57] ARM: dts: bcm283x: Fix critical trip point Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 21/57] net: ena: fix napi handler misbehavior when the napi budget is zero Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 22/57] bpf, mips: Limit to 33 tail calls Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 23/57] ARM: dts: am437x-gp/epos-evm: fix panel compatible Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 24/57] samples: bpf: Replace symbol compare of trace_event Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 25/57] samples: bpf: fix syscall_tp due to unused syscall Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 26/57] tty: serial: msm_serial: Fix lockup for sysrq and oops Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 27/57] net: usb: lan78xx: Fix suspend/resume PHY register access error Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 28/57] qede: Fix multicast mac configuration Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 29/57] powerpc: Ensure that swiotlb buffer is allocated from low memory Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 30/57] 6pack,mkiss: fix possible deadlock Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 31/57] bnx2x: Do not handle requests from VFs after parity Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 32/57] bnx2x: Fix logic to get total no. of PFs per engine Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 33/57] bonding: fix active-backup transition after link failure Sasha Levin
2019-12-27 18:01 ` [PATCH AUTOSEL 4.14 34/57] gtp: do not allow adding duplicate tid and ms_addr pdp context Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 35/57] gtp: fix wrong condition in gtp_genl_dump_pdp() Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 36/57] gtp: avoid zero size hashtable Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 37/57] net: usb: lan78xx: Fix error message format specifier Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 38/57] rfkill: Fix incorrect check to avoid NULL pointer dereference Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 39/57] ASoC: wm8962: fix lambda value Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 40/57] regulator: rn5t618: fix module aliases Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 41/57] kconfig: don't crash on NULL expressions in expr_eq() Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 42/57] perf/x86/intel/bts: Fix the use of page_private() Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 43/57] perf/x86/intel: Fix PT PMI handling Sasha Levin
2019-12-27 18:02 ` Sasha Levin [this message]
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 45/57] net: qlogic: Fix error paths in ql_alloc_large_buffers() Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 46/57] net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive() Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 47/57] net: stmmac: Do not accept invalid MTU values Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 48/57] net: stmmac: RX buffer size must be 16 byte aligned Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 49/57] net, sysctl: Fix compiler warning when only cBPF is present Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 50/57] s390/dasd/cio: Interpret ccw_device_get_mdc return value correctly Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 51/57] s390/dasd: fix memleak in path handling error case Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 52/57] block: fix memleak when __blk_rq_map_user_iov() is failed Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 53/57] parisc: Fix compiler warnings in debug_core.c Sasha Levin
2019-12-27 18:02 ` [PATCH AUTOSEL 4.14 54/57] net: hisilicon: Fix a BUG trigered by wrong bytes_compl Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191227180222.7076-44-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).