Re: [patch] updated inotify for 2.6.12-rc3.

From: Robert Love
Date: Fri Apr 22 2005 - 18:27:13 EST


On Fri, 2005-04-22 at 22:13 +0100, Al Viro wrote:

> Or it would, if remove_watch() had been called only once. In the scenario
> above that will not be true.

Thanks.

Robert Love


Double check that we don't race.

Signed-off-by: Robert Love <rml@xxxxxxxxxx>

fs/inotify.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

diff -urN linux-2.6.12-rc3-inotify/fs/inotify.c linux/fs/inotify.c
--- linux-2.6.12-rc3-inotify/fs/inotify.c 2005-04-22 19:20:14.000000000 -0400
+++ linux/fs/inotify.c 2005-04-22 19:25:44.000000000 -0400
@@ -861,12 +861,17 @@
return -EINVAL;
}
get_inotify_watch(watch);
+ inode = watch->inode;
up(&dev->sem);

- inode = watch->inode;
down(&inode->inotify_sem);
down(&dev->sem);
- remove_watch(watch, dev);
+
+ /* make sure we did not race */
+ watch = idr_find(&dev->idr, wd);
+ if (likely(watch))
+ remove_watch(watch, dev);
+
up(&dev->sem);
up(&inode->inotify_sem);
put_inotify_watch(watch);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/