Skip to content

Commit ac05fbb

Browse files
author
Josef Bacik
committed
inode: don't softlockup when evicting inodes
On a box with a lot of ram (148gb) I can make the box softlockup after running an fs_mark job that creates hundreds of millions of empty files. This is because we never generate enough memory pressure to keep the number of inodes on our unused list low, so when we go to unmount we have to evict ~100 million inodes. This makes one processor a very unhappy person, so add a cond_resched() in dispose_list() and if we need a resched when processing the s_inodes list do that and run dispose_list() on what we've currently culled. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Reviewed-by: Jan Kara <jack@suse.cz>
1 parent c7f5408 commit ac05fbb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/inode.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ static void dispose_list(struct list_head *head)
575575
list_del_init(&inode->i_lru);
576576

577577
evict(inode);
578+
cond_resched();
578579
}
579580
}
580581

@@ -592,6 +593,7 @@ void evict_inodes(struct super_block *sb)
592593
struct inode *inode, *next;
593594
LIST_HEAD(dispose);
594595

596+
again:
595597
spin_lock(&sb->s_inode_list_lock);
596598
list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
597599
if (atomic_read(&inode->i_count))
@@ -607,6 +609,18 @@ void evict_inodes(struct super_block *sb)
607609
inode_lru_list_del(inode);
608610
spin_unlock(&inode->i_lock);
609611
list_add(&inode->i_lru, &dispose);
612+
613+
/*
614+
* We can have a ton of inodes to evict at unmount time given
615+
* enough memory, check to see if we need to go to sleep for a
616+
* bit so we don't livelock.
617+
*/
618+
if (need_resched()) {
619+
spin_unlock(&sb->s_inode_list_lock);
620+
cond_resched();
621+
dispose_list(&dispose);
622+
goto again;
623+
}
610624
}
611625
spin_unlock(&sb->s_inode_list_lock);
612626

0 commit comments

Comments
 (0)