diff options
author | Jan Kara <jack@suse.cz> | 2012-11-26 19:29:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-26 20:41:24 -0500 |
commit | 4eff96dd5283a102e0c1cac95247090be74a38ed (patch) | |
tree | f874a34c9048a35639c1597150d7984bd0f5c152 /fs/fs-writeback.c | |
parent | 50694c28f1e1dbea18272980d265742a5027fb63 (diff) |
writeback: put unused inodes to LRU after writeback completion
Commit 169ebd90131b ("writeback: Avoid iput() from flusher thread")
removed iget-iput pair from inode writeback. As a side effect, inodes
that are dirty during iput_final() call won't be ever added to inode LRU
(iput_final() doesn't add dirty inodes to LRU and later when the inode
is cleaned there's noone to add the inode there). Thus inodes are
effectively unreclaimable until someone looks them up again.
The practical effect of this bug is limited by the fact that inodes are
pinned by a dentry for long enough that the inode gets cleaned. But
still the bug can have nasty consequences leading up to OOM conditions
under certain circumstances. Following can easily reproduce the
problem:
for (( i = 0; i < 1000; i++ )); do
mkdir $i
for (( j = 0; j < 1000; j++ )); do
touch $i/$j
echo 2 > /proc/sys/vm/drop_caches
done
done
then one needs to run 'sync; ls -lR' to make inodes reclaimable again.
We fix the issue by inserting unused clean inodes into the LRU after
writeback finishes in inode_sync_complete().
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: <stable@vger.kernel.org> [3.5+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fs-writeback.c')
-rw-r--r-- | fs/fs-writeback.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 51ea267d444c..3e3422f7f0a4 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -228,6 +228,8 @@ static void requeue_io(struct inode *inode, struct bdi_writeback *wb) | |||
228 | static void inode_sync_complete(struct inode *inode) | 228 | static void inode_sync_complete(struct inode *inode) |
229 | { | 229 | { |
230 | inode->i_state &= ~I_SYNC; | 230 | inode->i_state &= ~I_SYNC; |
231 | /* If inode is clean an unused, put it into LRU now... */ | ||
232 | inode_add_lru(inode); | ||
231 | /* Waiters must see I_SYNC cleared before being woken up */ | 233 | /* Waiters must see I_SYNC cleared before being woken up */ |
232 | smp_mb(); | 234 | smp_mb(); |
233 | wake_up_bit(&inode->i_state, __I_SYNC); | 235 | wake_up_bit(&inode->i_state, __I_SYNC); |