Fix use of closefd from vfs_fsal_open_and_stat (CID 30332)

Initialize closefd to indicate invalid.

Also, for any fd that is opened and returned in closefd, set close_fd to
true instead of relying on file type.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Make cancel_blocked_lock a void function

If an error occurs during cancel, there really isn't anything done about
it so no need to return an error that will be ignored.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Convert pthread_rwlock_wrlock in lru_run to PTHREAD_RWLOCK_wrlock

Also convert pthread_rwlock_unlock to PTHREAD_RWLOCK_unlock.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add export manager function to process pseudo mount and unexport work

Add new exp_work lists that we can put exports on for various work.

mount_work is a list of exports that need to be mounted into the PseudoFS.

unexport_work is a list of exports to be unexported.

These lists will be populated as necessary, and allow a batch of work to be
done in a protected way without holding the export_by_id.lock the entire time.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Perform pseudo_mount_export without holding export_by_id.lock

By using export_take_mount_work(), create_pseudofs() can avoid holding
the export_by_id.lock. This makes life a lot easier if a problem arises.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Rework pseudo_unmount_export for proper locking, also rework cleanup_pseudofs_node

cleanup_pseudofs_node now just modifies the pseudopath string in place (with
the caller having made a copy). Also several paranoia checks have been removed
and the caller is now responsible for checking if the mounted_on_export is
FSAL_PSEUDO (this reduces the number of checks). Also, LRU refcount is
released by the caller. Also replaced:

   cache_inode_get_keyed(&entry->object.dir.parent

with:

   cache_inode_lookupp(entry,

pseudo_unmount_export now does proper synchronisation looking at
junction_inode. It uses the export read lock to protect looking at
junction_inode and gets and LRU reference, then it drops the export read lock.

Next it acquires the attr_lock, and verifies if junction_inode->junction_export
STILL points to the export in question. If so THEN it acquires the export write
lock and THEN proceeds to cleanup.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Move some creds functions from nfs_exports.h to nfs_creds.h

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Manage list of exports mounted on each export and pseudo unmount them

The PseudoFS is a tree of exports sub-mounted on the root PseudoFS or
other exports. In order to properly unmount an export from the PseudoFS
we must first unmount any exports sub-mounted on this export.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Cleanup exports on shutdown

First, deconstruct the PseudoFS by umounting Pseudo Root.

Then unexport all exports.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Release FSAL_PSEUDO export root handle on release export

This handle does not get cleaned up during unmounting of the exports that
are mounted on the particular Pseudo filesystem. Once export release is
called, there will finally be nothing that needs this node anymore.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Remake cache_inode_destroyer into disposing of AVL tree instead of entries

Unexporting all exports as part of shutdown flushes the cache inode, so
instead, we will destroy the AVL tree. If the tree is NOT empty, we will
throw an error.

The function is moved into cache_inode_init.c and cache_inode_hash.c to
be adjacent to the initialization code for ease of verifying that destroy
undoes everything that init does.

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