@@ -415,6 +415,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
415415 struct shrink_control * sc , unsigned long nr_to_split )
416416{
417417 LIST_HEAD (list ), * pos , * next ;
418+ LIST_HEAD (to_remove );
418419 struct inode * inode ;
419420 struct shmem_inode_info * info ;
420421 struct page * page ;
@@ -441,9 +442,8 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
441442 /* Check if there's anything to gain */
442443 if (round_up (inode -> i_size , PAGE_SIZE ) ==
443444 round_up (inode -> i_size , HPAGE_PMD_SIZE )) {
444- list_del_init (& info -> shrinklist );
445+ list_move (& info -> shrinklist , & to_remove );
445446 removed ++ ;
446- iput (inode );
447447 goto next ;
448448 }
449449
@@ -454,6 +454,13 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
454454 }
455455 spin_unlock (& sbinfo -> shrinklist_lock );
456456
457+ list_for_each_safe (pos , next , & to_remove ) {
458+ info = list_entry (pos , struct shmem_inode_info , shrinklist );
459+ inode = & info -> vfs_inode ;
460+ list_del_init (& info -> shrinklist );
461+ iput (inode );
462+ }
463+
457464 list_for_each_safe (pos , next , & list ) {
458465 int ret ;
459466
0 commit comments