diff options
| author | Vijay Bellur <vijay@gluster.com> | 2012-03-06 11:08:46 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2012-03-06 05:09:35 -0800 | 
| commit | 5fe34f3adbff8c9333f3d3ef47a99a1221aa9afb (patch) | |
| tree | 854e713d4011d3d3a30b81f447634d9c7462771e | |
| parent | 8127a6f35ec3090505cdfbbf28798b4da63a1688 (diff) | |
xlator/lib: Drain out sent requests to avoid multiple STACK_UNWINDs
Change-Id: Id48c468934ac64ec52e279ded8949c2a7a760598
BUG: 789078
Signed-off-by: Vijay Bellur <vijay@gluster.com>
Reviewed-on: http://review.gluster.com/2871
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
| -rw-r--r-- | xlators/lib/src/libxlator.c | 38 | ||||
| -rw-r--r-- | xlators/lib/src/libxlator.h | 1 | 
2 files changed, 25 insertions, 14 deletions
diff --git a/xlators/lib/src/libxlator.c b/xlators/lib/src/libxlator.c index 3a8ab121af9..a6213525923 100644 --- a/xlators/lib/src/libxlator.c +++ b/xlators/lib/src/libxlator.c @@ -92,12 +92,14 @@ cluster_markerxtime_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          if (!this || !frame || !frame->local || !cookie) {                  gf_log ("", GF_LOG_DEBUG, "possible NULL deref"); +                need_unwind = 1;                  goto out;          }          local = frame->local;          if (!local || !local->vol_uuid) {                  gf_log (this->name, GF_LOG_DEBUG, "possible NULL deref"); +                need_unwind = 1;                  goto out;          } @@ -178,14 +180,13 @@ unlock:          }  out: -        if (need_unwind && local->xl_specf_unwind) { +        if (need_unwind && local && local->xl_specf_unwind) {                  frame->local = local->xl_local;                  local->xl_specf_unwind (frame, op_ret,                                           op_errno, dict);                  return 0; -        } - -        STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict); +        } else if (need_unwind) +                STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict);          return 0;  } @@ -199,9 +200,11 @@ cluster_markeruuid_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          xl_marker_local_t   *local      = NULL;          int32_t             ret         = -1;          char                need_unwind = 0; +        char                *vol_uuid   = NULL;          if (!this || !frame || !cookie) {                  gf_log ("", GF_LOG_DEBUG, "possible NULL deref"); +                need_unwind = 1;                  goto out;          } @@ -209,20 +212,23 @@ cluster_markeruuid_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          if (!local) {                  gf_log (this->name, GF_LOG_DEBUG, "possible NULL deref"); +                need_unwind = 1;                  goto out;          }          LOCK (&frame->lock);          {                  callcnt = --local->call_count; +                vol_uuid = local->vol_uuid; +                  if (op_ret) {                          marker_local_incr_errcount (local, op_errno);                          goto unlock;                  } -                ret = dict_get_ptr (dict, GF_XATTR_MARKER_KEY, +                ret = dict_get_bin (dict, GF_XATTR_MARKER_KEY,                                      (void *)&volmark); -                if (!ret) +                if (ret)                          goto unlock;                  if (marker_has_volinfo (local)) { @@ -233,11 +239,13 @@ cluster_markeruuid_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                                  goto unlock;                          } -                        if (volmark->retval) { +                        if (local->retval) +                                goto unlock; +                        else if (volmark->retval) {                                  GF_FREE (local->volmark);                                  local->volmark =                                          memdup (volmark, sizeof (*volmark)); -                                callcnt = 0; +                                local->retval = volmark->retval;                          } else if ((volmark->sec > local->volmark->sec) ||                                     ((volmark->sec == local->volmark->sec) &&                                      (volmark->usec >= local->volmark->usec))) { @@ -249,8 +257,9 @@ cluster_markeruuid_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  } else {                          local->volmark = memdup (volmark, sizeof (*volmark));                          VALIDATE_OR_GOTO (local->volmark, unlock); +                        uuid_unparse (volmark->uuid, vol_uuid);                          if (volmark->retval) -                                callcnt = 0; +                                local->retval = volmark->retval;                  }          }  unlock: @@ -265,8 +274,9 @@ unlock:                          if (!dict)                                  dict = dict_new(); -                        if (dict_set_ptr (dict, GF_XATTR_MARKER_KEY, -                                          local->volmark)) { +                        if (dict_set_bin (dict, GF_XATTR_MARKER_KEY, +                                          local->volmark, +                                          sizeof (struct volume_mark))) {                                  op_ret = -1;                                  op_errno = ENOMEM;                          } @@ -278,14 +288,14 @@ unlock:          }   out: -        if (need_unwind && local->xl_specf_unwind) { +        if (need_unwind && local && local->xl_specf_unwind) {                  frame->local = local->xl_local;                  local->xl_specf_unwind (frame, op_ret,                                          op_errno, dict);                  return 0; +        } else if (need_unwind){ +                STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict);          } - -        STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict);          return 0;  } diff --git a/xlators/lib/src/libxlator.h b/xlators/lib/src/libxlator.h index 75a36379848..1bc20ac6b92 100644 --- a/xlators/lib/src/libxlator.h +++ b/xlators/lib/src/libxlator.h @@ -74,6 +74,7 @@ struct marker_str {          xlator_specf_unwind_t  xl_specf_unwind;          void                  *xl_local;          char                  *vol_uuid; +        uint8_t                retval;  };  typedef struct marker_str xl_marker_local_t;  | 
