Re: large directory iteration (getdents) over NFS mount resets due to stat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm starting to think this is a bug. I can't see a good reason why
accessing (stat) a directory entry should cause the READDIRPLUS cookie
to be reset.

It seems that the trigger for iteration reset is accessing a directory
entry that doesn't have a valid entry in the cache. If it does has a
valid cache entry it doesn't trigger the cookie reset. Note, it
doesn't matter if the entry (or traversed dir) has actually changed:
the reset occurs even if both did not change on the server side.

Setting actimeo to a large enough value allows the dir iteration to
complete without any resets, but this is just a workaround that isn't
acceptable if the file system is being modified or if there isn't
enough memory. It's also heuristic and can lead to unexpected hiccups
if something in the environment changes.

So my questions still stand: is this expected behavior? What's the reason?

P.S. I'm using NFSv3

On Mon, Jul 15, 2019, 08:56 Noam Lewis <noam.lewis@xxxxxxxxxxxxxx> wrote:
>
> I've encountered a problem while iterating large directories via an NFS mount.
>
> Scenario:
>
> 1. Linux NFS client iterates a directory with many (millions) of
> files, e.g. via getdents() until all entries are done. In my case,
> READDIRPLUS is being used under the hood. Trivial reproduction is to
> run: ls -la
> 2. At the same time, run the stat tool on a file inside that directory.
>
> The directory on the server is not being modified anywhere (on this
> client or any other client).
>
> Result: the next or ongoing getdents will get stuck for a long time
> (tens of seconds to minutes). It appears to be re-iterating some of
> the work it already did, by going back to a previous NFS READDIRPLUS
> cookie.
>
>
> Things I've tried as workarounds:
> - Mounting with nordirplus - the iteration doesn't seem to reset or at
> least getdents doesn't get stuck, but now I have tons of LOOKUPs, as
> expected.
> - Setting actimeo=(large number) doesn't affect the behavior
>
> Questions:
> 1. Why does the stat command cause this?
> 2. How can I avoid the reset, i.e. ensure forward progress of the dir iteration?



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux