From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 5/9] fsnotify: simplify dir argument to handle_event()
Date: Mon, 27 Jul 2020 21:32:18 +0200 [thread overview]
Message-ID: <20200727193218.GH5284@quack2.suse.cz> (raw)
In-Reply-To: <20200722125849.17418-6-amir73il@gmail.com>
On Wed 22-07-20 15:58:45, Amir Goldstein wrote:
> The meaning of dir argument could be simplified a lot to just the base
> of file_name it we let the only backends that care about it (fanotify and
> dnotify) cope with the case of NULL file_name themselves, which is easy.
>
> This will make dir argument meaning generic enough so we can use the
> same argument for fsnotify() without causing confusion.
>
> Fixes: e2c9d9039c3f ("fsnotify: pass dir argument to handle_event() callback")
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
I've folded this patch into "fsnotify: pass dir argument to handle_event()
callback" and int "fanotify: add basic support for FAN_REPORT_DIR_FID".
Honza
> ---
> fs/notify/dnotify/dnotify.c | 2 +-
> fs/notify/fanotify/fanotify.c | 7 ++++---
> fs/notify/fsnotify.c | 2 +-
> include/linux/fsnotify_backend.h | 4 +---
> 4 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
> index 305e5559560a..ca78d3f78da8 100644
> --- a/fs/notify/dnotify/dnotify.c
> +++ b/fs/notify/dnotify/dnotify.c
> @@ -112,7 +112,7 @@ static int dnotify_handle_event(struct fsnotify_group *group, u32 mask,
> struct fsnotify_mark *child_mark = fsnotify_iter_child_mark(iter_info);
>
> /* not a dir, dnotify doesn't care */
> - if (!dir)
> + if (!dir && !(mask & FS_ISDIR))
> return 0;
>
> if (WARN_ON(fsnotify_iter_vfsmount_mark(iter_info)))
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index 36ea0cd6387e..03e3dce2a97c 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -245,7 +245,7 @@ static u32 fanotify_group_event_mask(struct fsnotify_group *group,
> return 0;
> } else if (!(fid_mode & FAN_REPORT_FID)) {
> /* Do we have a directory inode to report? */
> - if (!dir)
> + if (!dir && !(event_mask & FS_ISDIR))
> return 0;
> }
>
> @@ -525,12 +525,13 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group,
> struct fanotify_event *event = NULL;
> gfp_t gfp = GFP_KERNEL_ACCOUNT;
> struct inode *id = fanotify_fid_inode(mask, data, data_type, dir);
> + struct inode *dirid = fanotify_dfid_inode(mask, data, data_type, dir);
> const struct path *path = fsnotify_data_path(data, data_type);
> unsigned int fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS);
> struct inode *child = NULL;
> bool name_event = false;
>
> - if ((fid_mode & FAN_REPORT_DIR_FID) && dir) {
> + if ((fid_mode & FAN_REPORT_DIR_FID) && dirid) {
> /*
> * With both flags FAN_REPORT_DIR_FID and FAN_REPORT_FID, we
> * report the child fid for events reported on a non-dir child
> @@ -540,7 +541,7 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group,
> (mask & FAN_EVENT_ON_CHILD) && !(mask & FAN_ONDIR))
> child = id;
>
> - id = fanotify_dfid_inode(mask, data, data_type, dir);
> + id = dirid;
>
> /*
> * We record file name only in a group with FAN_REPORT_NAME
> diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
> index 277af3d5efce..834775f61f6b 100644
> --- a/fs/notify/fsnotify.c
> +++ b/fs/notify/fsnotify.c
> @@ -365,7 +365,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_type,
> const struct path *path = fsnotify_data_path(data, data_type);
> struct fsnotify_iter_info iter_info = {};
> struct super_block *sb = to_tell->i_sb;
> - struct inode *dir = S_ISDIR(to_tell->i_mode) ? to_tell : NULL;
> + struct inode *dir = file_name ? to_tell : NULL;
> struct mount *mnt = NULL;
> struct inode *child = NULL;
> int ret = 0;
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 9bd75d0582b4..d94a50e0445a 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -123,9 +123,7 @@ struct mem_cgroup;
> * @data_type: type of object for fanotify_data_XXX() accessors
> * @dir: optional directory associated with event -
> * if @file_name is not NULL, this is the directory that
> - * @file_name is relative to. Otherwise, @dir is the object
> - * inode if event happened on directory and NULL if event
> - * happenned on a non-directory.
> + * @file_name is relative to
> * @file_name: optional file name associated with event
> * @cookie: inotify rename cookie
> * @iter_info: array of marks from this group that are interested in the event
> --
> 2.17.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-07-27 19:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 12:58 [PATCH 0/9] Fixes for fanotify name events Amir Goldstein
2020-07-22 12:58 ` [PATCH 1/9] fanotify: fix reporting event to sb/mount marks Amir Goldstein
2020-07-27 15:17 ` Jan Kara
2020-07-22 12:58 ` [PATCH 2/9] inotify: do not set FS_EVENT_ON_CHILD in non-dir mark mask Amir Goldstein
2020-07-27 15:33 ` Jan Kara
2020-07-22 12:58 ` [PATCH 3/9] audit: do not set FS_EVENT_ON_CHILD in audit marks mask Amir Goldstein
2020-07-27 15:33 ` Jan Kara
2020-07-22 12:58 ` [PATCH 4/9] fsnotify: create helper fsnotify_inode() Amir Goldstein
2020-07-27 16:26 ` Jan Kara
2020-07-22 12:58 ` [PATCH 5/9] fsnotify: simplify dir argument to handle_event() Amir Goldstein
2020-07-27 19:32 ` Jan Kara [this message]
2020-07-22 12:58 ` [PATCH 6/9] fsnotify: pass dir and inode arguments to fsnotify() Amir Goldstein
2020-07-27 21:26 ` Jan Kara
2020-07-22 12:58 ` [PATCH 7/9] fsnotify: fix merge with parent mark masks Amir Goldstein
2020-07-27 21:27 ` Jan Kara
2020-07-22 12:58 ` [PATCH 8/9] fsnotify: create method handle_inode_event() in fsnotify_operations Amir Goldstein
2020-07-27 21:27 ` Jan Kara
2020-07-22 12:58 ` [PATCH 9/9] fsnotify: pass inode to fsnotify_parent() Amir Goldstein
2020-07-27 21:29 ` Jan Kara
2020-07-27 21:57 ` [PATCH 0/9] Fixes for fanotify name events Jan Kara
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=20200727193218.GH5284@quack2.suse.cz \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.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).