From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
Matthew Bobrowski <mbobrowski@mbobrowski.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-api@vger.kernel.org,
Radu Voicilas <radu.voicilas@gmail.com>
Subject: Re: [PATCH v2 0/9] fanotify: add support for more event types
Date: Tue, 20 Nov 2018 11:34:13 +0100 [thread overview]
Message-ID: <20181120103413.GE8842@quack2.suse.cz> (raw)
In-Reply-To: <CAOQ4uxh_nErrA1h_aL7b5-y9et4jdUgpbCxtOxt0RNANx5HJOQ@mail.gmail.com>
On Sun 18-11-18 14:09:34, Amir Goldstein wrote:
> On Thu, Nov 15, 2018 at 8:45 PM Amir Goldstein <amir73il@gmail.com> wrote:
> >
> > Jan,
> >
> > This is the final part of patch series to add support for filesystem
> > change monitoring to fanotify.
> >
> > The end game is to use:
> > fd = fanotify_init(FAN_CLASS_NOTIF|FAN_REPORT_FID, ...);
> > rc = fanotify_mark(fd, FAN_MARK_FILESYSTEM, FAN_CREATE|FAN_DELETE...);
> > to monitor changes to a large scale namespace.
> >
> > This functionality was not available with inotify API, which does not
> > scale well with recursive directory watches and was not available
> > with fanotify API, which did not support directory modification events.
> >
>
> And to demonstrate the power unleashed by FAN_MARK_FILESYSTEM
> with FAN_REPORT_FID, I have made a prototype of "global filesystem
> monitor" based on inotify-tools:
> https://github.com/amir73il/inotify-tools/commits/fanotify_fid
This is indeed impressive :).
Honza
> === This is how legacy "recursive inotify" monitoring looks like: ===
>
> ~# /vtmp/inotifywait -m -r /vdf &
> Setting up watches. Beware: since -r was given, this may take a while!
> Watches established.
> root@kvm-xfstests:~# mkdir -p /vdf/a/b/c/d/e/ && touch /vdf/a/b/c/d/e/x
> /vdf/ CREATE,ISDIR a
> /vdf/ OPEN,ISDIR a
> /vdf/ CLOSE_NOWRITE,CLOSE,ISDIR a
> /vdf/ OPEN,ISDIR a
> /vdf/ ACCESS,ISDIR a
> /vdf/ CLOSE_NOWRITE,CLOSE,ISDIR a
> /vdf/a/b/c/d/e/ CREATE x
> /vdf/a/b/c/d/e/ OPEN x
> /vdf/a/b/c/d/e/ ATTRIB x
> /vdf/a/b/c/d/e/ CLOSE_WRITE,CLOSE x
>
> 1. The inherent recursive watch race missed most dir create events.
> 2. Watches setup time depends on the size of directory tree.
> 3. Recursive watches pins to inode cache all directory inodes in the tree.
> 4. CREATE events carry the created filename information
> 5. Events are generated only under the watched tree
>
> === And this is how "global fanotify" monitoring looks like: ===
>
> root@kvm-xfstests:~# /vtmp/inotifywait -m -g /vdf &
> Setting up global filesystem watches.
> Watches established.
>
> root@kvm-xfstests:~# mkdir -p /vdf/a/b/c/d/e/ && touch /vdf/a/b/c/d/e/x
>
> /vdf/ CREATE,ISDIR
> Start watching /vdf/a (fid=10001f1...).
> /vdf/a CLOSE_NOWRITE,OPEN,CLOSE
> /vdf/a CREATE,ISDIR
> /vdf/a CLOSE_NOWRITE,OPEN,CLOSE
> Start watching /vdf/a/b (fid=200e4a6...).
> /vdf/a/b CLOSE_NOWRITE,OPEN,CREATE,CLOSE,ISDIR
> /vdf/a/b CLOSE_NOWRITE,OPEN,CLOSE
> Start watching /vdf/a/b/c (fid=3000159...).
> /vdf/a/b/c CLOSE_NOWRITE,OPEN,CLOSE
> /vdf/a/b/c CLOSE_NOWRITE,OPEN,CLOSE
> /vdf/a/b/c CREATE,ISDIR
> Start watching /vdf/a/b/c/d (fid=105...).
> /vdf/a/b/c/d OPEN
> /vdf/a/b/c/d CLOSE_NOWRITE,OPEN,CLOSE
> /vdf/a/b/c/d CLOSE_NOWRITE,CLOSE
> /vdf/a/b/c/d CREATE,ISDIR
> Start watching /vdf/a/b/c/d/e (fid=10001f2...).
> /vdf/a/b/c/d/e CREATE
> Start watching /vdf/a/b/c/d/e/x (fid=10001f3...).
> /vdf/a/b/c/d/e/x ATTRIB,CLOSE_WRITE,OPEN,CLOSE
> /vdf/a/b/c/d/e CLOSE_NOWRITE,OPEN,CLOSE
> /vdf/a/b/c/d/e/x CLOSE_NOWRITE,OPEN,CLOSE
>
> 1. No directory create/access events are missed
> 2. Setup time in O(1)
> 3. No directory inodes are pinned to inode cache
> 4. CREATE events carry only the directory where file
> was created and the ISDIR flag if this was a mkdir
> 5. Events are generated for any object in the watched
> filesystem (can be filtered in userspace by regex on path)
>
> NOTE: "Start watching..." in global watch means that
> userspace adds an entry to fid => path map, but there is
> no object associated with that "watch" in the kernel and no
> kernel resource is consumed per "watch".
>
> NOTE #2: This is just a prototype. Some use cases like
> monitoring several filesystems and renaming userspace
> watch entries are not supported.
>
> Thanks,
> Amir.
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2018-11-20 21:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 18:45 [PATCH v2 0/9] fanotify: add support for more event types Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 1/9] fanotify: rename struct fanotify_{,perm_}event_info Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 2/9] fanotify: define the structures to report a unique file identifier Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 3/9] fanotify: classify events that hold a " Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 4/9] fanotify: encode file identifier for FAN_REPORT_FID Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 5/9] fanotify: copy event fid info to user Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 6/9] fanotify: enable FAN_REPORT_FID init flag Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 7/9] fanotify: support events with data type FSNOTIFY_EVENT_DENTRY Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 8/9] fanotify: add support for create/attrib/move/delete events Amir Goldstein
2018-11-15 18:45 ` [PATCH v2 9/9] fanotify: report FAN_ONDIR to listener for filename events Amir Goldstein
2018-11-18 12:09 ` [PATCH v2 0/9] fanotify: add support for more event types Amir Goldstein
2018-11-20 10:34 ` Jan Kara [this message]
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=20181120103413.GE8842@quack2.suse.cz \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mbobrowski@mbobrowski.org \
--cc=radu.voicilas@gmail.com \
/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).