Skip to contentSkip to conversation

NFS: Send attributes in OPEN request for NFS4_CREATE_EXCLUSIVE4_1

PATCH Superseded Kinglong Mee 2 participants 3 messages Jul 28, 2015 – Jul 30, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/5 NFS: Send attributes in OPEN request for NFS4_CREATE_EXCLUSIVE4_1

Client sends a SETATTR request after OPEN for updating attributes. For create file with S_ISGID is set, the SETATTR will be not set S_ISGID as chmod of no PERMISSION.

---
 fs/nfs/nfs4proc.c | 2 +-
 fs/nfs/nfs4xdr.c  | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +1 -1
index 8bee934..801f5f4 100644
@@ -2413,7 +2413,7 @@ static int _nfs4_do_open(struct inode *dir,
 	state = ctx->state;
 
 	if ((opendata->o_arg.open_flags & O_EXCL) &&
-	    (opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) {
+	    (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE)) {
 		nfs4_exclusive_attrset(opendata, sattr);
 
 		nfs_fattr_init(opendata->o_res.f_attr);
fs/nfs/nfs4xdr.c +1 -3
index 558cd65d..b5147bc 100644
@@ -1382,7 +1382,6 @@ 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)
 {
-	struct iattr dummy;
 	__be32 *p;
 
 	p = reserve_space(xdr, 4);
@@ -1402,8 +1401,7 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
 	case NFS4_CREATE_EXCLUSIVE4_1:
 		*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
 		encode_nfs4_verifier(xdr, &arg->u.verifier);
-		dummy.ia_valid = 0;
-		encode_attrs(xdr, &dummy, arg->label, arg->server);
+		encode_attrs(xdr, arg->u.attrs, arg->label, arg->server);
 	}
 }
 
Signature · 1 line
2.4.3
#1 lore raw

Hi Kinglong,

Quoted 36 lines · Kinglong Mee

Client sends a SETATTR request after OPEN for updating attributes. For create file with S_ISGID is set, the SETATTR will be not set S_ISGID as chmod of no PERMISSION.

---
 fs/nfs/nfs4proc.c | 2 +-
 fs/nfs/nfs4xdr.c  | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +1 -1
index 8bee934..801f5f4 100644
@@ -2413,7 +2413,7 @@ static int _nfs4_do_open(struct inode *dir,
        state = ctx->state;
 
        if ((opendata->o_arg.open_flags & O_EXCL) &&
-           (opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) {
+           (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE)) {
                nfs4_exclusive_attrset(opendata, sattr);
 
                nfs_fattr_init(opendata->o_res.f_attr);
fs/nfs/nfs4xdr.c +0 -1
index 558cd65d..b5147bc 100644
@@ -1382,7 +1382,6 @@ 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)
 {
-       struct iattr dummy;
        __be32 *p;
 
        p = reserve_space(xdr, 4);

fs/nfs/nfs4xdr.c static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op · line 1407

Quoted 9 lines
fs/nfs/nfs4xdr.c +1 -2
@@ -1402,8 +1401,7 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
        case NFS4_CREATE_EXCLUSIVE4_1:
                *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
                encode_nfs4_verifier(xdr, &arg->u.verifier);
-               dummy.ia_valid = 0;
-               encode_attrs(xdr, &dummy, arg->label, arg->server);
+               encode_attrs(xdr, arg->u.attrs, arg->label, arg->server);
        }
 }
 

The problem here is that NFSv4.1 requires that the client use the "suppattr_exclcreat" attribute (see
https://tools.ietf.org/html/rfc5661#section-5.8.1.14 and
https://tools.ietf.org/html/rfc5661#section-18.16.3) in order to figure out which attributes it is permitted to send. If it sends anything which is not on the approved list, the server is supposed to fail the create attempt with NFS4ERR_INVAL...

Cheers
Trond

#2 lore raw
Quoted 49 lines · Trond Myklebust

Hi Kinglong,

Quoted 36 lines · Kinglong Mee

Client sends a SETATTR request after OPEN for updating attributes. For create file with S_ISGID is set, the SETATTR will be not set S_ISGID as chmod of no PERMISSION.

---
 fs/nfs/nfs4proc.c | 2 +-
 fs/nfs/nfs4xdr.c  | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +1 -1
index 8bee934..801f5f4 100644
@@ -2413,7 +2413,7 @@ static int _nfs4_do_open(struct inode *dir,
        state = ctx->state;
 
        if ((opendata->o_arg.open_flags & O_EXCL) &&
-           (opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) {
+           (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE)) {
                nfs4_exclusive_attrset(opendata, sattr);
 
                nfs_fattr_init(opendata->o_res.f_attr);
fs/nfs/nfs4xdr.c +0 -1
index 558cd65d..b5147bc 100644
@@ -1382,7 +1382,6 @@ 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)
 {
-       struct iattr dummy;
        __be32 *p;
 
        p = reserve_space(xdr, 4);

fs/nfs/nfs4xdr.c static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op · line 1407

Quoted 9 lines
fs/nfs/nfs4xdr.c +1 -2
@@ -1402,8 +1401,7 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op
        case NFS4_CREATE_EXCLUSIVE4_1:
                *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
                encode_nfs4_verifier(xdr, &arg->u.verifier);
-               dummy.ia_valid = 0;
-               encode_attrs(xdr, &dummy, arg->label, arg->server);
+               encode_attrs(xdr, arg->u.attrs, arg->label, arg->server);
        }
 }
 
Quoted 7 lines

The problem here is that NFSv4.1 requires that the client use the "suppattr_exclcreat" attribute (see
https://tools.ietf.org/html/rfc5661#section-5.8.1.14 and
https://tools.ietf.org/html/rfc5661#section-18.16.3) in order to figure out which attributes it is permitted to send. If it sends anything which is not on the approved list, the server is supposed to fail the create attempt with NFS4ERR_INVAL...

Sorry for my missing it.
I will try to implement it later.

thanks,
Kinglong Mee