Fix function prototype for fsal_check_quota in header

Compile warnings fix.

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Cleanup and fixes to up call handlers

fix memeory leak

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Add BUILD_BUG_ON macro

Blatantly steal this macro from the kernel source. GPL to GPL
after all...

First use will be for build time validating of protocol handle
sizes.  This may move to a more top level place at some point
so others can use it too.

Add stddef.h so we get standard POSIX definitions

squash

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Add comments marking definitions that need to be fixed

Danger Will Robinson!  These structure defs are fragile
and need to be fixed at some point.  Comment them so we
can find them on a future refactor pass.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
New structure definitions for protocol file handles

Redefined what a file handle looks like on the wire.
There are two definitions, one for allocating space and the other
for handle processing.
* handle sizes for NFS3/4 are now variable size
* Handles have a ganesha specific version number for handle validation
* fsal_handle_desc is a new struct for referencing handles.  It has
  both a pointer and a size that can be validated.
* The FSAL_DIGEST_NOCHECK is used for bypassing handle validations
  when all we want is the FSAL's notion of how big the handle is.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Update handle transformation and validation functions

* More rigorous protocol handle validation.
* Update transforms between internal and protocol handles both for
  "real" handles and pseudo handles.
* DUILD_BUG_ON is used to compile time validate handle sizes.
* Handles are now passed around with fsal_handle_desc.

Other than now having a version number which makes the protocol more
robust, it also uses the descriptor so sizes can be validated all the
way down to the FSAL layer.  This is also the base for managing the
handle hash keys because we *know* exactly how big a handle really is
at all levels.

Signed-off-by: Jim Lieb <jlieb@panasas.com>

Update nfs_file_handle_mgmt.c xform

squash

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Cleanup HashTable functions

Missing lock release, restructure declarations

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Restructure hash table and cache inode

This is a major change to how the inode cache works.  Prior to this
change, it worked as follows:

Get/lookup:
* allocate space for a key (the handle bits)
* copy the key opaque bits (the whole opaque) into that space
* call a hash table function with that key
* free the key and continue on your way.

New entry:
* do a get as above.
* If missed, allocate space for a key and fill it as above
* allocate a cache entry and init it, including copying the handle
* call the FSAL with that handle to get info for the cache entry
* call the hash table function to insert it into the table
* free the space used for the "get"

On errors the code has to free the cache entry, the hash key for it, and
the key used for the get/lookup.

A free of a cache entry also must free the key from the hash table.

In the new way we have a pointer and length to the handle either in
the protocol payload or the cache entry :

Get/Lookup:
* Create a key by pointing directly to the handle opaque contents in the
  the protocol buffer.
* call the hash table function with that key.

There is nothing to free on either hit or miss.  The descriptor used to
compose the key is on the stack.

New entry:
* do a get as above
* If missed, allocate a cache entry, call the FSAL, and fill in the struct.
* copy the opaque handle part from the protocol buffer into the handle
  in the cache entry.
* fill in the handle descriptor in the cache entry to point to the handle in
  the cache entry.
* construct a key from the descriptor
* call the hash table function to insert the entry.

A free of  the cache entry (once removed from the hash) requires no free
of a key because the key is the handle element.

This change eliminates all memory allocations other than the cache entry
itself.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Remove cache_inode_fsaldata_2_key and cache_inode_release_fsaldata_key

These functions are redundant now that cache inode has been restructured
to use the handle in cache_entry as the key data.  A whole class of
memory alloc/free is gone with this change.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Fix bad assignment in cache_inode_get.

Bug creep from new handle changes.

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Update file content cache to new cache entry api

small changes to use new api

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Update protocol operation functions to new cache inode api

minor changes mostly to use the fsal_handle_desc for handle
processing.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Update misc functions that use the new cache inode and FSAL api

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Change FSAL handle digest api

Change to support fsal_handle_desc usage

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Fix strict compile for new handle

Numerous fixes to correct casts, constants, and function arguments.
Some are long standing, some on top of new handle changes.

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Additional state id support for new handles

Signed-off-by: Venkateswararao Jujjuri "<jvrao@linux.vnet.ibm.com>
Signed-off-by: Jim Lieb <jlieb@panasas.com>
Changes to pnfs common handle code to reflect new apis and structures

This will need further work with new api but these  changes keep it
in synch for now.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Update command line and shell tools to new cache inode api

Signed-off-by: Jim Lieb <jlieb@panasas.com>
Change VFS FSAL to handle new handle descriptor parameters

VFSFSAL_ExpandHandle:
	takes a handle descriptor instead of a handle pointer.  All it
	does it adjust the descriptor (fh_size) based on what the FSAL
	knows about the handle.  Copies/references done elsewhere.
	It validates the handle internals passed by the protocol.

VFSFSAL_DigestHandle:
	it can now do error checking/validation.  Use the descriptor
	to do the copy.  Update the descriptor to the actual copy length
	so that the upper layer can adjust the handle size in the
	metadata.

Signed-off-by: Jim Lieb <jlieb@panasas.com>
XFS FSAL - convert to the new way of dealing with file handles

Still using fixed size array to store the actual libhandle
data.

Signed-off-by: Max Matveev<makc@gmx.co.uk>
Signed-off-by: Jim Lieb <jlieb@panasas.com>