Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1608993

[PATCH 3/5] notify: Split up some fsnotify functions

From Jes Sorensen <jes.sorensen@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 3/5] notify: Split up some fsnotify functions
Date 2017-03-24 22:40 +0100
Message-ID <toF69-7By-19@gated-at.bofh.it> (permalink)
References <toF69-7By-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <jsorensen@fb.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
---
 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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] inofify: Reduce lock contention on read() Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-24 22:40 +0100
  [PATCH 5/5] inotify: Avoid taking spinlock for each event processed in read() Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-24 22:40 +0100
  [PATCH 1/5] notify: Call mutex_destroy() before freeing mutex memory Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-24 22:40 +0100
  [PATCH 2/5] inotify: Use mutex to prevent threaded clients reading events out of order Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-24 22:40 +0100
  [PATCH 4/5] inotify: switch get_one_event() to use fsnotify_list_*() helpers Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-24 22:40 +0100
  [PATCH 3/5] notify: Split up some fsnotify functions Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-24 22:40 +0100

csiph-web