Fix get_gsh_export_by_path and get_gsh_export_by_pseudo

These routines have to distinguish requirement for exact match and
partial match. Export config processing needs exact match to detect
duplicates, while mounting requires partial match since the mount
path might be a sub-directoru of an export.

Also fix up some bits in export parsing.

Also add locked versions for use when called from iterators.

Fixup to properly match root path to root export

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Don't lookup export in cache_inode_get_keyed

We actually have the export in the req_ctx. This eliminates the need to
acquire the export_by_id.lock lock here, which would be bad because while
constructing the Pseudo FS, we hold that lock, and could end up calling
cache_inode_get_keyed.

Put an assert in to catch us if the assumption is actually wrong.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add routines to mount an export in the new Pseudo FS

This is the big building block for creating a new Pseudo FS on top of
cache_inode and FSAL_PSEUDO.

pseudo_mount_export() will take a defined export, and use it's Pseudo
Path to find the export it would be mounted on, and then assure that
said export has the directory tree to support the mounted export. If a
directory is missing, it will be created.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Convert to using new Pseudo FS

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Remove old Pseduo FS code

This includes some operations that check for Pseudo FS that don't normally
apply to Pseudo FS, so they weren't done in the "convert to new Pseudo FS"
patch set.

Also caught a few stale nfs2 references.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Read LOG config before loading FSALs

Otherwise you can't enable debug etc. during FSAL loading.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make FSAL_PSEUDO built in

This required a hack in fsal_load_config to take a NULL name param to
indicate "don't look for an FSAL config block for this FSAL".

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
In sanity check currentFH/savedFH assert that cache entry is valid

Now that a valid file handle always references a cache inode, we can
assert that data->current_entry or data->saved_entry is non-NULL (and
also that the filetype is not NO_FILE_TYPE).

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add more debug in nfs4_op_lookup.c and nfs4_op_readdir.c

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Insert parent's handle key on create, lookup, or readdir

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Don't proceed with cache_inode_get_keyed if key is NULL

Sometimes cache_inode_get_keyed is called to lookup a
directory inode's parent which has a NULL key because the
parent is currently uknown, don't attempt to use it.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Strip NOSUID and NOSGID export options

These options don't make sense. As options with names like that, they
are client side mount options.

We do need to scrub the code for proper handling of S_ISGID and S_ISUID.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Strip unused access_type, new_access_list, and seckey fields from exportlist_t

These fields are not used anymore and are left over from the export
permissions work.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add check and refcount to prevent junctions and export roots from unlink

Any cache inode that is an active junction must be protected from unlink
as must any node that is an export root. Since an inode may be the root
of more than one export (with a different tag and/or Pseudo path), we
must refcount export root nodes rather than flagging the node as a root.

Note that this does not prevent non-Ganesha tasks from unlinking these
nodes. That is a task for another day.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fix a difference in definition of open_fd_count

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add routine set_current_entry to unify setting of data->current_entry

This routine sets:

cache_inode_put(data->current_entry)
data->current_entry
data->current_filetype
data->current_stateid_valid = false;
data->current_ds->ops->put(data->current_ds);
data->current_ds = NULL;

It will optionally take an extra reference on the current_entry

It may be passed NULL for current_entry in which case it effectively
clears current_entry.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make SAVEFH and RESTOREFH work correctly with DS handles

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Maintain list of exports rooted on a particular cache inode

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Use pin reference instead of LRU reference on export root and junction cache inodes

In order for cache_inode_kill_entry to work properly if an export root
or junction inode is deleted in the underlying file system, we must
pin the entries instead of taking an LRU reference.

Proper cleanup will be in the next patch.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fix definition of cache_inode_dec_pin_ref to be a void function

Also document the 2nd closefile parameter.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>