Reorganize fsal_api.h

!  minor version not incremented per Frank.  He will update.

* Divide pNFS DS (servers) from DS handles (files/objects).
+ allows more than one handle per server.
+ allows more than one server per export.
+ disentangle vectors from export (for ds-only).

* structures follow function (operations) definitions.
+ vectors now have prefixes (m_ops, exp_ops, obj_ops).
+ vectors now included in structure allocations:
++ removing unnecessary alloc & frees.
++ speeding every operation call (by one pointer).
++ reducing register pressure (fewer pointers).

Build against Lustre 2.6, on Centos 6.5.

Signed-off-by: William Allen Simpson <bill@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Fix ZFS build with ZFS_PREFIX.

The full invocation is to update CMAKE_C_FLAGS with the prefix
values, in FSAL/FSAL_ZFS/CMakeLists.txt.

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Configure pNFS Data Servers

Signed-off-by: William Allen Simpson <bill@cohortfs.com>
Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Replace FSAL_ESTALE, KILLED, DEAD_ENTRY, CACHE_INODE STATE errors with ESTALE

These three errors all mean the same thing, so just use CACHE_INODE_ESTALE
and STATE_ESTALE.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Signed-off-by: Matt Benjamin <matt@cohortfs.com>

Conflicts:
	src/include/cache_inode.h
	src/include/sal_data.h
Cosmetic. s/ganesha_<foo>.h/gsh_<foo>.h/.

Also ganesha_lttng.  Per Frank, only one of these two forms
should be used.  Take the shorter one.

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
Non-Trivial Merge remote-tracking branch 'linuxbox2/ds-only-ff-mb' into next

Fixed compile issue in FSAL/FSAL_GLUSTER/gluster_internal.c.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Merge remote-tracking branch 'ganltc/for-dev-19' into next

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

Checkpatch run on patches can't catch some issues, so every once in a while,
we use src/scripts/runcp.sh to checkpatch.pl on the entire tree.

This patch fixes the errors that have accumulated.

A new complex macro has been introduced, requiring a new file to have
complex macro warnings ignored.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
V2.2-dev-19

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add Open File Description Locks to multilock tool

Open File Description (OFD) locks are new in Linx kernel 3.15. They are specific
to open file descriptions, which for the ml_posix_client, amount to being
specific to a specific file descriptor. This means that the OFD locks from
two different open file descriptors will conflict.

The primary purpose of adding these to the multilock tool is to be able to
experiment with the new locks, however, it becomes interesting when these
locks are used from a Linux client. They SHOULD result in a single open
owner with multiple lock owners.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Multilock: Make sure STATUS_ERRNO always provides an errno value

Also make sure the errno is saved before calling sprintf...

Also, normalize all uses of STATUS_ERRNO with a hard coded errno to also
be prior to any sprintf (makes for more consistent code).

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Make ml_posix_client multithreaded to handle blocking locks

Instead of a blocking lock blocking the whole multilock tool, it now
is multi-threaded. There is a limited number of worker threads, and one
polling thread. The main thread will never invoke a blocking lock, it will
just poll once for the lock and then if not available, defer to the
worker threads. A single polling thread handles the overflow if more blocked
locks are in progress than the numeber of worker threads available.

This code is actually the model for how Ganesha will handle blocking locks
with the new Open File Description locks for FSAL_VFS (though actually it
probably would also work for POSIX locks also).

This allows for any number of blocking locks per file descriptor.

Blocking locks may be cancelled by an UNLOCK request that covers at least the
entire range of the blocked lock (thus UNLOCK fno 0 0 will cancel all blocked
locks on the file descriptor).

Here is a little sample execution:

open 1 rw create OFD foo
1 OPEN OK 1 3
open 2 rw OFD foo
2 OPEN OK 2 4
open 3 rw OFD foo
3 OPEN OK 3 5
open 4 rw OFD foo
4 OPEN OK 4 6
open 5 rw OFD foo
5 OPEN OK 5 7
open 6 rw OFD foo
6 OPEN OK 6 8
lock 1 write 0 0
7 LOCK GRANTED 1 write 0 0
lockw 2 read 0 0
lockw 3 read 0 0
lockw 4 write 0 0
lockw 5 write 0 0
lockw 6 read 0 0
lockw 6 read 0 0
unlock 1 0 0
14 UNLOCK GRANTED 1 unlock 0 0
8 LOCKW GRANTED 2 read 0 0
13 LOCKW GRANTED 6 read 0 0
9 LOCKW GRANTED 3 read 0 0
unlock 4 0 0
10 LOCKW CANCELED 4 write 0 0
15 UNLOCK GRANTED 4 unlock 0 0
unlock 3 0 0
16 UNLOCK GRANTED 3 unlock 0 0
unlock 2 0 0
17 UNLOCK GRANTED 2 unlock 0 0
unlock 6 0 0
18 UNLOCK GRANTED 6 unlock 0 0
11 LOCKW GRANTED 5 write 0 0
unlock 5 0 0
19 UNLOCK GRANTED 5 unlock 0 0

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Remove some extraneous glist_init

glist_init is to be called on glist_heads that are the actual head of the
list. An empty list is specified by {&head, &head}.

The glist_heads that link items into the list are set to {NULL, NULL} to'
indicate they are not in any list.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Replace FALSE with false and TRUE with true

FALSE and TRUE are ONLY used in XDR, otherwise we should stick with the
standard true and false constants.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Make cache_inode_put a static inline function

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Change name of list of states in cache_entry_t for simpler cscope examination

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Make fsal in cache_inode_key_t void * to assure it's not dereferenced

the struct fsal_module pointer is just used as an element of the key and
should not be dereferenced since a key does not hold an fsal module reference
and thus the pointer is not guaranteed to be valid.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
All NFS v4.0 ops that use an open/lock owner should check owner seqid the same

These ops all require the client to change the owner seqid, but also result
in a stateid seqid change. In order for the replay logic to work, we must
identify a potential replay based on the stateid seqid changing, and then
check the owner seqid for replay.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Use nfs4_sanity_check_FH for nfsa4_op_delegreturn

For correctness to RFC, replace NFS4ERR_ISDIR with NFS4ERR_INVAL.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Reorganize state_t and remove some typedefs

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Acked-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>