Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSv4.2: Fix detection of "Proxying of Times" server support

According to draft-ietf-nfsv4-delstid-07:
If a server informs the client via the fattr4_open_arguments
attribute that it supports
OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS and it returns a valid
delegation stateid for an OPEN operation which sets the
OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS flag, then it MUST query the
client via a CB_GETATTR for the fattr4_time_deleg_access (see
Section 5.2) attribute and fattr4_time_deleg_modify attribute (see
Section 5.2).

Thus, we should look that the server supports proxying of times via
OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS.

We want to be extra pedantic and continue to check that FATTR4_TIME_DELEG_ACCESS
and FATTR4_TIME_DELEG_MODIFY are set. The server needs to expose both for the
client to correctly detect "Proxying of Times" support.

Signed-off-by: Roi Azarzar <roi.azarzar@vastdata.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Fixes: dcb3c20f7419 ("NFSv4: Add a capability for delegated attributes")
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>

authored by

Roi Azarzar and committed by
Anna Schumaker
615e693b af94dca7

+14 -2
+14 -2
fs/nfs/nfs4proc.c
··· 3904 3904 #define FATTR4_WORD2_NFS41_MASK (2*FATTR4_WORD2_SUPPATTR_EXCLCREAT - 1UL) 3905 3905 #define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_OPEN_ARGUMENTS - 1UL) 3906 3906 3907 + #define FATTR4_WORD2_NFS42_TIME_DELEG_MASK \ 3908 + (FATTR4_WORD2_TIME_DELEG_MODIFY|FATTR4_WORD2_TIME_DELEG_ACCESS) 3909 + static bool nfs4_server_delegtime_capable(struct nfs4_server_caps_res *res) 3910 + { 3911 + u32 share_access_want = res->open_caps.oa_share_access_want[0]; 3912 + u32 attr_bitmask = res->attr_bitmask[2]; 3913 + 3914 + return (share_access_want & NFS4_SHARE_WANT_DELEG_TIMESTAMPS) && 3915 + ((attr_bitmask & FATTR4_WORD2_NFS42_TIME_DELEG_MASK) == 3916 + FATTR4_WORD2_NFS42_TIME_DELEG_MASK); 3917 + } 3918 + 3907 3919 static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) 3908 3920 { 3909 3921 u32 minorversion = server->nfs_client->cl_minorversion; ··· 3994 3982 #endif 3995 3983 if (res.attr_bitmask[0] & FATTR4_WORD0_FS_LOCATIONS) 3996 3984 server->caps |= NFS_CAP_FS_LOCATIONS; 3997 - if (res.attr_bitmask[2] & FATTR4_WORD2_TIME_DELEG_MODIFY) 3998 - server->caps |= NFS_CAP_DELEGTIME; 3999 3985 if (!(res.attr_bitmask[0] & FATTR4_WORD0_FILEID)) 4000 3986 server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID; 4001 3987 if (!(res.attr_bitmask[1] & FATTR4_WORD1_MODE)) ··· 4021 4011 if (res.open_caps.oa_share_access_want[0] & 4022 4012 NFS4_SHARE_WANT_OPEN_XOR_DELEGATION) 4023 4013 server->caps |= NFS_CAP_OPEN_XOR; 4014 + if (nfs4_server_delegtime_capable(&res)) 4015 + server->caps |= NFS_CAP_DELEGTIME; 4024 4016 4025 4017 memcpy(server->cache_consistency_bitmask, res.attr_bitmask, sizeof(server->cache_consistency_bitmask)); 4026 4018 server->cache_consistency_bitmask[0] &= FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE;