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

Johannes Berg
2005-08-25T12:18:51Z

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

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.

johannes

--begin test program--
/* Author: Johannes Berg <johannes@sipsolutions.net>
*
* This is a small inotify test program that simply
* repeatedly adds and removes watches.
*/

#include <stdio.h>
#include <linux/inotify.h>
#include <linux/inotify-syscalls.h>

int main()
{
int fd;
int wd1, wd2;
int ret;

fd = inotify_init();

if (fd < 0)
perror("inotify_init");

printf("inotify_init returned fd %d\n", fd);

while (1) {
wd1 = inotify_add_watch(fd, "/tmp", IN_ALL_EVENTS);

if (wd1 < 0) {
perror("inotify_add_watch");
break;
}
printf("inotify_add_watch returned wd1 %d\n", wd1);

wd2 = inotify_add_watch(fd, "/", IN_ALL_EVENTS);

if (wd2 < 0) {
perror("inotify_add_watch");
break;
}
printf("inotify_add_watch returned wd2 %d\n", wd2);

ret = inotify_rm_watch(fd, wd1);
if (ret < 0) {
perror("inotify_rm_watch wd1");
break;
}
ret = inotify_rm_watch(fd, wd2);
if (ret < 0) {
perror("inotify_rm_watch wd2");
break;
}
}
}

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 832 bytes --]