Commit 4882ef72 authored by Alexandros Batsakis's avatar Alexandros Batsakis Committed by Trond Myklebust

nfs41: add support for the exclusive create flags

In v4.1 the client MUST/SHOULD use the EXCLUSIVE4_1 flag instead of
EXCLUSIVE4, and GUARDED when the server supports persistent sessions.
For now (and until we support suppattr_exclcreat), we don't send any
attributes with EXCLUSIVE4_1 relying in the subsequent SETATTR as in v4.0
Signed-off-by: default avatarAlexandros Batsakis <batsakis@netapp.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent d8cb1a7c
...@@ -726,9 +726,15 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, ...@@ -726,9 +726,15 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,
p->o_arg.bitmask = server->attr_bitmask; p->o_arg.bitmask = server->attr_bitmask;
p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; p->o_arg.claim = NFS4_OPEN_CLAIM_NULL;
if (flags & O_EXCL) { if (flags & O_EXCL) {
u32 *s = (u32 *) p->o_arg.u.verifier.data; if (nfs4_has_persistent_session(server->nfs_client)) {
s[0] = jiffies; /* GUARDED */
s[1] = current->pid; p->o_arg.u.attrs = &p->attrs;
memcpy(&p->attrs, attrs, sizeof(p->attrs));
} else { /* EXCLUSIVE4_1 */
u32 *s = (u32 *) p->o_arg.u.verifier.data;
s[0] = jiffies;
s[1] = current->pid;
}
} else if (flags & O_CREAT) { } else if (flags & O_CREAT) {
p->o_arg.u.attrs = &p->attrs; p->o_arg.u.attrs = &p->attrs;
memcpy(&p->attrs, attrs, sizeof(p->attrs)); memcpy(&p->attrs, attrs, sizeof(p->attrs));
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <linux/nfs_fs.h> #include <linux/nfs_fs.h>
#include <linux/nfs_idmap.h> #include <linux/nfs_idmap.h>
#include "nfs4_fs.h" #include "nfs4_fs.h"
#include "internal.h"
#define NFSDBG_FACILITY NFSDBG_XDR #define NFSDBG_FACILITY NFSDBG_XDR
...@@ -134,7 +135,7 @@ static int nfs4_stat_to_errno(int); ...@@ -134,7 +135,7 @@ static int nfs4_stat_to_errno(int);
#define decode_lookup_maxsz (op_decode_hdr_maxsz) #define decode_lookup_maxsz (op_decode_hdr_maxsz)
#define encode_share_access_maxsz \ #define encode_share_access_maxsz \
(2) (2)
#define encode_createmode_maxsz (1 + encode_attrs_maxsz) #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz)
#define encode_opentype_maxsz (1 + encode_createmode_maxsz) #define encode_opentype_maxsz (1 + encode_createmode_maxsz)
#define encode_claim_null_maxsz (1 + nfs4_name_maxsz) #define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
#define encode_open_maxsz (op_encode_hdr_maxsz + \ #define encode_open_maxsz (op_encode_hdr_maxsz + \
...@@ -1140,6 +1141,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena ...@@ -1140,6 +1141,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
{ {
__be32 *p; __be32 *p;
struct nfs_client *clp;
p = reserve_space(xdr, 4); p = reserve_space(xdr, 4);
switch(arg->open_flags & O_EXCL) { switch(arg->open_flags & O_EXCL) {
...@@ -1148,8 +1150,23 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op ...@@ -1148,8 +1150,23 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
encode_attrs(xdr, arg->u.attrs, arg->server); encode_attrs(xdr, arg->u.attrs, arg->server);
break; break;
default: default:
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); clp = arg->server->nfs_client;
encode_nfs4_verifier(xdr, &arg->u.verifier); if (clp->cl_minorversion > 0) {
if (nfs4_has_persistent_session(clp)) {
*p = cpu_to_be32(NFS4_CREATE_GUARDED);
encode_attrs(xdr, arg->u.attrs, arg->server);
} else {
struct iattr dummy;
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
encode_nfs4_verifier(xdr, &arg->u.verifier);
dummy.ia_valid = 0;
encode_attrs(xdr, &dummy, arg->server);
}
} else {
*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
encode_nfs4_verifier(xdr, &arg->u.verifier);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment