@@ -128,26 +128,6 @@ is_create_with_attrs(struct nfsd4_open *open)
128128 || open -> op_createmode == NFS4_CREATE_EXCLUSIVE4_1 );
129129}
130130
131- /*
132- * if error occurs when setting the acl, just clear the acl bit
133- * in the returned attr bitmap.
134- */
135- static void
136- do_set_nfs4_acl (struct svc_rqst * rqstp , struct svc_fh * fhp ,
137- struct nfs4_acl * acl , u32 * bmval )
138- {
139- __be32 status ;
140-
141- status = nfsd4_set_nfs4_acl (rqstp , fhp , acl );
142- if (status )
143- /*
144- * We should probably fail the whole open at this point,
145- * but we've already created the file, so it's too late;
146- * So this seems the least of evils:
147- */
148- bmval [0 ] &= ~FATTR4_WORD0_ACL ;
149- }
150-
151131static inline void
152132fh_dup2 (struct svc_fh * dst , struct svc_fh * src )
153133{
@@ -281,6 +261,9 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
281261 if (host_err )
282262 return nfserrno (host_err );
283263
264+ if (is_create_with_attrs (open ))
265+ nfsd4_acl_to_attr (NF4REG , open -> op_acl , & attrs );
266+
284267 fh_lock_nested (fhp , I_MUTEX_PARENT );
285268
286269 child = lookup_one_len (open -> op_fname , parent , open -> op_fnamelen );
@@ -382,8 +365,11 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
382365
383366 if (attrs .na_labelerr )
384367 open -> op_bmval [2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;
368+ if (attrs .na_aclerr )
369+ open -> op_bmval [0 ] &= ~FATTR4_WORD0_ACL ;
385370out :
386371 fh_unlock (fhp );
372+ nfsd_attrs_free (& attrs );
387373 if (child && !IS_ERR (child ))
388374 dput (child );
389375 fh_drop_write (fhp );
@@ -446,9 +432,6 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru
446432 if (status )
447433 goto out ;
448434
449- if (is_create_with_attrs (open ) && open -> op_acl != NULL )
450- do_set_nfs4_acl (rqstp , * resfh , open -> op_acl , open -> op_bmval );
451-
452435 nfsd4_set_open_owner_reply_cache (cstate , open , * resfh );
453436 accmode = NFSD_MAY_NOP ;
454437 if (open -> op_created ||
@@ -779,6 +762,7 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
779762 if (status )
780763 return status ;
781764
765+ status = nfsd4_acl_to_attr (create -> cr_type , create -> cr_acl , & attrs );
782766 current -> fs -> umask = create -> cr_umask ;
783767 switch (create -> cr_type ) {
784768 case NF4LNK :
@@ -837,10 +821,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
837821
838822 if (attrs .na_labelerr )
839823 create -> cr_bmval [2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;
840-
841- if (create -> cr_acl != NULL )
842- do_set_nfs4_acl (rqstp , & resfh , create -> cr_acl ,
843- create -> cr_bmval );
824+ if (attrs .na_aclerr )
825+ create -> cr_bmval [0 ] &= ~FATTR4_WORD0_ACL ;
844826
845827 fh_unlock (& cstate -> current_fh );
846828 set_change_info (& create -> cr_cinfo , & cstate -> current_fh );
@@ -849,6 +831,7 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
849831 fh_put (& resfh );
850832out_umask :
851833 current -> fs -> umask = 0 ;
834+ nfsd_attrs_free (& attrs );
852835 return status ;
853836}
854837
@@ -1123,6 +1106,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11231106 .na_iattr = & setattr -> sa_iattr ,
11241107 .na_seclabel = & setattr -> sa_label ,
11251108 };
1109+ struct inode * inode ;
11261110 __be32 status = nfs_ok ;
11271111 int err ;
11281112
@@ -1145,16 +1129,18 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11451129 if (status )
11461130 goto out ;
11471131
1148- if (setattr -> sa_acl != NULL )
1149- status = nfsd4_set_nfs4_acl (rqstp , & cstate -> current_fh ,
1150- setattr -> sa_acl );
1132+ inode = cstate -> current_fh .fh_dentry -> d_inode ;
1133+ status = nfsd4_acl_to_attr (S_ISDIR (inode -> i_mode ) ? NF4DIR : NF4REG ,
1134+ setattr -> sa_acl , & attrs );
1135+
11511136 if (status )
11521137 goto out ;
11531138 status = nfsd_setattr (rqstp , & cstate -> current_fh , & attrs ,
11541139 0 , (time64_t )0 );
11551140 if (!status )
11561141 status = nfserrno (attrs .na_labelerr );
11571142out :
1143+ nfsd_attrs_free (& attrs );
11581144 fh_drop_write (& cstate -> current_fh );
11591145 return status ;
11601146}
0 commit comments