d2787b
From 1cd16553d436fa703f5e18d71c35108d0e179e8b Mon Sep 17 00:00:00 2001
d2787b
From: nik-redhat <nladha@redhat.com>
d2787b
Date: Thu, 9 Apr 2020 11:36:34 +0530
d2787b
Subject: [PATCH 600/610] dht xlator: integer handling issue
d2787b
d2787b
Issue: The ret value is passed to the function
d2787b
instead of the proper errno value
d2787b
d2787b
Fix: Passing the errno generated to
d2787b
the log function
d2787b
d2787b
CID: 1415824 : Improper use of negative value
d2787b
CID: 1420205 : Improper use of negative value
d2787b
>Change-Id: Iaa7407ebd03eda46a2c027695e6bf0f598b371b2
d2787b
>Updates: #1060
d2787b
>Signed-off-by: nik-redhat <nladha@redhat.com>
d2787b
d2787b
Upstream link: https://review.gluster.org/c/glusterfs/+/24314
d2787b
BUG: 1997447
d2787b
d2787b
Change-Id: Ibb7f432dbcc9ffd8dff6be6f984a6705894d6bef
d2787b
Signed-off-by: nik-redhat <nladha@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/280086
d2787b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 xlators/cluster/dht/src/dht-common.c   | 12 ++++++++----
d2787b
 xlators/cluster/dht/src/dht-common.h   |  2 +-
d2787b
 xlators/cluster/dht/src/dht-helper.c   |  9 ++++++---
d2787b
 xlators/cluster/dht/src/dht-selfheal.c |  8 +++++---
d2787b
 4 files changed, 20 insertions(+), 11 deletions(-)
d2787b
d2787b
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
d2787b
index e6a16ff..5eaaa1e 100644
d2787b
--- a/xlators/cluster/dht/src/dht-common.c
d2787b
+++ b/xlators/cluster/dht/src/dht-common.c
d2787b
@@ -672,13 +672,14 @@ dht_discover_complete(xlator_t *this, call_frame_t *discover_frame)
d2787b
 
d2787b
         if (local->need_xattr_heal && !heal_path) {
d2787b
             local->need_xattr_heal = 0;
d2787b
-            ret = dht_dir_xattr_heal(this, local);
d2787b
-            if (ret)
d2787b
-                gf_msg(this->name, GF_LOG_ERROR, ret,
d2787b
+            ret = dht_dir_xattr_heal(this, local, &op_errno);
d2787b
+            if (ret) {
d2787b
+                gf_msg(this->name, GF_LOG_ERROR, op_errno,
d2787b
                        DHT_MSG_DIR_XATTR_HEAL_FAILED,
d2787b
                        "xattr heal failed for "
d2787b
                        "directory  gfid is %s ",
d2787b
                        gfid_local);
d2787b
+            }
d2787b
         }
d2787b
     }
d2787b
 
d2787b
@@ -1205,7 +1206,7 @@ dht_dict_get_array(dict_t *dict, char *key, int32_t value[], int32_t size,
d2787b
    to non hashed subvol
d2787b
 */
d2787b
 int
d2787b
-dht_dir_xattr_heal(xlator_t *this, dht_local_t *local)
d2787b
+dht_dir_xattr_heal(xlator_t *this, dht_local_t *local, int *op_errno)
d2787b
 {
d2787b
     dht_local_t *copy_local = NULL;
d2787b
     call_frame_t *copy = NULL;
d2787b
@@ -1217,6 +1218,7 @@ dht_dir_xattr_heal(xlator_t *this, dht_local_t *local)
d2787b
                "No gfid exists for path %s "
d2787b
                "so healing xattr is not possible",
d2787b
                local->loc.path);
d2787b
+        *op_errno = EIO;
d2787b
         goto out;
d2787b
     }
d2787b
 
d2787b
@@ -1230,6 +1232,7 @@ dht_dir_xattr_heal(xlator_t *this, dht_local_t *local)
d2787b
                    "Memory allocation failed "
d2787b
                    "for path %s gfid %s ",
d2787b
                    local->loc.path, gfid_local);
d2787b
+            *op_errno = ENOMEM;
d2787b
             DHT_STACK_DESTROY(copy);
d2787b
         } else {
d2787b
             copy_local->stbuf = local->stbuf;
d2787b
@@ -1244,6 +1247,7 @@ dht_dir_xattr_heal(xlator_t *this, dht_local_t *local)
d2787b
                        "Synctask creation failed to heal xattr "
d2787b
                        "for path %s gfid %s ",
d2787b
                        local->loc.path, gfid_local);
d2787b
+                *op_errno = ENOMEM;
d2787b
                 DHT_STACK_DESTROY(copy);
d2787b
             }
d2787b
         }
d2787b
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
d2787b
index b856c68..1cb1c0c 100644
d2787b
--- a/xlators/cluster/dht/src/dht-common.h
d2787b
+++ b/xlators/cluster/dht/src/dht-common.h
d2787b
@@ -1493,7 +1493,7 @@ dht_dir_set_heal_xattr(xlator_t *this, dht_local_t *local, dict_t *dst,
d2787b
                        dict_t *src, int *uret, int *uflag);
d2787b
 
d2787b
 int
d2787b
-dht_dir_xattr_heal(xlator_t *this, dht_local_t *local);
d2787b
+dht_dir_xattr_heal(xlator_t *this, dht_local_t *local, int *op_errno);
d2787b
 
d2787b
 int32_t
d2787b
 dht_dict_get_array(dict_t *dict, char *key, int32_t value[], int32_t size,
d2787b
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
d2787b
index 4c3940a..d3444b3 100644
d2787b
--- a/xlators/cluster/dht/src/dht-helper.c
d2787b
+++ b/xlators/cluster/dht/src/dht-helper.c
d2787b
@@ -2105,6 +2105,7 @@ dht_heal_full_path_done(int op_ret, call_frame_t *heal_frame, void *data)
d2787b
     dht_local_t *local = NULL;
d2787b
     xlator_t *this = NULL;
d2787b
     int ret = -1;
d2787b
+    int op_errno = 0;
d2787b
 
d2787b
     local = heal_frame->local;
d2787b
     main_frame = local->main_frame;
d2787b
@@ -2114,10 +2115,12 @@ dht_heal_full_path_done(int op_ret, call_frame_t *heal_frame, void *data)
d2787b
     dht_set_fixed_dir_stat(&local->postparent);
d2787b
     if (local->need_xattr_heal) {
d2787b
         local->need_xattr_heal = 0;
d2787b
-        ret = dht_dir_xattr_heal(this, local);
d2787b
-        if (ret)
d2787b
-            gf_msg(this->name, GF_LOG_ERROR, ret, DHT_MSG_DIR_XATTR_HEAL_FAILED,
d2787b
+        ret = dht_dir_xattr_heal(this, local, &op_errno);
d2787b
+        if (ret) {
d2787b
+            gf_msg(this->name, GF_LOG_ERROR, op_errno,
d2787b
+                   DHT_MSG_DIR_XATTR_HEAL_FAILED,
d2787b
                    "xattr heal failed for directory  %s ", local->loc.path);
d2787b
+        }
d2787b
     }
d2787b
 
d2787b
     DHT_STACK_UNWIND(lookup, main_frame, 0, 0, local->inode, &local->stbuf,
d2787b
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
d2787b
index 8af7301..2da9817 100644
d2787b
--- a/xlators/cluster/dht/src/dht-selfheal.c
d2787b
+++ b/xlators/cluster/dht/src/dht-selfheal.c
d2787b
@@ -1471,6 +1471,7 @@ dht_selfheal_dir_mkdir(call_frame_t *frame, loc_t *loc, dht_layout_t *layout,
d2787b
 {
d2787b
     int missing_dirs = 0;
d2787b
     int i = 0;
d2787b
+    int op_errno = 0;
d2787b
     int ret = -1;
d2787b
     dht_local_t *local = NULL;
d2787b
     xlator_t *this = NULL;
d2787b
@@ -1493,13 +1494,14 @@ dht_selfheal_dir_mkdir(call_frame_t *frame, loc_t *loc, dht_layout_t *layout,
d2787b
         if (!__is_root_gfid(local->stbuf.ia_gfid)) {
d2787b
             if (local->need_xattr_heal) {
d2787b
                 local->need_xattr_heal = 0;
d2787b
-                ret = dht_dir_xattr_heal(this, local);
d2787b
-                if (ret)
d2787b
-                    gf_msg(this->name, GF_LOG_ERROR, ret,
d2787b
+                ret = dht_dir_xattr_heal(this, local, &op_errno);
d2787b
+                if (ret) {
d2787b
+                    gf_msg(this->name, GF_LOG_ERROR, op_errno,
d2787b
                            DHT_MSG_DIR_XATTR_HEAL_FAILED,
d2787b
                            "%s:xattr heal failed for "
d2787b
                            "directory (gfid = %s)",
d2787b
                            local->loc.path, local->gfid);
d2787b
+                }
d2787b
             } else {
d2787b
                 if (!gf_uuid_is_null(local->gfid))
d2787b
                     gf_uuid_copy(loc->gfid, local->gfid);
d2787b
-- 
d2787b
1.8.3.1
d2787b