mbox series

[v3,00/14] fanotify directory modify event

Message ID 20200319151022.31456-1-amir73il@gmail.com (mailing list archive)
Headers show
Series fanotify directory modify event | expand

Message

Amir Goldstein March 19, 2020, 3:10 p.m. UTC
Jan,

This v3 posting is a trimmed down version of v2 name info patches [1].
It includes the prep/fix patches and the patches to add support for
the new FAN_DIR_MODIFY event, but leaves out the FAN_REPORT_NAME
patches. I will re-post those as a later time.

The v3 patches are available on my github branch fanotify_dir_modify [2].
Same branch names for LTP tests [3], man page draft [6] and a demo [7].
The fanotify_name branches in those github trees include the additional
FAN_REPORT_NAME related changes.

Main changes since v2:
- Split fanotify_path_event fanotify_fid_event and fanotify_name_event
- Drop the FAN_REPORT_NAME patches

[1] https://lore.kernel.org/linux-fsdevel/20200217131455.31107-1-amir73il@gmail.com/
[2] https://github.com/amir73il/linux/commits/fanotify_dir_modify
[3] https://github.com/amir73il/ltp/commits/fanotify_dir_modify
[4] https://github.com/amir73il/man-pages/commits/fanotify_dir_modify
[5] https://github.com/amir73il/inotify-tools/commits/fanotify_dir_modify

Amir Goldstein (14):
  fsnotify: tidy up FS_ and FAN_ constants
  fsnotify: factor helpers fsnotify_dentry() and fsnotify_file()
  fsnotify: funnel all dirent events through fsnotify_name()
  fsnotify: use helpers to access data by data_type
  fsnotify: simplify arguments passing to fsnotify_parent()
  fsnotify: pass dentry instead of inode for events possible on child
  fsnotify: replace inode pointer with an object id
  fanotify: merge duplicate events on parent and child
  fanotify: fix merging marks masks with FAN_ONDIR
  fanotify: divorce fanotify_path_event and fanotify_fid_event
  fanotify: send FAN_DIR_MODIFY event flavor with dir inode and name
  fanotify: prepare to report both parent and child fid's
  fanotify: record name info for FAN_DIR_MODIFY event
  fanotify: report name info for FAN_DIR_MODIFY event

 fs/notify/fanotify/fanotify.c        | 304 ++++++++++++++++++++-------
 fs/notify/fanotify/fanotify.h        | 172 +++++++++------
 fs/notify/fanotify/fanotify_user.c   | 171 ++++++++++-----
 fs/notify/fsnotify.c                 |  22 +-
 fs/notify/inotify/inotify_fsnotify.c |  12 +-
 fs/notify/inotify/inotify_user.c     |   2 +-
 include/linux/fanotify.h             |   3 +-
 include/linux/fsnotify.h             | 138 +++++-------
 include/linux/fsnotify_backend.h     |  87 ++++++--
 include/uapi/linux/fanotify.h        |   6 +-
 kernel/audit_fsnotify.c              |  13 +-
 kernel/audit_watch.c                 |  16 +-
 12 files changed, 610 insertions(+), 336 deletions(-)

Comments

Jan Kara March 25, 2020, 3:54 p.m. UTC | #1
Hi,

On Thu 19-03-20 17:10:08, Amir Goldstein wrote:
> Jan,
> 
> This v3 posting is a trimmed down version of v2 name info patches [1].
> It includes the prep/fix patches and the patches to add support for
> the new FAN_DIR_MODIFY event, but leaves out the FAN_REPORT_NAME
> patches. I will re-post those as a later time.
> 
> The v3 patches are available on my github branch fanotify_dir_modify [2].
> Same branch names for LTP tests [3], man page draft [6] and a demo [7].
> The fanotify_name branches in those github trees include the additional
> FAN_REPORT_NAME related changes.
> 
> Main changes since v2:
> - Split fanotify_path_event fanotify_fid_event and fanotify_name_event
> - Drop the FAN_REPORT_NAME patches

So I have pushed out the result to my tree (fsnotify branch and also pulled
it to for_next branch).

								Honza

> 
> [1] https://lore.kernel.org/linux-fsdevel/20200217131455.31107-1-amir73il@gmail.com/
> [2] https://github.com/amir73il/linux/commits/fanotify_dir_modify
> [3] https://github.com/amir73il/ltp/commits/fanotify_dir_modify
> [4] https://github.com/amir73il/man-pages/commits/fanotify_dir_modify
> [5] https://github.com/amir73il/inotify-tools/commits/fanotify_dir_modify
> 
> Amir Goldstein (14):
>   fsnotify: tidy up FS_ and FAN_ constants
>   fsnotify: factor helpers fsnotify_dentry() and fsnotify_file()
>   fsnotify: funnel all dirent events through fsnotify_name()
>   fsnotify: use helpers to access data by data_type
>   fsnotify: simplify arguments passing to fsnotify_parent()
>   fsnotify: pass dentry instead of inode for events possible on child
>   fsnotify: replace inode pointer with an object id
>   fanotify: merge duplicate events on parent and child
>   fanotify: fix merging marks masks with FAN_ONDIR
>   fanotify: divorce fanotify_path_event and fanotify_fid_event
>   fanotify: send FAN_DIR_MODIFY event flavor with dir inode and name
>   fanotify: prepare to report both parent and child fid's
>   fanotify: record name info for FAN_DIR_MODIFY event
>   fanotify: report name info for FAN_DIR_MODIFY event
> 
>  fs/notify/fanotify/fanotify.c        | 304 ++++++++++++++++++++-------
>  fs/notify/fanotify/fanotify.h        | 172 +++++++++------
>  fs/notify/fanotify/fanotify_user.c   | 171 ++++++++++-----
>  fs/notify/fsnotify.c                 |  22 +-
>  fs/notify/inotify/inotify_fsnotify.c |  12 +-
>  fs/notify/inotify/inotify_user.c     |   2 +-
>  include/linux/fanotify.h             |   3 +-
>  include/linux/fsnotify.h             | 138 +++++-------
>  include/linux/fsnotify_backend.h     |  87 ++++++--
>  include/uapi/linux/fanotify.h        |   6 +-
>  kernel/audit_fsnotify.c              |  13 +-
>  kernel/audit_watch.c                 |  16 +-
>  12 files changed, 610 insertions(+), 336 deletions(-)
> 
> -- 
> 2.17.1
>
Amir Goldstein March 25, 2020, 4:55 p.m. UTC | #2
On Wed, Mar 25, 2020 at 5:54 PM Jan Kara <jack@suse.cz> wrote:
>
> Hi,
>
> On Thu 19-03-20 17:10:08, Amir Goldstein wrote:
> > Jan,
> >
> > This v3 posting is a trimmed down version of v2 name info patches [1].
> > It includes the prep/fix patches and the patches to add support for
> > the new FAN_DIR_MODIFY event, but leaves out the FAN_REPORT_NAME
> > patches. I will re-post those as a later time.
> >
> > The v3 patches are available on my github branch fanotify_dir_modify [2].
> > Same branch names for LTP tests [3], man page draft [6] and a demo [7].
> > The fanotify_name branches in those github trees include the additional
> > FAN_REPORT_NAME related changes.
> >
> > Main changes since v2:
> > - Split fanotify_path_event fanotify_fid_event and fanotify_name_event
> > - Drop the FAN_REPORT_NAME patches
>
> So I have pushed out the result to my tree (fsnotify branch and also pulled
> it to for_next branch).

Great!

Liked the cleanups.
Suggest to squash the attached simplification to "record name info" patch.
I will start try to get to finalizing man page patch next week.

Thanks,
Amir.
Jan Kara March 25, 2020, 5:01 p.m. UTC | #3
On Wed 25-03-20 18:55:46, Amir Goldstein wrote:
> On Wed, Mar 25, 2020 at 5:54 PM Jan Kara <jack@suse.cz> wrote:
> >
> > Hi,
> >
> > On Thu 19-03-20 17:10:08, Amir Goldstein wrote:
> > > Jan,
> > >
> > > This v3 posting is a trimmed down version of v2 name info patches [1].
> > > It includes the prep/fix patches and the patches to add support for
> > > the new FAN_DIR_MODIFY event, but leaves out the FAN_REPORT_NAME
> > > patches. I will re-post those as a later time.
> > >
> > > The v3 patches are available on my github branch fanotify_dir_modify [2].
> > > Same branch names for LTP tests [3], man page draft [6] and a demo [7].
> > > The fanotify_name branches in those github trees include the additional
> > > FAN_REPORT_NAME related changes.
> > >
> > > Main changes since v2:
> > > - Split fanotify_path_event fanotify_fid_event and fanotify_name_event
> > > - Drop the FAN_REPORT_NAME patches
> >
> > So I have pushed out the result to my tree (fsnotify branch and also pulled
> > it to for_next branch).
> 
> Great!
> 
> Liked the cleanups.
> Suggest to squash the attached simplification to "record name info" patch.
> I will start try to get to finalizing man page patch next week.

Yeah, nice, I'll squash this into the series. Thanks!

								Honza

> From d42d388ed1a9f90a623552e6fabfa3418ceb40ae Mon Sep 17 00:00:00 2001
> From: Amir Goldstein <amir73il@gmail.com>
> Date: Wed, 25 Mar 2020 18:50:16 +0200
> Subject: [PATCH] fanotify: simplify record name info
> 
> ---
>  fs/notify/fanotify/fanotify.c | 22 ++++++++--------------
>  1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index 7a889da1ee12..4c1a4eb597d5 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -282,6 +282,9 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode,
>  	void *buf = fh->buf;
>  	int err;
>  
> +	if (!inode)
> +		goto out;
> +
>  	dwords = 0;
>  	err = -ENOENT;
>  	type = exportfs_encode_inode_fh(inode, NULL, &dwords, NULL);
> @@ -315,6 +318,7 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode,
>  			    type, bytes, err);
>  	kfree(ext_buf);
>  	*fanotify_fh_ext_buf_ptr(fh) = NULL;
> +out:
>  	/* Report the event without a file identifier on encode error */
>  	fh->type = FILEID_INVALID;
>  	fh->len = 0;
> @@ -429,22 +433,12 @@ struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group,
>  	if (fsid && fanotify_event_fsid(event))
>  		*fanotify_event_fsid(event) = *fsid;
>  
> -	if (fanotify_event_object_fh(event)) {
> -		struct fanotify_fh *obj_fh = fanotify_event_object_fh(event);
> +	if (fanotify_event_object_fh(event))
> +		fanotify_encode_fh(fanotify_event_object_fh(event), id, gfp);
>  
> -		if (id)
> -			fanotify_encode_fh(obj_fh, id, gfp);
> -		else
> -			obj_fh->len = 0;
> -	}
> -	if (fanotify_event_dir_fh(event)) {
> -		struct fanotify_fh *dir_fh = fanotify_event_dir_fh(event);
> +	if (fanotify_event_dir_fh(event))
> +		fanotify_encode_fh(fanotify_event_dir_fh(event), id, gfp);
>  
> -		if (id)
> -			fanotify_encode_fh(dir_fh, id, gfp);
> -		else
> -			dir_fh->len = 0;
> -	}
>  	if (fanotify_event_has_path(event)) {
>  		struct path *p = fanotify_event_path(event);
>  
> -- 
> 2.17.1
>