diff options
author | Weston Andros Adamson <dros@netapp.com> | 2013-08-13 16:37:37 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-09-05 10:50:45 -0400 |
commit | 8c21c62c4452f4e66c3dac9b3f6b74474fad3e08 (patch) | |
tree | c7c5b3edd7dfa21604336c3820e6b859d3cf0fa6 /fs/nfs/nfs4_fs.h | |
parent | 3787d5063c52b0c38003e6293f24839508604070 (diff) |
nfs4.1: Add SP4_MACH_CRED write and commit support
WRITE and COMMIT can use the machine credential.
If WRITE is supported and COMMIT is not, make all (mach cred) writes FILE_SYNC4.
Signed-off-by: Weston Andros Adamson <dros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4_fs.h')
-rw-r--r-- | fs/nfs/nfs4_fs.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 3559e899666e..d2db3ce07d3a 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -269,15 +269,9 @@ is_ds_client(struct nfs_client *clp) | |||
269 | return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS; | 269 | return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS; |
270 | } | 270 | } |
271 | 271 | ||
272 | /* | 272 | static inline bool |
273 | * Function responsible for determining if an rpc_message should use the | 273 | _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, |
274 | * machine cred under SP4_MACH_CRED and if so switching the credential and | 274 | struct rpc_clnt **clntp, struct rpc_message *msg) |
275 | * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p). | ||
276 | * Should be called before rpc_call_sync/rpc_call_async. | ||
277 | */ | ||
278 | static inline void | ||
279 | nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, | ||
280 | struct rpc_clnt **clntp, struct rpc_message *msg) | ||
281 | { | 275 | { |
282 | struct rpc_cred *newcred = NULL; | 276 | struct rpc_cred *newcred = NULL; |
283 | rpc_authflavor_t flavor; | 277 | rpc_authflavor_t flavor; |
@@ -295,7 +289,37 @@ nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, | |||
295 | WARN_ON(flavor != RPC_AUTH_GSS_KRB5I && | 289 | WARN_ON(flavor != RPC_AUTH_GSS_KRB5I && |
296 | flavor != RPC_AUTH_GSS_KRB5P); | 290 | flavor != RPC_AUTH_GSS_KRB5P); |
297 | *clntp = clp->cl_rpcclient; | 291 | *clntp = clp->cl_rpcclient; |
292 | |||
293 | return true; | ||
298 | } | 294 | } |
295 | return false; | ||
296 | } | ||
297 | |||
298 | /* | ||
299 | * Function responsible for determining if an rpc_message should use the | ||
300 | * machine cred under SP4_MACH_CRED and if so switching the credential and | ||
301 | * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p). | ||
302 | * Should be called before rpc_call_sync/rpc_call_async. | ||
303 | */ | ||
304 | static inline void | ||
305 | nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, | ||
306 | struct rpc_clnt **clntp, struct rpc_message *msg) | ||
307 | { | ||
308 | _nfs4_state_protect(clp, sp4_mode, clntp, msg); | ||
309 | } | ||
310 | |||
311 | /* | ||
312 | * Special wrapper to nfs4_state_protect for write. | ||
313 | * If WRITE can use machine cred but COMMIT cannot, make sure all writes | ||
314 | * that use machine cred use NFS_FILE_SYNC. | ||
315 | */ | ||
316 | static inline void | ||
317 | nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, | ||
318 | struct rpc_message *msg, struct nfs_write_data *wdata) | ||
319 | { | ||
320 | if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) && | ||
321 | !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags)) | ||
322 | wdata->args.stable = NFS_FILE_SYNC; | ||
299 | } | 323 | } |
300 | #else /* CONFIG_NFS_v4_1 */ | 324 | #else /* CONFIG_NFS_v4_1 */ |
301 | static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server) | 325 | static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server) |
@@ -320,6 +344,12 @@ nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags, | |||
320 | struct rpc_clnt **clntp, struct rpc_message *msg) | 344 | struct rpc_clnt **clntp, struct rpc_message *msg) |
321 | { | 345 | { |
322 | } | 346 | } |
347 | |||
348 | static inline void | ||
349 | nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, | ||
350 | struct rpc_message *msg, struct nfs_write_data *wdata) | ||
351 | { | ||
352 | } | ||
323 | #endif /* CONFIG_NFS_V4_1 */ | 353 | #endif /* CONFIG_NFS_V4_1 */ |
324 | 354 | ||
325 | extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[]; | 355 | extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[]; |
@@ -455,6 +485,8 @@ static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state) | |||
455 | 485 | ||
456 | #define nfs4_close_state(a, b) do { } while (0) | 486 | #define nfs4_close_state(a, b) do { } while (0) |
457 | #define nfs4_close_sync(a, b) do { } while (0) | 487 | #define nfs4_close_sync(a, b) do { } while (0) |
488 | #define nfs4_state_protect(a, b, c, d) do { } while (0) | ||
489 | #define nfs4_state_protect_write(a, b, c, d) do { } while (0) | ||
458 | 490 | ||
459 | #endif /* CONFIG_NFS_V4 */ | 491 | #endif /* CONFIG_NFS_V4 */ |
460 | #endif /* __LINUX_FS_NFS_NFS4_FS.H */ | 492 | #endif /* __LINUX_FS_NFS_NFS4_FS.H */ |