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>
DELEGRETURN does not have an open/lock owner, don't call Copy_nfs4_state_req

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>
Hold state_lock in write for nfs4_return_one_state and state_lookup_layout_state

nfs4_return_one_state does a glist_length which requires the state lock,
since most callers hold the lock, change so all callers hold the lock.

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>
Fix various typos.

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fix CMakeLists and spec to install new scripts
ganesha_mgr.py and ganesha_mgr_utils.py

Signed-off-by: Allison Henderson <achender@vnet.linux.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fix systemd sysconfig files for nfs-ganesha

Choose appropriate files for init.d and systemd environments

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
Acked-by: Allison Henderson <achender@vnet.linux.ibm.com>
Acked-by: Malahal Naineni <malahal@us.ibm.com>
Fixed build issues related to lttng headers

Repored by: thomas.favre-bulle@bull.net

Signed-off-by: Venkateswararao Jujjuri (JV) <jvrao@linux.vnet.ibm.com>
V2.2-dev-20

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Manage pNFS Data Servers

* Parallels export manager.
* Moved DS handle creation to pDS ops vector (and *ds.c files).
* Added FSAL op for creation of subsequent pDS ops vectors.
* Added pDS op for creation of subsequent DS handle ops vectors.

+ FSAL_CEPH with minimal support, requires DS {} configuration.
+ FSAL_GPFS manages DS {} at same time as EXPORT {}.
+ FSAL_LUSTRE manages DS {} at same time as EXPORT {}.

- Merged static one time use functions in FSAL/commonlib.c
- Provided default pDS creation/destruction in FSAL/default_methods.c
  (unlike exports).
- Increase refcount size to 64 bits for DS handles, matching others.
- Related minor field/function renaming.

Bug fix: in PutFH, put before get, then comparing old id, could cause
use of dereferenced data.  Always get (inc) new before put (dec) old.

Bug fix: wrong macro list element in shutdown_pnfs_ds() --
motivating field rename.

Signed-off-by: William Allen Simpson <bill@cohortfs.com>