Inotify problem [was Re: 2.6.13-rc6-mm1]
Subsystems (3)
Hi Everyone,
I'm answering this from my home email. I have not heard from my co-workers in Florida yet, and I imagine that they are busy cleaning up after hurricane Katrina and waiting for the power to come back on.
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().
I would be glad to spend some time looking at the inotify problem assuming that fixing the off-by-one problem above doesn't solve it. I have not used inotify and would need pointers to the user space header files and library.
Jim
Quoted 6 lines · Jim Houston
Hi Everyone,
I'm answering this from my home email. I have not heard from my co-workers in Florida yet, and I imagine that they are busy cleaning up after hurricane Katrina and waiting for the power to come back on.
Quoted 8 lines
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. Thestart_idparameter 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 thestart_idand it has already been freed (by anidr_removecall), it will be allocated again. The obvious fix would be to incrementstart_idinidr_get_new_above().
Thanks for your suggestion, it has 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.
fs/inotify.c +1 -1
@@ -353,7 +353,7 @@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;
lib/idr.c +1 -1
@@ -207,7 +207,7 @@ }/** -* 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
Quoted 10 lines · John McCutchan
Thanks for your suggestion, it has 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:682callidr_get_new_aboveas 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]>
Keeping the current behavior is probably the best way to go.
Robert Love
Quoted 27 lines
Index:
linux/fs/inotify.c
===================================================================fs/inotify.c +1
-1@@ -353,7 +353,7 @@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;Index:
linux/lib/idr.c
===================================================================lib/idr.c +1
-1@@ -207,7 +207,7 @@ }/** -* 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