public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bryan Rittmeyer <bryan@staidm.org>
To: John McCutchan <ttb@tentacle.dhs.org>, Robert Love <rml@novell.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] inotify 0.13.1 cleanup
Date: Tue, 12 Oct 2004 03:50:56 -0700	[thread overview]
Message-ID: <20041012105056.GA26353@staidm.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 47 bytes --]

Two minor optimizations and an ENOMEM.

-Bryan

[-- Attachment #2: inotify-0.13.1-cleanup_1.patch --]
[-- Type: text/plain, Size: 2117 bytes --]

--- inotify.c.orig	2004-10-12 01:16:12.000000000 -0700
+++ inotify.c	2004-10-12 02:44:52.000000000 -0700
@@ -218,7 +218,6 @@
 
 	/* the queue has just overflowed and we need to notify user space */
 	if (dev->event_count == MAX_INOTIFY_QUEUED_EVENTS) {
-		dev->event_count++;
 		kevent = kernel_event(-1, IN_Q_OVERFLOW, cookie, NULL);
 		iprintk(INOTIFY_DEBUG_EVENTS, "sending IN_Q_OVERFLOW to %p\n",
 			dev);
@@ -229,19 +228,18 @@
 			!event_and(mask, watch->mask))
 		return;
 
-	dev->event_count++;
 	kevent = kernel_event(watch->wd, mask, cookie, filename);
 
 add_event_to_queue:
 	if (!kevent) {
 		iprintk(INOTIFY_DEBUG_EVENTS, "failed to queue event for %p"
 			" -- could not allocate kevent\n", dev);
-		dev->event_count--;
 		return;
 	}
 
 	/* queue the event and wake up anyone waiting */
 	list_add_tail(&kevent->list, &dev->events);
+	dev->event_count++;
 	iprintk(INOTIFY_DEBUG_EVENTS,
 		"queued event %x for %p\n", kevent->event.mask, dev);
 	wake_up_interruptible(&dev->wait);
@@ -470,13 +468,17 @@
 	if (!inode->inotify_data) {
 		inode->inotify_data = kmem_cache_alloc(inode_data_cachep,
 							GFP_ATOMIC);
+
+		if(!inode->inotify_data)
+			return -ENOMEM;
+
 		INIT_LIST_HEAD(&inode->inotify_data->watches);
 		inode->inotify_data->watch_mask = 0;
 		inode->inotify_data->watch_count = 0;
 	}
 	list_add(&watch->i_list, &inode->inotify_data->watches);
 	inode->inotify_data->watch_count++;
-	inode_update_watch_mask(inode);
+	inode->inotify_data->watch_mask |= watch->mask;
 
 	return 0;
 }
@@ -788,6 +790,7 @@
 {
 	struct inode *inode;
 	struct inotify_watch *watch;
+	int ret;
 
 	inode = find_inode(request->dirname);
 	if (IS_ERR(inode))
@@ -842,7 +845,17 @@
 		return -ENOSPC;
 	}
 
-	inode_add_watch(inode, watch);
+	ret = inode_add_watch(inode, watch);
+	if(ret < 0) {
+		iprintk(INOTIFY_DEBUG_ERRORS,
+			"can't add watch\n");
+		list_del(&watch->d_list); /* inotify_dev_rm_watch w/o event */
+		delete_watch(dev, watch);
+		spin_unlock(&dev->lock);
+		spin_unlock(&inode->i_lock);
+		unref_inode(inode);
+		return ret;
+	}
 
 	spin_unlock(&dev->lock);
 	spin_unlock(&inode->i_lock);

                 reply	other threads:[~2004-10-12 10:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20041012105056.GA26353@staidm.org \
    --to=bryan@staidm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@novell.com \
    --cc=ttb@tentacle.dhs.org \
    /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