1) Look again; it's O(1) work per entry, or O(n) work for an n-entry
directory. And O(1) space. With very small constant factors, and
very little code. The only thing exponentially increasing is the
interval at which you save the current cookie for future comparison.
2) You said it *was* a problem, so it seemed worth presenting a
practical solution. If you don't think it's worth it, I'm not
going to disagree. But it's not impossible, or even difficult.
Yes. I was thinking about it this morning (after coffee).
One variant on those algorithms that might make sense here is to save
the current cookie each time we see that the result of a cookie search
is a filp->f_pos offset < the current filp->f_pos offset. That means we
will in general only detect the loop after going through an entire
cycle, but that should be sufficient...
Linux NFS client maintainer