> On Feb 3, 2023, at 10:13 AM, Benjamin Coddington <bcodding@xxxxxxxxxx> wrote: > > On 3 Feb 2023, at 9:38, Chuck Lever III wrote: > >>> On Feb 1, 2023, at 10:53 AM, Benjamin Coddington <bcodding@xxxxxxxxxx> wrote: >>> >>> On 1 Feb 2023, at 9:10, Benjamin Coddington wrote: >>>> >>>> Working on a fix.. >>> >>> .. actually, I have no idea how to fix this - if tmpfs is going to modify >>> the position of its dentries, I can't think of a way for the client to loop >>> through getdents() and remove every file reliably. >>> >>> The patch you bisected into just makes this happen on directories with 18 >>> entries instead of 127 which can be verified by changing COUNT in the >>> reproducer. >>> >>> As Trond pointed out in: >>> https://lore.kernel.org/all/eb2a551096bb3537a9de7091d203e0cbff8dc6be.camel@xxxxxxxxxxxxxxx/ >>> >>> POSIX states very explicitly that if you're making changes to the >>> directory after the call to opendir() or rewinddir(), then the >>> behaviour w.r.t. whether that file appears in the readdir() call is >>> unspecified. See >>> https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html >>> >>> The issue here is not quite the same though, we unlink the first batch of >>> entries, then do a second getdents(), which returns zero entries even though >>> some still exist. I don't think POSIX talks about this case directly. >>> >>> I guess the question now is if we need to drop the "ls -l" improvement >>> because after it we are going to see this behavior on directories with >17 >>> entiries instead of >127 entries. >> >> I don't have any suggestions about how to fix your optimization. > > I wasn't trying to fix it. I was trying to fix your testing setup. > >> Technically I think this counts as a regression; Thorsten seems >> to agree with that opinion. It's late in the cycle, so it is >> appropriate to consider reverting 85aa8ddc3818 and trying again >> in v6.3 or v6.4. > > Thorsten's bot is just scraping your regression report email, I doubt > they've carefully read this thread. > >>> It should be possible to make tmpfs (and friends) generate reliable cookies >>> by doing something like hashing out the cursor->d_child into the cookie >>> space.. (waving hands) >> >> Sure, but what if there are non-Linux NFS-exported filesystems >> that behave this way? > > Then they would display this same behavior, and claiming it is a server bug > might be defensible position. It's a server bug if we can cite something (perhaps less confusing and more on-point than the POSIX specification) that says READDIR cookies aren't supposed to behave this way. I bet the tmpfs folks are going to want to see that kind of mandate before allowing a code change. I'm wondering if you can trigger the same behavior when running directly on tmpfs? > The reality as I understand it is that if the server is going to change the > cookie or offset of the dentries in between calls to READDIR, you're never > going to reliably be able to list the directory completely. Or maybe we > can, but at least I can't think of any way it can be done. > > You can ask Trond/Anna to revert this, but that's only going to fix your > test setup. The behavior you're claiming is a regression is still there - > just at a later offset. No-one is complaining about the existing situation, which suggests this is currently only a latent bug, and harmless in practice. This is a regression because your optimization exposes the misbehavior to more common workloads. Even if this is a server bug, the guidelines about not introducing behavior regressions mean we have to stick with the current client side behavior until the server side part of the issue has been corrected. > Or we can modify the server to make tmpfs and friends generate stable > cookies/offsets. > > Or we can patch git so that it doesn't assume it can walk a directory > completely while simultaneously modifying it. I'm guessing that is something that other workloads might do, so fixing git is not going to solve the issue. And also, the test works fine on other filesystem types, so it's not git that is the problem. > What do you think? IMO, since the situation is not easy or not possible to fix, you should revert 85aa8ddc3818 for v6.2 and work on fixing tmpfs first. It's going to have to be a backportable fix because your optimization will break with any Linux server exporting an unfixed tmpfs. -- Chuck Lever