Skip to contentSkip to conversation

fanotify01: Test setting two marks on different filesystems

PATCH In review Amir Goldstein 3 participants 12 messages Jan 25, 2024 – Jan 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fanotify01: Test setting two marks on different filesystems

When tested fs has zero fsid (e.g. fuse) and events are reported with fsid+fid, watching different filesystems with the same group is not supported.

Try to setup a bogus mark on test tmp dir, in addition to the mark on the tested filesystem, to check if marks on different filesystems are supported.

Run on all filesystem to test both fs with zero fsid (e.g. fuse) and fs with valid fsid.

---

Petr,

The fanotify tests changes that you already picked from my github [1] have to do with fixing new test failures in v6.7 and v6.8-rc1, dues to the fact that each of those kernel versions added new filesystems that support fanotify events with fid+fsid.

This is the only change to test new functionality in v6.8-rc1, namely, that for fs with zero fsid (e.g. fuse), an fanotify group can watch a single fs instance.

To fix the problem that you reported with this test on exfat [2], I needed to make a distiction between the fs that do not support mount mark with fid due to having zero fsid (e.g. fuse) and those fs that do not support decoding fid (e.g. exfat).

It is not urgent to merge this change to the upcoming code freeze - it's up to you, but since I already tested it I am posting it now.

Thanks,
Amir.

[1] https://github.com/amir73il/ltp/commits/fanotify_fsid/
[2] https://lore.kernel.org/ltp/CAOQ4uxh1VwoMK_ssjdcxo_sk4cw0pD_FcXZ6Lb2=XHLf21kGAw@mail.gmail.com/T/#mf15d751e8f77a497ee4387b0791219e800cde7ea

 testcases/kernel/syscalls/fanotify/fanotify.h |  6 +++++-
 .../kernel/syscalls/fanotify/fanotify01.c     | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/fanotify/fanotify.h +5 -1
index e0d178bcc..554940a7e 100644
@@ -166,20 +166,23 @@ static inline int fanotify_flags_supported_on_fs(unsigned int init_flags,
 {
 	int fd;
 	int rval = 0;
+	int err = 0;
 
 	fd = fanotify_init(init_flags, O_RDONLY);
-
 	if (fd < 0) {
+		err = errno;
 		if (errno == ENOSYS)
 			tst_brk(TCONF, "fanotify not configured in kernel");
 		if (errno != EINVAL)
 			tst_brk(TBROK | TERRNO,
 				"fanotify_init(%x, O_RDONLY) failed",
 				init_flags);
+		errno = err;
 		return -1;
 	}
 
 	if (fname && fanotify_mark(fd, FAN_MARK_ADD | mark_flags, event_flags, AT_FDCWD, fname) < 0) {
+		err = errno;
 		if (errno == ENODEV || errno == EOPNOTSUPP || errno == EXDEV) {
 			rval = strcmp(fname, OVL_MNT) ? -2 : -3;
 		} else if (errno != EINVAL) {
@@ -194,6 +197,7 @@ static inline int fanotify_flags_supported_on_fs(unsigned int init_flags,
 
 	SAFE_CLOSE(fd);
 
+	errno = err;
 	return rval;
 }
 
testcases/kernel/syscalls/fanotify/fanotify01.c +19 -0
index e4398f236..ba09f309d 100644
@@ -77,6 +77,7 @@ static char buf[BUF_SIZE];
 static int fd_notify;
 static int fan_report_fid_unsupported;
 static int mount_mark_fid_unsupported;
+static int inode_mark_fid_xdev;
 static int filesystem_mark_unsupported;
 
 static unsigned long long event_set[EVENT_MAX];
@@ -328,6 +329,17 @@ pass:
 
 	}
 
+
+	/*
+	 * Try to setup a bogus mark on test tmp dir, to check if marks on
+	 * different filesystems are supported.
+	 * 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);
+
 	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
 	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
 			  FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN,
@@ -352,6 +364,12 @@ static void setup(void)
 	mount_mark_fid_unsupported = fanotify_flags_supported_on_fs(FAN_REPORT_FID,
 								    FAN_MARK_MOUNT,
 								    FAN_OPEN, fname);
+	/* When mount mark is not supported due to zero fsid, multi fs inode marks are not supported */
+	if (mount_mark_fid_unsupported && errno == ENODEV) {
+		tst_res(TINFO, "filesystem %s does not support reporting events with fid from multi fs",
+				tst_device->fs_type);
+		inode_mark_fid_xdev = EXDEV;
+	}
 }
 
 static void cleanup(void)
@@ -368,6 +386,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
+	.all_filesystems = 1,
 };
 
 #else
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw
Quoted 8 lines

When tested fs has zero fsid (e.g. fuse) and events are reported with fsid+fid, watching different filesystems with the same group is not supported.

Try to setup a bogus mark on test tmp dir, in addition to the mark on the tested filesystem, to check if marks on different filesystems are supported.

Quoted 5 lines

Run on all filesystem to test both fs with zero fsid (e.g. fuse) and fs with valid fsid.

---

Hi Amir,

Quoted 10 lines

Petr,

The fanotify tests changes that you already picked from my github [1] have to do with fixing new test failures in v6.7 and v6.8-rc1, dues to the fact that each of those kernel versions added new filesystems that support fanotify events with fid+fsid.

This is the only change to test new functionality in v6.8-rc1, namely, that for fs with zero fsid (e.g. fuse), an fanotify group can watch a single fs instance.

This patch would have to be rebased, to be applicable of the previous one (which touches more tests) in your branch.

I also wonder what I did wrong, the branch works after reboot, tested on:
1) mainline kernel 6.8.0-rc1 in rapido-linux
2) openSUSE kernel 6.8.0-rc1-2.gf4ba5db-default
3) 6.7.0-9.gaedda80-default

Quoted 7 lines

To fix the problem that you reported with this test on exfat [2], I needed to make a distiction between the fs that do not support mount mark with fid due to having zero fsid (e.g. fuse) and those fs that do not support decoding fid (e.g. exfat).

It is not urgent to merge this change to the upcoming code freeze - it's up to you, but since I already tested it I am posting it now.

I'll probably merge it after LTP release.

Kind regards,
Petr

Quoted 98 lines

Thanks,
Amir.

[1] https://github.com/amir73il/ltp/commits/fanotify_fsid/
[2] https://lore.kernel.org/ltp/CAOQ4uxh1VwoMK_ssjdcxo_sk4cw0pD_FcXZ6Lb2=XHLf21kGAw@mail.gmail.com/T/#mf15d751e8f77a497ee4387b0791219e800cde7ea

 testcases/kernel/syscalls/fanotify/fanotify.h |  6 +++++-
 .../kernel/syscalls/fanotify/fanotify01.c     | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/fanotify/fanotify.h +5 -1
index e0d178bcc..554940a7e 100644
@@ -166,20 +166,23 @@ static inline int fanotify_flags_supported_on_fs(unsigned int init_flags,
 {
 	int fd;
 	int rval = 0;
+	int err = 0;
 
 	fd = fanotify_init(init_flags, O_RDONLY);
-
 	if (fd < 0) {
+		err = errno;
 		if (errno == ENOSYS)
 			tst_brk(TCONF, "fanotify not configured in kernel");
 		if (errno != EINVAL)
 			tst_brk(TBROK | TERRNO,
 				"fanotify_init(%x, O_RDONLY) failed",
 				init_flags);
+		errno = err;
 		return -1;
 	}
 
 	if (fname && fanotify_mark(fd, FAN_MARK_ADD | mark_flags, event_flags, AT_FDCWD, fname) < 0) {
+		err = errno;
 		if (errno == ENODEV || errno == EOPNOTSUPP || errno == EXDEV) {
 			rval = strcmp(fname, OVL_MNT) ? -2 : -3;
 		} else if (errno != EINVAL) {
@@ -194,6 +197,7 @@ static inline int fanotify_flags_supported_on_fs(unsigned int init_flags,
 
 	SAFE_CLOSE(fd);
 
+	errno = err;
 	return rval;
 }
 
testcases/kernel/syscalls/fanotify/fanotify01.c +19 -0
index e4398f236..ba09f309d 100644
@@ -77,6 +77,7 @@ static char buf[BUF_SIZE];
 static int fd_notify;
 static int fan_report_fid_unsupported;
 static int mount_mark_fid_unsupported;
+static int inode_mark_fid_xdev;
 static int filesystem_mark_unsupported;
 
 static unsigned long long event_set[EVENT_MAX];
@@ -328,6 +329,17 @@ pass:
 
 	}
 
+
+	/*
+	 * Try to setup a bogus mark on test tmp dir, to check if marks on
+	 * different filesystems are supported.
+	 * 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);
+
 	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
 	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
 			  FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN,
@@ -352,6 +364,12 @@ static void setup(void)
 	mount_mark_fid_unsupported = fanotify_flags_supported_on_fs(FAN_REPORT_FID,
 								    FAN_MARK_MOUNT,
 								    FAN_OPEN, fname);
+	/* When mount mark is not supported due to zero fsid, multi fs inode marks are not supported */
+	if (mount_mark_fid_unsupported && errno == ENODEV) {
+		tst_res(TINFO, "filesystem %s does not support reporting events with fid from multi fs",
+				tst_device->fs_type);
+		inode_mark_fid_xdev = EXDEV;
+	}
 }
 
 static void cleanup(void)
@@ -368,6 +386,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
+	.all_filesystems = 1,
 };
 
 #else
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 24 lines · Petr Vorel
Quoted 9 lines

When tested fs has zero fsid (e.g. fuse) and events are reported with fsid+fid, watching different filesystems with the same group is not supported.

Try to setup a bogus mark on test tmp dir, in addition to the mark on the tested filesystem, to check if marks on different filesystems are supported.

Quoted 5 lines

Run on all filesystem to test both fs with zero fsid (e.g. fuse) and fs with valid fsid.

---

Hi Amir,

Quoted 6 lines

Petr,

The fanotify tests changes that you already picked from my github [1] have to do with fixing new test failures in v6.7 and v6.8-rc1, dues to the fact that each of those kernel versions added new filesystems that support fanotify events with fid+fsid.

Quoted 6 lines
Quoted 3 lines

This is the only change to test new functionality in v6.8-rc1, namely, that for fs with zero fsid (e.g. fuse), an fanotify group can watch a single fs instance.

This patch would have to be rebased, to be applicable of the previous one (which touches more tests) in your branch.

I don't understand - this patch is already rebased. I have it in my branch after the fix patches:

7db2dac9f (HEAD -> fanotify_fsid) fanotify01: Test setting two marks on different filesystems
f80dc512e fanotify{01,09,10}: Check for report fid support with mount mark 9062824a7 (master) fanotify16: Fix test failure on FUSE
ea085713f fanotify{14,15,16}: Check for filesystem mark support on filesystem 921f0ce86 fanotify13: Use generic check for mark type support on filesystem

Quoted 6 lines

I also wonder what I did wrong, the branch works after reboot, tested on:
1) mainline kernel 6.8.0-rc1 in rapido-linux
2) openSUSE kernel 6.8.0-rc1-2.gf4ba5db-default
3) 6.7.0-9.gaedda80-default

Which branch works? LTP master branch?

My claim is that with the current LTP master branch, fanotify01,09,10 would fail on kernel 6.8.0-rc1 when running with LTP_DEV_FS_TYPE=exfat (not LTP_SINGLE_FS_TYPE=exfat)

So at least you should consider applying this fix for the release:
f80dc512e fanotify{01,09,10}: Check for report fid support with mount mark

Thanks,
Amir.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 25 lines · Petr Vorel
Quoted 23 lines
Quoted 9 lines

When tested fs has zero fsid (e.g. fuse) and events are reported with fsid+fid, watching different filesystems with the same group is not supported.

Try to setup a bogus mark on test tmp dir, in addition to the mark on the tested filesystem, to check if marks on different filesystems are supported.

Quoted 5 lines

Run on all filesystem to test both fs with zero fsid (e.g. fuse) and fs with valid fsid.

---

Hi Amir,

Quoted 6 lines

Petr,

The fanotify tests changes that you already picked from my github [1] have to do with fixing new test failures in v6.7 and v6.8-rc1, dues to the fact that each of those kernel versions added new filesystems that support fanotify events with fid+fsid.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This is the only change to test new functionality in v6.8-rc1, namely, that for fs with zero fsid (e.g. fuse), an fanotify group can watch a single fs instance.

This patch would have to be rebased, to be applicable of the previous one (which touches more tests) in your branch.

I don't understand - this patch is already rebased.

I meant, you sent just this 2nd commit, without 1st commit f80dc512e ("fanotify{01,09,10}: Check for report fid support with mount mark") Therefore this commit is not applicable. I got just confused you send only this commit with without the previous one...

Quoted 10 lines

I have it in my branch after the fix patches:

7db2dac9f (HEAD -> fanotify_fsid) fanotify01: Test setting two marks on different filesystems
f80dc512e fanotify{01,09,10}: Check for report fid support with mount mark 9062824a7 (master) fanotify16: Fix test failure on FUSE
ea085713f fanotify{14,15,16}: Check for filesystem mark support on filesystem 921f0ce86 fanotify13: Use generic check for mark type support on filesystem

Quoted 7 lines
Quoted 4 lines

I also wonder what I did wrong, the branch works after reboot, tested on:
1) mainline kernel 6.8.0-rc1 in rapido-linux
2) openSUSE kernel 6.8.0-rc1-2.gf4ba5db-default
3) 6.7.0-9.gaedda80-default

Which branch works? LTP master branch?

I meant HEAD of your fanotify_fsid branch.

Quoted 3 lines

My claim is that with the current LTP master branch, fanotify01,09,10 would fail on kernel 6.8.0-rc1 when running with LTP_DEV_FS_TYPE=exfat (not LTP_SINGLE_FS_TYPE=exfat)

I'm sorry, I overlooked the different variable.
I see LTP_DEV_FS_TYPE=exfat gets EOPNOTSUPP on LTP master on 6.8.0-rc1:
fanotify01.c:106: TBROK: fanotify_mark(3, 0x11, 0x3b, ..., fs_mnt/tfile_4503) failed: EOPNOTSUPP (95)

Quoted 2 lines

So at least you should consider applying this fix for the release:
f80dc512e fanotify{01,09,10}: Check for report fid support with mount mark

I see. Yes, I reproduced the problem and thus cherry-picked and merged this one as bae8ec9a3.

Although this patch (the 2nd commit) should also work everywhere, I'll backport it just after the release.

Thanks a lot for explanation and sorry for the confusion.

Kind regards,
Petr

Quoted 2 lines

Thanks,
Amir.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
Quoted 67 lines · Petr Vorel
Quoted 26 lines · Petr Vorel
Quoted 23 lines
Quoted 9 lines

When tested fs has zero fsid (e.g. fuse) and events are reported with fsid+fid, watching different filesystems with the same group is not supported.

Try to setup a bogus mark on test tmp dir, in addition to the mark on the tested filesystem, to check if marks on different filesystems are supported.

Quoted 5 lines

Run on all filesystem to test both fs with zero fsid (e.g. fuse) and fs with valid fsid.

---

Hi Amir,

Quoted 6 lines

Petr,

The fanotify tests changes that you already picked from my github [1] have to do with fixing new test failures in v6.7 and v6.8-rc1, dues to the fact that each of those kernel versions added new filesystems that support fanotify events with fid+fsid.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This is the only change to test new functionality in v6.8-rc1, namely, that for fs with zero fsid (e.g. fuse), an fanotify group can watch a single fs instance.

This patch would have to be rebased, to be applicable of the previous one (which touches more tests) in your branch.

I don't understand - this patch is already rebased.

I meant, you sent just this 2nd commit, without 1st commit f80dc512e ("fanotify{01,09,10}: Check for report fid support with mount mark") Therefore this commit is not applicable. I got just confused you send only this commit with without the previous one...

Quoted 10 lines

I have it in my branch after the fix patches:

7db2dac9f (HEAD -> fanotify_fsid) fanotify01: Test setting two marks on different filesystems
f80dc512e fanotify{01,09,10}: Check for report fid support with mount mark 9062824a7 (master) fanotify16: Fix test failure on FUSE
ea085713f fanotify{14,15,16}: Check for filesystem mark support on filesystem 921f0ce86 fanotify13: Use generic check for mark type support on filesystem

Quoted 7 lines
Quoted 4 lines

I also wonder what I did wrong, the branch works after reboot, tested on:
1) mainline kernel 6.8.0-rc1 in rapido-linux
2) openSUSE kernel 6.8.0-rc1-2.gf4ba5db-default
3) 6.7.0-9.gaedda80-default

Which branch works? LTP master branch?

I meant HEAD of your fanotify_fsid branch.

Quoted 3 lines

My claim is that with the current LTP master branch, fanotify01,09,10 would fail on kernel 6.8.0-rc1 when running with LTP_DEV_FS_TYPE=exfat (not LTP_SINGLE_FS_TYPE=exfat)

I'm sorry, I overlooked the different variable.
I see LTP_DEV_FS_TYPE=exfat gets EOPNOTSUPP on LTP master on 6.8.0-rc1:
fanotify01.c:106: TBROK: fanotify_mark(3, 0x11, 0x3b, ..., fs_mnt/tfile_4503) failed: EOPNOTSUPP (95)

Quoted 8 lines
Quoted 2 lines

So at least you should consider applying this fix for the release:
f80dc512e fanotify{01,09,10}: Check for report fid support with mount mark

I see. Yes, I reproduced the problem and thus cherry-picked and merged this one as bae8ec9a3.

Although this patch (the 2nd commit) should also work everywhere, I'll backport it just after the release.

Sounds good.
Better also wait for ACK from Jan on this new test.

Quoted 3 lines

Thanks a lot for explanation and sorry for the confusion.

No worries.

The change of behavior that many fs started supporting fanotify with fid events was a bit challenging for those tests.

Sorry for not foreseeing this outcome. Glad it all worked out.

Thanks,
Amir.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#5 lore raw
In reply to Amir Goldstein
Quoted 4 lines · Amir Goldstein

When tested fs has zero fsid (e.g. fuse) and events are reported with fsid+fid, watching different filesystems with the same group is not supported.

Quoted 8 lines

Try to setup a bogus mark on test tmp dir, in addition to the mark on the tested filesystem, to check if marks on different filesystems are supported.

Run on all filesystem to test both fs with zero fsid (e.g. fuse) and fs with valid fsid.

The test looks good to me so feel free to add:

Honza

Quoted 122 lines

---

Petr,

The fanotify tests changes that you already picked from my github [1] have to do with fixing new test failures in v6.7 and v6.8-rc1, dues to the fact that each of those kernel versions added new filesystems that support fanotify events with fid+fsid.

This is the only change to test new functionality in v6.8-rc1, namely, that for fs with zero fsid (e.g. fuse), an fanotify group can watch a single fs instance.

To fix the problem that you reported with this test on exfat [2], I needed to make a distiction between the fs that do not support mount mark with fid due to having zero fsid (e.g. fuse) and those fs that do not support decoding fid (e.g. exfat).

It is not urgent to merge this change to the upcoming code freeze - it's up to you, but since I already tested it I am posting it now.

Thanks,
Amir.

[1] https://github.com/amir73il/ltp/commits/fanotify_fsid/
[2] https://lore.kernel.org/ltp/CAOQ4uxh1VwoMK_ssjdcxo_sk4cw0pD_FcXZ6Lb2=XHLf21kGAw@mail.gmail.com/T/#mf15d751e8f77a497ee4387b0791219e800cde7ea

 testcases/kernel/syscalls/fanotify/fanotify.h |  6 +++++-
 .../kernel/syscalls/fanotify/fanotify01.c     | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/fanotify/fanotify.h +5 -1
index e0d178bcc..554940a7e 100644
@@ -166,20 +166,23 @@ static inline int fanotify_flags_supported_on_fs(unsigned int init_flags,
 {
 	int fd;
 	int rval = 0;
+	int err = 0;
 
 	fd = fanotify_init(init_flags, O_RDONLY);
-
 	if (fd < 0) {
+		err = errno;
 		if (errno == ENOSYS)
 			tst_brk(TCONF, "fanotify not configured in kernel");
 		if (errno != EINVAL)
 			tst_brk(TBROK | TERRNO,
 				"fanotify_init(%x, O_RDONLY) failed",
 				init_flags);
+		errno = err;
 		return -1;
 	}
 
 	if (fname && fanotify_mark(fd, FAN_MARK_ADD | mark_flags, event_flags, AT_FDCWD, fname) < 0) {
+		err = errno;
 		if (errno == ENODEV || errno == EOPNOTSUPP || errno == EXDEV) {
 			rval = strcmp(fname, OVL_MNT) ? -2 : -3;
 		} else if (errno != EINVAL) {
@@ -194,6 +197,7 @@ static inline int fanotify_flags_supported_on_fs(unsigned int init_flags,
 
 	SAFE_CLOSE(fd);
 
+	errno = err;
 	return rval;
 }
 
testcases/kernel/syscalls/fanotify/fanotify01.c +19 -0
index e4398f236..ba09f309d 100644
@@ -77,6 +77,7 @@ static char buf[BUF_SIZE];
 static int fd_notify;
 static int fan_report_fid_unsupported;
 static int mount_mark_fid_unsupported;
+static int inode_mark_fid_xdev;
 static int filesystem_mark_unsupported;
 
 static unsigned long long event_set[EVENT_MAX];
@@ -328,6 +329,17 @@ pass:
 
 	}
 
+
+	/*
+	 * Try to setup a bogus mark on test tmp dir, to check if marks on
+	 * different filesystems are supported.
+	 * 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);
+
 	/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */
 	SAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE | mark->flag,
 			  FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN,
@@ -352,6 +364,12 @@ static void setup(void)
 	mount_mark_fid_unsupported = fanotify_flags_supported_on_fs(FAN_REPORT_FID,
 								    FAN_MARK_MOUNT,
 								    FAN_OPEN, fname);
+	/* When mount mark is not supported due to zero fsid, multi fs inode marks are not supported */
+	if (mount_mark_fid_unsupported && errno == ENODEV) {
+		tst_res(TINFO, "filesystem %s does not support reporting events with fid from multi fs",
+				tst_device->fs_type);
+		inode_mark_fid_xdev = EXDEV;
+	}
 }
 
 static void cleanup(void)
@@ -368,6 +386,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
+	.all_filesystems = 1,
 };
 
 #else
Signature · 1 line
2.34.1
Signature · 5 lines
Jan Kara <[email protected]>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw
In reply to Amir Goldstein

Hi Amir, Jan,

I was going to merge, but I suspect this does not work on TMPDIR on btrfs.

Tested on SLE 15-SP6 (kernel 6.4), on 15-SP4 (kernel 5.14), Tumbleweed (kernel 6.8.0-rc1), Alpine Linux (kernel 6.4) I get:

fanotify01.c:341: TFAIL: fanotify_mark(fd_notify, 0x00000001, 0x00000008, -100, ".") failed: EXDEV (18)

for tests #3, #4 and #5 on all filesystems.

Testing on other on other filesystem it works: Debian kernel 5.10, 6.1 on ext4, Alpine Linux kernel 6.4 on tmpfs, Tumbleweed kernel 6.8.0-rc1 on tmpfs.

Should be btrfs handled differently or skipped? (below)
Or test EXDEV for #3, #4 and #5? (not sure how handle just half of the tests on btrfs differently).

Kind regards,
Petr

kernel/syscalls/fanotify/fanotify01.c +7 -0
index ba09f309d..97ade1829 100644
@@ -335,8 +335,15 @@ pass:
 	 * different filesystems are supported.
 	 * When tested fs has zero fsid (e.g. fuse) and events are reported
 	 * with fsid+fid, watching different filesystems is not supported.
+	 * Not supported on Btrfs.
 	 */
+	if (tst_fs_type(".") == TST_BTRFS_MAGIC) {
+		tst_res(TCONF, "skipped on Btrfs");
+		return;
+	}
+
 	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);
 
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw
Quoted 5 lines · Petr Vorel

Hi Amir, Jan,

I was going to merge, but I suspect this does not work on TMPDIR on btrfs.

This is a problem because the test result depends on the type of TMPDIR. The failure in your case is because TMPDIR is not only btrfs, but a btrfs subvol.
Jan has dealt with several related fanotify tests failures lately.

Quoted 22 lines

Tested on SLE 15-SP6 (kernel 6.4), on 15-SP4 (kernel 5.14), Tumbleweed (kernel 6.8.0-rc1), Alpine Linux (kernel 6.4) I get:

fanotify01.c:341: TFAIL: fanotify_mark(fd_notify, 0x00000001, 0x00000008, -100, ".") failed: EXDEV (18)

for tests #3, #4 and #5 on all filesystems.

Testing on other on other filesystem it works: Debian kernel 5.10, 6.1 on ext4, Alpine Linux kernel 6.4 on tmpfs, Tumbleweed kernel 6.8.0-rc1 on tmpfs.

Should be btrfs handled differently or skipped? (below)
Or test EXDEV for #3, #4 and #5? (not sure how handle just half of the tests on btrfs differently).

Kind regards,
Petr

kernel/syscalls/fanotify/fanotify01.c +0 -0
index ba09f309d..97ade1829 100644

kernel/syscalls/fanotify/fanotify01.c pass: · line 344

Quoted 10 lines
kernel/syscalls/fanotify/fanotify01.c +6 -0
@@ -335,8 +335,15 @@ pass:
         * different filesystems are supported.
         * When tested fs has zero fsid (e.g. fuse) and events are reported
         * with fsid+fid, watching different filesystems is not supported.
+        * Not supported on Btrfs.
         */
+       if (tst_fs_type(".") == TST_BTRFS_MAGIC) {
+               tst_res(TCONF, "skipped on Btrfs");
+               return;
+       }
+

Note that btrfs is not the FS under test. It is the FS of TMPFS, so even if you did skip, this message would have been wrong.

Please try the patch below.

Thanks,
Amir.

testcases/kernel/syscalls/fanotify/fanotify01.c +0 -0
@@ -364,12 +364,19 @@ static void setup(void)
        mount_mark_fid_unsupported =

fanotify_flags_supported_on_fs(FAN_REPORT_FID,

FAN_MARK_MOUNT,

FAN_OPEN, fname);
- /* When mount mark is not supported due to zero fsid, multi fs
inode marks are not supported */
+ /*
+ * When mount mark is not supported due to zero fsid (e.g.
fuse) or if TMPDIR has non-uniform
+ * fsid (e.g. btrfs subvol), multi fs inode marks are not supported.
+ */
if (mount_mark_fid_unsupported && errno == ENODEV) {
tst_res(TINFO, "filesystem %s does not support
reporting events with fid from multi fs",

                                tst_device->fs_type);
                inode_mark_fid_xdev = EXDEV;
        }

+ if (fanotify_flags_supported_on_fs(FAN_REPORT_FID,
FAN_MARK_MOUNT, FAN_OPEN, ".")) {
+ inode_mark_fid_xdev = errno;
+ tst_res(TINFO, "TMPDIR does not support reporting
events with fid from multi fs");
+ }
}

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

Hi Amir,

Quoted 48 lines · Petr Vorel
Quoted 4 lines

Hi Amir, Jan,

I was going to merge, but I suspect this does not work on TMPDIR on btrfs.

This is a problem because the test result depends on the type of TMPDIR. The failure in your case is because TMPDIR is not only btrfs, but a btrfs subvol.
Jan has dealt with several related fanotify tests failures lately.

Quoted 22 lines

Tested on SLE 15-SP6 (kernel 6.4), on 15-SP4 (kernel 5.14), Tumbleweed (kernel 6.8.0-rc1), Alpine Linux (kernel 6.4) I get:

fanotify01.c:341: TFAIL: fanotify_mark(fd_notify, 0x00000001, 0x00000008, -100, ".") failed: EXDEV (18)

for tests #3, #4 and #5 on all filesystems.

Testing on other on other filesystem it works: Debian kernel 5.10, 6.1 on ext4, Alpine Linux kernel 6.4 on tmpfs, Tumbleweed kernel 6.8.0-rc1 on tmpfs.

Should be btrfs handled differently or skipped? (below)
Or test EXDEV for #3, #4 and #5? (not sure how handle just half of the tests on btrfs differently).

Kind regards,
Petr

kernel/syscalls/fanotify/fanotify01.c +0 -0
index ba09f309d..97ade1829 100644

kernel/syscalls/fanotify/fanotify01.c pass: · line 344

Quoted 10 lines
kernel/syscalls/fanotify/fanotify01.c +6 -0
@@ -335,8 +335,15 @@ pass:
         * different filesystems are supported.
         * When tested fs has zero fsid (e.g. fuse) and events are reported
         * with fsid+fid, watching different filesystems is not supported.
+        * Not supported on Btrfs.
         */
+       if (tst_fs_type(".") == TST_BTRFS_MAGIC) {
+               tst_res(TCONF, "skipped on Btrfs");
+               return;
+       }
+

Note that btrfs is not the FS under test. It is the FS of TMPFS, so even if you did skip, this message would have been wrong.

Quoted 1 line

Please try the patch below.

Great, works as expected.

I can merge amended commit [1], or feel free to send v2 if you want to mention btrfs subvol in the commit message.

Kind regards,
Petr

[1] https://github.com/pevik/ltp/commit/359047c97151d87b4e709bbabaaa529a31bcc50b

Quoted 32 lines

Thanks,
Amir.

testcases/kernel/syscalls/fanotify/fanotify01.c +0 -1
@@ -364,12 +364,19 @@ static void setup(void)
        mount_mark_fid_unsupported =
 fanotify_flags_supported_on_fs(FAN_REPORT_FID,
 
 FAN_MARK_MOUNT,
 
 FAN_OPEN, fname);
-       /* When mount mark is not supported due to zero fsid, multi fs

inode marks are not supported */

testcases/kernel/syscalls/fanotify/fanotify01.c +2 -0
+       /*
+        * When mount mark is not supported due to zero fsid (e.g.

fuse) or if TMPDIR has non-uniform

testcases/kernel/syscalls/fanotify/fanotify01.c +2 -0
+        * fsid (e.g. btrfs subvol), multi fs inode marks are not supported.
+        */
        if (mount_mark_fid_unsupported && errno == ENODEV) {
                tst_res(TINFO, "filesystem %s does not support

reporting events with fid from multi fs",

                                tst_device->fs_type);
                inode_mark_fid_xdev = EXDEV;
        }

+ if (fanotify_flags_supported_on_fs(FAN_REPORT_FID,
FAN_MARK_MOUNT, FAN_OPEN, ".")) {

testcases/kernel/syscalls/fanotify/fanotify01.c +2 -0
+               inode_mark_fid_xdev = errno;
+               tst_res(TINFO, "TMPDIR does not support reporting

events with fid from multi fs");
+ }
}

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw
Quoted 51 lines · Petr Vorel

Hi Amir,

Quoted 47 lines · Petr Vorel
Quoted 4 lines

Hi Amir, Jan,

I was going to merge, but I suspect this does not work on TMPDIR on btrfs.

This is a problem because the test result depends on the type of TMPDIR. The failure in your case is because TMPDIR is not only btrfs, but a btrfs subvol.
Jan has dealt with several related fanotify tests failures lately.

Quoted 22 lines

Tested on SLE 15-SP6 (kernel 6.4), on 15-SP4 (kernel 5.14), Tumbleweed (kernel 6.8.0-rc1), Alpine Linux (kernel 6.4) I get:

fanotify01.c:341: TFAIL: fanotify_mark(fd_notify, 0x00000001, 0x00000008, -100, ".") failed: EXDEV (18)

for tests #3, #4 and #5 on all filesystems.

Testing on other on other filesystem it works: Debian kernel 5.10, 6.1 on ext4, Alpine Linux kernel 6.4 on tmpfs, Tumbleweed kernel 6.8.0-rc1 on tmpfs.

Should be btrfs handled differently or skipped? (below)
Or test EXDEV for #3, #4 and #5? (not sure how handle just half of the tests on btrfs differently).

Kind regards,
Petr

kernel/syscalls/fanotify/fanotify01.c +0 -0
index ba09f309d..97ade1829 100644

kernel/syscalls/fanotify/fanotify01.c pass: · line 344

Quoted 10 lines
kernel/syscalls/fanotify/fanotify01.c +6 -0
@@ -335,8 +335,15 @@ pass:
         * different filesystems are supported.
         * When tested fs has zero fsid (e.g. fuse) and events are reported
         * with fsid+fid, watching different filesystems is not supported.
+        * Not supported on Btrfs.
         */
+       if (tst_fs_type(".") == TST_BTRFS_MAGIC) {
+               tst_res(TCONF, "skipped on Btrfs");
+               return;
+       }
+

Note that btrfs is not the FS under test. It is the FS of TMPFS, so even if you did skip, this message would have been wrong.

Quoted 7 lines
Quoted 1 line

Please try the patch below.

Great, works as expected.

I can merge amended commit [1], or feel free to send v2 if you want to mention btrfs subvol in the commit message.

Amended commit looks fine.

I don't think there is a need to specify btrfs subvol TMPDIR in the commit message.
It is a minor implementation detail, not the main thing.

Thanks,
Amir.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw
Quoted 60 lines · Petr Vorel
Quoted 51 lines

Hi Amir,

Quoted 47 lines · Petr Vorel
Quoted 4 lines

Hi Amir, Jan,

I was going to merge, but I suspect this does not work on TMPDIR on btrfs.

This is a problem because the test result depends on the type of TMPDIR. The failure in your case is because TMPDIR is not only btrfs, but a btrfs subvol.
Jan has dealt with several related fanotify tests failures lately.

Quoted 22 lines

Tested on SLE 15-SP6 (kernel 6.4), on 15-SP4 (kernel 5.14), Tumbleweed (kernel 6.8.0-rc1), Alpine Linux (kernel 6.4) I get:

fanotify01.c:341: TFAIL: fanotify_mark(fd_notify, 0x00000001, 0x00000008, -100, ".") failed: EXDEV (18)

for tests #3, #4 and #5 on all filesystems.

Testing on other on other filesystem it works: Debian kernel 5.10, 6.1 on ext4, Alpine Linux kernel 6.4 on tmpfs, Tumbleweed kernel 6.8.0-rc1 on tmpfs.

Should be btrfs handled differently or skipped? (below)
Or test EXDEV for #3, #4 and #5? (not sure how handle just half of the tests on btrfs differently).

Kind regards,
Petr

kernel/syscalls/fanotify/fanotify01.c +0 -0
index ba09f309d..97ade1829 100644

kernel/syscalls/fanotify/fanotify01.c pass: · line 344

Quoted 10 lines
kernel/syscalls/fanotify/fanotify01.c +6 -0
@@ -335,8 +335,15 @@ pass:
         * different filesystems are supported.
         * When tested fs has zero fsid (e.g. fuse) and events are reported
         * with fsid+fid, watching different filesystems is not supported.
+        * Not supported on Btrfs.
         */
+       if (tst_fs_type(".") == TST_BTRFS_MAGIC) {
+               tst_res(TCONF, "skipped on Btrfs");
+               return;
+       }
+

Note that btrfs is not the FS under test. It is the FS of TMPFS, so even if you did skip, this message would have been wrong.

Quoted 6 lines
Quoted 1 line

Please try the patch below.

Great, works as expected.

I can merge amended commit [1], or feel free to send v2 if you want to mention btrfs subvol in the commit message.

Quoted 5 lines

Amended commit looks fine.

I don't think there is a need to specify btrfs subvol TMPDIR in the commit message.
It is a minor implementation detail, not the main thing.

Good, merged!

Thanks!
Petr

Quoted 2 lines

Thanks,
Amir.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw
In reply to Amir Goldstein
Quoted 37 lines · Amir Goldstein
Quoted 22 lines · Petr Vorel

Tested on SLE 15-SP6 (kernel 6.4), on 15-SP4 (kernel 5.14), Tumbleweed (kernel 6.8.0-rc1), Alpine Linux (kernel 6.4) I get:

fanotify01.c:341: TFAIL: fanotify_mark(fd_notify, 0x00000001, 0x00000008, -100, ".") failed: EXDEV (18)

for tests #3, #4 and #5 on all filesystems.

Testing on other on other filesystem it works: Debian kernel 5.10, 6.1 on ext4, Alpine Linux kernel 6.4 on tmpfs, Tumbleweed kernel 6.8.0-rc1 on tmpfs.

Should be btrfs handled differently or skipped? (below)
Or test EXDEV for #3, #4 and #5? (not sure how handle just half of the tests on btrfs differently).

Kind regards,
Petr

kernel/syscalls/fanotify/fanotify01.c +0 -0
index ba09f309d..97ade1829 100644

kernel/syscalls/fanotify/fanotify01.c pass: · line 344

Quoted 10 lines
kernel/syscalls/fanotify/fanotify01.c +6 -0
@@ -335,8 +335,15 @@ pass:
         * different filesystems are supported.
         * When tested fs has zero fsid (e.g. fuse) and events are reported
         * with fsid+fid, watching different filesystems is not supported.
+        * Not supported on Btrfs.
         */
+       if (tst_fs_type(".") == TST_BTRFS_MAGIC) {
+               tst_res(TCONF, "skipped on Btrfs");
+               return;
+       }
+

Note that btrfs is not the FS under test. It is the FS of TMPFS, so even if you did skip, this message would have been wrong.

Quoted 1 line

Please try the patch below.

Thanks for fixing this so quickly! The fix looks good to me.

Honza

Signature · 5 lines
Jan Kara <[email protected]>
SUSE Labs, CR

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