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