mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: linux-kernel@vger.kernel.org, viro@ZenIV.linux.org.uk
Subject: [PATCH 2/5] inotify: use ZERO_PAGE instead of private static declaration
Date: Sun, 09 Aug 2009 17:59:42 -0400	[thread overview]
Message-ID: <20090809215941.26204.52486.stgit@paris.rdu.redhat.com> (raw)
In-Reply-To: <20090809215935.26204.46787.stgit@paris.rdu.redhat.com>

inotify needs to pad filenames to an inotify event length.  Currently this
is done by copying 0s from an event declared globally.  This patch doesn't
waste global address space just to have some 0s and instead uses
clear_user()

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

 fs/notify/inotify/inotify_user.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index c17d5a3..c3086b0 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -47,9 +47,6 @@
 
 static struct vfsmount *inotify_mnt __read_mostly;
 
-/* this just sits here and wastes global memory.  used to just pad userspace messages with zeros */
-static struct inotify_event nul_inotify_event;
-
 /* these are configurable via /proc/sys/fs/inotify/ */
 static int inotify_max_user_instances __read_mostly;
 static int inotify_max_queued_events __read_mostly;
@@ -215,7 +212,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
 	/*
 	 * fsnotify only stores the pathname, so here we have to send the pathname
 	 * and then pad that pathname out to a multiple of sizeof(inotify_event)
-	 * with zeros.  I get my zeros from the nul_inotify_event.
+	 * with zeros.
 	 */
 	if (name_len) {
 		unsigned int len_to_zero = name_len - event->name_len;
@@ -224,8 +221,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
 			return -EFAULT;
 		buf += event->name_len;
 
-		/* fill userspace with 0's from nul_inotify_event */
-		if (copy_to_user(buf, &nul_inotify_event, len_to_zero))
+		/* fill userspace with 0's */
+		if (clear_user(buf, len_to_zero))
 			return -EFAULT;
 		buf += len_to_zero;
 		event_size += name_len;


  reply	other threads:[~2009-08-09 21:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Eric Paris [this message]
2009-08-10 14:12   ` [PATCH 2/5] inotify: use ZERO_PAGE instead of private static declaration 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090809215941.26204.52486.stgit@paris.rdu.redhat.com \
    --to=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®