Blob Blame History Raw
From 5fad99f77264a6c63da4e5b9064b7bfac3356f5c Mon Sep 17 00:00:00 2001
From: Poornima G <pgurusid@redhat.com>
Date: Mon, 18 Jul 2016 21:19:34 +0530
Subject: [PATCH 124/141] dht: Implement ipc fop

ipc is used by md-cache to communicate the list of xattrs that
it is caching, to the upcall xlator. Hence implement this in
dht, such that it winds to all the bricks if the ipc op is
GF_IPC_MDC_TARGET_UPCALL. The ips should not fail if any of
the bricks is down, as md-cache will replay the ipc late when
the brick comes back up.

Change-Id: Ica551a550c04cbb1240c0d211fe831c2e5eb6017
BUG: 1284873
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/15225
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/87037
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
---
 xlators/cluster/dht/src/dht-common.c |   84 ++++++++++++++++++++++++++++++++++
 xlators/cluster/dht/src/dht-common.h |    2 +
 xlators/cluster/dht/src/dht.c        |    1 +
 3 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index c0ebff2..1906376 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -8537,6 +8537,90 @@ err:
 }
 
 
+int32_t
+dht_ipc_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+             int32_t op_ret, int32_t op_errno, dict_t *xdata)
+{
+        dht_local_t  *local                   = NULL;
+        int           this_call_cnt           = 0;
+        dht_layout_t *layout                  = NULL;
+        int           ret                     = -1;
+
+        GF_VALIDATE_OR_GOTO ("dht", frame, out);
+        GF_VALIDATE_OR_GOTO ("dht", this, out);
+        GF_VALIDATE_OR_GOTO ("dht", frame->local, out);
+
+        local = frame->local;
+
+        LOCK (&frame->lock);
+        {
+                if (op_ret < 0 && op_errno != ENOTCONN) {
+                        local->op_errno = op_errno;
+                        goto unlock;
+                }
+                local->op_ret = 0;
+        }
+unlock:
+        UNLOCK (&frame->lock);
+
+        this_call_cnt = dht_frame_return (frame);
+        if (is_last_call (this_call_cnt)) {
+                DHT_STACK_UNWIND (ipc, frame, local->op_ret, local->op_errno,
+                                  NULL);
+        }
+
+out:
+        return 0;
+}
+
+
+int32_t
+dht_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata)
+{
+        dht_local_t  *local    = NULL;
+        int           op_errno = EINVAL;
+        dht_conf_t   *conf     = NULL;
+        int           call_cnt = 0;
+        int           i        = 0;
+
+        VALIDATE_OR_GOTO (frame, err);
+        VALIDATE_OR_GOTO (this, err);
+
+        if (op != GF_IPC_TARGET_UPCALL)
+                goto wind_default;
+
+        VALIDATE_OR_GOTO (this->private, err);
+        conf = this->private;
+
+        local = dht_local_init (frame, NULL, NULL, GF_FOP_IPC);
+        if (!local) {
+                op_errno = ENOMEM;
+                goto err;
+        }
+
+        call_cnt        = conf->subvolume_cnt;
+        local->call_cnt = call_cnt;
+
+        for (i = 0; i < call_cnt; i++) {
+                STACK_WIND (frame, dht_ipc_cbk, conf->subvolumes[i],
+                            conf->subvolumes[i]->fops->ipc, op, xdata);
+        }
+
+        return 0;
+
+err:
+        op_errno = (op_errno == -1) ? errno : op_errno;
+        DHT_STACK_UNWIND (ipc, frame, -1, op_errno, NULL);
+
+        return 0;
+
+wind_default:
+        STACK_WIND (frame, default_ipc_cbk, FIRST_CHILD (this),
+                    FIRST_CHILD (this)->fops->ipc, op, xdata);
+        return 0;
+}
+
+
 int
 dht_forget (xlator_t *this, inode_t *inode)
 {
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 96df385..a4285c5 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -1016,6 +1016,8 @@ int32_t dht_discard(call_frame_t *frame, xlator_t *this, fd_t *fd,
 		    off_t offset, size_t len, dict_t *xdata);
 int32_t dht_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
                     off_t offset, off_t len, dict_t *xdata);
+int32_t dht_ipc (call_frame_t *frame, xlator_t *this, int32_t op,
+                 dict_t *xdata);
 
 int
 dht_set_subvol_range(xlator_t *this);
diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c
index afdfd5c..9096263 100644
--- a/xlators/cluster/dht/src/dht.c
+++ b/xlators/cluster/dht/src/dht.c
@@ -20,6 +20,7 @@ class_methods_t class_methods = {
 };
 
 struct xlator_fops fops = {
+        .ipc         = dht_ipc,
         .lookup      = dht_lookup,
         .mknod       = dht_mknod,
         .create      = dht_create,
-- 
1.7.1