The patch titled

     inotify fix for unexected IDR behaviour

has been added to the -mm tree.  Its filename is

     inotify-fix-for-unexpected-idr-behaviour.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

inotify-fix-for-unexpected-idr-behaviour.patch
inotify-speedup.patch
fsnotify-hook-on-removexattr-too.patch



From: John McCutchan <[EMAIL PROTECTED]>

Jim Houston <[EMAIL PROTECTED]> wrote:
>
> It looks like we have an "off by one" problem with idr_get_new_above()
> which may be part of the inotify problem.  I'm not sure if the problem
> is the behavior or the name & comments.  The start_id parameter is the
> starting point for the idr allocation search, and if it is available, it
> will be allocated.  If you pass in the last id allocated as the start_id
> and it has already been freed (by an idr_remove call), it will be
> allocated again.  The obvious fix would be to increment start_id
> in idr_get_new_above().

This fixed the inotify problem.  But where to put the fix is turning into a
bit of a mess.  Some callers like drivers/md/dm.c:682 call
idr_get_new_above as if it will return >= starting_id.  The comment says
that it will return > starting_id, and the function name leads people to
believe the same thing.

In the patch below I change inotify do add one to the value was pass into
idr.  I also change the comment to more accurately reflect what the
function does.  The function name doesn't fit, but it never did.

Signed-off-by: John McCutchan <[EMAIL PROTECTED]>
Cc: Robert Love <[EMAIL PROTECTED]>
Cc: george anzinger <[email protected]>
Cc: Neil Brown <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 fs/inotify.c |    2 +-
 lib/idr.c    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff -puN fs/inotify.c~inotify-fix-for-unexpected-idr-behaviour fs/inotify.c
--- devel/fs/inotify.c~inotify-fix-for-unexpected-idr-behaviour 2005-08-26 
11:55:02.000000000 -0700
+++ devel-akpm/fs/inotify.c     2005-08-26 11:55:02.000000000 -0700
@@ -353,7 +353,7 @@ static int inotify_dev_get_wd(struct ino
        do {
                if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
                        return -ENOSPC;
-               ret = idr_get_new_above(&dev->idr, watch, dev->last_wd, 
&watch->wd);
+               ret = idr_get_new_above(&dev->idr, watch, dev->last_wd+1, 
&watch->wd);
        } while (ret == -EAGAIN);
 
        return ret;
diff -puN lib/idr.c~inotify-fix-for-unexpected-idr-behaviour lib/idr.c
--- devel/lib/idr.c~inotify-fix-for-unexpected-idr-behaviour    2005-08-26 
11:55:02.000000000 -0700
+++ devel-akpm/lib/idr.c        2005-08-26 11:55:02.000000000 -0700
@@ -207,7 +207,7 @@ build_up:
 }
 
 /**
- * idr_get_new_above - allocate new idr entry above a start id
+ * idr_get_new_above - allocate new idr entry above or equal to a start id
  * @idp: idr handle
  * @ptr: pointer you want associated with the ide
  * @start_id: id to start search at
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to