diff mbox series

[3/6] fsnotify: Create function to remove event from notification list

Message ID 20190213145443.26836-4-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series fanotify: Make wait for permission event response interruptible | expand

Commit Message

Jan Kara Feb. 13, 2019, 2:54 p.m. UTC
Create function to remove event from the notification list. Later it will
be used from more places.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/notify/notification.c         | 20 +++++++++++++-------
 include/linux/fsnotify_backend.h |  3 +++
 2 files changed, 16 insertions(+), 7 deletions(-)

Comments

Amir Goldstein Feb. 13, 2019, 8:23 p.m. UTC | #1
On Wed, Feb 13, 2019 at 4:54 PM Jan Kara <jack@suse.cz> wrote:
>
> Create function to remove event from the notification list. Later it will
> be used from more places.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>

> ---
>  fs/notify/notification.c         | 20 +++++++++++++-------
>  include/linux/fsnotify_backend.h |  3 +++
>  2 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/fs/notify/notification.c b/fs/notify/notification.c
> index 3c3e36745f59..2195a5cf745a 100644
> --- a/fs/notify/notification.c
> +++ b/fs/notify/notification.c
> @@ -141,6 +141,18 @@ int fsnotify_add_event(struct fsnotify_group *group,
>         return ret;
>  }
>
> +void fsnotify_remove_queued_event(struct fsnotify_group *group,
> +                                 struct fsnotify_event *event)
> +{
> +       assert_spin_locked(&group->notification_lock);
> +       /*
> +        * We need to init list head for the case of overflow event so that
> +        * check in fsnotify_add_event() works
> +        */
> +       list_del_init(&event->list);
> +       group->q_len--;
> +}
> +
>  /*
>   * Remove and return the first event from the notification list.  It is the
>   * responsibility of the caller to destroy the obtained event
> @@ -155,13 +167,7 @@ struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group)
>
>         event = list_first_entry(&group->notification_list,
>                                  struct fsnotify_event, list);
> -       /*
> -        * We need to init list head for the case of overflow event so that
> -        * check in fsnotify_add_event() works
> -        */
> -       list_del_init(&event->list);
> -       group->q_len--;
> -
> +       fsnotify_remove_queued_event(group, event);
>         return event;
>  }
>
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 7639774e7475..cddf839bac96 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -416,6 +416,9 @@ extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group);
>  extern struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group);
>  /* return AND dequeue the first event on the notification queue */
>  extern struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group);
> +/* Remove event queued in the notification list */
> +extern void fsnotify_remove_queued_event(struct fsnotify_group *group,
> +                                        struct fsnotify_event *event);
>
>  /* functions used to manipulate the marks attached to inodes */
>
> --
> 2.16.4
>
diff mbox series

Patch

diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 3c3e36745f59..2195a5cf745a 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -141,6 +141,18 @@  int fsnotify_add_event(struct fsnotify_group *group,
 	return ret;
 }
 
+void fsnotify_remove_queued_event(struct fsnotify_group *group,
+				  struct fsnotify_event *event)
+{
+	assert_spin_locked(&group->notification_lock);
+	/*
+	 * We need to init list head for the case of overflow event so that
+	 * check in fsnotify_add_event() works
+	 */
+	list_del_init(&event->list);
+	group->q_len--;
+}
+
 /*
  * Remove and return the first event from the notification list.  It is the
  * responsibility of the caller to destroy the obtained event
@@ -155,13 +167,7 @@  struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group)
 
 	event = list_first_entry(&group->notification_list,
 				 struct fsnotify_event, list);
-	/*
-	 * We need to init list head for the case of overflow event so that
-	 * check in fsnotify_add_event() works
-	 */
-	list_del_init(&event->list);
-	group->q_len--;
-
+	fsnotify_remove_queued_event(group, event);
 	return event;
 }
 
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 7639774e7475..cddf839bac96 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -416,6 +416,9 @@  extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group);
 extern struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group);
 /* return AND dequeue the first event on the notification queue */
 extern struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group);
+/* Remove event queued in the notification list */
+extern void fsnotify_remove_queued_event(struct fsnotify_group *group,
+					 struct fsnotify_event *event);
 
 /* functions used to manipulate the marks attached to inodes */