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
1627 else1627 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;
include/linux/fs.h+1−2
@@ -2878,8 +2878,7 @@ extern int inode_needs_sync(struct inode *inode); · 2877 unmodified lines
2878extern int generic_delete_inode(struct inode *inode);2878extern int generic_delete_inode(struct inode *inode);
2879static inline int generic_drop_inode(struct inode *inode)2879static 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}
2884extern void d_mark_dontcache(struct inode *inode);2883extern void d_mark_dontcache(struct inode *inode);
2885 2884

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