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>
One more fix for PROXY for SET_TO_SERVER_TIME

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Don't make local copy of passed attr in GPFSFSAL_setattrs

A local copy was made so umask could be applied. This can be
applied as the mode is copied into the gpfsfsal_xstat_t
that is passed to fsal_set_xstat_by_handle.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Only get current attr in GPFSFSAL_setattrs when FSAL is at NIV_DEBUG

Also, if we fail to get the attributes, don't return the error, just
zero out the attributes (but log a message).

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Simplify test of needing to call fsal_set_xstat_by_handle for GPFS

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove setfsuid/setfsgid from GPFS setattrs path

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

Now that FSALs are prepared to take "set to server time", we
will use the new attribute flags for that to let the FSAL
handle setting to server time.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Stop calling FSAL_truncate from cache_inode_setattr

Now that FSALs are capable of handling truncate as part of
FSAL_setattrs, stop calling FSAL_truncate.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Check fattr4 that passed attr value has data for each attr

Also, at end, check that we have used up all the data.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Move export_perms_t from nfs_rpc_execute into nfs_worker_data__

This will make the export perms available to all NFS v2 and v3 and NLM operations.

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