linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Matthew Bobrowski <mbobrowski@mbobrowski.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 4/5] fanotify: add support for exclusive create of mark
Date: Fri, 18 Mar 2022 05:13:01 +0200	[thread overview]
Message-ID: <CAOQ4uxi85LV7upQuBUjL==aaWoY8WGMG4DRQToj6Y-JCn-Ex=g@mail.gmail.com> (raw)
In-Reply-To: <20220317154550.y3rvxmmfcaf5n5st@quack3.lan>

On Thu, Mar 17, 2022 at 5:45 PM Jan Kara <jack@suse.cz> wrote:
>
> On Thu 17-03-22 16:34:43, Jan Kara wrote:
> > On Mon 07-03-22 17:57:40, Amir Goldstein wrote:
> > > Similar to inotify's IN_MARK_CREATE, adding an fanotify mark with flag
> > > FAN_MARK_CREATE will fail with error EEXIST if an fanotify mark already
> > > exists on the object.
> > >
> > > Unlike inotify's IN_MARK_CREATE, FAN_MARK_CREATE has to supplied in
> > > combination with FAN_MARK_ADD (FAN_MARK_ADD is like inotify_add_watch()
> > > and the behavior of IN_MARK_ADD is the default for fanotify_mark()).
> > >
> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> >
> > What I'm missing in this changelog is "why". Is it just about feature
> > parity with inotify? I don't find this feature particularly useful...
>
> OK, now I understand after reading patch 5/5. Hum, but I'm not quite happy
> about the limitation to non-existing mark as much as I understand why you
> need it. Let me think...
>

Sorry for not articulating the problem better.
Let me write up the problem and maybe someone can come up with a better
solution than I did.

The problem that I was trying to avoid with FAN_MARK_VOLATILE is similar
to an existing UAPI problem with FAN_MARK_IGNORED_SURV_MODIFY -
This flag can only be set and not cleared and when set it affects all the events
set in the mask prior to that time, leading to unpredictable results.

Let's say a user sets FAN_CLOSE in ignored mask without _SURV_MODIFY
and later sets FAN_OPEN  in ignored mask with _SURV_MODIFY.
Does the ignored mask now include FAN_CLOSE? That depends
whether or not FAN_MODIFY event took place between the two calls.

That is one of the reasons I was trying to get rid of _SURV_MODIFY with
new FAN_MARK_IGNORE flag. The trickery in FAN_MARK_CREATE is
that the problem is averted - if a mark property can only be set and never
cleared and if it affects all past and future changes to mask, allow to set
this property during mark creation time and only during mark creation time.

I don't think there is a real use case for changing the _SURV_MODIFY
nor _VOLATILE property of a mark and indeed with new FAN_MARK_IGNORE
semantics, we may only allow to set _SURV_MODIFY along with
FAN_MARK_CREATE, so there are two problems solved using this method.

The fact that FAN_MARK_CREATE has feature parity with inotify is not
the reason to add it, but it does help to swallow this somewhat awkward
solution. And it is certainly easy to document.

As the commit message implies, I was contemplating whether
FAN_MARK_CREATE should be an alternative to FAN_MARK_ADD
or an ORed flag.
Semantics-wise we could decide either way.
I chose the option that seemed easier to implement and document
the behavior of FAN_MARK_VOLATILE.
Using FAN_MARK_CREATE as an alternative to FAN_MARK_ADD may
be a bit more elegant for UAPI though.
We could use a macro to get UAPI elegance without compromising simplicity:

#define FAN_MARK_NEW (FAN_MARK_ADD | FAN_MARK_CREATE)

Thanks,
Amir.

  reply	other threads:[~2022-03-18  3:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 15:57 [PATCH 0/5] Volatile fanotify marks Amir Goldstein
2022-03-07 15:57 ` [PATCH 1/5] fsnotify: move inotify control flags to mark flags Amir Goldstein
2022-03-17 14:25   ` Jan Kara
2022-03-17 15:12     ` Amir Goldstein
2022-03-07 15:57 ` [PATCH 2/5] fsnotify: pass flags argument to fsnotify_add_mark() Amir Goldstein
2022-03-07 15:57 ` [PATCH 3/5] fsnotify: allow adding an inode mark without pinning inode Amir Goldstein
2022-03-17 15:27   ` Jan Kara
2022-03-18  6:23     ` Amir Goldstein
2022-03-20 13:06       ` Amir Goldstein
2022-03-07 15:57 ` [PATCH 4/5] fanotify: add support for exclusive create of mark Amir Goldstein
2022-03-17 15:34   ` Jan Kara
2022-03-17 15:45     ` Jan Kara
2022-03-18  3:13       ` Amir Goldstein [this message]
2022-03-18 10:32         ` Jan Kara
2022-03-18 11:04           ` Amir Goldstein
2022-03-18 14:09             ` Jan Kara
2022-03-18 16:06               ` Amir Goldstein
2022-03-20 13:00                 ` Amir Goldstein
2022-03-22 16:44                   ` direct reclaim of fanotify evictable marks Amir Goldstein
2022-03-23  9:16                     ` Amir Goldstein
2022-03-21  9:09                 ` [PATCH 4/5] fanotify: add support for exclusive create of mark Jan Kara
2022-03-07 15:57 ` [PATCH 5/5] fanotify: add support for "volatile" inode marks Amir Goldstein
2022-03-17 14:12 ` [PATCH 0/5] Volatile fanotify marks Jan Kara
2022-03-17 15:14   ` Amir Goldstein
2022-03-20 12:54     ` Amir Goldstein
2022-06-13  5:40       ` LTP test for fanotify evictable marks Amir Goldstein
2022-06-13 11:59         ` Jan Kara
2022-06-13 14:16           ` Amir Goldstein

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='CAOQ4uxi85LV7upQuBUjL==aaWoY8WGMG4DRQToj6Y-JCn-Ex=g@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mbobrowski@mbobrowski.org \
    /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).