Skip to content

Commit

Permalink
fanotify10: Calling drop_cache twice to ensure the inode is evicted
Browse files Browse the repository at this point in the history
In this test case, some scenarios are designed to verify whether the
FANOTIFY_EVICTABLE flag takes effect: by verifying that information cannot
be obtained from the corresponding inode after drop_cache, as this flag
does not ping the inode.

However, drop_cache is only performed once here, which may result in the
inode not being released in NUMA scenarios. Suppose the inode is located
on NUMA0 and the dentry is located on NUMA1; the first drop_cache can only
ensure that the inode is added to the LRU list, but does not guarantee that
evict() can been called because dispose_list does not yet include this
inode when traversing NUMA0, which causes the testcase execution fail.

For the single-file scenario in this testcase, executing drop_cache twice
is necessary to ensure the inode is evicted, thus allowing the testcase to
pass.

Link: https://lore.kernel.org/ltp/[email protected]/
Acked-by: Petr Vorel <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Amir Goldstein <[email protected]>
Signed-off-by: Zizhi Wo <[email protected]>
  • Loading branch information
Zizhi Wo authored and pevik committed Sep 4, 2024
1 parent f4c1c00 commit 6df425b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testcases/kernel/syscalls/fanotify/fanotify10.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ static void drop_caches(void)
if (syncfs(fd_syncfs) < 0)
tst_brk(TBROK | TERRNO, "Unexpected error when syncing filesystem");

/* Need to drop twice to ensure the inode is evicted. */
SAFE_FILE_PRINTF(DROP_CACHES_FILE, "3");
SAFE_FILE_PRINTF(DROP_CACHES_FILE, "3");
}

Expand Down

0 comments on commit 6df425b

Please sign in to comment.