REWORD Add cache_inode_get_protected MOVE AHAED OF Use pin reference instead of LRU reference on export root and junction cache inodes

This routine enables taking a reference on a cache inode given a pointer
to one (that is guaranteed to not go bad based on the lock passed to
cache_inode_get_protected). The reference is taken by copying the
entry's key under the lock provided, and then doing a regular hash look
up using that key.

The passed lock MUST guarantee the inode can not proceed far enough
along being cleaned to have it's key released (nor the cache_entry_t
memory either).

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

Add text describing use of cache_inode_get_protected

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add cache_inode_unexport to clean up cache inodes associated with unexport

When an export is unexported, any cache inodes that are exclusively
associated with that export must be cleaned up since they might become
otherwise unreachable.

Any cache inode that is still associated with another export will be
left untouched (other than removing it from the list of cache inodes
associated with the export being unexported).

cache_inode_get_protected is used to get a reference to each cache inode
in the list. This guarantees that if unexport is racing with a
cache_inode_kill_entry, that we don't work on a half-killed entry.

cache_inode_lru_cleanup_try_push is used to try and push an entry to
cleanup. This protects against a race where another thread suddenly
references this inode via some other export.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
SQUASH (NEW TITLE) Check for NULL alloc in cih_hash_entry

Fix up issues in cache_inode_hash.h

Check for NULL alloc in cih_hash_entry

Fix comparison in cih_fh_cmpf:

1. check hash first, if equal, then
2. check key len second, if equal then
3. compare key third

Old code didn't look at length at all, and worse, didn't actually
compare the keys...

Remove /n from log messages

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Remove /n from some log messages

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Add function to remove all SAL state associated with a particular export

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Keep all NLM shares on a list per export.

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

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
MORE Keep mapping of all cache entries per export and exports per cache entry

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

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Don't take/release LRU ref on pin/unpin

Pinning an entry protects it from reaping/recycling or any other removal
from the hash table other than by cache_inode_kill_entry. Any caller of
cache_inode_inc_pin_ref is expected to have an LRU reference on the
entry.

Cleanup of killed entries depends on the LRU refcount being drained to
zero prior to calling state_wipe_file, and the pin refcount will not
drain to zero without state_wipe_file being called. The only way to
prevent this chicken and egg problem is to not take LRU reference on
pin.

Also fix a type in cache_inode_lru_unref

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Clean up export on release of last reference.

Also, take a sentinel reference when creating an export.

remove_gsh_export will remove this sentinel reference.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
First pass of pseudo_unmount_export

Limitations:

Does not handle situation where junction cache inode is killed.

Does not remove FSAL_PSEUDO directories leading only to the export.

Does not clean out the directories in an FSAL_PSEUDO export that is
removed.

Does not handle unmount of any exports mounted on the removed export.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Provide unexport and kill_export_root_entry routines

unexport will be called by admin driven unexport.

kill_export_root_entry is called by cache inode after the last LRU
reference to a killed entry has been removed. It will clean up the
no longer viable export.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
We cannot set garray to NULL. it is dynamically allocated.
Also, we can't free it because later we may have to restore it!!

Ported from 7ef1f5db5488b8d837dd2b18595945d1b4f8f440

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

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

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