All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] fanotify01: Test setting two marks on different filesystems
Date: Thu, 25 Jan 2024 13:23:37 +0100	[thread overview]
Message-ID: <20240125122337.GA398849@pevik> (raw)
In-Reply-To: <20240125110510.751445-1-amir73il@gmail.com>

> 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.

> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---

Hi Amir,

> 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

> 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

> 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(-)

> diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
> index e0d178bcc..554940a7e 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify.h
> +++ b/testcases/kernel/syscalls/fanotify/fanotify.h
> @@ -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;
>  }

> diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
> index e4398f236..ba09f309d 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify01.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
> @@ -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

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

  reply	other threads:[~2024-01-25 12:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 11:05 [LTP] [PATCH] fanotify01: Test setting two marks on different filesystems Amir Goldstein
2024-01-25 12:23 ` Petr Vorel [this message]
2024-01-25 13:45   ` Amir Goldstein
2024-01-25 14:44     ` Petr Vorel
2024-01-26  7:38       ` Amir Goldstein
2024-01-26 11:44 ` Jan Kara
2024-01-30 13:07 ` Petr Vorel
2024-01-30 14:58   ` Amir Goldstein
2024-01-30 18:44     ` Petr Vorel
2024-01-30 19:22       ` Amir Goldstein
2024-01-30 20:26         ` Petr Vorel
2024-01-30 21:31     ` Jan Kara

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=20240125122337.GA398849@pevik \
    --to=pvorel@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.