[Bug 14458] New: more upstream inotify goodness

bugzilla-daemon at bugzilla.ubuntu.com bugzilla-daemon at bugzilla.ubuntu.com
Thu Sep 1 01:58:41 UTC 2005


Please do not reply to this email.  You can add comments at
http://bugzilla.ubuntu.com/show_bug.cgi?id=14458
Ubuntu | linux

           Summary: more upstream inotify goodness
           Product: Ubuntu
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: linux
        AssignedTo: ben.collins at ubuntu.com
        ReportedBy: desrt at desrt.ca
         QAContact: kernel-bugs at lists.ubuntu.com
                CC: jbailey at ubuntu.com
OtherBugsDependingO 14456
             nThis:


To address some of the issues in a recent rant I made about inotify, John
McCutchan has made some changes.  These changes are 100% ABI compatible
(otherwise, they would never be accepted upstream).  They'll likely be in
2.6.14, and it would be really nice if Breezy had them.

It fixes a potential race condition problem with the old ABI where events might
have been missed by requesting a new watch when a watch was already in place on
the same inode.

If the old watch had more events being reported than the new watch then the
result would be that some of the requested events would go unreported (since the
mask was replaced outright).  The patch allows users to request that the
existing mask is OR'd with the new mask so that no events are lost.

Cheers



Signed-off-by: John McCutchan <ttb at tentacle.dhs.org>
Signed-off-by: Robert Love <rml at novell.com>

Index: linux/fs/inotify.c
===================================================================
--- linux.orig/fs/inotify.c     2005-08-28 19:41:01.000000000 -0400
+++ linux/fs/inotify.c  2005-08-31 15:41:11.000000000 -0400
@@ -925,6 +925,7 @@
        struct nameidata nd;
        struct file *filp;
        int ret, fput_needed;
+       int mask_add = 0;
 
        filp = fget_light(fd, &fput_needed);
        if (unlikely(!filp))
@@ -947,6 +948,9 @@
        down(&inode->inotify_sem);
        down(&dev->sem);
 
+       if (mask & IN_MASK_ADD)
+               mask_add = 1;
+
        /* don't let user-space set invalid bits: we don't want flags set */
        mask &= IN_ALL_EVENTS;
        if (unlikely(!mask)) {
@@ -960,7 +964,10 @@
         */
        old = inode_find_dev(inode, dev);
        if (unlikely(old)) {
-               old->mask = mask;
+               if (mask_add)
+                       old->mask |= mask;
+               else
+                       old->mask = mask;
                ret = old->wd;
                goto out;
        }
Index: linux/include/linux/inotify.h
===================================================================
--- linux.orig/include/linux/inotify.h  2005-08-28 19:41:01.000000000 -0400
+++ linux/include/linux/inotify.h       2005-08-31 15:38:36.000000000 -0400
@@ -47,6 +47,7 @@
 #define IN_MOVE                        (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
 
 /* special flags */
+#define IN_MASK_ADD            0x20000000      /* add to the mask of an already
existing watch */
 #define IN_ISDIR               0x40000000      /* event occurred against dir */
 #define IN_ONESHOT             0x80000000      /* only send event once */

-- 
Configure bugmail: http://bugzilla.ubuntu.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.




More information about the kernel-bugs mailing list