diff options
Diffstat (limited to 'xlators')
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 186 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 4 | 
2 files changed, 17 insertions, 173 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 4a8e035c21c..3a671ccea9e 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -281,163 +281,6 @@ out:  }  int -dht_lookup_root_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, -                         int op_ret, int op_errno, -                         inode_t *inode, struct iatt *stbuf, dict_t *xattr, -                         struct iatt *postparent) -{ -        dht_conf_t   *conf                    = NULL; -        dht_local_t  *local                   = NULL; -        int           this_call_cnt           = 0; -        call_frame_t *prev                    = NULL; -        dht_layout_t *layout                  = NULL; -        int           ret                     = -1; -        int           is_dir                  = 0; - -        GF_VALIDATE_OR_GOTO ("dht", frame, out); -        GF_VALIDATE_OR_GOTO ("dht", this, out); -        GF_VALIDATE_OR_GOTO ("dht", frame->local, out); -        GF_VALIDATE_OR_GOTO ("dht", this->private, out); -        GF_VALIDATE_OR_GOTO ("dht", cookie, out); - -        conf  = this->private; -        local = frame->local; -        prev  = cookie; - -        layout = local->layout; - -        LOCK (&frame->lock); -        { -                ret = dht_layout_merge (this, layout, prev->this, -                                        op_ret, op_errno, xattr); - -                if (op_ret == -1) { -                        local->op_errno = op_errno; -                        gf_log (this->name, GF_LOG_ERROR, -                                "lookup of %s on %s returned error (%s)", -                                local->loc.path, prev->this->name, -                                strerror (op_errno)); -                        goto unlock; -                } - -                is_dir = check_is_dir (inode, stbuf, xattr); -                if (!is_dir) { -                        gf_log (this->name, GF_LOG_CRITICAL, -                                "lookup of %s on %s returned non dir 0%o", -                                local->loc.path, prev->this->name, -                                stbuf->ia_type); -                        goto unlock; -                } - -                local->op_ret = 0; -                if (local->xattr == NULL) { -                        local->xattr = dict_ref (xattr); -                } else { -                        dht_aggregate_xattr (local->xattr, xattr); -                } - -                if (local->inode == NULL) -                        local->inode = inode_ref (inode); - -                dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); - -                if (prev->this == dht_first_up_subvol (this)) { -                        local->ia_ino = local->stbuf.ia_ino; -                } - -        } -unlock: -        UNLOCK (&frame->lock); - - -        this_call_cnt = dht_frame_return (frame); - -        if (is_last_call (this_call_cnt)) { -                if (local->op_ret == 0) { -                        ret = dht_layout_normalize (this, &local->loc, layout); -                        if (ret != 0) { -                                gf_log (this->name, GF_LOG_INFO, -                                        "fixing assignment on %s", -                                        local->loc.path); -                        } - -                        ret = dht_layout_set (this, local->inode, layout); -                } - -                DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno, -                                  local->inode, &local->stbuf, local->xattr, -                                  &local->postparent); -        } - -out: -        return ret; -} - -static int -dht_do_fresh_lookup_on_root (xlator_t *this, call_frame_t *frame) -{ -        dht_local_t  *local    = NULL; -        dht_conf_t   *conf     = NULL; -        int           ret      = -1; -        int           call_cnt = 0; -        int           i        = 0; -        int           op_errno = EINVAL; - -        GF_VALIDATE_OR_GOTO ("dht", this, out); -        GF_VALIDATE_OR_GOTO ("dht", frame, unwind); -        GF_VALIDATE_OR_GOTO ("dht", frame->local, unwind); - -        local = frame->local; -        conf = this->private; -        if (!conf) -                goto err; - -        if (local->layout) { -                dht_layout_unref (this, local->layout); -                local->layout = NULL; -        } - -        if (local->xattr != NULL) { -                dict_unref (local->xattr); -                local->xattr = NULL; -        } - -        ret = dict_set_uint32 (local->xattr_req, -                               "trusted.glusterfs.dht", 4 * 4); -        if (ret) -                gf_log (this->name, GF_LOG_DEBUG, -                        "failed to set the dict entry for dht"); - -        call_cnt = local->call_cnt = conf->subvolume_cnt; - -        local->layout = dht_layout_new (this, -                                        conf->subvolume_cnt); -        if (!local->layout) { -                local->op_errno = ENOMEM; -                goto err; -        } - -        for (i = 0; i < call_cnt; i++) { -                STACK_WIND (frame, dht_lookup_root_dir_cbk, -                            conf->subvolumes[i], -                            conf->subvolumes[i]->fops->lookup, -                            &local->loc, local->xattr_req); -        } - -        return 0; -err: -        DHT_STACK_UNWIND (lookup, frame, -1, local->op_errno, -                          local->inode, &local->stbuf, local->xattr, -                          &local->postparent); - -        return 0; -unwind: -        DHT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL); -out: -        return -1; -} - -int  dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                      int op_ret, int op_errno,                      inode_t *inode, struct iatt *stbuf, dict_t *xattr, @@ -451,7 +294,6 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          int           ret  = -1;          int           is_dir = 0;          int           is_linkfile = 0; -        unsigned char root_gfid[16] = {0,};          GF_VALIDATE_OR_GOTO ("dht", frame, err);          GF_VALIDATE_OR_GOTO ("dht", this, err); @@ -479,9 +321,9 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,  			}                          if (op_errno == ESTALE) {                                  /* propogate the ESTALE to parent. -                                 * setting local->layout_mismatch would send +                                 * setting local->return_estale would send                                   * ESTALE to parent. */ -                                local->layout_mismatch = 1; +                                local->return_estale = 1;                          }                          goto unlock; @@ -508,7 +350,7 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                          gf_log (this->name, GF_LOG_INFO,                                  "linkfile found in revalidate for %s",                                  local->loc.path); -                        local->layout_mismatch = 1; +                        local->return_estale = 1;                          goto unlock;                  } @@ -556,20 +398,18 @@ out:                      && (conf && conf->unhashed_sticky_bit)) {                          local->stbuf.ia_prot.sticky = 1;                  } -                  if (local->layout_mismatch) { +                        /* Found layout mismatch in the directory, need to +                           fix this in the inode context */ +                        dht_layout_unref (this, local->layout); +                        local->layout = NULL; +                        dht_lookup_directory (frame, this, &local->loc); +                        return 0; +                } + +                if (local->return_estale) {                          local->op_ret = -1;                          local->op_errno = ESTALE; - -                        /* Because for 'root' inode, there is no FRESH lookup -                         * sent from FUSE layer upon ESTALE, we need to handle -                         * that one case here */ -                        root_gfid[15] = 1; -                        if (!local->loc.parent && -                            !uuid_compare (local->loc.inode->gfid, root_gfid)) { -                                dht_do_fresh_lookup_on_root (this, frame); -                                return 0; -                        }                  }                  WIPE (&local->postparent); @@ -1203,7 +1043,7 @@ dht_lookup (call_frame_t *frame, xlator_t *this,  		for (i = 0; i < layout->cnt; i++) {  			subvol = layout->list[i].xlator; -			 +  			STACK_WIND (frame, dht_revalidate_cbk,  				    subvol, subvol->fops->lookup,  				    &local->loc, local->xattr_req); diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 67cc16e4304..bc84098b7ae 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -132,6 +132,10 @@ struct dht_local {          /*Marker Related*/          struct marker_str    marker; + +        /* flag used to make sure we need to return estale in +           {lookup,revalidate}_cbk */ +        char    return_estale;  };  typedef struct dht_local dht_local_t;  | 
