14f8ab
From d8c98e9785e652692d928a2efbbb571703f728b0 Mon Sep 17 00:00:00 2001
14f8ab
From: Anuradha Talur <atalur@commvault.com>
14f8ab
Date: Wed, 24 Apr 2019 12:35:08 -0700
14f8ab
Subject: [PATCH 156/169] cloudsync: Fix bug in cloudsync-fops-c.py
14f8ab
14f8ab
In some of the fops generated by generator.py, xdata request
14f8ab
was not being wound to the child xlator correctly.
14f8ab
14f8ab
This was happening because when though the logic in
14f8ab
cloudsync-fops-c.py was correct, generator.py was generating
14f8ab
a resultant code that omits this logic.
14f8ab
14f8ab
Made changes in cloudsync-fops-c.py so that correct code is
14f8ab
produced.
14f8ab
14f8ab
backport of: https://review.gluster.org/#/c/glusterfs/+/22617/
14f8ab
14f8ab
> Change-Id: I6f25bdb36ede06fd03be32c04087a75639d79150
14f8ab
> updates: bz#1642168
14f8ab
> Signed-off-by: Anuradha Talur <atalur@commvault.com>
14f8ab
14f8ab
Change-Id: I87cc71e98c2c6cec78a6e84850fc8d82f8dd4dfd
14f8ab
Signed-off-by: Susant Palai <spalai@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/172195
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
14f8ab
---
14f8ab
 xlators/features/cloudsync/src/cloudsync-fops-c.py | 24 +++++++++++++++++++---
14f8ab
 1 file changed, 21 insertions(+), 3 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync-fops-c.py b/xlators/features/cloudsync/src/cloudsync-fops-c.py
14f8ab
index 8878b70..c444ea6 100755
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync-fops-c.py
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync-fops-c.py
14f8ab
@@ -39,7 +39,15 @@ cs_@NAME@ (call_frame_t *frame, xlator_t *this,
14f8ab
         else
14f8ab
                 state = GF_CS_LOCAL;
14f8ab
 
14f8ab
-        local->xattr_req = xdata ? dict_ref (xdata) : (xdata = dict_new ());
14f8ab
+        xdata = xdata ? dict_ref (xdata) : dict_new ();
14f8ab
+
14f8ab
+        if (!xdata) {
14f8ab
+                gf_msg (this->name, GF_LOG_ERROR, 0, 0, "insufficient memory");
14f8ab
+                op_errno = ENOMEM;
14f8ab
+                goto err;
14f8ab
+        }
14f8ab
+
14f8ab
+        local->xattr_req = xdata;
14f8ab
 
14f8ab
         ret = dict_set_uint32 (local->xattr_req, GF_CS_OBJECT_STATUS, 1);
14f8ab
         if (ret) {
14f8ab
@@ -187,19 +195,29 @@ int32_t
14f8ab
 cs_@NAME@ (call_frame_t *frame, xlator_t *this,
14f8ab
            @LONG_ARGS@)
14f8ab
 {
14f8ab
+        int              op_errno = EINVAL;
14f8ab
         cs_local_t      *local = NULL;
14f8ab
         int              ret   = 0;
14f8ab
 
14f8ab
         local = cs_local_init (this, frame, loc, NULL, GF_FOP_@UPNAME@);
14f8ab
         if (!local) {
14f8ab
                 gf_msg (this->name, GF_LOG_ERROR, 0, 0, "local is NULL");
14f8ab
+                op_errno = ENOMEM;
14f8ab
                 goto err;
14f8ab
         }
14f8ab
 
14f8ab
         if (loc->inode->ia_type == IA_IFDIR)
14f8ab
                 goto wind;
14f8ab
 
14f8ab
-        local->xattr_req = xdata ? dict_ref (xdata) : dict_new ();
14f8ab
+        xdata = xdata ? dict_ref (xdata) : dict_new ();
14f8ab
+
14f8ab
+        if (!xdata) {
14f8ab
+                gf_msg (this->name, GF_LOG_ERROR, 0, 0, "insufficient memory");
14f8ab
+                op_errno = ENOMEM;
14f8ab
+                goto err;
14f8ab
+        }
14f8ab
+
14f8ab
+        local->xattr_req = xdata;
14f8ab
 
14f8ab
         ret = dict_set_uint32 (local->xattr_req, GF_CS_OBJECT_STATUS, 1);
14f8ab
         if (ret) {
14f8ab
@@ -215,7 +233,7 @@ wind:
14f8ab
 
14f8ab
         return 0;
14f8ab
 err:
14f8ab
-        CS_STACK_UNWIND (@NAME@, frame, -1, errno, @CBK_ERROR_ARGS@);
14f8ab
+        CS_STACK_UNWIND (@NAME@, frame, -1, op_errno, @CBK_ERROR_ARGS@);
14f8ab
 
14f8ab
         return 0;
14f8ab
 }
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab