[LTP] [PATCH] fanotify13: fix test failure when running iterations
Amir Goldstein
amir73il@gmail.com
Thu May 28 17:19:37 CEST 2026
The test case for FAN_SELETE_SELF deletes the objects created in
do_setup() so we need to re-create them for the next iteration.
This bring up a problem with ext2 and filesystem that do not support
RENAME_EXCHANGE because overlayfs fails to re-create objects over a
whiteout.
It is generally not interesting to test overlayfs over such base fs,
but for now, let just exclude this type of base fs from the delete
self event test case.
Reported-by: AnonymeMeow <anonymemeow@gmail.com>
Link: https://lore.kernel.org/linux-fsdevel/20260527195056.337081-1-anonymemeow@gmail.com/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
Petr,
The basic fix is taken from AnonymeMeow's patch.
I applied a skip instead of fix for the issue with test_variant 3 on
ext2 base fs.
Thanks,
Amir.
.../kernel/syscalls/fanotify/fanotify13.c | 37 +++++++++++++++----
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index 32b2b8238..d2e65167f 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -109,6 +109,7 @@ static int nofid_fd;
static int fanotify_fd;
static int at_handle_fid;
static int filesystem_mark_unsupported;
+static int rename_exchange_unsupported;
static char events_buf[BUF_SIZE];
static struct event_t event_set[EVENT_MAX];
@@ -190,6 +191,13 @@ static void do_test(unsigned int number)
return;
}
+ if (tst_variant && (tc->mask & FAN_DELETE_SELF) &&
+ (!ovl_bind_mounted || rename_exchange_unsupported)) {
+ /* The eviction of base fs inodes is defered due to overlay held reference */
+ tst_res(TCONF, "overlayfs base fs cannot be watched for delete self events");
+ return;
+ }
+
if (filesystem_mark_unsupported && mark->flag != FAN_MARK_INODE) {
FANOTIFY_MARK_FLAGS_ERR_MSG(mark, filesystem_mark_unsupported);
return;
@@ -211,11 +219,6 @@ static void do_test(unsigned int number)
tst_res(TCONF, "overlayfs base fs cannot be watched with mount mark");
goto out;
}
- if (tc->mask & FAN_DELETE_SELF) {
- /* The eviction of base fs inodes is defered due to overlay held reference */
- tst_res(TCONF, "overlayfs base fs cannot be watched for delete self events");
- goto out;
- }
SAFE_MOUNT(OVL_MNT, MOUNT_PATH, "none", MS_BIND, NULL);
}
@@ -339,10 +342,18 @@ static void do_test(unsigned int number)
"Did not get an expected event (expected: %llx)",
event_set[i].expected_mask);
}
+
+ if (tc->mask & FAN_DELETE_SELF) {
+ create_objects();
+ get_object_stats();
+ }
out:
SAFE_CLOSE(fanotify_fd);
}
+#define TST_VARINAT_OVL_LOWER (tst_variant & 1)
+#define TST_VARIANT_OVL_WATCH (tst_variant > 2)
+
static void do_setup(void)
{
const char *mnt;
@@ -370,10 +381,9 @@ static void do_setup(void)
if (!ovl_mounted)
return;
- mnt = tst_variant & 1 ? OVL_LOWER : OVL_UPPER;
+ mnt = TST_VARINAT_OVL_LOWER ? OVL_LOWER : OVL_UPPER;
} else {
mnt = OVL_BASE_MNTPOINT;
-
}
REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(FAN_REPORT_FID, mnt);
SAFE_MKDIR(MOUNT_PATH, 0755);
@@ -385,7 +395,18 @@ static void do_setup(void)
/* Create file and directory objects for testing on base fs */
create_objects();
- if (tst_variant > 2) {
+ /* RENAME_EXCHANGE is required for create over whiteout in overlayfs */
+ if (TST_VARINAT_OVL_LOWER) {
+ rename_exchange_unsupported = renameat2(AT_FDCWD, FILE_PATH_ONE,
+ AT_FDCWD, FILE_PATH_TWO,
+ RENAME_EXCHANGE);
+ if (rename_exchange_unsupported) {
+ tst_res(TCONF, "RENAME_EXCHANGE not supported on %s",
+ tst_device->fs_type);
+ }
+ }
+
+ if (TST_VARIANT_OVL_WATCH) {
/* Setup watches on overlayfs */
SAFE_MOUNT(OVL_MNT, MOUNT_PATH, "none", MS_BIND, NULL);
ovl_bind_mounted = 1;
--
2.54.0
More information about the ltp
mailing list