mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] fsnotify: use fsnotify_create_event to allocate the q_overflow event
@ 2009-08-09 21:59 Eric Paris
  2009-08-09 21:59 ` [PATCH 2/5] inotify: use ZERO_PAGE instead of private static declaration Eric Paris
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Eric Paris @ 2009-08-09 21:59 UTC (permalink / raw)
  To: linux-kernel, viro

Currently fsnotify defines a static fsnotify event which is sent when a
group overflows its allotted queue length.  This patch just allocates that
event from the event cache rather than defining it statically.  There is no
known reason that the current implementation is wrong, but this makes sure the
event is initialized and created like any other.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 fs/notify/notification.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 5213685..4ab9243 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -56,7 +56,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
  * it is needed.  It's refcnt is set 1 at kernel init time and will never
  * get set to 0 so it will never get 'freed'
  */
-static struct fsnotify_event q_overflow_event;
+static struct fsnotify_event *q_overflow_event;
 static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
 
 /**
@@ -193,7 +193,7 @@ alloc_holder:
 	mutex_lock(&group->notification_mutex);
 
 	if (group->q_len >= group->max_events) {
-		event = &q_overflow_event;
+		event = q_overflow_event;
 		/* sorry, no private data on the overflow event */
 		priv = NULL;
 	}
@@ -409,8 +409,11 @@ __init int fsnotify_notification_init(void)
 	fsnotify_event_cachep = KMEM_CACHE(fsnotify_event, SLAB_PANIC);
 	fsnotify_event_holder_cachep = KMEM_CACHE(fsnotify_event_holder, SLAB_PANIC);
 
-	initialize_event(&q_overflow_event);
-	q_overflow_event.mask = FS_Q_OVERFLOW;
+	q_overflow_event = fsnotify_create_event(NULL, FS_Q_OVERFLOW, NULL,
+						 FSNOTIFY_EVENT_NONE, NULL, 0,
+						 GFP_KERNEL);
+	if (!q_overflow_event)
+		panic("unable to allocate fsnotify q_overflow_event\n");
 
 	return 0;
 }


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH 1/5] fsnotify: use fsnotify_create_event to allocate the q_overflow event
@ 2009-08-11 16:27 Eric Paris
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Paris @ 2009-08-11 16:27 UTC (permalink / raw)
  To: linux-kernel, viro

Currently fsnotify defines a static fsnotify event which is sent when a
group overflows its allotted queue length.  This patch just allocates that
event from the event cache rather than defining it statically.  There is no
known reason that the current implementation is wrong, but this makes sure the
event is initialized and created like any other.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 fs/notify/notification.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 5213685..4ab9243 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -56,7 +56,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
  * it is needed.  It's refcnt is set 1 at kernel init time and will never
  * get set to 0 so it will never get 'freed'
  */
-static struct fsnotify_event q_overflow_event;
+static struct fsnotify_event *q_overflow_event;
 static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
 
 /**
@@ -193,7 +193,7 @@ alloc_holder:
 	mutex_lock(&group->notification_mutex);
 
 	if (group->q_len >= group->max_events) {
-		event = &q_overflow_event;
+		event = q_overflow_event;
 		/* sorry, no private data on the overflow event */
 		priv = NULL;
 	}
@@ -409,8 +409,11 @@ __init int fsnotify_notification_init(void)
 	fsnotify_event_cachep = KMEM_CACHE(fsnotify_event, SLAB_PANIC);
 	fsnotify_event_holder_cachep = KMEM_CACHE(fsnotify_event_holder, SLAB_PANIC);
 
-	initialize_event(&q_overflow_event);
-	q_overflow_event.mask = FS_Q_OVERFLOW;
+	q_overflow_event = fsnotify_create_event(NULL, FS_Q_OVERFLOW, NULL,
+						 FSNOTIFY_EVENT_NONE, NULL, 0,
+						 GFP_KERNEL);
+	if (!q_overflow_event)
+		panic("unable to allocate fsnotify q_overflow_event\n");
 
 	return 0;
 }


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-08-11 16:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-09 21:59 [PATCH 1/5] fsnotify: use fsnotify_create_event to allocate the q_overflow event Eric Paris
2009-08-09 21:59 ` [PATCH 2/5] inotify: use ZERO_PAGE instead of private static declaration Eric Paris
2009-08-10 14:12   ` Eric Paris
2009-08-09 21:59 ` [PATCH 3/5] inotify: use container_of instead of casting Eric Paris
2009-08-09 21:59 ` [PATCH 4/5] fsnotify: kzalloc fsnotify groups Eric Paris
2009-08-09 21:59 ` [PATCH 5/5] fsnotify: use kmem_cache_zalloc to simplify event initialization Eric Paris
2009-08-11 16:27 [PATCH 1/5] fsnotify: use fsnotify_create_event to allocate the q_overflow event Eric Paris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®