Linux-Fsdevel Archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jonathan Gilbert <logic@deltaq.org>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: Re: fanotify and files being moved or deleted
Date: Wed, 22 May 2024 08:26:03 +0300	[thread overview]
Message-ID: <CAOQ4uxiMtd80k9N93wjkO13vmmSt5s1333WdSrauGD_-b+rsRQ@mail.gmail.com> (raw)
In-Reply-To: <CAOQ4uxgOmJjJT=mX96-AwWY_p9fHXtvNZFUcPgqggKgGtpsq9A@mail.gmail.com>

> > > If /home is a bind mount from, say, /data/home/ and you are watching
> > > both /home and /data, you will need to figure out that they are the same
> > > underlying fs and use a mount_fd of /data.
> >
> > My current plan is to discard any mounts which specify a root that is
> > a subpath of another mount, and in the case of multiple mounts of the
> > same root, pick one to move forward with (with hints from
> > configuration) and only mark that one.
> >
>
> You can also use open_by_handle() to determine if one mount
> is a subtree of another.
>
> if you have two fds and two different fhandles from the root of two mounts
> of the same fsid, only one of these commands will result in an fd with
> non empty path:
> fd2inmount1 = open_by_handle_at(mount1_fd, fhandle2, O_PATH);
> fd1inmount2 = open_by_handle_at(mount2_fd, fhandle1, O_PATH);
>
> So you can throw away subtree mounts of the same fsid keeping
> only one mount_fd per fsid as you traverse the mounts.
>

Well ,that's incorrect.
You may have bind mount of non-overlapping subtrees
and you may not have the root mount at all in your mount namespace.

In that case, you can always keep all mount_fd's of a certain fsid and try to
resolve the file handles in each one. Not optimal, but this is the information
we have in events at the moment.

Thanks,
Amir.

      reply	other threads:[~2024-05-22  5:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  1:03 fanotify and files being moved or deleted Jonathan Gilbert
2024-05-21  3:58 ` Amir Goldstein
2024-05-21 16:03   ` Jonathan Gilbert
2024-05-21 17:13     ` Amir Goldstein
2024-05-21 21:09       ` Jonathan Gilbert
2024-05-22  5:21         ` Amir Goldstein
2024-05-22  5:26           ` 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=CAOQ4uxiMtd80k9N93wjkO13vmmSt5s1333WdSrauGD_-b+rsRQ@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=logic@deltaq.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 read-only IMAP folder(s) and NNTP newsgroup(s).