Skip to contentSkip to conversation

fanotify01: Fix regression on kernels < v6.8

PATCH Applied Amir Goldstein 4 participants 4 messages Jun 28, 2025 – Jul 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fanotify01: Fix regression on kernels < v6.8

There was a test regression in case the TMPDIR has a zero fsid.

Kernels < v6.8 do not allow setting inodes marks on such fs, while kernels >= v6.8 do allow to set inode marks but on on a single fs.

Adjust the test expectation in those two different cases.

---

Petr,

I reproduced this but with TMPDIR set to ntfs-3g mount path, which has zero fsid link nfs.

Tested that fix works on new (upstream) and old v6.6 kernels.

Thanks,
Amir.

 testcases/kernel/syscalls/fanotify/fanotify01.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify01.c +11 -5
index f514dc1df..df50d84a1 100644
@@ -75,6 +75,7 @@ static char fname[BUF_SIZE];
 static char buf[BUF_SIZE];
 static int fd_notify;
 static int fan_report_fid_unsupported;
+static int tmpfs_report_fid_unsupported;
 static int mount_mark_fid_unsupported;
 static int inode_mark_fid_xdev;
 static int filesystem_mark_unsupported;
@@ -335,9 +336,11 @@ pass:
 	 * When tested fs has zero fsid (e.g. fuse) and events are reported
 	 * with fsid+fid, watching different filesystems is not supported.
 	 */
-	ret = report_fid ? inode_mark_fid_xdev : 0;
-	TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
-					 AT_FDCWD, "."), ret);
+	if (!tmpfs_report_fid_unsupported) {
+		ret = report_fid ? inode_mark_fid_xdev : 0;
+		TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
+						 AT_FDCWD, "."), ret);
+	}
 
 	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
 	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
@@ -373,8 +376,11 @@ static void setup(void)
 		inode_mark_fid_xdev = EXDEV;
 	}
 
-	if (fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".")) {
-		inode_mark_fid_xdev = (errno == ENODEV) ? EXDEV : errno;
+	tmpfs_report_fid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FID, ".");
+	if (!tmpfs_report_fid_unsupported &&
+	    fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".") &&
+	    (errno == ENODEV || errno == EXDEV)) {
+		inode_mark_fid_xdev = EXDEV;
 		tst_res(TINFO | TERRNO, "TMPDIR does not support reporting events with fid from multi fs");
 	}
 }
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Amir Goldstein

There was a test regression in case the TMPDIR has a zero fsid.

Kernels < v6.8 do not allow setting inodes marks on such fs, while kernels >= v6.8 do allow to set inode marks but on on a single fs.

Adjust the test expectation in those two different cases.

Thanks for fixing this up. The patch looks good to me. Feel free to add:

Honza

Quoted 59 lines

---

Petr,

I reproduced this but with TMPDIR set to ntfs-3g mount path, which has zero fsid link nfs.

Tested that fix works on new (upstream) and old v6.6 kernels.

Thanks,
Amir.

 testcases/kernel/syscalls/fanotify/fanotify01.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify01.c +11 -5
index f514dc1df..df50d84a1 100644
@@ -75,6 +75,7 @@ static char fname[BUF_SIZE];
 static char buf[BUF_SIZE];
 static int fd_notify;
 static int fan_report_fid_unsupported;
+static int tmpfs_report_fid_unsupported;
 static int mount_mark_fid_unsupported;
 static int inode_mark_fid_xdev;
 static int filesystem_mark_unsupported;
@@ -335,9 +336,11 @@ pass:
 	 * When tested fs has zero fsid (e.g. fuse) and events are reported
 	 * with fsid+fid, watching different filesystems is not supported.
 	 */
-	ret = report_fid ? inode_mark_fid_xdev : 0;
-	TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
-					 AT_FDCWD, "."), ret);
+	if (!tmpfs_report_fid_unsupported) {
+		ret = report_fid ? inode_mark_fid_xdev : 0;
+		TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
+						 AT_FDCWD, "."), ret);
+	}
 
 	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
 	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
@@ -373,8 +376,11 @@ static void setup(void)
 		inode_mark_fid_xdev = EXDEV;
 	}
 
-	if (fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".")) {
-		inode_mark_fid_xdev = (errno == ENODEV) ? EXDEV : errno;
+	tmpfs_report_fid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FID, ".");
+	if (!tmpfs_report_fid_unsupported &&
+	    fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".") &&
+	    (errno == ENODEV || errno == EXDEV)) {
+		inode_mark_fid_xdev = EXDEV;
 		tst_res(TINFO | TERRNO, "TMPDIR does not support reporting events with fid from multi fs");
 	}
 }
Signature · 1 line
2.43.0
Signature · 5 lines
Jan Kara <[email protected]>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Tested-by Linux Kernel Functional Testing on v1 1/1
#2 lore raw
In reply to Amir Goldstein

Hi Amir,

Quoted 7 lines · Amir Goldstein

There was a test regression in case the TMPDIR has a zero fsid.

Kernels < v6.8 do not allow setting inodes marks on such fs, while kernels >= v6.8 do allow to set inode marks but on on a single fs.

Adjust the test expectation in those two different cases.

Thanks for providing a fix patch,
this patch was tested and the reported failures have been fixed.

Quoted 61 lines

---

Petr,

I reproduced this but with TMPDIR set to ntfs-3g mount path, which has zero fsid link nfs.

Tested that fix works on new (upstream) and old v6.6 kernels.

Thanks,
Amir.

 testcases/kernel/syscalls/fanotify/fanotify01.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify01.c +11 -6
index f514dc1df..df50d84a1 100644
@@ -75,6 +75,7 @@ static char fname[BUF_SIZE];
 static char buf[BUF_SIZE];
 static int fd_notify;
 static int fan_report_fid_unsupported;
+static int tmpfs_report_fid_unsupported;
 static int mount_mark_fid_unsupported;
 static int inode_mark_fid_xdev;
 static int filesystem_mark_unsupported;
@@ -335,9 +336,11 @@ pass:
         * When tested fs has zero fsid (e.g. fuse) and events are reported
         * with fsid+fid, watching different filesystems is not supported.
         */
-       ret = report_fid ? inode_mark_fid_xdev : 0;
-       TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
-                                        AT_FDCWD, "."), ret);
+       if (!tmpfs_report_fid_unsupported) {
+               ret = report_fid ? inode_mark_fid_xdev : 0;
+               TST_EXP_FD_OR_FAIL(fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_CLOSE_WRITE,
+                                                AT_FDCWD, "."), ret);
+       }
 
        /* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
        SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
@@ -373,8 +376,11 @@ static void setup(void)
                inode_mark_fid_xdev = EXDEV;
        }
 
-       if (fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".")) {
-               inode_mark_fid_xdev = (errno == ENODEV) ? EXDEV : errno;
+       tmpfs_report_fid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FID, ".");
+       if (!tmpfs_report_fid_unsupported &&
+           fanotify_flags_supported_on_fs(FAN_REPORT_FID, FAN_MARK_MOUNT, FAN_OPEN, ".") &&
+           (errno == ENODEV || errno == EXDEV)) {
+               inode_mark_fid_xdev = EXDEV;
                tst_res(TINFO | TERRNO, "TMPDIR does not support reporting events with fid from multi fs");
        }
 }
--
Quoted 1 line

2.43.0

LAVA test jobs 1 :
https://lkft.validation.linaro.org/scheduler/job/8338092#L2028
LAVA test jobs 2 :
https://lkft.validation.linaro.org/scheduler/job/8338077#L4569

- Naresh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp