From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
Marko Rauhamaa <marko.rauhamaa@f-secure.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v3 2/3] fsnotify: send path type events to group with super block marks
Date: Mon, 3 Sep 2018 10:36:16 +0200 [thread overview]
Message-ID: <20180903083616.GB10027@quack2.suse.cz> (raw)
In-Reply-To: <CAOQ4uxgrvUDs-GH3eNeX2sfhc36aTkN6POoo2jcSn7wwh=b5Mw@mail.gmail.com>
On Fri 31-08-18 18:07:27, Amir Goldstein wrote:
> On Fri, Aug 31, 2018 at 4:56 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Thu 30-08-18 18:15:50, Amir Goldstein wrote:
> > > Send events to group if super block mark mask matches the event
> > > and unless the same group has an ignore mask on the vfsmount or
> > > the inode on which the event occurred.
> > >
> > > Soon, fanotify backend is going to support super block marks and
> > > fanotify backend only supports path type events.
> > >
> > > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> >
> > Two small questions below. Otherwise the patch looks good to me.
> >
> > > ---
> > > fs/notify/fsnotify.c | 27 +++++++++++++++++----------
> > > 1 file changed, 17 insertions(+), 10 deletions(-)
> > >
> > ...
> > > if (!(mask & FS_MODIFY) &&
> > > !(test_mask & to_tell->i_fsnotify_mask) &&
> > > - !(mnt && test_mask & mnt->mnt_fsnotify_mask))
> > > + !(mnt && (test_mask & mnt_or_sb_mask)))
> >
> > When you use mnt_or_sb_mask, the 'mnt' check is useless, right?
>
> Right. it could be !(test_mask & (to_tell->i_fsnotify_mask | mnt_or_sb_mask))
> if you think that is nicer.
>
> >
> > > iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
> > > @@ -364,16 +367,20 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
> > > }
> > >
> > > if (mnt && ((mask & FS_MODIFY) ||
> > > - (test_mask & mnt->mnt_fsnotify_mask))) {
> > > + (test_mask & mnt_or_sb_mask))) {
> > > iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
> > > fsnotify_first_mark(&to_tell->i_fsnotify_marks);
> > > iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] =
> > > fsnotify_first_mark(&mnt->mnt_fsnotify_marks);
> > > + if ((mask & FS_MODIFY) ||
> > > + (test_mask & sb->s_fsnotify_mask))
> >
> > Why is here this additional test? We might need to clear ignore masks on SB
> > list if nothing else. Also we need to reflect ignore mask from the
> > superblock marks... I agree there's probably no huge use for either of
> > these two functionalities but I just don't see a strong reason for
> > sb & mnt marks to behave differently.
> >
>
> Hmm, that is indeed not pretty.
> It seems that I perpetuated the asymetric ignore relations between inode and
> mnt mark that the test above implemented forever.
>
> In this thread [1], we already agreed that include-the-exclude is the desired
> semantics for ignore masks and the result was commit 92183a42898d
> ("fsnotify: fix ignore mask logic in send_to_group()").
Right.
> However, it seems we have missed this subtle spot here and need to fix
> it as well. The end result should look like this with no tests at all: (?)
>
> iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
> fsnotify_first_mark(&to_tell->i_fsnotify_marks);
> iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] =
> fsnotify_first_mark(&mnt->mnt_fsnotify_marks);
> iter_info.marks[FSNOTIFY_OBJ_TYPE_SB] =
> fsnotify_first_mark(&sb->s_fsnotify_marks);
>
> Right?
Let me think loud and please correct me if I'm wrong somewhere. We need all
three lists if:
1) It is a FS_MODIFY event as that may need to clear ignore masks on some
list.
or
2) Mask for any list type (inode, mnt, sb) matches the mask of event - so
that we can collect also ignore masks and thus find out whether event
really should be reported.
This is already checked by a condition early in fsnotify(). So I agree that
the iter_info initialization should look like:
iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
fsnotify_first_mark(&to_tell->i_fsnotify_marks);
if (mnt) {
iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] =
fsnotify_first_mark(&mnt->mnt_fsnotify_marks);
iter_info.marks[FSNOTIFY_OBJ_TYPE_SB] =
fsnotify_first_mark(&sb->s_fsnotify_marks);
}
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2018-09-03 12:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 15:15 [PATCH v3 0/3] fanotify super block marks Amir Goldstein
2018-08-30 15:15 ` [PATCH v3 1/3] fsnotify: add super block object type Amir Goldstein
2018-08-31 13:52 ` Jan Kara
2018-08-30 15:15 ` [PATCH v3 2/3] fsnotify: send path type events to group with super block marks Amir Goldstein
2018-08-31 13:50 ` Jan Kara
2018-08-31 15:07 ` Amir Goldstein
2018-09-03 8:36 ` Jan Kara [this message]
2018-08-30 15:15 ` [PATCH v3 3/3] fanotify: add API to attach/detach super block mark Amir Goldstein
2018-08-31 14:05 ` Jan Kara
2018-08-31 15:30 ` Amir Goldstein
2018-09-03 8:48 ` Jan Kara
2018-09-03 9:58 ` 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=20180903083616.GB10027@quack2.suse.cz \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=marko.rauhamaa@f-secure.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).