Skip to content

Commit

Permalink
fsnotify: Create function to remove event from notification list
Browse files Browse the repository at this point in the history
Create function to remove event from the notification list. Later it will
be used from more places.

Reviewed-by: Amir Goldstein <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
jankara committed Feb 18, 2019
1 parent 8c55446 commit f7db89a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 13 additions & 7 deletions fs/notify/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions include/linux/fsnotify_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,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 */

Expand Down

0 comments on commit f7db89a

Please sign in to comment.