Simple fix for NFS v4 CLOSE replay

If we get a NFS4ERR_BAD_STATEID as a result of looking up the stateid
in close, choose to interpret it as a replayed close (an original close
would have deleted the stateid, but this stateid is for a valid clientid
and is of the right epoch).

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Cleanup fsal_export_context_t before freeing exportlist_t

GPFS has a glist of exports for each file system to track
FSAL_UP threads. The list at least must be cleaned up if
an export is removed due to problems in setting it up.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Be verbose about what is happening to core limit

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Make sure HashTable doesn't get a bad index

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add configure.ac conditional for valgrind memcheck

Some FSALs and other parts of the code may need workarounds for
valgrind memcheck to initialize data.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Initialize some GPFS data for valgrind memcheck

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Save cache entry pointer before calling state_del

We need the cache entry pointer from the state after we
remove and free it so we can release the cache inode reference.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Initialize handle in GPFSFSAL_UP_Thread for valgrind

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Properly copy NFS v4 conflicting lock owner

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

These new FSAL attribute flags will allow passing of
SET_TO_SERVER_TIME into FSAL.

Later patches will implement this functionality.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add cache_inode_check_setattr_perms and need_wr_lock to cache_inode_lock_trust_attrs

Add a new permission checking routine in cache inode to validate permissions for
setattr.

cache_inode_check_setattr_perms will examine the attributes being set, and determine
what permission checks will need to be made by the FSAL. Since this is a complex
routine, and root is always allowed to set attr, the first check made is to exit
quickly if root (squashing has already been taken care of).

First, there is a general rule on owner and owner_group, a user can only set the
owner to himself, and owner_group to a group he is a member of.

owner and owner_group are may only be changed by the owner of the file, or a user
that has been granted WRITE_OWNER permission by ACL. Root/admin granting WRITE_OWNER
permission in an ACE for a specific user is used to implement "Take Owner" permission.
By using this, the admin grants a specific user the right to change the owner and
owner_group to himself (due to the general rule above).

mode and ACL may only be changed by the owner of a file, or a user granted WRITE_ACL
permission by an ACE.

size may be changed by anyone who has write permission to the file.

atime and mtime may be set to "now" by anyone who has write permission. Setting to
a specific time is only allowed for the owner of the file, or a user granted
WRITE_ATTR permissission in an ACL.

New setattr will require getting attr lock for write and we need to check trust
of attrs, so add ability in cache_inode_lock_trust_attrs to request write lock.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add is_open_write parm to cache_inode_setattr

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Make cache_inode_setattr call FSAL_truncate the same as cache_inode_truncate

There were some differences in how FSAL_truncate was called, make them go away.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Don't call cache_inode_truncate

cache_inode_setattr already handles truncate.

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

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Check permissions in cache_inode_setattr

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Strip permission checking from FSAL_setattrs (LUSTRE, POSIX, VFS, XFS, GPFS)

Permission checking will be done up in cache_inode_setattr

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Merge FSAL_truncate into FSAL_setattrs (LUSTRE, POSIX, VFS, XFS, GPFS)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Enable FSAL_PROXY to pass SET_TO_SERVER_TIME4 along in FSAL_setattrs

Since FSAL_PROXY just builds a v4 SETATTRS call from the FSAL attributes,
enabling FSAL_PROXY to pass SET_TO_SERVER_TIME4 to the proxied server is
no more that enhancing conversion of FSAL attrs to NFS4 attrs.

FSAL_PROXY appears to already be able to handle size change (truncate)
within FSAL_setattrs.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Allow passing SET_TO_SERVER_TIME to file system (LUSTRE, POSIX, VFS, XFS, GPFS)

VFS and XFS have a file descriptor, so are able to use utimesn which
provides nanosecond granularity and allows setting one or both of
atime and mtime to either a specified value or to current time. This
allows a "perfect" match with the SETATTR requests.

For LUSTRE and POSIX, we must use utimes which provides only microsecond
granularity and must set both times (though it can set both times to
current time). If only one time is set to server time, then we use
gettimeofday to set it. If one of the times is not set, then it
is "re-set" using the recently fetched attributes. This clearly is
not ideal, but is the best we can do.

GPFS OPENHANDLE_SET_XSTAT is able to handle all the intricacies of
SETATTR. Minor bug fix though, we were not originally setting
nseconds for atime and mtime...

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