linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Murphy Zhou <jencce.kernel@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: Amir Goldstein <amir73il@gmail.com>
Subject: [regression] fsnotify fails stress test since fsnotify_for_v5.15-rc1 merged
Date: Tue, 7 Sep 2021 14:33:38 +0800	[thread overview]
Message-ID: <20210907063338.ycaw6wvhzrfsfdlp@xzhoux.usersys.redhat.com> (raw)

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

             reply	other threads:[~2021-09-07  6:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07  6:33 Murphy Zhou [this message]
2021-09-09 11:00 ` [regression] fsnotify fails stress test since fsnotify_for_v5.15-rc1 merged 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

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=20210907063338.ycaw6wvhzrfsfdlp@xzhoux.usersys.redhat.com \
    --to=jencce.kernel@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).