Blob Blame History Raw
From aceb2395a6d7dc369fe24f8903241168354b3c92 Mon Sep 17 00:00:00 2001
From: Krutika Dhananjay <kdhananj@redhat.com>
Date: Thu, 24 Nov 2016 18:36:28 +0530
Subject: [PATCH 194/206] cluster/afr: Handle rpc errors, xdr failures etc with
 proper NULL checks

        Backport of: http://review.gluster.org/15924

Change-Id: I15d82fcac5ca3fe885f349852fd32e8336417ad4
BUG: 1398331
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/91339
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
---
 xlators/cluster/afr/src/afr-transaction.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 690062f..bff8226 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -1252,12 +1252,23 @@ afr_pre_op_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                 local->op_errno = op_errno;
 		afr_transaction_fop_failed (frame, this, child_index);
         }
-        write_args_cbk = &args_cbk->rsp_list[1];
-        afr_inode_write_fill  (frame, this, (long) i, write_args_cbk->op_ret,
-                               write_args_cbk->op_errno,
-                               &write_args_cbk->prestat,
-                               &write_args_cbk->poststat,
-                               write_args_cbk->xdata);
+
+        /* If the compound fop failed due to saved_frame_unwind(), then
+         * protocol/client fails it even before args_cbk is allocated.
+         * Handle that case by passing the op_ret, op_errno values explicitly.
+         */
+        if ((op_ret == -1) && (args_cbk == NULL)) {
+                afr_inode_write_fill  (frame, this, (long) i, op_ret, op_errno,
+                                       NULL, NULL, NULL);
+        } else {
+                write_args_cbk = &args_cbk->rsp_list[1];
+                afr_inode_write_fill  (frame, this, (long) i,
+                                       write_args_cbk->op_ret,
+                                       write_args_cbk->op_errno,
+                                       &write_args_cbk->prestat,
+                                       &write_args_cbk->poststat,
+                                       write_args_cbk->xdata);
+        }
 
 	call_count = afr_frame_return (frame);
 
-- 
2.9.3