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