From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756745AbdCXVh1 (ORCPT ); Fri, 24 Mar 2017 17:37:27 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:34839 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752942AbdCXVg7 (ORCPT ); Fri, 24 Mar 2017 17:36:59 -0400 From: Jes Sorensen X-Google-Original-From: Jes Sorensen To: linux-kernel@vger.kernel.org Cc: john@johnmccutchan.com, rlove@rlove.org, eparis@parisplace.org, josef@toxicpanda.com, kernel-team@fb.com, Jes Sorensen Subject: [PATCH 3/5] notify: Split up some fsnotify functions Date: Fri, 24 Mar 2017 17:36:36 -0400 Message-Id: <20170324213638.9114-4-jsorensen@fb.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170324213638.9114-1-jsorensen@fb.com> References: <20170324213638.9114-1-jsorensen@fb.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This splits up fsnotify_remove_first_event() and fsnotify_peek_first_event() into a helper function with a wrapper, and introduces two new versions that takes a list instead of the group as argument. Signed-off-by: Jes Sorensen Reviewed-by: Josef Bacik --- fs/notify/notification.c | 38 +++++++++++++++++++++++++++++++------- include/linux/fsnotify_backend.h | 4 ++++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 66f85c6..7b38cf8 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c @@ -144,26 +144,43 @@ int fsnotify_add_event(struct fsnotify_group *group, * Remove and return the first event from the notification list. It is the * responsibility of the caller to destroy the obtained event */ -struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group) +struct fsnotify_event * +__fsnotify_remove_first_event(struct list_head *notification_list) { struct fsnotify_event *event; - assert_spin_locked(&group->notification_lock); - - pr_debug("%s: group=%p\n", __func__, group); - - event = list_first_entry(&group->notification_list, + event = list_first_entry(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--; return event; } +struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group) +{ + struct list_head *notification_list = &group->notification_list; + + assert_spin_locked(&group->notification_lock); + + pr_debug("%s: group=%p\n", __func__, group); + + group->q_len--; + return __fsnotify_remove_first_event(notification_list); +} + +/* + * Note this version doesn't update the queue depth counter. + */ +struct fsnotify_event * +fsnotify_list_remove_first_event(struct list_head *notification_list) +{ + return __fsnotify_remove_first_event(notification_list); +} + /* * This will not remove the event, that must be done with * fsnotify_remove_first_event() @@ -176,6 +193,13 @@ struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group) struct fsnotify_event, list); } +struct fsnotify_event * +fsnotify_list_peek_first_event(struct list_head *notification_list) +{ + return list_first_entry(notification_list, + struct fsnotify_event, list); +} + /* * Called when a group is being torn down to clean up any outstanding * event notifications. diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index e0686ed..80d4c3b 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -313,8 +313,12 @@ extern int fsnotify_add_event(struct fsnotify_group *group, extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); /* return, but do not dequeue the first event on the notification queue */ extern struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group); +/* return, but do not dequeue the first event on the notification list */ +extern struct fsnotify_event *fsnotify_list_peek_first_event(struct list_head *notification_list); /* return AND dequeue the first event on the notification queue */ extern struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group); +/* return AND dequeue the first event on the notification list */ +extern struct fsnotify_event *fsnotify_list_remove_first_event(struct list_head *notification_list); /* functions used to manipulate the marks attached to inodes */ -- 2.9.3