public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it, Jan Kara <jack@suse.cz>,
	linux-unionfs@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>
Subject: [LTP] [PATCH 1/2] fanotify13: Test overlayfs while watching lower fs
Date: Tue, 14 Nov 2023 09:23:37 +0200	[thread overview]
Message-ID: <20231114072338.1669277-2-amir73il@gmail.com> (raw)
In-Reply-To: <20231114072338.1669277-1-amir73il@gmail.com>

We already have a test variant when watching upper fs.

Improve test coverage by adding a test variant with overlayfs
(over all supported fs) when watching the lower fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 .../kernel/syscalls/fanotify/fanotify13.c     | 25 +++++++++++--------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index a25a360fd..4bcffaab2 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -168,10 +168,10 @@ static void do_test(unsigned int number)
 	if (setup_marks(fanotify_fd, tc) != 0)
 		goto out;
 
-	/* Variant #1: watching upper fs - open files on overlayfs */
-	if (tst_variant == 1) {
+	/* Watching base fs - open files on overlayfs */
+	if (tst_variant) {
 		if (mark->flag & FAN_MARK_MOUNT) {
-			tst_res(TCONF, "overlayfs upper fs cannot be watched with mount mark");
+			tst_res(TCONF, "overlayfs base fs cannot be watched with mount mark");
 			goto out;
 		}
 		SAFE_MOUNT(OVL_MNT, MOUNT_PATH, "none", MS_BIND, NULL);
@@ -191,7 +191,7 @@ static void do_test(unsigned int number)
 			SAFE_CLOSE(fds[i]);
 	}
 
-	if (tst_variant == 1)
+	if (tst_variant)
 		SAFE_UMOUNT(MOUNT_PATH);
 
 	/* Read events from event queue */
@@ -286,9 +286,10 @@ static void do_setup(void)
 	/*
 	 * Bind mount to either base fs or to overlayfs over base fs:
 	 * Variant #0: watch base fs - open files on base fs
-	 * Variant #1: watch upper fs - open files on overlayfs
+	 * Variant #1: watch lower fs - open lower files on overlayfs
+	 * Variant #2: watch upper fs - open upper files on overlayfs
 	 *
-	 * Variant #1 tests a bug whose fix bc2473c90fca ("ovl: enable fsnotify
+	 * Variants 1,2 test a bug whose fix bc2473c90fca ("ovl: enable fsnotify
 	 * events on underlying real files") in kernel 6.5 is not likely to be
 	 * backported to older kernels.
 	 * To avoid waiting for events that won't arrive when testing old kernels,
@@ -298,7 +299,10 @@ static void do_setup(void)
 	if (tst_variant) {
 		REQUIRE_HANDLE_TYPE_SUPPORTED_BY_KERNEL(AT_HANDLE_FID);
 		ovl_mounted = TST_MOUNT_OVERLAY();
-		mnt = OVL_UPPER;
+		if (!ovl_mounted)
+			return;
+
+		mnt = tst_variant & 1 ? OVL_LOWER : OVL_UPPER;
 	} else {
 		mnt = OVL_BASE_MNTPOINT;
 
@@ -312,7 +316,7 @@ static void do_setup(void)
 
 	nofid_fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
 
-	/* Create file and directory objects for testing */
+	/* Create file and directory objects for testing on base fs */
 	create_objects();
 
 	/*
@@ -329,7 +333,8 @@ static void do_setup(void)
 
 static void do_cleanup(void)
 {
-	SAFE_CLOSE(nofid_fd);
+	if (nofid_fd > 0)
+		SAFE_CLOSE(nofid_fd);
 	if (fanotify_fd > 0)
 		SAFE_CLOSE(fanotify_fd);
 	if (bind_mounted) {
@@ -343,7 +348,7 @@ static void do_cleanup(void)
 static struct tst_test test = {
 	.test = do_test,
 	.tcnt = ARRAY_SIZE(test_cases),
-	.test_variants = 2,
+	.test_variants = 3,
 	.setup = do_setup,
 	.cleanup = do_cleanup,
 	.needs_root = 1,
-- 
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-11-14  7:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  7:23 [LTP] [PATCH 0/2] fanotify LTP tests for v6.6 Amir Goldstein
2023-11-14  7:23 ` Amir Goldstein [this message]
2023-11-14 10:29   ` [LTP] [PATCH 1/2] fanotify13: Test overlayfs while watching lower fs Petr Vorel
2023-11-14  7:23 ` [LTP] [PATCH 2/2] fanotify13: Test watching overlayfs with FAN_REPORT_FID Amir Goldstein
2023-11-14 10:57   ` Petr Vorel
2023-11-21  9:59     ` Petr Vorel
2023-11-21 10:31       ` Amir Goldstein

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=20231114072338.1669277-2-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=miklos@szeredi.hu \
    --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