diff options
| author | Poornima G <pgurusid@redhat.com> | 2016-06-05 00:06:11 -0400 | 
|---|---|---|
| committer | Raghavendra G <rgowdapp@redhat.com> | 2016-06-10 04:03:54 -0700 | 
| commit | 57372682b174c1483c41e8bc2474dcfebf0b86df (patch) | |
| tree | 8cb8e92e0f8767f4894bcce21c5c95a99038a8dc | |
| parent | 9c6f0d0ad7a1212f451f3cc502da3329c3534c31 (diff) | |
protocol: Add framework to send transaction id with recall
Backport of: http://review.gluster.org/#/c/14647/
Issue:
The upcall(cache invalidation/recall) event is sent from the bricks
to clients. In AFR/EC setup, it can so happen that all the bricks
will send the upcall for the same event, and if AFR/EC doesn't filter
out these duplicate notifications, the logic above cluster xlators
can fail.
Solution:
Use transaction id to filter out duplicate notifications.
This patch adds framework for duplicate notifications.
AFR/EC can build up on this patch for deduping the notifications
Change-Id: I66b08e63b8799bc5932f2b2545376138a5701168
BUG: 1337638
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/14648
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
| -rw-r--r-- | libglusterfs/src/upcall-utils.h | 6 | ||||
| -rw-r--r-- | rpc/xdr/src/glusterfs3-xdr.x | 2 | ||||
| -rw-r--r-- | rpc/xdr/src/glusterfs3.h | 30 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-callback.c | 11 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server.c | 9 | 
5 files changed, 47 insertions, 11 deletions
diff --git a/libglusterfs/src/upcall-utils.h b/libglusterfs/src/upcall-utils.h index 7acfff15a0b..78db806503f 100644 --- a/libglusterfs/src/upcall-utils.h +++ b/libglusterfs/src/upcall-utils.h @@ -37,8 +37,10 @@ struct gf_upcall_cache_invalidation {  };  struct gf_upcall_recall_lease { -        uint32_t  lease_type; -        /* TODO: Add the lease type it can be downgraded to */ +        uint32_t  lease_type; /* Lease type to which client can downgrade to*/ +        uuid_t    tid;        /* transaction id of the fop that caused +                                 the recall */ +        dict_t   *dict;  };  #endif /* _UPCALL_UTILS_H */ diff --git a/rpc/xdr/src/glusterfs3-xdr.x b/rpc/xdr/src/glusterfs3-xdr.x index eefad57ce80..37fda8551b4 100644 --- a/rpc/xdr/src/glusterfs3-xdr.x +++ b/rpc/xdr/src/glusterfs3-xdr.x @@ -330,6 +330,8 @@ struct gfs3_lease_rsp {  struct gfs3_recall_lease_req {          opaque       gfid[16];          unsigned int lease_type; +        opaque       tid[16]; +        opaque       xdata<>; /* Extra data */  }  ;   struct gfs3_inodelk_req { diff --git a/rpc/xdr/src/glusterfs3.h b/rpc/xdr/src/glusterfs3.h index b1d43f95e87..57a289b1259 100644 --- a/rpc/xdr/src/glusterfs3.h +++ b/rpc/xdr/src/glusterfs3.h @@ -204,11 +204,12 @@ gf_proto_lease_from_lease (struct gf_proto_lease *gf_proto_lease, struct gf_leas          memcpy (gf_proto_lease->lease_id, gf_lease->lease_id, LEASE_ID_SIZE);  } -static inline void +static inline int  gf_proto_recall_lease_to_upcall (struct gfs3_recall_lease_req *recall_lease,                                   struct gf_upcall *gf_up_data)  {          struct gf_upcall_recall_lease *tmp = NULL; +        int    ret                         = 0;          GF_VALIDATE_OR_GOTO(THIS->name, recall_lease, out);          GF_VALIDATE_OR_GOTO(THIS->name, gf_up_data, out); @@ -216,25 +217,40 @@ gf_proto_recall_lease_to_upcall (struct gfs3_recall_lease_req *recall_lease,          tmp = (struct gf_upcall_recall_lease *)gf_up_data->data;          tmp->lease_type = recall_lease->lease_type;          memcpy (gf_up_data->gfid, recall_lease->gfid, 16); +        memcpy (tmp->tid, recall_lease->tid, 16); + +        GF_PROTOCOL_DICT_UNSERIALIZE (THIS, tmp->dict, +                                      (recall_lease->xdata).xdata_val, +                                      (recall_lease->xdata).xdata_len, ret, +                                      errno, out);  out: -        return; +        return ret;  } -static inline void -gf_proto_recall_lease_from_upcall (struct gfs3_recall_lease_req *recall_lease, +static inline int +gf_proto_recall_lease_from_upcall (xlator_t *this, +                                   struct gfs3_recall_lease_req *recall_lease,                                     struct gf_upcall *gf_up_data)  {          struct gf_upcall_recall_lease *tmp = NULL; +        int    ret                         = 0; -        GF_VALIDATE_OR_GOTO(THIS->name, recall_lease, out); -        GF_VALIDATE_OR_GOTO(THIS->name, gf_up_data, out); +        GF_VALIDATE_OR_GOTO(this->name, recall_lease, out); +        GF_VALIDATE_OR_GOTO(this->name, gf_up_data, out);          tmp = (struct gf_upcall_recall_lease *)gf_up_data->data;          recall_lease->lease_type = tmp->lease_type;          memcpy (recall_lease->gfid, gf_up_data->gfid, 16); +        memcpy (recall_lease->tid, tmp->tid, 16); + +        GF_PROTOCOL_DICT_SERIALIZE (this, tmp->dict, +                                    &(recall_lease->xdata).xdata_val, +                                    (recall_lease->xdata).xdata_len, ret, out); +        if (ret > 0) +                ret = -ret;  out: -        return; +        return ret;  } diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c index 4935ef5de7c..09097e9981f 100644 --- a/xlators/protocol/client/src/client-callback.c +++ b/xlators/protocol/client/src/client-callback.c @@ -63,7 +63,10 @@ client_cbk_recall_lease (struct rpc_clnt *rpc, void *mydata, void *data)          }          upcall_data.data = &rl_data; -        gf_proto_recall_lease_to_upcall (&recall_lease, &upcall_data); +        ret = gf_proto_recall_lease_to_upcall (&recall_lease, &upcall_data); +        if (ret < 0) +                goto out; +          upcall_data.event_type = GF_UPCALL_RECALL_LEASE;          gf_msg_trace (THIS->name, 0, "Upcall gfid = %s, ret = %d", @@ -72,6 +75,12 @@ client_cbk_recall_lease (struct rpc_clnt *rpc, void *mydata, void *data)          default_notify (THIS, GF_EVENT_UPCALL, &upcall_data);  out: +        if (recall_lease.xdata.xdata_val) +                free (recall_lease.xdata.xdata_val); + +        if (rl_data.dict) +                dict_unref (rl_data.dict); +          return ret;  } diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 99874acae72..10009e2b4a7 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -1208,7 +1208,11 @@ server_process_event_upcall (xlator_t *this, void *data)                  xdrproc = (xdrproc_t)xdr_gfs3_cbk_cache_invalidation_req;                  break;          case GF_UPCALL_RECALL_LEASE: -                gf_proto_recall_lease_from_upcall (&gf_recall_lease, upcall_data); +                ret = gf_proto_recall_lease_from_upcall (this, &gf_recall_lease, +                                                         upcall_data); +                if (ret < 0) +                        goto out; +                  up_req = &gf_recall_lease;                  cbk_procnum = GF_CBK_RECALL_LEASE;                  xdrproc = (xdrproc_t)xdr_gfs3_recall_lease_req; @@ -1243,6 +1247,9 @@ server_process_event_upcall (xlator_t *this, void *data)          pthread_mutex_unlock (&conf->mutex);          ret = 0;  out: +        if ((gf_recall_lease.xdata).xdata_val) +                GF_FREE ((gf_recall_lease.xdata).xdata_val); +          return ret;  }  | 
