On 5/9/19 7:20 PM, katcherw(a)gmail.com wrote:
 I'm developing a proprietary FSAL in Ganesha 2.6.3. When using
NFSv3, I see that nfs3_create calls open2, which presumably is supposed to create the file
and open it. My question is when does the file get closed? I have a huge amount of open
files in my FSAL and not sure how to close them. Even in VFS, I see that created files
stay open. 
For NFSv3, there isn't an explicit close in the protocol.  This leaves 
servers with two choices:  close the file every time, and incur the 
overhead of opening it every time, or cache the opens for a while, and 
close them later.  This is what Ganesha does.  MDCACHE has a 2 layer LRU 
that keeps track entries.  When an entry transitions from L1 to L2 of 
the LRU, it's open file handle is closed.  This is done in the 
background by a scrub thread, and is governed by a high-water and 
low-water mark on the number of FDs, configured by FD_HWMark_Percent and 
FD_LWMark_Percent.  When lwmark is passed, the thread wakes up; when 
hwmark is passed, it runs really hard.  There's a hard limit, detected 
at startup from the system rlimit.  Percentages are relative to this.
Long story short: NFSv4 files will generally be closed when the client 
is done; NFSv3 files will hang around
Daniel