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