fsnotify: Pass group argument to free_event
authorGabriel Krisman Bertazi <krisman@collabora.com>
Mon, 25 Oct 2021 19:27:27 +0000 (16:27 -0300)
committerJan Kara <jack@suse.cz>
Wed, 27 Oct 2021 10:34:18 +0000 (12:34 +0200)
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.

Link: https://lore.kernel.org/r/20211025192746.66445-13-krisman@collabora.com
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/fanotify/fanotify.c
fs/notify/group.c
fs/notify/inotify/inotify_fsnotify.c
fs/notify/notification.c
include/linux/fsnotify_backend.h

index f82e20228999c07c8fc2c28fb9d7393e76e2274a..c620b4f6fe123527be1d4dc0461a2d60e152987d 100644 (file)
@@ -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;
 
index fb89c351295d6ee1e8156c176417915e60969812..6a297efc478874b10346b1d8ac0e8a9c941d6bd3 100644 (file)
@@ -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);
 }
index a96582cbfad1c1cf087b5e70847738acc3ef5d16..d92d7b0adc9a2764f16923fbf797df68730c0e7d 100644 (file)
@@ -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));
 }
index 44bb10f50715305d056bc02fd5f931d99d5292e2..9022ae650cf863ea5276027204fcae754024cf62 100644 (file)
@@ -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);
 }
 
 /*
index b71dc788018e4755495f53ebb34702c33462de52..3a7c3143618245152bde5affd5bbd4c4017c6fd3 100644 (file)
@@ -156,7 +156,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);
 };