On Mon, Mar 01 2021, J. Bruce Fields wrote: > On Tue, Mar 02, 2021 at 02:01:36PM +1100, NeilBrown wrote: >> On Mon, Mar 01 2021, J. Bruce Fields wrote: >> >> > I've gotten requests for similar functionality, and intended to >> > implement it using directory notifications on /proc/fs/nfsd/clients. >> >> I've been exploring this a bit. >> When I mount a filesystem, 2 clients get created. >> With NFSv4.0, the second client is immediately deleted, and the first >> client is deleted one grace period after the filesystem is unmounted. >> With NFSv4.1 and 4.2, the first client is immediately deleted, and the >> second client is deleted immediately after the unmount. > > Yeah, internally it's creating an "unconfirmed client" on SETCLIENTID > (or EXCHANGE_ID) and then a new "confirmed client" on > SETCLIENTID_CONFIRM (or CREATE_SESSION). Of course - the "confirm" step. That would explain it. > > I'm not sure why the ordering's a little different between the 4.0/4.1+ > cases. > > The difference on unmount is because 4.1+ clients immediately send a > DESTROY_CLIENTID on unmount, but that op was new to 4.1. I thought it would be something like that - a protocol improvements. > > (Note of course this isn't precisely mount/unmount, as the same client > can be used for multiple filesystems.) True. It could also be a network disconnect, not an explicit unmount. Still I think it could be useful to log. > > Honestly, I think this is exposing an implementation detail and it's > dumb. I'll look into fixing it. Thanks. > > (I don't know if that change itself would cause additional difficulty.) I doubt it. You would need to look at "info" in a directory to do anything useful, and in my simple testing that always said cat: /proc/fs/nfsd/clients/41/info: No such file or directory or similar in the transient directory. So code is mostly likely to quickly ignore any such directory. I'll see how easy it is to add "client added" and "client removed" log messages to mountd before resending my series. Thanks, NeilBrown