History

fs: Handle I_DONTCACHE in iput_final() instead of generic_drop_inode()

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/

Hao Li committed 5 years ago

Commit 88149081 parent edf7ddb2 files · +4 −3Browse files

Unified · Split

2 files
  1. fs/inode.c +3 −1
  2. include/linux/fs.h +1 −2
fs/inode.c+3−1
@@ -1627,7 +1627,9 @@ static void iput_final(struct inode *inode) · 1626 unmodified lines
16271627 else
16281628 drop = generic_drop_inode(inode);
16291629
1630− if (!drop && (sb->s_flags & SB_ACTIVE)) {
1630+ if (!drop &&
1631+ !(inode->i_state & I_DONTCACHE) &&
1632+ (sb->s_flags & SB_ACTIVE)) {
16311633 inode_add_lru(inode);
16321634 spin_unlock(&inode->i_lock);
16331635 return;
include/linux/fs.h+1−2
@@ -2878,8 +2878,7 @@ extern int inode_needs_sync(struct inode *inode); · 2877 unmodified lines
28782878 extern int generic_delete_inode(struct inode *inode);
28792879 static inline int generic_drop_inode(struct inode *inode)
28802880 {
2881− return !inode->i_nlink || inode_unhashed(inode) ||
2882− (inode->i_state & I_DONTCACHE);
2881+ return !inode->i_nlink || inode_unhashed(inode);
28832882 }
28842883 extern void d_mark_dontcache(struct inode *inode);
28852884

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t