Skip to content

Commit 4348d15

Browse files
committed
ec_inode readmask
1 parent a9f3973 commit 4348d15

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

xlators/cluster/ec/src/ec-helpers.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,3 +834,12 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
834834
}
835835
return _gf_false;
836836
}*/
837+
838+
gf_boolean_t
839+
ec_is_readmask_xattr(dict_t *dict)
840+
{
841+
if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
842+
return _gf_true;
843+
}
844+
return _gf_false;
845+
}

xlators/cluster/ec/src/ec-helpers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,7 @@ ec_filter_internal_xattrs(dict_t *xattr);
192192
int32_t
193193
ec_launch_replace_heal(ec_t *ec);
194194

195+
gf_boolean_t
196+
ec_is_readmask_xattr(dict_t *dict);
197+
195198
#endif /* __EC_HELPERS_H__ */

xlators/cluster/ec/src/ec-inode-read.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,7 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
13531353
{
13541354
ec_cbk_data_t *cbk;
13551355
ec_t *ec = fop->xl->private;
1356+
ec_inode_t* ctx = __ec_inode_get(fop->fd->inode, fop->xl);
13561357

13571358
switch (state) {
13581359
case EC_STATE_INIT:
@@ -1372,6 +1373,9 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
13721373
return EC_STATE_DISPATCH;
13731374

13741375
case EC_STATE_DISPATCH:
1376+
if (ctx && ctx->read_mask != 0) {
1377+
fop->mask &= ctx->read_mask;
1378+
}
13751379
if (ec->read_mask) {
13761380
fop->mask &= ec->read_mask;
13771381
}

xlators/cluster/ec/src/ec-types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ struct _ec_inode {
187187
struct list_head heal;
188188
ec_stripe_list_t stripe_cache;
189189
uint64_t bad_version;
190+
uintptr_t read_mask;
190191
};
191192

192193
typedef int32_t (*fop_heal_cbk_t)(call_frame_t *, void *, xlator_t *, int32_t,

xlators/cluster/ec/src/ec.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
13241387
int32_t
13251388
ec_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,

xlators/cluster/ec/src/ec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define EC_XATTR_HEAL EC_XATTR_PREFIX "heal"
2121
#define EC_XATTR_HEAL_NEW EC_XATTR_PREFIX "heal-new"
2222
#define EC_XATTR_DIRTY EC_XATTR_PREFIX "dirty"
23+
#define EC_XATTR_READMASK EC_XATTR_PREFIX "readmask"
2324
#define EC_STRIPE_CACHE_MAX_SIZE 10
2425
#define EC_VERSION_SIZE 2
2526
#define EC_SHD_INODE_LRU_LIMIT 10

0 commit comments

Comments
 (0)