All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Matthew Bobrowski <repnop@google.com>
Subject: Re: FAN_REPORT_CHILD_FID
Date: Mon, 12 Jul 2021 13:10:16 +0200	[thread overview]
Message-ID: <20210712111016.GC26530@quack2.suse.cz> (raw)
In-Reply-To: <CAOQ4uxgckzeRuiKSe7D=TVaJGTYwy4cbCFDpdWMQr1R_xXkJig@mail.gmail.com>

Hi Amir!

On Sun 11-07-21 20:02:29, Amir Goldstein wrote:
> I am struggling with an attempt to extend the fanotify API and
> I wanted to ask your opinion before I go too far in the wrong direction.
> 
> I am working with an application that used to use inotify rename
> cookies to match MOVED_FROM/MOVED_TO events.
> The application was converted to use fanotify name events, but
> the rename cookie functionality was missing, so I am carrying
> a small patch for FAN_REPORT_COOKIE.
> 
> I do not want to propose this patch for upstream, because I do
> not like this API.
> 
> What I thought was that instead of a "cookie" I would like to
> use the child fid as a way to pair up move events.
> This requires that the move events will never be merged and
> therefore not re-ordered (as is the case with inotify move events).
> 
> My thinking was to generalize this concept and introduce
> FAN_REPORT_CHILD_FID flag. With that flag, dirent events
> will report additional FID records, like events on a non-dir child
> (but also for dirent events on subdirs).

I'm starting to get lost in what reports what so let me draw a table here:

Non-directories
				DFID	FID	CHILD_FID
ACCESS/MODIFY/OPEN/CLOSE/ATTRIB parent	self	self
CREATE/DELETE/MOVE		-	-	-
DELETE_SELF/MOVE_SELF		x	self	self
('-' means cannot happen, 'x' means not generated)

Directories
				DFID	FID	CHILD_FID
ACCESS/MODIFY/OPEN/CLOSE/ATTRIB self	self	self
CREATE/DELETE/MOVE		self	self	target
DELETE_SELF/MOVE_SELF		x	self	self

Did I get this right?

I guess "CHILD_FID" seems somewhat confusing as it isn't immediately clear
from the name what it would report e.g. for open of a non-directory. Maybe
we could call it "TARGET_FID"? Also I'm not sure it needs to be exclusive
with FID. Sure it doesn't make much sense to report both FID and CHILD_FID
but does the exclusivity buy us anything? I guess I don't have strong
opinion either way, I'm just curious.
 
> Either FAN_REPORT_CHILD_FID would also prevent dirent events
> from being merged or we could use another flag for that purpose,
> but I wasn't able to come up with an idea for a name for this flag :-/
> 
> I sketched this patch [1] to implement the flag and to document
> the desired semantics. It's only build tested and I did not even
> implement the merge rules listed in the commit message.
> 
> [1] https://github.com/amir73il/linux/commits/fanotify_child_fid

WRT changes to merging: Whenever some application wants to depend on the
ordering of events I'm starting to get suspicious. What is it using these
events for? How is renaming different from linking a file into a new dir
and unlinking it from the previous one which is a series of events that
could be merged? Also fanotify could still be merging events happening
after rename to events before rename. Can the application tolerate that?
Inotify didn't do this because it is always merging only to the last event
in the queue.

When we were talking about FID events in the past (in the context of
directory events) we always talked about application just maintaining a set
of dirs (plus names) to look into. And that is safe and sound. But what you
talk about now seems rather fragile at least from the limited information I
have about your usecase...

> There are other benefits from FAN_REPORT_CHILD_FID which are
> not related to matching move event pairs, such as the case described
> in this discussion [2], where I believe you suggested something along
> the lines of FAN_REPORT_CHILD_FID.
> 
> [2] https://lore.kernel.org/linux-fsdevel/CAOQ4uxhEsbfA5+sW4XPnUKgCkXtwoDA-BR3iRO34Nx5c4y7Nug@mail.gmail.com/

Yes, I can see FAN_REPORT_CHILD_FID (or however we call it) can be useful
at times (in fact I think we made a mistake that we didn't make reported
FID to always be what you now suggest as CHILD_FID, but we found that out
only when DFID+NAME implementation settled so that train was long gone).
So I have no problem with that functionality as such.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2021-07-12 11:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11 17:02 FAN_REPORT_CHILD_FID Amir Goldstein
2021-07-12 11:10 ` Jan Kara [this message]
2021-07-12 13:00   ` FAN_REPORT_CHILD_FID Amir Goldstein
2021-07-12 16:26     ` FAN_REPORT_CHILD_FID Jan Kara
2021-07-12 18:08       ` FAN_REPORT_CHILD_FID Amir Goldstein
2021-07-14  1:16         ` FAN_REPORT_CHILD_FID Matthew Bobrowski
2021-07-14 12:09           ` FAN_REPORT_CHILD_FID Amir Goldstein
2021-07-15 23:53             ` FAN_REPORT_CHILD_FID Matthew Bobrowski
2021-07-16  9:47               ` FAN_REPORT_CHILD_FID Jan Kara
2021-07-16 11:24                 ` FAN_REPORT_CHILD_FID Amir Goldstein
2021-07-27 10:44                   ` FAN_REPORT_CHILD_FID Amir Goldstein
2021-07-28  9:51                     ` FAN_REPORT_CHILD_FID 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=20210712111016.GC26530@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --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 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.