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