@@ -97,8 +97,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
9797 struct nfs_fattr * fattr , struct inode * inode );
9898static int nfs4_do_setattr (struct inode * inode , const struct cred * cred ,
9999 struct nfs_fattr * fattr , struct iattr * sattr ,
100- struct nfs_open_context * ctx , struct nfs4_label * ilabel ,
101- struct nfs4_label * olabel );
100+ struct nfs_open_context * ctx , struct nfs4_label * ilabel );
102101#ifdef CONFIG_NFS_V4_1
103102static struct rpc_task * _nfs41_proc_sequence (struct nfs_client * clp ,
104103 const struct cred * cred ,
@@ -3176,7 +3175,7 @@ static int _nfs4_do_open(struct inode *dir,
31763175 nfs_fattr_init (opendata -> o_res .f_attr );
31773176 status = nfs4_do_setattr (state -> inode , cred ,
31783177 opendata -> o_res .f_attr , sattr ,
3179- ctx , label , opendata -> o_res . f_attr -> label );
3178+ ctx , label );
31803179 if (status == 0 ) {
31813180 nfs_setattr_update_inode (state -> inode , sattr ,
31823181 opendata -> o_res .f_attr );
@@ -3341,8 +3340,7 @@ static int _nfs4_do_setattr(struct inode *inode,
33413340
33423341static int nfs4_do_setattr (struct inode * inode , const struct cred * cred ,
33433342 struct nfs_fattr * fattr , struct iattr * sattr ,
3344- struct nfs_open_context * ctx , struct nfs4_label * ilabel ,
3345- struct nfs4_label * olabel )
3343+ struct nfs_open_context * ctx , struct nfs4_label * ilabel )
33463344{
33473345 struct nfs_server * server = NFS_SERVER (inode );
33483346 __u32 bitmask [NFS4_BITMASK_SZ ];
@@ -3356,7 +3354,6 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
33563354 };
33573355 struct nfs_setattrres res = {
33583356 .fattr = fattr ,
3359- .label = olabel ,
33603357 .server = server ,
33613358 };
33623359 struct nfs4_exception exception = {
@@ -3373,7 +3370,7 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
33733370 adjust_flags |= NFS_INO_INVALID_OTHER ;
33743371
33753372 do {
3376- nfs4_bitmap_copy_adjust (bitmask , nfs4_bitmask (server , olabel ),
3373+ nfs4_bitmap_copy_adjust (bitmask , nfs4_bitmask (server , fattr -> label ),
33773374 inode , adjust_flags );
33783375
33793376 err = _nfs4_do_setattr (inode , & arg , & res , cred , ctx );
@@ -4232,7 +4229,6 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
42324229 struct inode * inode = d_inode (dentry );
42334230 const struct cred * cred = NULL ;
42344231 struct nfs_open_context * ctx = NULL ;
4235- struct nfs4_label * label = NULL ;
42364232 int status ;
42374233
42384234 if (pnfs_ld_layoutret_on_setattr (inode ) &&
@@ -4258,20 +4254,15 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
42584254 cred = ctx -> cred ;
42594255 }
42604256
4261- label = nfs4_label_alloc (NFS_SERVER (inode ), GFP_KERNEL );
4262- if (IS_ERR (label ))
4263- return PTR_ERR (label );
4264-
42654257 /* Return any delegations if we're going to change ACLs */
42664258 if ((sattr -> ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID )) != 0 )
42674259 nfs4_inode_make_writeable (inode );
42684260
4269- status = nfs4_do_setattr (inode , cred , fattr , sattr , ctx , NULL , label );
4261+ status = nfs4_do_setattr (inode , cred , fattr , sattr , ctx , NULL );
42704262 if (status == 0 ) {
42714263 nfs_setattr_update_inode (inode , sattr , fattr );
4272- nfs_setsecurity (inode , fattr , label );
4264+ nfs_setsecurity (inode , fattr , fattr -> label );
42734265 }
4274- nfs4_label_free (label );
42754266 return status ;
42764267}
42774268
@@ -6021,8 +6012,7 @@ static int nfs4_get_security_label(struct inode *inode, void *buf,
60216012
60226013static int _nfs4_do_set_security_label (struct inode * inode ,
60236014 struct nfs4_label * ilabel ,
6024- struct nfs_fattr * fattr ,
6025- struct nfs4_label * olabel )
6015+ struct nfs_fattr * fattr )
60266016{
60276017
60286018 struct iattr sattr = {0 };
@@ -6037,7 +6027,6 @@ static int _nfs4_do_set_security_label(struct inode *inode,
60376027 };
60386028 struct nfs_setattrres res = {
60396029 .fattr = fattr ,
6040- .label = olabel ,
60416030 .server = server ,
60426031 };
60436032 struct rpc_message msg = {
@@ -6058,15 +6047,13 @@ static int _nfs4_do_set_security_label(struct inode *inode,
60586047
60596048static int nfs4_do_set_security_label (struct inode * inode ,
60606049 struct nfs4_label * ilabel ,
6061- struct nfs_fattr * fattr ,
6062- struct nfs4_label * olabel )
6050+ struct nfs_fattr * fattr )
60636051{
60646052 struct nfs4_exception exception = { };
60656053 int err ;
60666054
60676055 do {
6068- err = _nfs4_do_set_security_label (inode , ilabel ,
6069- fattr , olabel );
6056+ err = _nfs4_do_set_security_label (inode , ilabel , fattr );
60706057 trace_nfs4_set_security_label (inode , err );
60716058 err = nfs4_handle_exception (NFS_SERVER (inode ), err ,
60726059 & exception );
@@ -6077,32 +6064,21 @@ static int nfs4_do_set_security_label(struct inode *inode,
60776064static int
60786065nfs4_set_security_label (struct inode * inode , const void * buf , size_t buflen )
60796066{
6080- struct nfs4_label ilabel , * olabel = NULL ;
6081- struct nfs_fattr fattr ;
6067+ struct nfs4_label ilabel = { 0 , 0 , buflen , ( char * ) buf } ;
6068+ struct nfs_fattr * fattr ;
60826069 int status ;
60836070
60846071 if (!nfs_server_capable (inode , NFS_CAP_SECURITY_LABEL ))
60856072 return - EOPNOTSUPP ;
60866073
6087- nfs_fattr_init (& fattr );
6088-
6089- ilabel .pi = 0 ;
6090- ilabel .lfs = 0 ;
6091- ilabel .label = (char * )buf ;
6092- ilabel .len = buflen ;
6093-
6094- olabel = nfs4_label_alloc (NFS_SERVER (inode ), GFP_KERNEL );
6095- if (IS_ERR (olabel )) {
6096- status = - PTR_ERR (olabel );
6097- goto out ;
6098- }
6074+ fattr = nfs_alloc_fattr_with_label (NFS_SERVER (inode ));
6075+ if (fattr == NULL )
6076+ return - ENOMEM ;
60996077
6100- status = nfs4_do_set_security_label (inode , & ilabel , & fattr , olabel );
6078+ status = nfs4_do_set_security_label (inode , & ilabel , fattr );
61016079 if (status == 0 )
6102- nfs_setsecurity (inode , & fattr , olabel );
6080+ nfs_setsecurity (inode , fattr , fattr -> label );
61036081
6104- nfs4_label_free (olabel );
6105- out :
61066082 return status ;
61076083}
61086084#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
0 commit comments