From: Amir Goldstein <amir73il@gmail.com>
To: Petr Vorel <pvorel@suse.cz>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: [LTP] [PATCH 2/5] fanotify13: Add test case for FAN_DELETE_SELF
Date: Wed, 22 Jan 2025 18:24:37 +0100 [thread overview]
Message-ID: <20250122172440.506677-3-amir73il@gmail.com> (raw)
In-Reply-To: <20250122172440.506677-1-amir73il@gmail.com>
Verify that FAN_DELETE_SELF on overlayfs reports a valid file handle.
This was fixed in v6.13-rc7 and backported to v6.12.10 and v6.6.74.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
.../kernel/syscalls/fanotify/fanotify13.c | 68 ++++++++++++++++---
1 file changed, 57 insertions(+), 11 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index 16fd99ba1..67f05da20 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -15,6 +15,15 @@
/*
* This is also regression test for:
* c285a2f01d69 ("fanotify: update connector fsid cache on add mark")
+ *
+ * The test variants 1-2 are regression tests for:
+ * bc2473c90fca5 ("ovl: enable fsnotify events on underlying real files")
+ *
+ * The test variants 3-4 are tests for overlay fid events supprted since v6.6:
+ * 16aac5ad1fa9 ("ovl: support encoding non-decodable file handles")
+ *
+ * The last test case for FAN_DELETE_SELF is a regression test for:
+ * c45beebfde34a ("ovl: support encoding fid from inode with no alias")
*/
#define _GNU_SOURCE
@@ -86,7 +95,12 @@ static struct test_case_t {
{
INIT_FANOTIFY_MARK_TYPE(FILESYSTEM),
FAN_OPEN | FAN_CLOSE_NOWRITE | FAN_ONDIR
- }
+ },
+ /* Keep this test case last because it deletes the test files */
+ {
+ INIT_FANOTIFY_MARK_TYPE(INODE),
+ FAN_DELETE_SELF | FAN_ONDIR
+ },
};
static int ovl_mounted;
@@ -111,6 +125,18 @@ static void create_objects(void)
}
}
+static void delete_objects(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(objects); i++) {
+ if (objects[i].is_dir)
+ SAFE_RMDIR(objects[i].path);
+ else
+ SAFE_UNLINK(objects[i].path);
+ }
+}
+
static void get_object_stats(void)
{
unsigned int i;
@@ -155,8 +181,10 @@ static void do_test(unsigned int number)
struct fanotify_mark_type *mark = &tc->mark;
tst_res(TINFO,
- "Test #%d.%d: FAN_REPORT_FID with mark flag: %s",
- number, tst_variant, mark->name);
+ "Test #%d.%d: FAN_REPORT_FID of %s events with mark type %s",
+ number, tst_variant,
+ (tc->mask & FAN_DELETE_SELF) ? "delete" : "open/close",
+ mark->name);
if (tst_variant && !ovl_mounted) {
tst_res(TCONF, "overlayfs not supported on %s", tst_device->fs_type);
@@ -184,23 +212,40 @@ 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);
}
/* Generate sequence of FAN_OPEN events on objects */
- for (i = 0; i < ARRAY_SIZE(objects); i++)
- fds[i] = SAFE_OPEN(objects[i].path, O_RDONLY);
+ if (tc->mask & FAN_OPEN) {
+ for (i = 0; i < ARRAY_SIZE(objects); i++)
+ fds[i] = SAFE_OPEN(objects[i].path, O_RDONLY);
+ }
/*
- * Generate sequence of FAN_CLOSE_NOWRITE events on objects. Each
- * FAN_CLOSE_NOWRITE event is expected to be merged with its
- * respective FAN_OPEN event that was performed on the same object.
+ * Generate sequence of FAN_CLOSE_NOWRITE events on objects.
+ * Each FAN_CLOSE_NOWRITE event is expected to be merged with the
+ * respective FAN_OPEN event that was reported on the same object.
*/
- for (i = 0; i < ARRAY_SIZE(objects); i++) {
- if (fds[i] > 0)
- SAFE_CLOSE(fds[i]);
+ if (tc->mask & FAN_CLOSE) {
+ for (i = 0; i < ARRAY_SIZE(objects); i++) {
+ if (fds[i] > 0)
+ SAFE_CLOSE(fds[i]);
+ }
}
+ /*
+ * Generate sequence of FAN_DELETE_SELF events on objects.
+ * Each FAN_DELETE_SELF event is expected to be merged with the
+ * respective OPEN/CLOSE events that were reported on the same object.
+ */
+ if (tc->mask & FAN_DELETE_SELF)
+ delete_objects();
+
if (tst_variant && !ovl_bind_mounted)
SAFE_UMOUNT(MOUNT_PATH);
@@ -392,6 +437,7 @@ static struct tst_test test = {
.tags = (const struct tst_tag[]) {
{"linux-git", "c285a2f01d69"},
{"linux-git", "bc2473c90fca"},
+ {"linux-git", "c45beebfde34a"},
{}
}
};
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-01-22 17:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 17:24 [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Amir Goldstein
2025-01-22 17:24 ` [LTP] [PATCH 1/5] fanotify13: Verify that we did not get an extra event Amir Goldstein
2025-01-23 17:18 ` Petr Vorel
2025-01-24 10:11 ` Petr Vorel
2025-01-24 10:33 ` Amir Goldstein
2025-01-24 12:45 ` Petr Vorel
2025-01-22 17:24 ` Amir Goldstein [this message]
2025-01-22 17:24 ` [LTP] [PATCH 3/5] fanotify05: Test reporting overflow event with FAN_REPORT_FD_ERROR Amir Goldstein
2025-01-24 7:44 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 4/5] fanotify21: Test reporting event with RDWR fd on RO mount Amir Goldstein
2025-01-24 8:01 ` Petr Vorel
2025-01-22 17:24 ` [LTP] [PATCH 5/5] fanotify21: Test reporting fd open errors with FAN_REPORT_FD_ERROR Amir Goldstein
2025-01-24 8:09 ` Petr Vorel
2025-01-22 20:50 ` [LTP] [PATCH 0/5] LTP fanotify tests for v6.13 Petr Vorel
2025-01-23 13:09 ` Amir Goldstein
2025-01-23 13:31 ` Cyril Hrubis
2025-01-24 10:46 ` Cyril Hrubis
2025-01-24 11:32 ` Petr Vorel
2025-01-30 20:07 ` Petr Vorel
2025-01-31 14:16 ` Amir Goldstein
2025-01-31 16:42 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250122172440.506677-3-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox