If generic_drop_inode() returns true, it means iput_final() can evict this inode regardless of whether it is dirty or not. If we check I_DONTCACHE in generic_drop_inode(), any inode with this bit set will be evicted unconditionally. This is not the desired behavior because I_DONTCACHE only means the inode shouldn't be cached on the LRU list. As for whether we need to evict this inode, this is what generic_drop_inode() should do. This patch corrects the usage of I_DONTCACHE. This patch was proposed in [1]. [1]: https://lore.kernel.org/linux-fsdevel/20200831003407.GE12096@dread.disaster.area/
Unified · Split
| @@ -1627,7 +1627,9 @@ static void iput_final(struct inode *inode) · 1626 unmodified lines | |||
| 1627 | else | 1627 | else |
| 1628 | drop = generic_drop_inode(inode); | 1628 | drop = generic_drop_inode(inode); |
| 1629 | 1629 | ||
| 1630 | if (!drop && (sb->s_flags & SB_ACTIVE)) { | 1630 | if (!drop && |
| 1631 | !(inode->i_state & I_DONTCACHE) && | ||
| 1632 | (sb->s_flags & SB_ACTIVE)) { | ||
| 1631 | inode_add_lru(inode); | 1633 | inode_add_lru(inode); |
| 1632 | spin_unlock(&inode->i_lock); | 1634 | spin_unlock(&inode->i_lock); |
| 1633 | return; | 1635 | return; |
| @@ -2878,8 +2878,7 @@ extern int inode_needs_sync(struct inode *inode); · 2877 unmodified lines | |||
| 2878 | extern int generic_delete_inode(struct inode *inode); | 2878 | extern int generic_delete_inode(struct inode *inode); |
| 2879 | static inline int generic_drop_inode(struct inode *inode) | 2879 | static inline int generic_drop_inode(struct inode *inode) |
| 2880 | { | 2880 | { |
| 2881 | return !inode->i_nlink || inode_unhashed(inode) || | 2881 | return !inode->i_nlink || inode_unhashed(inode); |
| 2882 | (inode->i_state & I_DONTCACHE); | ||
| 2883 | } | 2882 | } |
| 2884 | extern void d_mark_dontcache(struct inode *inode); | 2883 | extern void d_mark_dontcache(struct inode *inode); |
| 2885 | 2884 | ||