Skip to content

Commit dae2f8e

Browse files
weiny2djwong
authored andcommitted
fs: Lift XFS_IDONTCACHE to the VFS layer
DAX effective mode (S_DAX) changes requires inode eviction. XFS has an advisory flag (XFS_IDONTCACHE) to prevent caching of the inode if no other additional references are taken. We lift this flag to the VFS layer and change the behavior slightly by allowing the flag to remain even if multiple references are taken. This will expedite the eviction of inodes to change S_DAX. Cc: Al Viro <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Ira Weiny <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 83d9088 commit dae2f8e

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

fs/xfs/xfs_icache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ xfs_iget_cache_hit(
479479
xfs_ilock(ip, lock_flags);
480480

481481
if (!(flags & XFS_IGET_INCORE))
482-
xfs_iflags_clear(ip, XFS_ISTALE | XFS_IDONTCACHE);
482+
xfs_iflags_clear(ip, XFS_ISTALE);
483483
XFS_STATS_INC(mp, xs_ig_found);
484484

485485
return 0;
@@ -561,7 +561,7 @@ xfs_iget_cache_miss(
561561
*/
562562
iflags = XFS_INEW;
563563
if (flags & XFS_IGET_DONTCACHE)
564-
iflags |= XFS_IDONTCACHE;
564+
VFS_I(ip)->i_state |= I_DONTCACHE;
565565
ip->i_udquot = NULL;
566566
ip->i_gdquot = NULL;
567567
ip->i_pdquot = NULL;

fs/xfs/xfs_inode.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ static inline bool xfs_inode_has_cow_data(struct xfs_inode *ip)
218218
#define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT)
219219
#define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */
220220
#define XFS_IPINNED (1 << __XFS_IPINNED_BIT)
221-
#define XFS_IDONTCACHE (1 << 9) /* don't cache the inode long term */
222-
#define XFS_IEOFBLOCKS (1 << 10)/* has the preallocblocks tag set */
221+
#define XFS_IEOFBLOCKS (1 << 9) /* has the preallocblocks tag set */
223222
/*
224223
* If this unlinked inode is in the middle of recovery, don't let drop_inode
225224
* truncate and free the inode. This can happen if we iget the inode during

fs/xfs/xfs_super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ xfs_fs_drop_inode(
702702
return 0;
703703
}
704704

705-
return generic_drop_inode(inode) || (ip->i_flags & XFS_IDONTCACHE);
705+
return generic_drop_inode(inode);
706706
}
707707

708708
static void

include/linux/fs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,8 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
21562156
*
21572157
* I_CREATING New object's inode in the middle of setting up.
21582158
*
2159+
* I_DONTCACHE Evict inode as soon as it is not used anymore.
2160+
*
21592161
* Q: What is the difference between I_WILL_FREE and I_FREEING?
21602162
*/
21612163
#define I_DIRTY_SYNC (1 << 0)
@@ -2178,6 +2180,7 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
21782180
#define I_WB_SWITCH (1 << 13)
21792181
#define I_OVL_INUSE (1 << 14)
21802182
#define I_CREATING (1 << 15)
2183+
#define I_DONTCACHE (1 << 16)
21812184

21822185
#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
21832186
#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
@@ -3049,7 +3052,8 @@ extern int inode_needs_sync(struct inode *inode);
30493052
extern int generic_delete_inode(struct inode *inode);
30503053
static inline int generic_drop_inode(struct inode *inode)
30513054
{
3052-
return !inode->i_nlink || inode_unhashed(inode);
3055+
return !inode->i_nlink || inode_unhashed(inode) ||
3056+
(inode->i_state & I_DONTCACHE);
30533057
}
30543058

30553059
extern struct inode *ilookup5_nowait(struct super_block *sb,

0 commit comments

Comments
 (0)