diff mbox series

[v7,11/28] fsnotify: Pass group argument to free_event

Message ID 20211014213646.1139469-12-krisman@collabora.com (mailing list archive)
State New, archived
Headers show
Series file system-wide error monitoring | expand

Commit Message

Gabriel Krisman Bertazi Oct. 14, 2021, 9:36 p.m. UTC
For group-wide mempool backed events, like FS_ERROR, the free_event
callback will need to reference the group's mempool to free the memory.
Wire that argument into the current callers.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
 fs/notify/fanotify/fanotify.c        | 3 ++-
 fs/notify/group.c                    | 2 +-
 fs/notify/inotify/inotify_fsnotify.c | 3 ++-
 fs/notify/notification.c             | 2 +-
 include/linux/fsnotify_backend.h     | 2 +-
 5 files changed, 7 insertions(+), 5 deletions(-)

Comments

Amir Goldstein Oct. 15, 2021, 5:40 a.m. UTC | #1
On Fri, Oct 15, 2021 at 12:38 AM Gabriel Krisman Bertazi
<krisman@collabora.com> wrote:
>
> For group-wide mempool backed events, like FS_ERROR, the free_event
> callback will need to reference the group's mempool to free the memory.
> Wire that argument into the current callers.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>

> ---
>  fs/notify/fanotify/fanotify.c        | 3 ++-
>  fs/notify/group.c                    | 2 +-
>  fs/notify/inotify/inotify_fsnotify.c | 3 ++-
>  fs/notify/notification.c             | 2 +-
>  include/linux/fsnotify_backend.h     | 2 +-
>  5 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index f82e20228999..c620b4f6fe12 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -835,7 +835,8 @@ static void fanotify_free_name_event(struct fanotify_event *event)
>         kfree(FANOTIFY_NE(event));
>  }
>
> -static void fanotify_free_event(struct fsnotify_event *fsn_event)
> +static void fanotify_free_event(struct fsnotify_group *group,
> +                               struct fsnotify_event *fsn_event)
>  {
>         struct fanotify_event *event;
>
> diff --git a/fs/notify/group.c b/fs/notify/group.c
> index fb89c351295d..6a297efc4788 100644
> --- a/fs/notify/group.c
> +++ b/fs/notify/group.c
> @@ -88,7 +88,7 @@ void fsnotify_destroy_group(struct fsnotify_group *group)
>          * that deliberately ignores overflow events.
>          */
>         if (group->overflow_event)
> -               group->ops->free_event(group->overflow_event);
> +               group->ops->free_event(group, group->overflow_event);
>
>         fsnotify_put_group(group);
>  }
> diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
> index a96582cbfad1..d92d7b0adc9a 100644
> --- a/fs/notify/inotify/inotify_fsnotify.c
> +++ b/fs/notify/inotify/inotify_fsnotify.c
> @@ -177,7 +177,8 @@ static void inotify_free_group_priv(struct fsnotify_group *group)
>                 dec_inotify_instances(group->inotify_data.ucounts);
>  }
>
> -static void inotify_free_event(struct fsnotify_event *fsn_event)
> +static void inotify_free_event(struct fsnotify_group *group,
> +                              struct fsnotify_event *fsn_event)
>  {
>         kfree(INOTIFY_E(fsn_event));
>  }
> diff --git a/fs/notify/notification.c b/fs/notify/notification.c
> index 44bb10f50715..9022ae650cf8 100644
> --- a/fs/notify/notification.c
> +++ b/fs/notify/notification.c
> @@ -64,7 +64,7 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
>                 WARN_ON(!list_empty(&event->list));
>                 spin_unlock(&group->notification_lock);
>         }
> -       group->ops->free_event(event);
> +       group->ops->free_event(group, event);
>  }
>
>  /*
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 035438fe4a43..1e69e9fe45c9 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -155,7 +155,7 @@ struct fsnotify_ops {
>                             const struct qstr *file_name, u32 cookie);
>         void (*free_group_priv)(struct fsnotify_group *group);
>         void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
> -       void (*free_event)(struct fsnotify_event *event);
> +       void (*free_event)(struct fsnotify_group *group, struct fsnotify_event *event);
>         /* called on final put+free to free memory */
>         void (*free_mark)(struct fsnotify_mark *mark);
>  };
> --
> 2.33.0
>
Jan Kara Oct. 15, 2021, 9:26 a.m. UTC | #2
On Thu 14-10-21 18:36:29, Gabriel Krisman Bertazi wrote:
> For group-wide mempool backed events, like FS_ERROR, the free_event
> callback will need to reference the group's mempool to free the memory.
> Wire that argument into the current callers.
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/notify/fanotify/fanotify.c        | 3 ++-
>  fs/notify/group.c                    | 2 +-
>  fs/notify/inotify/inotify_fsnotify.c | 3 ++-
>  fs/notify/notification.c             | 2 +-
>  include/linux/fsnotify_backend.h     | 2 +-
>  5 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index f82e20228999..c620b4f6fe12 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -835,7 +835,8 @@ static void fanotify_free_name_event(struct fanotify_event *event)
>  	kfree(FANOTIFY_NE(event));
>  }
>  
> -static void fanotify_free_event(struct fsnotify_event *fsn_event)
> +static void fanotify_free_event(struct fsnotify_group *group,
> +				struct fsnotify_event *fsn_event)
>  {
>  	struct fanotify_event *event;
>  
> diff --git a/fs/notify/group.c b/fs/notify/group.c
> index fb89c351295d..6a297efc4788 100644
> --- a/fs/notify/group.c
> +++ b/fs/notify/group.c
> @@ -88,7 +88,7 @@ void fsnotify_destroy_group(struct fsnotify_group *group)
>  	 * that deliberately ignores overflow events.
>  	 */
>  	if (group->overflow_event)
> -		group->ops->free_event(group->overflow_event);
> +		group->ops->free_event(group, group->overflow_event);
>  
>  	fsnotify_put_group(group);
>  }
> diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
> index a96582cbfad1..d92d7b0adc9a 100644
> --- a/fs/notify/inotify/inotify_fsnotify.c
> +++ b/fs/notify/inotify/inotify_fsnotify.c
> @@ -177,7 +177,8 @@ static void inotify_free_group_priv(struct fsnotify_group *group)
>  		dec_inotify_instances(group->inotify_data.ucounts);
>  }
>  
> -static void inotify_free_event(struct fsnotify_event *fsn_event)
> +static void inotify_free_event(struct fsnotify_group *group,
> +			       struct fsnotify_event *fsn_event)
>  {
>  	kfree(INOTIFY_E(fsn_event));
>  }
> diff --git a/fs/notify/notification.c b/fs/notify/notification.c
> index 44bb10f50715..9022ae650cf8 100644
> --- a/fs/notify/notification.c
> +++ b/fs/notify/notification.c
> @@ -64,7 +64,7 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
>  		WARN_ON(!list_empty(&event->list));
>  		spin_unlock(&group->notification_lock);
>  	}
> -	group->ops->free_event(event);
> +	group->ops->free_event(group, event);
>  }
>  
>  /*
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 035438fe4a43..1e69e9fe45c9 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -155,7 +155,7 @@ struct fsnotify_ops {
>  			    const struct qstr *file_name, u32 cookie);
>  	void (*free_group_priv)(struct fsnotify_group *group);
>  	void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
> -	void (*free_event)(struct fsnotify_event *event);
> +	void (*free_event)(struct fsnotify_group *group, struct fsnotify_event *event);
>  	/* called on final put+free to free memory */
>  	void (*free_mark)(struct fsnotify_mark *mark);
>  };
> -- 
> 2.33.0
>
diff mbox series

Patch

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index f82e20228999..c620b4f6fe12 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -835,7 +835,8 @@  static void fanotify_free_name_event(struct fanotify_event *event)
 	kfree(FANOTIFY_NE(event));
 }
 
-static void fanotify_free_event(struct fsnotify_event *fsn_event)
+static void fanotify_free_event(struct fsnotify_group *group,
+				struct fsnotify_event *fsn_event)
 {
 	struct fanotify_event *event;
 
diff --git a/fs/notify/group.c b/fs/notify/group.c
index fb89c351295d..6a297efc4788 100644
--- a/fs/notify/group.c
+++ b/fs/notify/group.c
@@ -88,7 +88,7 @@  void fsnotify_destroy_group(struct fsnotify_group *group)
 	 * that deliberately ignores overflow events.
 	 */
 	if (group->overflow_event)
-		group->ops->free_event(group->overflow_event);
+		group->ops->free_event(group, group->overflow_event);
 
 	fsnotify_put_group(group);
 }
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index a96582cbfad1..d92d7b0adc9a 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -177,7 +177,8 @@  static void inotify_free_group_priv(struct fsnotify_group *group)
 		dec_inotify_instances(group->inotify_data.ucounts);
 }
 
-static void inotify_free_event(struct fsnotify_event *fsn_event)
+static void inotify_free_event(struct fsnotify_group *group,
+			       struct fsnotify_event *fsn_event)
 {
 	kfree(INOTIFY_E(fsn_event));
 }
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 44bb10f50715..9022ae650cf8 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -64,7 +64,7 @@  void fsnotify_destroy_event(struct fsnotify_group *group,
 		WARN_ON(!list_empty(&event->list));
 		spin_unlock(&group->notification_lock);
 	}
-	group->ops->free_event(event);
+	group->ops->free_event(group, event);
 }
 
 /*
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 035438fe4a43..1e69e9fe45c9 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -155,7 +155,7 @@  struct fsnotify_ops {
 			    const struct qstr *file_name, u32 cookie);
 	void (*free_group_priv)(struct fsnotify_group *group);
 	void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
-	void (*free_event)(struct fsnotify_event *event);
+	void (*free_event)(struct fsnotify_group *group, struct fsnotify_event *event);
 	/* called on final put+free to free memory */
 	void (*free_mark)(struct fsnotify_mark *mark);
 };