All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Tycho Kirchner <tychokirchner@mail.de>
Subject: Re: [RFC] Volatile fanotify marks
Date: Mon, 28 Feb 2022 19:40:07 +0200	[thread overview]
Message-ID: <CAOQ4uxiMp4HjSj01FZm8-jPzHD4jVugxuXBDW2JnSpVizhCeTQ@mail.gmail.com> (raw)
In-Reply-To: <20220228140556.ae5rhgqsyzm5djbp@quack3.lan>

On Mon, Feb 28, 2022 at 4:06 PM Jan Kara <jack@suse.cz> wrote:
>
> Hi Amir!
>
> On Wed 23-02-22 20:42:37, Amir Goldstein wrote:
> > I wanted to get your feedback on an idea I have been playing with.
> > It started as a poor man's alternative to the old subtree watch problem.
> > For my employer's use case, we are watching the entire filesystem using
> > a filesystem mark, but would like to exclude events on a subtree
> > (i.e. all files underneath .private/).
> >
> > At the moment, those events are filtered in userspace.
> > I had considered adding directory marks with an ignored mask on every
> > event that is received for a directory path under .private/, but that has the
> > undesired side effect of pinning those directory inodes to cache.
> >
> > I have this old fsnotify-volatile branch [1] that I am using for an overlayfs
> > kernel internal fsnotify backend. I wonder what are your thoughts on
> > exposing this functionally to fanotify UAPI (i.e. FAN_MARK_VOLATILE).
>
> Interesting idea. I have some reservations wrt to the implementation (e.g.
> fsnotify_add_mark_list() convention of returning EEXIST when it updated
> mark's mask, or the fact that inode reclaim should now handle freeing of
> mark connector and attached marks - which may get interesting locking wise)
> but they are all fixable.

Can you give me a hint as to how to implement the freeing of marks?

>
> I'm wondering a bit whether this is really useful enough (and consequently
> whether we will not get another request to extend fanotify API in some
> other way to cater better to some other usecase related to subtree watches
> in the near future). I understand ignore marks are mainly a performance
> optimization and as such allowing inodes to be reclaimed (which means they
> are not used much and hence ignored mark is not very useful anyway) makes

The problem is that we do not know in advance which of the many dirs in
the subtree are accessed often and which are accessed rarely (and that may
change over time), so volatile ignore marks are a way to set up ignore marks
on the most accessed dirs dynamically.

> sense. Thinking about this more, I guess it is useful to improve efficiency
> when you want to implement any userspace event-filtering scheme.
>
> The only remaining pending question I have is whether we should not go
> further and allow event filtering to happen using an eBPF program. That
> would be even more efficient (both in terms of memory and CPU). What do you
> think?
>

I think that is an unrelated question.

I do agree that we should NOT add "subtree filter" functionality to fanotify
(or any other filter) and that instead, we should add support for attaching an
eBPF program that implements is_subdir().
I found this [1] convection with Tycho where you had suggested this idea.
I wonder if Tycho got to explore this path further?

But I think that it is one thing to recommend users to implement their
filters as
eBPF programs and another thing to stand in the way of users that prefer to
implement userspace event filtering. It could be that the filter
cannot be easily
described by static rules to an eBPF program (e.g. need to query a database).

In my POV, FAN_MARK_VOLATILE does not add any new logic/filtering rule.
It adds resource control by stating that the ignore mark is "best effort".

Does it make sense?

Thanks,
Amir.

[1] https://lore.kernel.org/linux-fsdevel/20200828084603.GA7072@quack2.suse.cz/

  reply	other threads:[~2022-02-28 17:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 18:42 [RFC] Volatile fanotify marks Amir Goldstein
2022-02-28 14:05 ` Jan Kara
2022-02-28 17:40   ` Amir Goldstein [this message]
2022-03-01 11:07     ` Jan Kara
2022-03-01 11:27       ` Amir Goldstein
2022-03-01 12:26     ` Tycho Kirchner
2022-03-01 16:58       ` Amir Goldstein
2022-03-02 10:04         ` Tycho Kirchner
2022-03-02 18:14           ` Amir Goldstein
2022-03-03  9:24             ` Jan Kara
2022-05-02  9:13               ` Tycho Kirchner
2022-05-04  6:13                 ` Amir Goldstein
2022-05-04 10:01                   ` Tycho Kirchner
2022-05-04 14:37                     ` Amir Goldstein
2022-05-06  9:59                       ` Tycho Kirchner
2022-05-05 10:42                     ` Jan Kara
2022-05-13 15:30   ` Matthew Bobrowski

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=CAOQ4uxiMp4HjSj01FZm8-jPzHD4jVugxuXBDW2JnSpVizhCeTQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tychokirchner@mail.de \
    /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 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.