readahead-watch fails silently when it runs out of inotify watches

Bug #323403 reported by Daniel Silva
4
Affects Status Importance Assigned to Milestone
readahead-list (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: readahead-list

in readahead-watch.c, in watch_directory, the following code block:

                /* Add a watch on the directory */
                wd = inotify_add_watch (inotify_fd, queue->path,
                                        IN_OPEN | IN_CLOSE | IN_CREATE);
                if (wd < 0) {
                        continue;
                }

makes readahead-watch skip a directory and continue on any error when trying to add a watch. This includes ENOSPC, which from the inotify_add_watch man page means:

       ENOSPC The user limit on the total number of inotify watches was reached or
              the kernel failed to allocate a needed resource.

If readahead-watch gets a ENOSPC, it's pointless to keep trying to add more watches, so it should break out of rather than continue the loop. It should also inform the user that this happened, so that the user is not confused (as I was) when readahead-watch finishes with an empty output file.

Maybe it should do the following instead:

                /* Add a watch on the directory */
                wd = inotify_add_watch (inotify_fd, queue->path,
                                        IN_OPEN | IN_CLOSE | IN_CREATE);
                if (wd < 0) {
                   if (-wd == ENOSPC) {
                     fprintf(stderr, "%s: ran out of inotify watches at %s\n", program_name, queue->path);
                     break;
                   }
                   else continue;
                }

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.