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