@@ -1321,12 +1321,78 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
13211321 return 0 ;
13221322}
13231323
1324+ int32_t
1325+ ec_handle_readmask (call_frame_t * frame , xlator_t * this , loc_t * loc , dict_t * dict ,
1326+ int32_t flags , dict_t * xdata )
1327+ {
1328+ char * read_mask_str = NULL ;
1329+ char * mask = NULL ;
1330+ char * maskptr = NULL ;
1331+ char * id_str = NULL ;
1332+ char * saveptr = NULL ;
1333+ data_t * dict_data = NULL ;
1334+ ec_inode_t * ctx = NULL ;
1335+ int id = 0 ;
1336+ int op_ret = -1 ;
1337+ int op_errno = ENOMEM ;
1338+ uintptr_t read_mask = 0 ;
1339+
1340+ if (!ec_is_readmask_xattr (dict )){
1341+ return -1 ;
1342+ }
1343+
1344+ ctx = __ec_inode_get (loc -> inode , this );
1345+ if (!ctx ){
1346+ goto out ;
1347+ }
1348+
1349+ int ret = dict_lookup (dict , EC_XATTR_READMASK , & dict_data );
1350+ if (ret != 0 ) {
1351+ op_ret = -1 ;
1352+ goto out ;
1353+ }
1354+ read_mask_str = data_to_str (dict_data );
1355+ if (!read_mask_str ) {
1356+ goto out ;
1357+ }
1358+ mask = gf_strdup (read_mask_str );
1359+ if (!mask ) {
1360+ goto out ;
1361+ }
1362+ maskptr = mask ;
1363+
1364+ for (;;){
1365+ id_str = strtok_r (maskptr , ":" , & saveptr );
1366+ if (id_str == NULL )
1367+ break ;
1368+ if (gf_string2int (id_str , & id )) {
1369+ goto out ;
1370+ }
1371+
1372+ read_mask |= (1UL << id );
1373+ maskptr = NULL ;
1374+ }
1375+
1376+ ctx -> read_mask = read_mask ;
1377+ op_ret = op_errno = 0 ;
1378+
1379+ out :
1380+ if (mask ){
1381+ GF_FREE (mask );
1382+ }
1383+ STACK_UNWIND_STRICT (setxattr , frame , op_ret , op_errno , xdata );
1384+ return 0 ;
1385+ }
1386+
13241387int32_t
13251388ec_gf_setxattr (call_frame_t * frame , xlator_t * this , loc_t * loc , dict_t * dict ,
13261389 int32_t flags , dict_t * xdata )
13271390{
13281391 int error = 0 ;
13291392
1393+ if (ec_handle_readmask (frame , this , loc , dict , flags , xdata ) == 0 )
1394+ return 0 ;
1395+
13301396 EC_INTERNAL_XATTR_OR_GOTO ("" , dict , error , out );
13311397
13321398 ec_setxattr (frame , this , -1 , EC_MINIMUM_MIN , default_setxattr_cbk , NULL ,
0 commit comments