All of lore.kernel.org
 help / color / mirror / Atom feed
* Reproducible, long-standing fanotify+autofs problem
@ 2017-01-25 11:48 Marko Rauhamaa
  2017-01-25 12:03 ` Amir Goldstein
  0 siblings, 1 reply; 11+ messages in thread
From: Marko Rauhamaa @ 2017-01-25 11:48 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: marko.rauhamaa, Amir Goldstein


We have run into an easily reproducible fanotify hang that affects
several distros as well as the latest development kernel. (It isn't
fixed by Amir Goldstein's recent fanotify patch, BTW.)

Here is a simple reproduction:

 1. Compile and build the tiny test program below, which has been
    adapted from the example in "man fanotify":

    cc -o fantest3 fantest.c

 2. Install autofs.

 3. Run these commands as root:

      mkdir -p foo/home/test foo/user/test
      echo /sshome /etc/auto.sshome >/etc/auto.master
      echo "test / :/root/foo/home/test /user :/root/foo/user/test" \
          >/etc/auto.sshome
      systemctl start autofs
      ls -l /sshome/test
      ./fantest3 / /sshome/test /sshome/test/user/

      # NB! The final slash in the fantest3 command can be significant!

  4. Observe the last command hang. While it is hung, other file system
     operations from other processes are blocked.

  5. Press Ctrl-C to force fantest3 to exit. The file system becomes
     alive. Rerunning the fantest3 command no longer hangs.

  6. To get back into the problem state, execute (as root):

      systemctl restart autofs
      ls -l /sshome/test
      ./fantest3 / /sshome/test /sshome/test/user/


===Begin fantest.c======================================================
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/fanotify.h>

int main(int argc, char *argv[])
{
    int fd, i;
    if (argc < 2) {
        fprintf(stderr, "Usage: %s MOUNT ...\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,
                       O_RDONLY);
    if (fd == -1) {
        perror("fanotify_init");
        exit(EXIT_FAILURE);
    }
    for (i = 1; i < argc; i++)
        if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,
                          FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD,
                          argv[i]) == -1) {
            perror("fanotify_mark");
            exit(EXIT_FAILURE);
        }
    exit(EXIT_SUCCESS);
}
===End fantest.c========================================================


Marko

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

end of thread, other threads:[~2017-01-27 14:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25 11:48 Reproducible, long-standing fanotify+autofs problem Marko Rauhamaa
2017-01-25 12:03 ` Amir Goldstein
2017-01-25 14:06   ` Marko Rauhamaa
2017-01-25 14:11     ` Amir Goldstein
2017-01-25 14:42       ` Marko Rauhamaa
2017-01-25 14:54         ` Amir Goldstein
2017-01-25 15:15           ` Jan Kara
     [not found]             ` <87efzrrwec.fsf@drapion.f-secure.com>
     [not found]               ` <20170127134620.GA16757@quack2.suse.cz>
2017-01-27 14:21                 ` Marko Rauhamaa
2017-01-25 15:20           ` Marko Rauhamaa
2017-01-26 17:47             ` Marko Rauhamaa
2017-01-26 18:05               ` Marko Rauhamaa

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.