By default, the server starts one threadpool as before. However, if diod is started with --threadmode=aname, then a new threadpool is started up for each unique aname (except 'ctl' which is handled with the default threadpool) This solves issue 26, where a down NFS server mounted with -ohard that is being forwarded through diod could hang the threadpool, preventing access to other file systems. Thread pools, with private request queues, are created/selected at attach time and a reference to the thread pool is attached to the fid. Cloned fids inherit a reference back to the thread pool selected at attach time. Thread pools are destroyed when their reference count goes to zero (all fids are clunked = file system is unmounted).
Create fid->aname and look up each request's fid before enqueueing for the server. This allows us to, for example, create a separate queue and worker thread pool for each forwarded file system, so when one gets stuck the entire server doesn't deadlock.
Instead of mounting synthetic file system with nil aname, use aname=ctl (issue 38). Fix a bug in diodmount where aname was used uninitialized in initial pre-auth mount from user space. Add CFLAGS=-Werror to spec file build so compiler warnings get noticed when building a package. In diodmount, clunk the afid, if any, when attach fails. Rename internal names from np_syn_* to np_ctl_*. Rename np_ctl_mkdir to np_ctl_adddir to avoid confusion with op callback that would have the same name. Add quotes around all Npstr's in trace output, so empty strings stand out from white space, then fix up regression tests that were expecting the non-quoted output. Implement ctl/exports Make it possible for clients, etc. to access the list of exported file systems through ctl/exports. Modify auto.diod to use this to map automounter keys. In the process, split export handling code in diod/ops.c out to diod/exp.c. Also fixed an incidental config problem where defaults were not restored when config file values that were previously set explicitly, were commented out and the server sent a SIGHUP. Minor cleanup.
Rename File to Npfile. Add np_syn_mkdir () so an entire hierarchy can be externally created. The internal synthetic namespace is selected (only) by nil aname. Move the usercache onto the Npsrv struct so we can free it when the server is cleaned up. Add 'usercache' - list users in cache and ttl Add "connections" - includes last aname attached, active fids in the fidpool, and number of requests submitted and retired. Add "wthreads" - thread state, fsuid, fsgid, number of requests handled.
Use P9_QTTMP qid type flag to identify synthetic files. Handle them along side a regular server so they can be used to implement utilities that monitor or reconfigure the server. Identify synthetic files in an attach for an aname that does not begin with a "/" character.
Return EPERM to P9_LCREATE et al if the provided gid is not one of the user's supplemental groups. Without this check, a user could get elevated privilege in a server running as root by attaching as themselves from user space and issuing requests with arbitrary gids. Add a testcase demonstrating this.
And remember whose groups are loaded so if that user runs next in this worker, we don't have to load them then either. Also, instead of always calling setfsuid and setfsgid in each thread's first work item, initialize to geteuid and getegid and only call if they're different.
Optimize the case where many clients all mount file systems on behalf of the same user by adding a 60s ttl cache for Npuser data. This minimizes the number of password/group file lookups in that case, and causes the cached Npuser data to be shared rather than duplicated. Although Npuser's are only in the cache for 60s, as before, users holding a reference on them won't see updated data after 60s. In other words, updates to supplemental group membership won't be picked up by existing mounts. As a side effect, a usercache mutex serializes all password/group file lookup functions. However there should be many many fewer of them.
Avoid back to back password file lookups between auth and attach. Add np_afid2user () which checks if the attaching user is the same as the auth user and then takes another reference on that Npuser and returns it. Clean up log messages in auth and attach handlers in libnpfs. Clean up log messages in diod_auth.c and make the code more resilient to unexpected argument values.