Re: Inotify problem [was Re: 2.6.13-rc6-mm1]

John McCutchan
2005-08-25T13:40:53Z

On Thu, 2005-08-25 at 14:18 +0200, Johannes Berg wrote:
> Hi,
>
> > I have also observed another problem with inotify with dovecot - so I spoke
> > with Johannes Berg who wrote the inotify code in dovecot. He suggested I post
> > here to LKML since his opinion is that this to be a kernel bug.
>
> Allow me to jump in at this point. The small tool below triggers this
> problem for Reuben (confirmed via private mail) but works fine for me on
> 2.6.13-rc6.

On 2.6.13-rc7 the test program fails. It always fails when a wd == 1024.
If I skip inotify_rm_watch when wd == 1024, it will fail at wd == 2048.
It seems the idr layer has an aversion to multiples of 1024.

When I run your test program I get this a lot:

inotify_add_watch returned wd1 5
inotify_add_watch returned wd2 6
inotify_add_watch returned wd1 6
inotify_add_watch returned wd2 7

The pattern of

add_watch wd1 = X
add_watch wd2 = X+1
rm_watch X
rm_watch X+1
add_watch wd1 = X+1
add_watch wd2 = X+2

Should never happen. We tell the idr layer to always give us something
bigger than the last wd we received.

Also, idr_get_new_above doesn't work all the time. Under 2.6.13-rc7, I
added this to inotify.c:359:

if (ret <= dev->last_wd) {
printk(KERN_INFO "idr_get_new_above returned <= dev->last_wd\n");
}

I get that message a lot. I know I have said this before (and was wrong)
but I think the idr layer is busted.

--
John McCutchan <ttb@tentacle.dhs.org>