Skip to content

Enhancement: Added read_mask on ec_inode to specify bricks for read #4496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

sbk173
Copy link

@sbk173 sbk173 commented Mar 17, 2025

Added ability to specify bricks from which data is to be read. This can be set by doing a setfattr on a file with key as "glusterfs.ec.readmask".

@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 1101f61b1..762761703 100644
--- a/libglusterfs/src/glusterfs/inode.h
+++ b/libglusterfs/src/glusterfs/inode.h
@@ -73,7 +73,7 @@ struct _dentry {
     struct list_head hash;       /* hash table pointers */
     inode_t *inode;              /* inode of this directory entry */
     inode_t *parent;             /* directory of the entry */
-    char name[];                  /* name of the directory entry */
+    char name[];                 /* name of the directory entry */
 };
 
 struct _inode_ctx {
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 10b092f6d..ea9e7cafb 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1375,7 +1375,7 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
             if (ec->read_mask) {
                 fop->mask &= ec->read_mask;
             }
-            if (fop->fd->inode->read_mask != 0){
+            if (fop->fd->inode->read_mask != 0) {
                 fop->mask &= fop->fd->inode->read_mask;
             }
             ec_dispatch_min(fop);
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
index 212cf633b..fc8711879 100644
--- a/xlators/cluster/ec/src/ec-inode-write.c
+++ b/xlators/cluster/ec/src/ec-inode-write.c
@@ -722,8 +722,8 @@ ec_setxattr(call_frame_t *frame, xlator_t *this, uintptr_t target,
     GF_VALIDATE_OR_GOTO(this->name, this->private, out);
 
     ret = dict_lookup(dict, mask_key, &dict_data);
-    if(!ret && dict_data){
-        if(loc != NULL && loc->inode != NULL){
+    if (!ret && dict_data) {
+        if (loc != NULL && loc->inode != NULL) {
             loc->inode->read_mask = data_to_uint16(dict_data);
         }
         dict_deln(dict, mask_key, strlen(mask_key));

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 1101f61b1..762761703 100644
--- a/libglusterfs/src/glusterfs/inode.h
+++ b/libglusterfs/src/glusterfs/inode.h
@@ -73,7 +73,7 @@ struct _dentry {
     struct list_head hash;       /* hash table pointers */
     inode_t *inode;              /* inode of this directory entry */
     inode_t *parent;             /* directory of the entry */
-    char name[];                  /* name of the directory entry */
+    char name[];                 /* name of the directory entry */
 };
 
 struct _inode_ctx {
diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c
index c18f90873..c855503cb 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -838,7 +838,8 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
 gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict)
 {
-    if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
+    if (dict && dict->count == 1 &&
+        strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0) {
         return _gf_true;
     }
     return _gf_false;
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index f3a84ea84..bba806f93 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1353,7 +1353,7 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
 {
     ec_cbk_data_t *cbk;
     ec_t *ec = fop->xl->private;
-    ec_inode_t* ctx = __ec_inode_get(fop->fd->inode, fop->xl);
+    ec_inode_t *ctx = __ec_inode_get(fop->fd->inode, fop->xl);
 
     switch (state) {
         case EC_STATE_INIT:
@@ -1379,7 +1379,7 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
             if (ec->read_mask) {
                 fop->mask &= ec->read_mask;
             }
-            if (fop->fd->inode->read_mask != 0){
+            if (fop->fd->inode->read_mask != 0) {
                 fop->mask &= fop->fd->inode->read_mask;
             }
             ec_dispatch_min(fop);
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
index 212cf633b..fc8711879 100644
--- a/xlators/cluster/ec/src/ec-inode-write.c
+++ b/xlators/cluster/ec/src/ec-inode-write.c
@@ -722,8 +722,8 @@ ec_setxattr(call_frame_t *frame, xlator_t *this, uintptr_t target,
     GF_VALIDATE_OR_GOTO(this->name, this->private, out);
 
     ret = dict_lookup(dict, mask_key, &dict_data);
-    if(!ret && dict_data){
-        if(loc != NULL && loc->inode != NULL){
+    if (!ret && dict_data) {
+        if (loc != NULL && loc->inode != NULL) {
             loc->inode->read_mask = data_to_uint16(dict_data);
         }
         dict_deln(dict, mask_key, strlen(mask_key));
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index c07b89a87..5fd296386 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -1322,8 +1322,8 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
 }
 
 int32_t
-ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
-                   int32_t flags, dict_t *xdata)
+ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc,
+                   dict_t *dict, int32_t flags, dict_t *xdata)
 {
     char *read_mask_str = NULL;
     char *mask = NULL;
@@ -1337,12 +1337,12 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     int op_errno = ENOMEM;
     uintptr_t read_mask = 0;
 
-    if (!ec_is_readmask_xattr(dict)){
+    if (!ec_is_readmask_xattr(dict)) {
         return -1;
     }
 
     ctx = __ec_inode_get(loc->inode, this);
-    if(!ctx){
+    if (!ctx) {
         goto out;
     }
 
@@ -1361,11 +1361,11 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     }
     maskptr = mask;
 
-    for(;;){
+    for (;;) {
         id_str = strtok_r(maskptr, ":", &saveptr);
         if (id_str == NULL)
             break;
-        if(gf_string2int(id_str, &id)) {
+        if (gf_string2int(id_str, &id)) {
             goto out;
         }
 
@@ -1377,7 +1377,7 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     op_ret = op_errno = 0;
 
 out:
-    if(mask){
+    if (mask) {
         GF_FREE(mask);
     }
     STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno, xdata);
@@ -1390,9 +1390,9 @@ ec_gf_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
 {
     int error = 0;
 
-    if  (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
-         return 0;
-    
+    if (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
+        return 0;
+
     EC_INTERNAL_XATTR_OR_GOTO("", dict, error, out);
 
     ec_setxattr(frame, this, -1, EC_MINIMUM_MIN, default_setxattr_cbk, NULL,

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index c18f90873..c855503cb 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -838,7 +838,8 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
 gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict)
 {
-    if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
+    if (dict && dict->count == 1 &&
+        strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0) {
         return _gf_true;
     }
     return _gf_false;
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 79a16f62f..e066e3755 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1353,7 +1353,7 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
 {
     ec_cbk_data_t *cbk;
     ec_t *ec = fop->xl->private;
-    ec_inode_t* ctx = __ec_inode_get(fop->fd->inode, fop->xl);
+    ec_inode_t *ctx = __ec_inode_get(fop->fd->inode, fop->xl);
 
     switch (state) {
         case EC_STATE_INIT:
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index c07b89a87..5fd296386 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -1322,8 +1322,8 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
 }
 
 int32_t
-ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
-                   int32_t flags, dict_t *xdata)
+ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc,
+                   dict_t *dict, int32_t flags, dict_t *xdata)
 {
     char *read_mask_str = NULL;
     char *mask = NULL;
@@ -1337,12 +1337,12 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     int op_errno = ENOMEM;
     uintptr_t read_mask = 0;
 
-    if (!ec_is_readmask_xattr(dict)){
+    if (!ec_is_readmask_xattr(dict)) {
         return -1;
     }
 
     ctx = __ec_inode_get(loc->inode, this);
-    if(!ctx){
+    if (!ctx) {
         goto out;
     }
 
@@ -1361,11 +1361,11 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     }
     maskptr = mask;
 
-    for(;;){
+    for (;;) {
         id_str = strtok_r(maskptr, ":", &saveptr);
         if (id_str == NULL)
             break;
-        if(gf_string2int(id_str, &id)) {
+        if (gf_string2int(id_str, &id)) {
             goto out;
         }
 
@@ -1377,7 +1377,7 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     op_ret = op_errno = 0;
 
 out:
-    if(mask){
+    if (mask) {
         GF_FREE(mask);
     }
     STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno, xdata);
@@ -1390,9 +1390,9 @@ ec_gf_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
 {
     int error = 0;
 
-    if  (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
-         return 0;
-    
+    if (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
+        return 0;
+
     EC_INTERNAL_XATTR_OR_GOTO("", dict, error, out);
 
     ec_setxattr(frame, this, -1, EC_MINIMUM_MIN, default_setxattr_cbk, NULL,

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index c18f90873..c855503cb 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -838,7 +838,8 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
 gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict)
 {
-    if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
+    if (dict && dict->count == 1 &&
+        strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0) {
         return _gf_true;
     }
     return _gf_false;
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 79a16f62f..e066e3755 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1353,7 +1353,7 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
 {
     ec_cbk_data_t *cbk;
     ec_t *ec = fop->xl->private;
-    ec_inode_t* ctx = __ec_inode_get(fop->fd->inode, fop->xl);
+    ec_inode_t *ctx = __ec_inode_get(fop->fd->inode, fop->xl);
 
     switch (state) {
         case EC_STATE_INIT:
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index c07b89a87..5fd296386 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -1322,8 +1322,8 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
 }
 
 int32_t
-ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
-                   int32_t flags, dict_t *xdata)
+ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc,
+                   dict_t *dict, int32_t flags, dict_t *xdata)
 {
     char *read_mask_str = NULL;
     char *mask = NULL;
@@ -1337,12 +1337,12 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     int op_errno = ENOMEM;
     uintptr_t read_mask = 0;
 
-    if (!ec_is_readmask_xattr(dict)){
+    if (!ec_is_readmask_xattr(dict)) {
         return -1;
     }
 
     ctx = __ec_inode_get(loc->inode, this);
-    if(!ctx){
+    if (!ctx) {
         goto out;
     }
 
@@ -1361,11 +1361,11 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     }
     maskptr = mask;
 
-    for(;;){
+    for (;;) {
         id_str = strtok_r(maskptr, ":", &saveptr);
         if (id_str == NULL)
             break;
-        if(gf_string2int(id_str, &id)) {
+        if (gf_string2int(id_str, &id)) {
             goto out;
         }
 
@@ -1377,7 +1377,7 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     op_ret = op_errno = 0;
 
 out:
-    if(mask){
+    if (mask) {
         GF_FREE(mask);
     }
     STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno, xdata);
@@ -1390,9 +1390,9 @@ ec_gf_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
 {
     int error = 0;
 
-    if  (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
-         return 0;
-    
+    if (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
+        return 0;
+
     EC_INTERNAL_XATTR_OR_GOTO("", dict, error, out);
 
     ec_setxattr(frame, this, -1, EC_MINIMUM_MIN, default_setxattr_cbk, NULL,

@sbk173 sbk173 changed the title Enhancement: Added read_mask on inode to specify bricks for read Enhancement: Added read_mask on ec_inode to specify bricks for read Mar 26, 2025
@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 94a7754f0..c2f83fa80 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -746,7 +746,6 @@ ec_inode_readmask_set(inode_t *inode, xlator_t *xl, uintptr_t read_mask)
     ctx->read_mask = read_mask;
 
     UNLOCK(&inode->lock);
-
 }
 
 uintptr_t
@@ -870,14 +869,15 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
 gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict)
 {
-    if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
+    if (dict && dict->count == 1 &&
+        strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0) {
         return _gf_true;
     }
     return _gf_false;
 }
 
 uintptr_t
-ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid)
+ec_parse_read_mask(ec_t *ec, char *read_mask_str, uint64_t msgid)
 {
     char *mask = NULL;
     char *maskptr = NULL;
@@ -922,8 +922,8 @@ ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid)
         read_mask = 0;
         goto out;
     }
-    
+
 out:
     GF_FREE(mask);
-    return read_mask;   
+    return read_mask;
 }
diff --git a/xlators/cluster/ec/src/ec-helpers.h b/xlators/cluster/ec/src/ec-helpers.h
index d393b12bd..ca06c3287 100644
--- a/xlators/cluster/ec/src/ec-helpers.h
+++ b/xlators/cluster/ec/src/ec-helpers.h
@@ -201,6 +201,6 @@ gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict);
 
 uintptr_t
-ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid);
+ec_parse_read_mask(ec_t *ec, char *read_mask_str, uint64_t msgid);
 
 #endif /* __EC_HELPERS_H__ */
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 0e177088b..94ffd8787 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1372,14 +1372,14 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
             return EC_STATE_DISPATCH;
 
         case EC_STATE_DISPATCH:
-            uintptr_t inode_read_mask = ec_inode_readmask_get(fop->fd->inode, fop->xl);
+            uintptr_t inode_read_mask = ec_inode_readmask_get(fop->fd->inode,
+                                                              fop->xl);
             if (inode_read_mask != 0) {
                 fop->mask &= inode_read_mask;
-            }
-            else if (ec->read_mask) {
+            } else if (ec->read_mask) {
                 fop->mask &= ec->read_mask;
             }
-        
+
             ec_dispatch_min(fop);
 
             return EC_STATE_PREPARE_ANSWER;
diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h
index aadb4d6ff..c9fddb3a4 100644
--- a/xlators/cluster/ec/src/ec-messages.h
+++ b/xlators/cluster/ec/src/ec-messages.h
@@ -23,39 +23,37 @@
  * glfs-message-id.h.
  */
 
-GLFS_MSGID(EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL,
-           EC_MSG_DICT_COMBINE_FAIL, EC_MSG_STIME_COMBINE_FAIL,
-           EC_MSG_INVALID_DICT_NUMS, EC_MSG_IATT_COMBINE_FAIL,
-           EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED,
-           EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL,
-           EC_MSG_LOC_COPY_FAIL, EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL,
-           EC_MSG_LK_UNLOCK_FAILED, EC_MSG_UNLOCK_FAILED,
-           EC_MSG_LOC_PARENT_INODE_MISSING, EC_MSG_INVALID_LOC_NAME,
-           EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH, EC_MSG_UNSUPPORTED_VERSION,
-           EC_MSG_FD_CREATE_FAIL, EC_MSG_READDIRP_REQ_PREP_FAIL,
-           EC_MSG_LOOKUP_REQ_PREP_FAIL, EC_MSG_INODE_REF_FAIL,
-           EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH,
-           EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH,
-           EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL,
-           EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT,
-           EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED,
-           EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST,
-           EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL,
-           EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH,
-           EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL,
-           EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL,
-           EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE,
-           EC_MSG_INODE_REMOVE_FAIL, EC_MSG_INVALID_REDUNDANCY,
-           EC_MSG_XLATOR_PARSE_OPT_FAIL, EC_MSG_OP_FAIL_ON_SUBVOLS,
-           EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH, EC_MSG_XDATA_MISMATCH,
-           EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS, EC_MSG_FULL_SWEEP_START,
-           EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP, EC_MSG_EC_UP,
-           EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL,
-           EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL,
-           EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
-           EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
-           EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
-           EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
-           EC_MSG_THREAD_CLEANUP_FAILED, EC_MSG_FD_BAD, EC_MSG_INVALID_READMASK);
+GLFS_MSGID(
+    EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL, EC_MSG_DICT_COMBINE_FAIL,
+    EC_MSG_STIME_COMBINE_FAIL, EC_MSG_INVALID_DICT_NUMS,
+    EC_MSG_IATT_COMBINE_FAIL, EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED,
+    EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL, EC_MSG_LOC_COPY_FAIL,
+    EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL, EC_MSG_LK_UNLOCK_FAILED,
+    EC_MSG_UNLOCK_FAILED, EC_MSG_LOC_PARENT_INODE_MISSING,
+    EC_MSG_INVALID_LOC_NAME, EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH,
+    EC_MSG_UNSUPPORTED_VERSION, EC_MSG_FD_CREATE_FAIL,
+    EC_MSG_READDIRP_REQ_PREP_FAIL, EC_MSG_LOOKUP_REQ_PREP_FAIL,
+    EC_MSG_INODE_REF_FAIL, EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH,
+    EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH,
+    EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL,
+    EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT,
+    EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED,
+    EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST,
+    EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL,
+    EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH,
+    EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL,
+    EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL,
+    EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE, EC_MSG_INODE_REMOVE_FAIL,
+    EC_MSG_INVALID_REDUNDANCY, EC_MSG_XLATOR_PARSE_OPT_FAIL,
+    EC_MSG_OP_FAIL_ON_SUBVOLS, EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH,
+    EC_MSG_XDATA_MISMATCH, EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS,
+    EC_MSG_FULL_SWEEP_START, EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP,
+    EC_MSG_EC_UP, EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL,
+    EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL,
+    EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
+    EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
+    EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
+    EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
+    EC_MSG_THREAD_CLEANUP_FAILED, EC_MSG_FD_BAD, EC_MSG_INVALID_READMASK);
 
 #endif /* !_EC_MESSAGES_H_ */
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index cab557869..9dbdb17c5 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -730,7 +730,7 @@ ec_assign_read_mask(ec_t *ec, char *read_mask_str)
         ret = -1;
         goto out;
     }
-    
+
     ec->read_mask = read_mask;
     ret = 0;
 out:
@@ -1285,16 +1285,15 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
 }
 
 int32_t
-ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
-                   int32_t flags, dict_t *xdata)
+ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc,
+                   dict_t *dict, int32_t flags, dict_t *xdata)
 {
-    ec_t* ec = this->private;
+    ec_t *ec = this->private;
     data_t *dict_data = NULL;
     char *read_mask_str = NULL;
     int32_t op_ret = -1;
     int32_t op_errno = EINVAL;
     uintptr_t read_mask;
-    
 
     if (!ec_is_readmask_xattr(dict)) {
         return -1;
@@ -1309,7 +1308,7 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
     if (!read_mask_str) {
         goto out;
     }
-    
+
     read_mask = ec_parse_read_mask(ec, read_mask_str, EC_MSG_INVALID_READMASK);
     if (read_mask == 0) {
         goto out;
@@ -1328,9 +1327,9 @@ ec_gf_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
 {
     int error = 0;
 
-    if  (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
-         return 0;
-    
+    if (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
+        return 0;
+
     EC_INTERNAL_XATTR_OR_GOTO("", dict, error, out);
 
     ec_setxattr(frame, this, -1, EC_MINIMUM_MIN, default_setxattr_cbk, NULL,

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 94a7754f0..c2f83fa80 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -746,7 +746,6 @@ ec_inode_readmask_set(inode_t *inode, xlator_t *xl, uintptr_t read_mask)
     ctx->read_mask = read_mask;
 
     UNLOCK(&inode->lock);
-
 }
 
 uintptr_t
@@ -870,14 +869,15 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
 gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict)
 {
-    if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
+    if (dict && dict->count == 1 &&
+        strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0) {
         return _gf_true;
     }
     return _gf_false;
 }
 
 uintptr_t
-ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid)
+ec_parse_read_mask(ec_t *ec, char *read_mask_str, uint64_t msgid)
 {
     char *mask = NULL;
     char *maskptr = NULL;
@@ -922,8 +922,8 @@ ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid)
         read_mask = 0;
         goto out;
     }
-    
+
 out:
     GF_FREE(mask);
-    return read_mask;   
+    return read_mask;
 }
diff --git a/xlators/cluster/ec/src/ec-helpers.h b/xlators/cluster/ec/src/ec-helpers.h
index d393b12bd..ca06c3287 100644
--- a/xlators/cluster/ec/src/ec-helpers.h
+++ b/xlators/cluster/ec/src/ec-helpers.h
@@ -201,6 +201,6 @@ gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict);
 
 uintptr_t
-ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid);
+ec_parse_read_mask(ec_t *ec, char *read_mask_str, uint64_t msgid);
 
 #endif /* __EC_HELPERS_H__ */
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 0e177088b..94ffd8787 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1372,14 +1372,14 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
             return EC_STATE_DISPATCH;
 
         case EC_STATE_DISPATCH:
-            uintptr_t inode_read_mask = ec_inode_readmask_get(fop->fd->inode, fop->xl);
+            uintptr_t inode_read_mask = ec_inode_readmask_get(fop->fd->inode,
+                                                              fop->xl);
             if (inode_read_mask != 0) {
                 fop->mask &= inode_read_mask;
-            }
-            else if (ec->read_mask) {
+            } else if (ec->read_mask) {
                 fop->mask &= ec->read_mask;
             }
-        
+
             ec_dispatch_min(fop);
 
             return EC_STATE_PREPARE_ANSWER;
diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h
index aadb4d6ff..c9fddb3a4 100644
--- a/xlators/cluster/ec/src/ec-messages.h
+++ b/xlators/cluster/ec/src/ec-messages.h
@@ -23,39 +23,37 @@
  * glfs-message-id.h.
  */
 
-GLFS_MSGID(EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL,
-           EC_MSG_DICT_COMBINE_FAIL, EC_MSG_STIME_COMBINE_FAIL,
-           EC_MSG_INVALID_DICT_NUMS, EC_MSG_IATT_COMBINE_FAIL,
-           EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED,
-           EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL,
-           EC_MSG_LOC_COPY_FAIL, EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL,
-           EC_MSG_LK_UNLOCK_FAILED, EC_MSG_UNLOCK_FAILED,
-           EC_MSG_LOC_PARENT_INODE_MISSING, EC_MSG_INVALID_LOC_NAME,
-           EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH, EC_MSG_UNSUPPORTED_VERSION,
-           EC_MSG_FD_CREATE_FAIL, EC_MSG_READDIRP_REQ_PREP_FAIL,
-           EC_MSG_LOOKUP_REQ_PREP_FAIL, EC_MSG_INODE_REF_FAIL,
-           EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH,
-           EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH,
-           EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL,
-           EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT,
-           EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED,
-           EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST,
-           EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL,
-           EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH,
-           EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL,
-           EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL,
-           EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE,
-           EC_MSG_INODE_REMOVE_FAIL, EC_MSG_INVALID_REDUNDANCY,
-           EC_MSG_XLATOR_PARSE_OPT_FAIL, EC_MSG_OP_FAIL_ON_SUBVOLS,
-           EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH, EC_MSG_XDATA_MISMATCH,
-           EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS, EC_MSG_FULL_SWEEP_START,
-           EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP, EC_MSG_EC_UP,
-           EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL,
-           EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL,
-           EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
-           EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
-           EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
-           EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
-           EC_MSG_THREAD_CLEANUP_FAILED, EC_MSG_FD_BAD, EC_MSG_INVALID_READMASK);
+GLFS_MSGID(
+    EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL, EC_MSG_DICT_COMBINE_FAIL,
+    EC_MSG_STIME_COMBINE_FAIL, EC_MSG_INVALID_DICT_NUMS,
+    EC_MSG_IATT_COMBINE_FAIL, EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED,
+    EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL, EC_MSG_LOC_COPY_FAIL,
+    EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL, EC_MSG_LK_UNLOCK_FAILED,
+    EC_MSG_UNLOCK_FAILED, EC_MSG_LOC_PARENT_INODE_MISSING,
+    EC_MSG_INVALID_LOC_NAME, EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH,
+    EC_MSG_UNSUPPORTED_VERSION, EC_MSG_FD_CREATE_FAIL,
+    EC_MSG_READDIRP_REQ_PREP_FAIL, EC_MSG_LOOKUP_REQ_PREP_FAIL,
+    EC_MSG_INODE_REF_FAIL, EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH,
+    EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH,
+    EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL,
+    EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT,
+    EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED,
+    EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST,
+    EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL,
+    EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH,
+    EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL,
+    EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL,
+    EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE, EC_MSG_INODE_REMOVE_FAIL,
+    EC_MSG_INVALID_REDUNDANCY, EC_MSG_XLATOR_PARSE_OPT_FAIL,
+    EC_MSG_OP_FAIL_ON_SUBVOLS, EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH,
+    EC_MSG_XDATA_MISMATCH, EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS,
+    EC_MSG_FULL_SWEEP_START, EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP,
+    EC_MSG_EC_UP, EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL,
+    EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL,
+    EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
+    EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
+    EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
+    EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
+    EC_MSG_THREAD_CLEANUP_FAILED, EC_MSG_FD_BAD, EC_MSG_INVALID_READMASK);
 
 #endif /* !_EC_MESSAGES_H_ */
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 20cf4ff4f..66e53ca4c 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -730,7 +730,7 @@ ec_assign_read_mask(ec_t *ec, char *read_mask_str)
         ret = -1;
         goto out;
     }
-    
+
     ec->read_mask = read_mask;
     ret = 0;
 out:
@@ -1285,10 +1285,10 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
 }
 
 int32_t
-ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
-                   int32_t flags, dict_t *xdata)
+ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc,
+                   dict_t *dict, int32_t flags, dict_t *xdata)
 {
-    ec_t* ec = this->private;
+    ec_t *ec = this->private;
     data_t *dict_data = NULL;
     char *read_mask_str = NULL;
     int32_t op_ret = -1;
@@ -1314,7 +1314,7 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
         op_ret = op_errno = 0;
         goto out;
     }
-    
+
     read_mask = ec_parse_read_mask(ec, read_mask_str, EC_MSG_INVALID_READMASK);
     if (read_mask == 0) {
         goto out;
@@ -1332,10 +1332,10 @@ ec_gf_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
                int32_t flags, dict_t *xdata)
 {
     int error = 0;
-    
+
     EC_INTERNAL_XATTR_OR_GOTO("", dict, error, out);
 
-    if  (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
+    if (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
         return 0;
 
     ec_setxattr(frame, this, -1, EC_MINIMUM_MIN, default_setxattr_cbk, NULL,

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 94a7754f0..c2f83fa80 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -746,7 +746,6 @@ ec_inode_readmask_set(inode_t *inode, xlator_t *xl, uintptr_t read_mask)
     ctx->read_mask = read_mask;
 
     UNLOCK(&inode->lock);
-
 }
 
 uintptr_t
@@ -870,14 +869,15 @@ ec_is_metadata_fop (int32_t lock_kind, glusterfs_fop_t fop)
 gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict)
 {
-    if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
+    if (dict && dict->count == 1 &&
+        strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0) {
         return _gf_true;
     }
     return _gf_false;
 }
 
 uintptr_t
-ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid)
+ec_parse_read_mask(ec_t *ec, char *read_mask_str, uint64_t msgid)
 {
     char *mask = NULL;
     char *maskptr = NULL;
@@ -922,8 +922,8 @@ ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid)
         read_mask = 0;
         goto out;
     }
-    
+
 out:
     GF_FREE(mask);
-    return read_mask;   
+    return read_mask;
 }
diff --git a/xlators/cluster/ec/src/ec-helpers.h b/xlators/cluster/ec/src/ec-helpers.h
index d393b12bd..ca06c3287 100644
--- a/xlators/cluster/ec/src/ec-helpers.h
+++ b/xlators/cluster/ec/src/ec-helpers.h
@@ -201,6 +201,6 @@ gf_boolean_t
 ec_is_readmask_xattr(dict_t *dict);
 
 uintptr_t
-ec_parse_read_mask(ec_t * ec, char *read_mask_str, uint64_t msgid);
+ec_parse_read_mask(ec_t *ec, char *read_mask_str, uint64_t msgid);
 
 #endif /* __EC_HELPERS_H__ */
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index 0e177088b..94ffd8787 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -1372,14 +1372,14 @@ ec_manager_readv(ec_fop_data_t *fop, int32_t state)
             return EC_STATE_DISPATCH;
 
         case EC_STATE_DISPATCH:
-            uintptr_t inode_read_mask = ec_inode_readmask_get(fop->fd->inode, fop->xl);
+            uintptr_t inode_read_mask = ec_inode_readmask_get(fop->fd->inode,
+                                                              fop->xl);
             if (inode_read_mask != 0) {
                 fop->mask &= inode_read_mask;
-            }
-            else if (ec->read_mask) {
+            } else if (ec->read_mask) {
                 fop->mask &= ec->read_mask;
             }
-        
+
             ec_dispatch_min(fop);
 
             return EC_STATE_PREPARE_ANSWER;
diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h
index aadb4d6ff..c9fddb3a4 100644
--- a/xlators/cluster/ec/src/ec-messages.h
+++ b/xlators/cluster/ec/src/ec-messages.h
@@ -23,39 +23,37 @@
  * glfs-message-id.h.
  */
 
-GLFS_MSGID(EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL,
-           EC_MSG_DICT_COMBINE_FAIL, EC_MSG_STIME_COMBINE_FAIL,
-           EC_MSG_INVALID_DICT_NUMS, EC_MSG_IATT_COMBINE_FAIL,
-           EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED,
-           EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL,
-           EC_MSG_LOC_COPY_FAIL, EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL,
-           EC_MSG_LK_UNLOCK_FAILED, EC_MSG_UNLOCK_FAILED,
-           EC_MSG_LOC_PARENT_INODE_MISSING, EC_MSG_INVALID_LOC_NAME,
-           EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH, EC_MSG_UNSUPPORTED_VERSION,
-           EC_MSG_FD_CREATE_FAIL, EC_MSG_READDIRP_REQ_PREP_FAIL,
-           EC_MSG_LOOKUP_REQ_PREP_FAIL, EC_MSG_INODE_REF_FAIL,
-           EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH,
-           EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH,
-           EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL,
-           EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT,
-           EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED,
-           EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST,
-           EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL,
-           EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH,
-           EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL,
-           EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL,
-           EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE,
-           EC_MSG_INODE_REMOVE_FAIL, EC_MSG_INVALID_REDUNDANCY,
-           EC_MSG_XLATOR_PARSE_OPT_FAIL, EC_MSG_OP_FAIL_ON_SUBVOLS,
-           EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH, EC_MSG_XDATA_MISMATCH,
-           EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS, EC_MSG_FULL_SWEEP_START,
-           EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP, EC_MSG_EC_UP,
-           EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL,
-           EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL,
-           EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
-           EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
-           EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
-           EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
-           EC_MSG_THREAD_CLEANUP_FAILED, EC_MSG_FD_BAD, EC_MSG_INVALID_READMASK);
+GLFS_MSGID(
+    EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL, EC_MSG_DICT_COMBINE_FAIL,
+    EC_MSG_STIME_COMBINE_FAIL, EC_MSG_INVALID_DICT_NUMS,
+    EC_MSG_IATT_COMBINE_FAIL, EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED,
+    EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL, EC_MSG_LOC_COPY_FAIL,
+    EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL, EC_MSG_LK_UNLOCK_FAILED,
+    EC_MSG_UNLOCK_FAILED, EC_MSG_LOC_PARENT_INODE_MISSING,
+    EC_MSG_INVALID_LOC_NAME, EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH,
+    EC_MSG_UNSUPPORTED_VERSION, EC_MSG_FD_CREATE_FAIL,
+    EC_MSG_READDIRP_REQ_PREP_FAIL, EC_MSG_LOOKUP_REQ_PREP_FAIL,
+    EC_MSG_INODE_REF_FAIL, EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH,
+    EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH,
+    EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL,
+    EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT,
+    EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED,
+    EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST,
+    EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL,
+    EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH,
+    EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL,
+    EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL,
+    EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE, EC_MSG_INODE_REMOVE_FAIL,
+    EC_MSG_INVALID_REDUNDANCY, EC_MSG_XLATOR_PARSE_OPT_FAIL,
+    EC_MSG_OP_FAIL_ON_SUBVOLS, EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH,
+    EC_MSG_XDATA_MISMATCH, EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS,
+    EC_MSG_FULL_SWEEP_START, EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP,
+    EC_MSG_EC_UP, EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL,
+    EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL,
+    EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE,
+    EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED,
+    EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED,
+    EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED,
+    EC_MSG_THREAD_CLEANUP_FAILED, EC_MSG_FD_BAD, EC_MSG_INVALID_READMASK);
 
 #endif /* !_EC_MESSAGES_H_ */
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 20cf4ff4f..66e53ca4c 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -730,7 +730,7 @@ ec_assign_read_mask(ec_t *ec, char *read_mask_str)
         ret = -1;
         goto out;
     }
-    
+
     ec->read_mask = read_mask;
     ret = 0;
 out:
@@ -1285,10 +1285,10 @@ ec_gf_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
 }
 
 int32_t
-ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
-                   int32_t flags, dict_t *xdata)
+ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc,
+                   dict_t *dict, int32_t flags, dict_t *xdata)
 {
-    ec_t* ec = this->private;
+    ec_t *ec = this->private;
     data_t *dict_data = NULL;
     char *read_mask_str = NULL;
     int32_t op_ret = -1;
@@ -1314,7 +1314,7 @@ ec_handle_readmask(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict
         op_ret = op_errno = 0;
         goto out;
     }
-    
+
     read_mask = ec_parse_read_mask(ec, read_mask_str, EC_MSG_INVALID_READMASK);
     if (read_mask == 0) {
         goto out;
@@ -1332,10 +1332,10 @@ ec_gf_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
                int32_t flags, dict_t *xdata)
 {
     int error = 0;
-    
+
     EC_INTERNAL_XATTR_OR_GOTO("", dict, error, out);
 
-    if  (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
+    if (ec_handle_readmask(frame, this, loc, dict, flags, xdata) == 0)
         return 0;
 
     ec_setxattr(frame, this, -1, EC_MINIMUM_MIN, default_setxattr_cbk, NULL,

read_mask_str = data_to_str(dict_data);
if (!read_mask_str) {
goto out;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly do dict_get_str_sizen() to get the read_mask_str

int id = 0;

mask = gf_strdup(read_mask_str);
if (!mask) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fail the operation with op_ret=-1 and op_errno = ENOMEM

gf_msg(ec->xl->name, GF_LOG_ERROR, 0, msgid,
"In read-mask \"%s\" id %s is not a valid integer",
read_mask_str, id_str);
read_mask = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fail the operation with op_ret=-1 and op_errno=EINVAL.

"In read-mask \"%s\" id %d is not in range [0 - %d]",
read_mask_str, id, ec->nodes - 1);
read_mask = 0;
goto out;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fail the operation with op_ret=-1 and op_errno=EINVAL

maskptr = NULL;
}

if (gf_bits_count(read_mask) < ec->fragments) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fail the operation with op_ret=-1 and op_errno=EINVAL

gf_boolean_t
ec_is_readmask_xattr(dict_t *dict)
{
if (dict && dict->count == 1 && strcmp(dict->members_list->key, EC_XATTR_READMASK) == 0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do dict_lookup/dict_get instead of accessing the structure variables.


LOCK(&inode->lock);

ctx = __ec_inode_get(inode, xl);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not supposed to happen for a linked_inode but handle ctx being null, incase someone erroneously calls it on not yet linked inode.

"read-mask \"%s\" should contain at least %d ids", read_mask_str,
ec->fragments);
read_mask = ec_parse_read_mask(ec, read_mask_str, EC_MSG_XLATOR_INIT_FAIL);
if (read_mask == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_mask being zero is not an error, we have been treating it equivalent to all bricks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants