Re: Reproducible, long-standing fanotify+autofs problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 25, 2017 at 1:48 PM, Marko Rauhamaa
<marko.rauhamaa@xxxxxxxxxxxx> wrote:
>
> 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.)
>

Not sure what is the role that autofs is playing in this hang, but it is worth
checking if Jan's latest work fixes the problem. I estimate that it should,
because it isolated the user space handling of permission events from
affecting processes generating fsnotify events on other fs objects.

git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git #for_testing

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

You mean other processes not trying to access objects under the
watched mounts. right?

>
>   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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux