Improve performance for non existing files in populated directory (no need to get content write lock).
Fix return value for the case cache_inode_add_cached_dirent return CACHE_INODE_ENTRY_EXISTS.
Moved related client export params to worker data so it can be used by the nfs3/4 protocols to supports squashes.
(Base on porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

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.
(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Add ability in cache_inode_lock_trust_attrs to request write lock.
(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Fixed a bug in cache_inode_create_verify, ReadWrite lock might be unlock without locking it first.
Add cache_inode_check_setattr_perms
(porting from IBM 1.5.x (https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)
commit - 4b685aabb1516873fd38048c31d411f61534663d)

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.

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
New squash_setattr routine
This routine can be called by protocol operations to squash the owner
and owner_group attributes for SETATTR and CREATE type operations.

The routine accesses the current user credentials to determine
what has been squashed (uid, gid, and/or alt_groups).

Call squash_setattr for SETATTR and CREATE calls
(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Change permissions check in cache_inode_setattr to use new function cache_inode_check_setattr_perms

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove calls to cache_inode_truncate
(Setattr will take care of truncate)

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Removed cache_inode_truncate (No called from anywhere anymore).

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Added ATTR_ATIME_SERVER and ATTR_MTIME_SERVER to all fsals.
Setattr now supportted truncation.

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Removed calls to fsal truncate.
Ensure taking content lock when truncating a file.

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Remove support for truncate from all fsals.

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Added support in protocol level for ATTR_SERVER_MTIME and ATTR_SERVER_ATIME.
To do so, I extended fattr4_dent, to support expecption result with different attrmask.

(porting from IBM 1.5.x https://github.com/ffilz/nfs-ganesha/tree/S1041011-S1041052-setattr-perms)

Signed-off-by: Frank Filz <ffilz@us.ibm.com>
Fixed bugs in nfsV4 under release (actions with side effect were done inside assert code).

Signed-off-by: Amir Frankel <amirf@infinidat.com>