[LTP] [PATCH] fanotify13: clean overlay workdir when restoring lower objects
Amir Goldstein
amir73il@gmail.com
Mon Nov 16 11:36:36 CET 2026
On Mon, Nov 16, 2026 at 8:40 AM Zhao Gongyi <zhaogongyi@bytedance.com> wrote:
>
> The FAN_DELETE_SELF test case removes test files. For lower variants,
> overlayfs creates upper whiteouts to hide the lower objects. The current
> clean_upper_dir() helper unmounts overlayfs and removes only the object
> names from OVL_UPPER before remounting overlayfs.
>
> When overlayfs is mounted with nfs_export/index enabled by default,
> deleting lower objects may also leave index entries under OVL_WORK.
> Removing only the upper whiteouts can leave stale index state. On remount,
> collecting the recreated object ids may then fail with:
>
> overlayfs: bad index found (... ftype=2000, origin ftype=8000)
> fanotify.h:85: TBROK: statfs(tstmnt/file_one, ...) failed: EIO (5)
>
> Purge both OVL_UPPER and OVL_WORK before remounting overlayfs so the
> lower-variant restore starts from a clean overlay upper/work state.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
> ---
> testcases/kernel/syscalls/fanotify/fanotify13.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
> index a43fae8..fde765e 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify13.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
> @@ -142,15 +142,16 @@ static void delete_objects(void)
> -
> +
> static void clean_upper_dir(void)
> {
> - unsigned int i;
> -
> SAFE_UMOUNT(MOUNT_PATH);
> SAFE_UMOUNT(OVL_MNT);
> -
> +
> - SAFE_MOUNT(OVL_UPPER, MOUNT_PATH, "none", MS_BIND, NULL);
> - for (i = 0; i < ARRAY_SIZE(objects); i++)
> - SAFE_UNLINK(objects[i].path);
> - SAFE_UMOUNT(MOUNT_PATH);
> + /*
> + * FAN_DELETE_SELF on lower objects creates whiteouts in upper and,
> + * with nfs_export/index enabled, index entries under workdir. Remove
> + * both trees before remounting overlayfs to avoid stale index state.
> + */
> + tst_purge_dir(OVL_UPPER);
> + tst_purge_dir(OVL_WORK);
> -
> +
Without trailing spaces here and above
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
More information about the ltp
mailing list