diff options
author | Alexandros Batsakis <batsakis@netapp.com> | 2009-12-05 13:30:21 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-12-05 13:30:21 -0500 |
commit | 4882ef72cd9a5c006087ca94a228323018eac29f (patch) | |
tree | 4dba8abfbde3ca48b0012bf8d9abe8ec4260b061 /fs | |
parent | d8cb1a7ce36d44602946f06af4267da304fb4011 (diff) |
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: Alexandros Batsakis <batsakis@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs4proc.c | 12 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 23 |
2 files changed, 29 insertions, 6 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 637a6b476bd6..e07f6c7f5b97 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -726,9 +726,15 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, | |||
726 | p->o_arg.bitmask = server->attr_bitmask; | 726 | p->o_arg.bitmask = server->attr_bitmask; |
727 | p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; | 727 | p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; |
728 | if (flags & O_EXCL) { | 728 | if (flags & O_EXCL) { |
729 | u32 *s = (u32 *) p->o_arg.u.verifier.data; | 729 | if (nfs4_has_persistent_session(server->nfs_client)) { |
730 | s[0] = jiffies; | 730 | /* GUARDED */ |
731 | s[1] = current->pid; | 731 | p->o_arg.u.attrs = &p->attrs; |
732 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); | ||
733 | } else { /* EXCLUSIVE4_1 */ | ||
734 | u32 *s = (u32 *) p->o_arg.u.verifier.data; | ||
735 | s[0] = jiffies; | ||
736 | s[1] = current->pid; | ||
737 | } | ||
732 | } else if (flags & O_CREAT) { | 738 | } else if (flags & O_CREAT) { |
733 | p->o_arg.u.attrs = &p->attrs; | 739 | p->o_arg.u.attrs = &p->attrs; |
734 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); | 740 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 3a71b40a990a..0b1f3fcdd28a 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/nfs_fs.h> | 51 | #include <linux/nfs_fs.h> |
52 | #include <linux/nfs_idmap.h> | 52 | #include <linux/nfs_idmap.h> |
53 | #include "nfs4_fs.h" | 53 | #include "nfs4_fs.h" |
54 | #include "internal.h" | ||
54 | 55 | ||
55 | #define NFSDBG_FACILITY NFSDBG_XDR | 56 | #define NFSDBG_FACILITY NFSDBG_XDR |
56 | 57 | ||
@@ -134,7 +135,7 @@ static int nfs4_stat_to_errno(int); | |||
134 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) | 135 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
135 | #define encode_share_access_maxsz \ | 136 | #define encode_share_access_maxsz \ |
136 | (2) | 137 | (2) |
137 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz) | 138 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
138 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) | 139 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
139 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) | 140 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
140 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ | 141 | #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 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 1141 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
1141 | { | 1142 | { |
1142 | __be32 *p; | 1143 | __be32 *p; |
1144 | struct nfs_client *clp; | ||
1143 | 1145 | ||
1144 | p = reserve_space(xdr, 4); | 1146 | p = reserve_space(xdr, 4); |
1145 | switch(arg->open_flags & O_EXCL) { | 1147 | switch(arg->open_flags & O_EXCL) { |
@@ -1148,8 +1150,23 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op | |||
1148 | encode_attrs(xdr, arg->u.attrs, arg->server); | 1150 | encode_attrs(xdr, arg->u.attrs, arg->server); |
1149 | break; | 1151 | break; |
1150 | default: | 1152 | default: |
1151 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | 1153 | clp = arg->server->nfs_client; |
1152 | encode_nfs4_verifier(xdr, &arg->u.verifier); | 1154 | if (clp->cl_minorversion > 0) { |
1155 | if (nfs4_has_persistent_session(clp)) { | ||
1156 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); | ||
1157 | encode_attrs(xdr, arg->u.attrs, arg->server); | ||
1158 | } else { | ||
1159 | struct iattr dummy; | ||
1160 | |||
1161 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); | ||
1162 | encode_nfs4_verifier(xdr, &arg->u.verifier); | ||
1163 | dummy.ia_valid = 0; | ||
1164 | encode_attrs(xdr, &dummy, arg->server); | ||
1165 | } | ||
1166 | } else { | ||
1167 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | ||
1168 | encode_nfs4_verifier(xdr, &arg->u.verifier); | ||
1169 | } | ||
1153 | } | 1170 | } |
1154 | } | 1171 | } |
1155 | 1172 | ||