From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Matthew Bobrowski <repnop@google.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux API <linux-api@vger.kernel.org>
Subject: Re: [PATCH 2/2] fanotify: introduce FAN_MARK_IGNORE
Date: Thu, 23 Jun 2022 15:17:00 +0300 [thread overview]
Message-ID: <CAOQ4uxiy7WkzhUO6o4ZgpNH2rrca5iXwTFujw=rJNWosVaK8zA@mail.gmail.com> (raw)
In-Reply-To: <20220623101408.ejmqpp7xw6f67me7@quack3.lan>
On Thu, Jun 23, 2022 at 1:14 PM Jan Kara <jack@suse.cz> wrote:
>
> On Mon 20-06-22 16:45:51, Amir Goldstein wrote:
> > This flag is a new way to configure ignore mask which allows adding and
> > removing the event flags FAN_ONDIR and FAN_EVENT_ON_CHILD in ignore mask.
> >
> > The legacy FAN_MARK_IGNORED_MASK flag would always ignore events on
> > directories and would ignore events on children depending on whether
> > the FAN_EVENT_ON_CHILD flag was set in the (non ignored) mask.
> >
> > FAN_MARK_IGNORE can be used to ignore events on children without setting
> > FAN_EVENT_ON_CHILD in the mark's mask and will not ignore events on
> > directories unconditionally, only when FAN_ONDIR is set in ignore mask.
> >
> > The new behavior is sticky. After calling fanotify_mark() with
> > FAN_MARK_IGNORE once, calling fanotify_mark() with FAN_MARK_IGNORED_MASK
> > will update the ignore mask, but will not change the event flags in
> > ignore mask nor how these flags are treated.
>
> IMHO this stickyness is not very obvious. Wouldn't it be less error-prone
> for users to say that once FAN_MARK_IGNORE is used for a mark, all
> subsequent modifications of ignore mask have to use FAN_MARK_IGNORE? I mean
> if some program bothers with FAN_MARK_IGNORE, I'd expect it to use it for
> all its calls as otherwise the mixup is kind of difficult to reason
> about...
I like that.
>
> Also it follows the behavior we have picked for FAN_MARK_EVICTABLE AFAIR
> but that's not really important to me.
It's kind of the opposite in the case of FAN_MARK_EVICTABLE.
FAN_MARK_EVICTABLE can be "upgraded" no non-evictable
but not the other way around.
And also with FAN_MARK_EVICTABLE we do not deprecate the
old API...
See man page draft:
https://github.com/amir73il/man-pages/commit/58851140bbc08b9ab9c7edd8830f37cf883d8d2a#diff-7a4387558a34e18ed6fb13d31933b2e4506496f8b3dd55df700f62b258e6f004R165
>
> > @@ -1591,10 +1601,20 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
> >
> > /*
> > * Event flags (FAN_ONDIR, FAN_EVENT_ON_CHILD) have no effect with
> > - * FAN_MARK_IGNORED_MASK.
> > + * FAN_MARK_IGNORED_MASK. They can be updated in ignore mask with
> > + * FAN_MARK_IGNORE and then they do take effect.
> > */
> > - if (ignore)
> > + switch (ignore) {
> > + case 0:
> > + case FAN_MARK_IGNORE:
> > + break;
> > + case FAN_MARK_IGNORED_MASK:
> > mask &= ~FANOTIFY_EVENT_FLAGS;
> > + umask = FANOTIFY_EVENT_FLAGS;
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
>
> I think this would be easier to follow as two ifs:
>
> /* We don't allow FAN_MARK_IGNORE & FAN_MARK_IGNORED_MASK together */
> if (ignore == FAN_MARK_IGNORE | FAN_MARK_IGNORED_MASK)
> return -EINVAL;
> /*
> * Event flags (FAN_ONDIR, FAN_EVENT_ON_CHILD) have no effect with
> * FAN_MARK_IGNORED_MASK.
> */
> if (ignore == FAN_MARK_IGNORED_MASK) {
> mask &= ~FANOTIFY_EVENT_FLAGS;
> umask = FANOTIFY_EVENT_FLAGS;
> }
>
Yeh that looks better.
Thanks,
Amir.
prev parent reply other threads:[~2022-06-23 12:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 13:45 [PATCH 0/2] New fanotify API for ignoring events Amir Goldstein
2022-06-20 13:45 ` [PATCH 1/2] fanotify: prepare for setting event flags in ignore mask Amir Goldstein
2022-06-22 15:52 ` Jan Kara
2022-06-22 18:31 ` Amir Goldstein
2022-06-24 11:32 ` Amir Goldstein
2022-06-24 12:35 ` Jan Kara
2022-06-22 16:00 ` Jan Kara
2022-06-22 18:28 ` Amir Goldstein
2022-06-23 9:49 ` Jan Kara
2022-06-23 13:59 ` Amir Goldstein
2022-06-20 13:45 ` [PATCH 2/2] fanotify: introduce FAN_MARK_IGNORE Amir Goldstein
2022-06-23 10:14 ` Jan Kara
2022-06-23 12:17 ` Amir Goldstein [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='CAOQ4uxiy7WkzhUO6o4ZgpNH2rrca5iXwTFujw=rJNWosVaK8zA@mail.gmail.com' \
--to=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=repnop@google.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).