The patch titled inotify: allow watch removal from event handler has been added to the -mm tree. Its filename is inotify-allow-watch-removal-from-event-handler.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: inotify: allow watch removal from event handler From: Amy Griffis <amy.griffis@xxxxxx> 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@xxxxxx> Acked-by: Robert Love <rml@xxxxxxxxxx> Cc: "John McCutchan" <john@xxxxxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- fs/inotify.c | 23 ++++++++++++++--------- include/linux/inotify.h | 7 +++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff -puN fs/inotify.c~inotify-allow-watch-removal-from-event-handler fs/inotify.c --- 25/fs/inotify.c~inotify-allow-watch-removal-from-event-handler Thu Jun 1 13:11:04 2006 +++ 25-akpm/fs/inotify.c Thu Jun 1 13:11:04 2006 @@ -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 -puN include/linux/inotify.h~inotify-allow-watch-removal-from-event-handler include/linux/inotify.h --- 25/include/linux/inotify.h~inotify-allow-watch-removal-from-event-handler Thu Jun 1 13:11:04 2006 +++ 25-akpm/include/linux/inotify.h Thu Jun 1 13:11:04 2006 @@ -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) { } _ Patches currently in -mm which might be from amy.griffis@xxxxxx are git-audit-master.patch inotify-split-kernel-api-from-userspace-support.patch inotify-add-names-inode-to-event-handler.patch inotify-add-interfaces-to-kernel-api.patch inotify-allow-watch-removal-from-event-handler.patch inotify-update-kernel-documentation.patch inotify-kernel-api.patch inotify-kernel-api-fix.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html