linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [regression] fsnotify fails stress test since fsnotify_for_v5.15-rc1 merged
@ 2021-09-07  6:33 Murphy Zhou
  2021-09-09 11:00 ` Amir Goldstein
  0 siblings, 1 reply; 6+ messages in thread
From: Murphy Zhou @ 2021-09-07  6:33 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Amir Goldstein

Hi,

Since this commit:

commit ec44610fe2b86daef70f3f53f47d2a2542d7094f
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Tue Aug 10 18:12:19 2021 +0300

    fsnotify: count all objects with attached connectors




Kernel fsnotify can't finish a stress testcase that used to pass quickly.

Kernel hung at umount. Can not be killed but restarting the server.

Reproducer text is attached.

Thanks,
Murphy

--- reproducer test.sh start -------------------------------------

#!/bin/bash

cc fanotify_init_stress.c -o fanotify_init_stress || exit
cc fanotify_flush_stress.c -o fanotify_flush_stress || exit

export TIMEOUT=10s
STRESSES="fanotify_flush_stress fanotify_init_stress"

function cleanup_processes()
{
	while ps jf | egrep "fanotify_flush_stress|fanotify_init_stress" | grep -v grep ; do
		killall fanotify_init_stress > /dev/null 2>&1
		killall fanotify_flush_stress > /dev/null 2>&1
		sleep 1
	done
}

SCRATCH_MNT=/fsn

fallocate -l 1G fsn.img || exit
mkfs.xfs -f fsn.img || exit
mkdir -p $SCRATCH_MNT
mount -o loop fsn.img $SCRATCH_MNT || exit

touch $SCRATCH_MNT/testfile
for i in $STRESSES
do
for j in $STRESSES
do
	echo testing $i $j
	./$i $SCRATCH_MNT $TIMEOUT > /dev/null 2>&1 &
	./$i $SCRATCH_MNT/testfile $TIMEOUT > /dev/null 2>&1 &
	./$j $SCRATCH_MNT $TIMEOUT > /dev/null 2>&1 &
	./$j $SCRATCH_MNT/testfile $TIMEOUT > /dev/null 2>&1 &
	sleep $TIMEOUT
	cleanup_processes
done
done
sleep $TIMEOUT
sync
umount $SCRATCH_MNT
rm -rf fsn* tmp
--- reproducer test.sh end -------------------------------------

--- reproducer fanotify_flush_stress.c start----------------
#define _GNU_SOURCE     /* Needed to get O_LARGEFILE definition */
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/fanotify.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char *argv[])
{
	char buf;
	int fd;

#if 0
	/* Check mount point is supplied */
	if (argc != 2) {
		fprintf(stderr, "Usage: %s MOUNT\n", argv[0]);
		exit(EXIT_FAILURE);
	}
#endif

	printf("%s on %s\n", argv[0], argv[1]);
	/* Create the file descriptor for accessing the fanotify API */
	fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,
					   O_RDONLY | O_LARGEFILE);
	if (fd == -1) {
		perror("fanotify_init");
		exit(EXIT_FAILURE);
	}

	/* Loop marking all kinds of events and flush */
	while (1) {

		if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,
			  FAN_ACCESS | FAN_MODIFY | FAN_OPEN_PERM | FAN_CLOSE |
			  FAN_OPEN | FAN_ACCESS_PERM | FAN_ONDIR |
			  FAN_EVENT_ON_CHILD, -1, argv[1]) == -1)

			perror("fanotify_mark add");

		if (fanotify_mark(fd, FAN_MARK_FLUSH | FAN_MARK_MOUNT,
						0, -1, argv[1]) == -1)
			perror("fanotify_mark flush mount");

		if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,
			  FAN_ACCESS | FAN_MODIFY | FAN_OPEN_PERM | FAN_CLOSE |
			  FAN_OPEN | FAN_ACCESS_PERM | FAN_ONDIR |
			  FAN_EVENT_ON_CHILD, -1, argv[1]) == -1)

			perror("fanotify_mark add");

		if (fanotify_mark(fd, FAN_MARK_FLUSH, 0, -1, argv[1]) == -1)
			perror("fanotify_mark flush");
	}

	close(fd);
	exit(EXIT_SUCCESS);
}
--- reproducer fanotify_flush_stress.c end ----------------
--- reproducer fanotify_init_stress.c start -----------_
#define _GNU_SOURCE     /* Needed to get O_LARGEFILE definition */
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/fanotify.h>

int main(int argc, char *argv[])
{
	char buf;
	int fd;
#if 0
	/* Check mount point is supplied */
	if (argc != 2) {
		fprintf(stderr, "Usage: %s MOUNT\n", argv[0]);
		exit(EXIT_FAILURE);
	}
#endif
	printf("%s on %s\n", argv[0], argv[1]);
	while (1) {

		/* Create the file descriptor for accessing the fanotify API */
		fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT |
				FAN_NONBLOCK, O_RDONLY | O_LARGEFILE);
		if (fd == -1)
			perror("fanotify_init");

		if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,
				FAN_ACCESS | FAN_MODIFY | FAN_OPEN_PERM |
				FAN_CLOSE | FAN_OPEN | FAN_ACCESS_PERM |
				FAN_ONDIR | FAN_EVENT_ON_CHILD, -1,
				argv[1]) == -1)
			perror("fanotify_mark");

		close(fd);
	}

	exit(EXIT_SUCCESS);
}
--- reproducer fanotify_init_stress.c end -----------_

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-10  1:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07  6:33 [regression] fsnotify fails stress test since fsnotify_for_v5.15-rc1 merged Murphy Zhou
2021-09-09 11:00 ` Amir Goldstein
2021-09-09 11:11   ` Petr Vorel
2021-09-09 11:14     ` Petr Vorel
2021-09-10  1:06       ` Murphy Zhou
2021-09-10  1:05   ` Murphy Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).