Increase number of pseudo fs nodes to 2048 and check limits

Also clean up some dead code.

The limit of 100 pseudo fs nodes is rather insufficient for 1000 exports...

To make it somewhat sane to test, I increased the number of path elements in
a pseudo path to 128.

Moved set up of pseudo fs until after creating root entries. This assures
that the pseudo fs only contains valid exports (previously, an export for
a path that didn't actually exist in the FSAL would be instantiated in the
pseudo fs, and then the export would have been discarded, leaving a dangling
pointer for someone to trip on).

Also improved the logging within the pseudo fs.

Also check pseudofs_id in pseudo fs handle before dereferencing array.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Improve GPFS errors in building export context

Make the check if the GPFS file system exists more
stringent. Export path must actually be a sub-directory
under the GPFS mount point or the mount point itself.
Check for \0 or / after the portion of the export path
that is equal to the mount point. So, for example, if
mount point is /ibm/fs0:

/ibm/fs0 is a valid export path
/ibm/fs0/ is a valid export path
/ibm/fs01 is not a match
/ibm/fs0/dir is a valid export path

Cleanly report that the exported path doesn't exist.

Cleanly report that the exported path is not a directory.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Make fsal_up_event_pool global, remove event_pool_lock, do init earlier

Also declare process_event in header file for future use.

Also move init of event pool and event queue to nfs_Init_FSAL_UP.

Call nfs_Init_FSAL_UP() before nfs_export_create_root_entry().

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add some infrastructure for GPFS to manage FSAL UP Threads

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add GPFSFSAL_UP_Thread

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove fsal_up threads

FSAL UP threads will be managed by FSALs, generally created
during FSAL_BuildExportContext if the FSAL needs more than one.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Clean some unused stuff from FSAL UP

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Make use of GPFSFSAL_UP_Thread

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove obsolete code from GPFSFSAL_UP_GetEvents

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
GPFS event INODE_LOCK_AGAIN should map to FSAL_UP_EVENT_LOCK_AVAIL

This bug has been around since this code was introduced...

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Fix up READDIR in pseudo fs so it handles NFS4ERR_WRONGSEC properly

Allow READDIR with just MOUNTED_ON_FILEID to succeed even if NFS4ERR_WRONGSEC.

Also clean up some out of memory handling for READDIR, don't bother trying
to recover, just LogFatal.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove unused data->mounted_on_FH

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add exportlist_t pointer to fsal_export_context_t

We fill it in after calling FSAL_BuildExportContext

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Use cache_inode_get instead of cache_inode_make_root and cache_inode_getattr

Use of cache_inode_make_root would result in extraneous LRU references
and the side effects are not necessary for pseudo fs operations.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Save cache entry pointer for each export root instead of using cache_inode_make_root

nfs_export_create_root_entry doesn't need the attributes
from cache_inode_get so we allow cache_inode_get to skip
returning attributes when they aren't asked for.

This will also, make nested exports, such as:

/ibm/fs0
/ibm/fs0/export1

Not mess things up. In the old code, export1 would have been turned into
a root cache inode, and a LOOKUPP from it would not go to fs0, even if
the client had mounted /ibm/fs0.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove cache_inode_make_root

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Fix MOUNTED_ON_FILEID, setting from export if entry is export root

Any cache inode routine that returns attributes must check
if the entry is root inode of current export, and if so,
grab the exp_mounted_on_fileid from that export. For
readdir, the actual cache inode entry attributes are changed
because a separate set of attributes are not available. This
will be ok since the attributes are immediatelyt consumed
during the readdir callback.

Since the current export is used, this will result in the
correct mounted_on_fileid when duplicate exports are again
supported.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Fix LOOKUPP to cross back over junctions into pseudo fs

LOOKUPP will check if the cache entry is the root of the
current export, and if so, will call
nfs4_op_lookupp_pseudo_by_exp to cross back into the pseudo
file system.

Note that the current export is used to determine which
pseudo fs entry is returned. This means that when duplicate
exports are supported again using different Pseudo paths for
each instance, LOOKUPP will return to the correct point in
the pseudo fs.

Note that this fix doesn't handle the case of junctions
inside an exported file system, but then LOOKUP doesn't handle
those either.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Don't check for write access for OPEN share deny write

AIX clients among others expect to OPEN access read/share deny write
when executing a file.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Fix a minor buffer issue in nfs4_ExportToPseudoFS

Signed-off-by: Frank Filz <ffilz@us.ibm.com>