From: Amy Griffis <amy.griffis@hp.com>
To: linux-kernel@vger.kernel.org
Cc: John McCutchan <john@johnmccutchan.com>,
Robert Love <rlove@rlove.org>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH 4/5] inotify: allow watch removal from event handler
Date: Thu, 1 Jun 2006 11:10:37 -0400 [thread overview]
Message-ID: <20060601151037.GB2214@zk3.dec.com> (raw)
In-Reply-To: <20060601150702.GA2171@zk3.dec.com>
Allow callers to remove watches from their event handler via
inotify_remove_watch_locked(). This functionality can be used to
achieve IN_ONESHOT-like functionality for a subset of events in the
mask.
Signed-off-by: Amy Griffis <amy.griffis@hp.com>
---
fs/inotify.c | 23 ++++++++++++++---------
include/linux/inotify.h | 7 +++++++
2 files changed, 21 insertions(+), 9 deletions(-)
3c6aadc67eed3796ce0b3fdbf7b47ce1469a0123
diff --git a/fs/inotify.c b/fs/inotify.c
index 8477c4f..723836a 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -207,7 +207,7 @@ static struct inotify_watch *inode_find_
}
/*
- * remove_watch_no_event - remove_watch() without the IN_IGNORED event.
+ * remove_watch_no_event - remove watch without the IN_IGNORED event.
*
* Callers must hold both inode->inotify_mutex and ih->mutex.
*/
@@ -223,17 +223,22 @@ static void remove_watch_no_event(struct
idr_remove(&ih->idr, watch->wd);
}
-/*
- * remove_watch - Remove a watch from both the handle and the inode. Sends
- * the IN_IGNORED event signifying that the inode is no longer watched.
+/**
+ * inotify_remove_watch_locked - Remove a watch from both the handle and the
+ * inode. Sends the IN_IGNORED event signifying that the inode is no longer
+ * watched. May be invoked from a caller's event handler.
+ * @ih: inotify handle associated with watch
+ * @watch: watch to remove
*
* Callers must hold both inode->inotify_mutex and ih->mutex.
*/
-static void remove_watch(struct inotify_watch *watch, struct inotify_handle *ih)
+void inotify_remove_watch_locked(struct inotify_handle *ih,
+ struct inotify_watch *watch)
{
remove_watch_no_event(watch, ih);
ih->in_ops->handle_event(watch, watch->wd, IN_IGNORED, 0, NULL, NULL);
}
+EXPORT_SYMBOL_GPL(inotify_remove_watch_locked);
/* Kernel API for producing events */
@@ -378,7 +383,7 @@ void inotify_unmount_inodes(struct list_
need_iput_tmp = need_iput;
need_iput = NULL;
- /* In case the remove_watch() drops a reference. */
+ /* In case inotify_remove_watch_locked() drops a reference. */
if (inode != need_iput_tmp)
__iget(inode);
else
@@ -411,7 +416,7 @@ void inotify_unmount_inodes(struct list_
mutex_lock(&ih->mutex);
ih->in_ops->handle_event(watch, watch->wd, IN_UNMOUNT, 0,
NULL, NULL);
- remove_watch(watch, ih);
+ inotify_remove_watch_locked(ih, watch);
mutex_unlock(&ih->mutex);
}
mutex_unlock(&inode->inotify_mutex);
@@ -434,7 +439,7 @@ void inotify_inode_is_dead(struct inode
list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
struct inotify_handle *ih = watch->ih;
mutex_lock(&ih->mutex);
- remove_watch(watch, ih);
+ inotify_remove_watch_locked(ih, watch);
mutex_unlock(&ih->mutex);
}
mutex_unlock(&inode->inotify_mutex);
@@ -687,7 +692,7 @@ int inotify_rm_wd(struct inotify_handle
/* make sure that we did not race */
if (likely(idr_find(&ih->idr, wd) == watch))
- remove_watch(watch, ih);
+ inotify_remove_watch_locked(ih, watch);
mutex_unlock(&ih->mutex);
mutex_unlock(&inode->inotify_mutex);
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index e7e7fb7..d4f48c6 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -122,6 +122,8 @@ extern __s32 inotify_add_watch(struct in
struct inode *, __u32);
extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *);
extern int inotify_rm_wd(struct inotify_handle *, __u32);
+extern void inotify_remove_watch_locked(struct inotify_handle *,
+ struct inotify_watch *);
extern void get_inotify_watch(struct inotify_watch *);
extern void put_inotify_watch(struct inotify_watch *);
@@ -205,6 +207,11 @@ static inline int inotify_rm_wd(struct i
return -EOPNOTSUPP;
}
+static inline void inotify_remove_watch_locked(struct inotify_handle *ih,
+ struct inotify_watch *watch)
+{
+}
+
static inline void get_inotify_watch(struct inotify_watch *watch)
{
}
--
1.3.0
next prev parent reply other threads:[~2006-06-01 15:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-01 15:07 [PATCH] inotify: split kernel API from userspace support Amy Griffis
2006-06-01 15:08 ` [PATCH 2/5] inotify: add name's inode to event handler Amy Griffis
2006-06-01 15:10 ` [PATCH 3/5] inotify: add interfaces to kernel API Amy Griffis
2006-06-01 15:10 ` Amy Griffis [this message]
2006-06-01 15:11 ` [PATCH 5/5] inotify: update kernel documentation Amy Griffis
2006-06-01 17:46 ` [PATCH] inotify: split kernel API from userspace support Robert Love
[not found] ` <1149216713.2865.0.camel@localhost.localdomain>
2006-06-02 2:51 ` John McCutchan
2006-06-02 12:32 ` Amy Griffis
2006-06-06 21:06 ` Pavel Machek
2006-06-08 3:59 ` Amy Griffis
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=20060601151037.GB2214@zk3.dec.com \
--to=amy.griffis@hp.com \
--cc=akpm@osdl.org \
--cc=john@johnmccutchan.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rlove@rlove.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
all inboxes | Powered by JetHome®