Fix comment in MainNFSD/nfs_worker_thread.c

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fix ordering of params to cache_inode_setattr - fixes CID 30387 and 60336

Since "false" is not strongly typed, it can be passed indicating as a
pointer parameter (indicating NULL). And a pointer can be passed as a
boolean (indicating true if non-NULL).

Very confusing and hard to find, thanks to Coverity for catching this
one.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fix NULL pointer reference issues in MainNFSD/nfs_worker_thread.c

Fixes CID 30253 (NULL req_ctx.export) and an issue with NULL req_ctx.client
that was suggested by CID 30252 but not exactly highlighted.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fix NULL req_ctx->client handling in server_stats.c (fixes CID 30252)

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Remove a paranoia check in nfs4_op_lookupp (fix CID 30386)

If CurrentFH is valid, original_export MUST be non-NULL.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Remove unused entry_src from nfs4_op_secinfo_no_name (fix CID 30245)

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
In cache_inode_new_entry error path, new_obj must always be released

Fixes CID 30379

Originally new_obj might have been set to NULL, but that is no longer
the case, so the test for NULL is superfluous.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fix cancel_all_nlm_blocked to use glist_first_entry (fixes CID 30209)

The safe way to drain a glist while possibly dropping the lock on the
list is to repeatedly use glist_first_entry.

Also stop making the paranoia check that sbd_lock_entry is non-NULL.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Save sle_type to fix use after free in state_export_unlock_all (fixes CID 30405)

This fixes the apparent intent of the code, however, it should be noted that
while this is definitely correct for range locks (sle_type == POSIX_LOCK), it
MAY not be correct for delegations (sle_type == LEASE_LOCK). On the other hand,
state_export_release_nfs4_state doesn't do anything else to clean up'
delegations.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
In state_nlm_notify pass POSIX_LOCK to state_unlock to fix use after free

NLM locks can ONLY be POSIX_LOCK so don't bother saving sle_type.

Fixes CID 30413.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
In state_owner_unlock_all pass POSIX_LOCK to state_unlock to fix use after free

LEASE_LOCK can ONLY be owned by cid_owner, so will NEVER appear in the list
of locks for a lock owner...

Fixes CID 30414.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Use &root_op_context.req_ctx in call to state_nlm_unshare from state_nlm_notify

Fixes CID 60334

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Use *fs instead of fs in vfs_check_handle (CID 56786)

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
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>
Acked-by: Malahal Naineni <malahal@us.ibm.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>
Acked-by: Malahal Naineni <malahal@us.ibm.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>
Acked-by: Malahal Naineni <malahal@us.ibm.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>
Acked-by: Malahal Naineni <malahal@us.ibm.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>
Acked-by: Malahal Naineni <malahal@us.ibm.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>
Acked-by: Malahal Naineni <malahal@us.ibm.com>