Reject state for file when owner has state on file via another export

To maintain locks and share reservations beloning to an export,
we assure that a given state owner may only have a locks or an
open on a given file under one export. If he uses a handle from
a different export to acquire state, it will be rejected
with EINVAL.

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Reject lock if owner already has locks via another export

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Added UPCALLS interface by default to GPFS_FSAL.
Added a function during BuildExportEntry() to support FSAL specific checks.
Pass reference to writeverf to DS_write and DS_commit

This makes it a char ** rather than a char *, so make sure to
dereference writeverf in the fsal_ds.c if passing it as an argument to
memcpy or similar.
Quick alignment fix and read/write/commit merge

This patch contains two fixes because the first requires the second.

Marc Eshel pointed out that memory allocated with posix_memalign was
being freed (unsuccessfully) with Mem_Free.  This is a quick fix to
add Mem_Alloc_Page_Aligned and Free_Page_Aligned calls for use in
read.  This is not a long-term solution, but solves the memory leak
and errors until more work on memory allocation can be done.

However, the NFSv4 READ request can be serviced by either nfs4_op_read
or nfs41_op_read, it can only be freed by nfs4_op_read_Free.
Therefore this patch also merges nfs41_op_read with nfs4_op_read,
nfs41_op_write with nfs4_op_write, and nfs41_op_commit with
nfs4_op_commit.  These functions have more similarity than difference
and should be merged anyway, regardless of memory alignment.
pNFS Refactor

Move pNFS functionality back for common use.  Clean up configure,
automake, and conditional compile options.  Within the C code there are three defines:

 _PNFS: Some pNFS functionality has been enabled, for common code.
 _PNFS_MDS: Metadata server functionality has been enabled
 _PNFS_DS: Data server functionality has been enabled

And three corresponding automake variables

 USE_PNFS, USE_PNFS_MDS, and USE_PNFS_DS

In order to let the Shell compile cleanly without pulling in the
entire NFS daemon, pNFS functionality has been split out from other
FSAL functionality.  Be sure to set FSALPNFS_LIB for your FSAL to get
it to link in.

Not yet done:

  The PARALLELL_FS code has not been refactored to work with the rest
  of the pNFS system.

  The configuration options to disable or enable pNFS support on a
  per-export basis need to be looked at.

  This probably does not work with a shared FSAL.  I was going to wait
  until after Jim Lieb's refactor branch hit mainline to address that.
Quota management : now available for NFSv4.x as well
Fix compiler warnings in latest upstream next branch

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

Conflicts:

	src/SAL/nfs4_lease.c
	src/include/sal_functions.h

Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
Clean up from rebase and connectathon changes
Fix pnfs_segment_contains

Fix bug reported by Marc Eshel.  This function should return true for
any sub-segment, even an improper one.
Fix Ceph cookie problem pointed out by Philippe
Merge branch 'master' into next
Merge branch 'master' into next
Use cache_inode_lookupp_sw in nfs_Readdir to avoid deadlock
Thomas's framework for test has been added to the repository
XFS FSAL - symlink support

XFS' libhandle only allows open_by_handle on regular files and
directories, anything else gets EPERM.

In order to be able to support symlinks on XFS FSAL we need to:

1. Detect a symlink during lookup - this is easy: just use openat(2)
   with O_NOFOLLOW flag and if you get ELOOP then assume it's a symlink.
   If this happens then fake symlink handle using hand-rolled
   fsal_internal_inum2handle and hope that it matches the handle
   generated by libhandle. Use attributes from fstatat to fill in the
   object attributes on the wire.

2. If you get a file handle which refers to a symlink in getattr then
   use XFS bulk inode stat interface to get information about the
   symlink itself.

   Note that xfs_bstat_t does not have the equivalent of st_dev - to
   work around this issue save the device id when building export context
   and use that to feed the attributes.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
XFS FSAL - don't leak open files when parsing export list

Signed-off-by: Max Matveev <makc@gmx.co.uk>
XFS FSAL - symlink support

XFS' libhandle only allows open_by_handle on regular files and
directories, anything else gets EPERM.

In order to be able to support symlinks on XFS FSAL we need to:

1. Detect a symlink during lookup - this is easy: just use openat(2)
   with O_NOFOLLOW flag and if you get ELOOP then assume it's a symlink.
   If this happens then fake symlink handle using hand-rolled
   fsal_internal_inum2handle and hope that it matches the handle
   generated by libhandle. Use attributes from fstatat to fill in the
   object attributes on the wire.

2. If you get a file handle which refers to a symlink in getattr then
   use XFS bulk inode stat interface to get information about the
   symlink itself.

   Note that xfs_bstat_t does not have the equivalent of st_dev - to
   work around this issue save the device id when building export context
   and use that to feed the attributes.

Signed-off-by: Max Matveev <makc@gmx.co.uk>
XFS FSAL - don't leak open files when parsing export list

Signed-off-by: Max Matveev <makc@gmx.co.uk>
XFS FSAL - deal with non-regular files

Symlinks are not the only filesystem objects which cannot be
opened using libhandle's open_by_handle interface: sockets
fifos, block and character device are in the same boat. In
order to deal with them switch from "open first, stat second"
to "stat first and only open what can be opened" mode.

And use real types when constructing file handles.
Regular files and directories are left with DT_UNKNOWN
to preserve on-the-wire format of the file handles.

Signed-off-by: Max Matveev <makc@gmx.co.uk>