linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, Matthew Bobrowski <repnop@google.com>,
	linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org
Subject: Re: [PATCH 2/2] fanotify: introduce FAN_MARK_IGNORE
Date: Thu, 23 Jun 2022 12:14:08 +0200	[thread overview]
Message-ID: <20220623101408.ejmqpp7xw6f67me7@quack3.lan> (raw)
In-Reply-To: <20220620134551.2066847-3-amir73il@gmail.com>

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...

Also it follows the behavior we have picked for FAN_MARK_EVICTABLE AFAIR
but that's not really important to me.

> @@ -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;
	}

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

  reply	other threads:[~2022-06-23 10:14 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 [this message]
2022-06-23 12:17     ` 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=20220623101408.ejmqpp7xw6f67me7@quack3.lan \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --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).