@@ -97,8 +97,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
97
97
struct nfs_fattr * fattr , struct inode * inode );
98
98
static int nfs4_do_setattr (struct inode * inode , const struct cred * cred ,
99
99
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 );
102
101
#ifdef CONFIG_NFS_V4_1
103
102
static struct rpc_task * _nfs41_proc_sequence (struct nfs_client * clp ,
104
103
const struct cred * cred ,
@@ -3176,7 +3175,7 @@ static int _nfs4_do_open(struct inode *dir,
3176
3175
nfs_fattr_init (opendata -> o_res .f_attr );
3177
3176
status = nfs4_do_setattr (state -> inode , cred ,
3178
3177
opendata -> o_res .f_attr , sattr ,
3179
- ctx , label , opendata -> o_res . f_attr -> label );
3178
+ ctx , label );
3180
3179
if (status == 0 ) {
3181
3180
nfs_setattr_update_inode (state -> inode , sattr ,
3182
3181
opendata -> o_res .f_attr );
@@ -3341,8 +3340,7 @@ static int _nfs4_do_setattr(struct inode *inode,
3341
3340
3342
3341
static int nfs4_do_setattr (struct inode * inode , const struct cred * cred ,
3343
3342
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 )
3346
3344
{
3347
3345
struct nfs_server * server = NFS_SERVER (inode );
3348
3346
__u32 bitmask [NFS4_BITMASK_SZ ];
@@ -3356,7 +3354,6 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
3356
3354
};
3357
3355
struct nfs_setattrres res = {
3358
3356
.fattr = fattr ,
3359
- .label = olabel ,
3360
3357
.server = server ,
3361
3358
};
3362
3359
struct nfs4_exception exception = {
@@ -3373,7 +3370,7 @@ static int nfs4_do_setattr(struct inode *inode, const struct cred *cred,
3373
3370
adjust_flags |= NFS_INO_INVALID_OTHER ;
3374
3371
3375
3372
do {
3376
- nfs4_bitmap_copy_adjust (bitmask , nfs4_bitmask (server , olabel ),
3373
+ nfs4_bitmap_copy_adjust (bitmask , nfs4_bitmask (server , fattr -> label ),
3377
3374
inode , adjust_flags );
3378
3375
3379
3376
err = _nfs4_do_setattr (inode , & arg , & res , cred , ctx );
@@ -4232,7 +4229,6 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
4232
4229
struct inode * inode = d_inode (dentry );
4233
4230
const struct cred * cred = NULL ;
4234
4231
struct nfs_open_context * ctx = NULL ;
4235
- struct nfs4_label * label = NULL ;
4236
4232
int status ;
4237
4233
4238
4234
if (pnfs_ld_layoutret_on_setattr (inode ) &&
@@ -4258,20 +4254,15 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
4258
4254
cred = ctx -> cred ;
4259
4255
}
4260
4256
4261
- label = nfs4_label_alloc (NFS_SERVER (inode ), GFP_KERNEL );
4262
- if (IS_ERR (label ))
4263
- return PTR_ERR (label );
4264
-
4265
4257
/* Return any delegations if we're going to change ACLs */
4266
4258
if ((sattr -> ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID )) != 0 )
4267
4259
nfs4_inode_make_writeable (inode );
4268
4260
4269
- status = nfs4_do_setattr (inode , cred , fattr , sattr , ctx , NULL , label );
4261
+ status = nfs4_do_setattr (inode , cred , fattr , sattr , ctx , NULL );
4270
4262
if (status == 0 ) {
4271
4263
nfs_setattr_update_inode (inode , sattr , fattr );
4272
- nfs_setsecurity (inode , fattr , label );
4264
+ nfs_setsecurity (inode , fattr , fattr -> label );
4273
4265
}
4274
- nfs4_label_free (label );
4275
4266
return status ;
4276
4267
}
4277
4268
@@ -6021,8 +6012,7 @@ static int nfs4_get_security_label(struct inode *inode, void *buf,
6021
6012
6022
6013
static int _nfs4_do_set_security_label (struct inode * inode ,
6023
6014
struct nfs4_label * ilabel ,
6024
- struct nfs_fattr * fattr ,
6025
- struct nfs4_label * olabel )
6015
+ struct nfs_fattr * fattr )
6026
6016
{
6027
6017
6028
6018
struct iattr sattr = {0 };
@@ -6037,7 +6027,6 @@ static int _nfs4_do_set_security_label(struct inode *inode,
6037
6027
};
6038
6028
struct nfs_setattrres res = {
6039
6029
.fattr = fattr ,
6040
- .label = olabel ,
6041
6030
.server = server ,
6042
6031
};
6043
6032
struct rpc_message msg = {
@@ -6058,15 +6047,13 @@ static int _nfs4_do_set_security_label(struct inode *inode,
6058
6047
6059
6048
static int nfs4_do_set_security_label (struct inode * inode ,
6060
6049
struct nfs4_label * ilabel ,
6061
- struct nfs_fattr * fattr ,
6062
- struct nfs4_label * olabel )
6050
+ struct nfs_fattr * fattr )
6063
6051
{
6064
6052
struct nfs4_exception exception = { };
6065
6053
int err ;
6066
6054
6067
6055
do {
6068
- err = _nfs4_do_set_security_label (inode , ilabel ,
6069
- fattr , olabel );
6056
+ err = _nfs4_do_set_security_label (inode , ilabel , fattr );
6070
6057
trace_nfs4_set_security_label (inode , err );
6071
6058
err = nfs4_handle_exception (NFS_SERVER (inode ), err ,
6072
6059
& exception );
@@ -6077,32 +6064,21 @@ static int nfs4_do_set_security_label(struct inode *inode,
6077
6064
static int
6078
6065
nfs4_set_security_label (struct inode * inode , const void * buf , size_t buflen )
6079
6066
{
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 ;
6082
6069
int status ;
6083
6070
6084
6071
if (!nfs_server_capable (inode , NFS_CAP_SECURITY_LABEL ))
6085
6072
return - EOPNOTSUPP ;
6086
6073
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 ;
6099
6077
6100
- status = nfs4_do_set_security_label (inode , & ilabel , & fattr , olabel );
6078
+ status = nfs4_do_set_security_label (inode , & ilabel , fattr );
6101
6079
if (status == 0 )
6102
- nfs_setsecurity (inode , & fattr , olabel );
6080
+ nfs_setsecurity (inode , fattr , fattr -> label );
6103
6081
6104
- nfs4_label_free (olabel );
6105
- out :
6106
6082
return status ;
6107
6083
}
6108
6084
#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
0 commit comments