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