diff options
| author | Amar Tumballi <amar@gluster.com> | 2011-06-10 02:50:18 +0000 | 
|---|---|---|
| committer | Anand Avati <avati@gluster.com> | 2011-06-14 00:13:51 -0700 | 
| commit | 5522ac20241436be6a005058b6360f4339eb678c (patch) | |
| tree | cbf9e466418d97e8f46cfdd1121a8ad86fc70aca | |
| parent | c5321286e540153ff04d189b20c2957776e2b7d5 (diff) | |
loc_t: add 'gfid' and 'pargfid' fields
these fields are used mainly in case of selfheal path, where
'inode->gfid'||'parent->gfid' is not yet set.
These fields in 'loc' will have lower precedence than 'inode->gfid'
in client protocol.
also contains 'Pranith <pranithk@gluster.com>'s patch to set proper
loc->gfid during afr selfheal
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2346 (Log message enhancements in GlusterFS - phase 1)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
| -rw-r--r-- | libglusterfs/src/xlator.c | 3 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 12 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 18 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-dir-write.c | 3 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-entry.c | 2 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr.h | 3 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 5 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-linkfile.c | 3 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 4 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client3_1-fops.c | 159 | 
10 files changed, 178 insertions, 34 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index b8f800c7050..16020c0d277 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -1663,6 +1663,9 @@ loc_copy (loc_t *dst, loc_t *src)  	dst->ino = src->ino; +        uuid_copy (dst->gfid, src->gfid); +        uuid_copy (dst->pargfid, src->pargfid); +  	if (src->inode)  		dst->inode = inode_ref (src->inode); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index e587ae5784d..60fd777614a 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -78,9 +78,19 @@ typedef int32_t (*event_notify_fn_t) (xlator_t *this, int32_t event, void *data,  struct _loc {          const char *path;          const char *name; -        ino_t       ino;          inode_t    *inode;          inode_t    *parent; +        /* Currently all location based operations are through 'gfid' of inode. +         * But the 'inode->gfid' only gets set in higher most layer (as in, +         * 'fuse', 'protocol/server', or 'nfs/server'). So if translators want +         * to send fops on a inode before the 'inode->gfid' is set, they have to +         * make use of below 'gfid' fields +         */ +        uuid_t      gfid; +        uuid_t      pargfid; + +        /* ideally, should not be used */ +        ino_t       ino;  }; diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index ef070a188f7..aa88d609837 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -509,6 +509,16 @@ afr_up_children_count (int child_count, unsigned char *child_up)          return ret;  } +void +afr_update_loc_gfids (loc_t *loc, struct iatt *buf, struct iatt *postparent) +{ +        GF_ASSERT (loc); +        GF_ASSERT (buf); + +        uuid_copy (loc->gfid, buf->ia_gfid); +        if (postparent) +                uuid_copy (loc->pargfid, postparent->ia_gfid); +}  ino64_t  afr_itransform (ino64_t ino, int child_count, int child_index) @@ -906,6 +916,10 @@ afr_fresh_lookup_cbk (call_frame_t *frame, void *cookie,                          *lookup_buf = *buf; +                        uuid_copy (local->loc.gfid, buf->ia_gfid); +                        uuid_copy (local->loc.pargfid, +                                   postparent->ia_gfid); +                          lookup_buf->ia_ino = afr_itransform (buf->ia_ino,                                                               priv->child_count,                                                               child_index); @@ -935,6 +949,10 @@ afr_fresh_lookup_cbk (call_frame_t *frame, void *cookie,                                  local->cont.lookup.postparent          = *postparent;                                  *lookup_buf = *buf; + +                                uuid_copy (local->loc.gfid, buf->ia_gfid); +                                uuid_copy (local->loc.pargfid, +                                           postparent->ia_gfid);                          }                  } diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c index 06559ede08e..30fcf92b60a 100644 --- a/xlators/cluster/afr/src/afr-dir-write.c +++ b/xlators/cluster/afr/src/afr-dir-write.c @@ -69,6 +69,9 @@ afr_build_parent_loc (loc_t *parent, loc_t *child)          parent->inode  = inode_ref (child->parent);          parent->parent = inode_parent (parent->inode, 0, NULL);          parent->ino    = parent->inode->ino; + +        if (!uuid_is_null (child->pargfid)) +                uuid_copy (parent->gfid, child->pargfid);  }  /* {{{ create */ diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index 8f7133b9730..e9e8a329e38 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -1591,6 +1591,8 @@ afr_sh_entry_impunge_recreate_lookup_cbk (call_frame_t *impunge_frame,          impunge_sh->parentbuf = *postparent;          impunge_local->cont.lookup.buf = *buf; +        afr_update_loc_gfids (&impunge_local->loc, buf, postparent); +          type = buf->ia_type;          switch (type) { diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index b806a524320..aaf3dbcc89d 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -735,6 +735,9 @@ afr_build_parent_loc (loc_t *parent, loc_t *child);  int  afr_up_children_count (int child_count, unsigned char *child_up); +void +afr_update_loc_gfids (loc_t *loc, struct iatt *buf, struct iatt *postparent); +  int  afr_locked_nodes_count (unsigned char *locked_nodes, int child_count); diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 113c7a18d8e..267ef8f6afa 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -4028,7 +4028,8 @@ dht_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  if (prev->this == dht_first_up_subvol (this)) {                          local->ia_ino = local->stbuf.ia_ino;                  } - +                if (uuid_is_null (local->loc.gfid) && !op_ret) +                        uuid_copy (local->loc.gfid, stbuf->ia_gfid);          }  unlock:          UNLOCK (&frame->lock); @@ -4086,6 +4087,8 @@ dht_mkdir_hashed_cbk (call_frame_t *frame, void *cookie,          local->call_cnt = conf->subvolume_cnt - 1;          if (local->call_cnt == 0) { +                if (uuid_is_null (local->loc.gfid) && !op_ret) +                        uuid_copy (local->loc.gfid, stbuf->ia_gfid);                  dht_selfheal_directory (frame, dht_mkdir_selfheal_cbk,                                          &local->loc, layout);          } diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c index 23314c1a5d7..82419a68bc1 100644 --- a/xlators/cluster/dht/src/dht-linkfile.c +++ b/xlators/cluster/dht/src/dht-linkfile.c @@ -92,6 +92,9 @@ dht_linkfile_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          local->linkfile.stbuf = *stbuf; +        if (uuid_is_null (local->linkfile.loc.inode->gfid)) +                uuid_copy (local->linkfile.loc.gfid, stbuf->ia_gfid); +          STACK_WIND (frame, dht_linkfile_xattr_cbk,                      prev->this, prev->this->fops->setxattr,                      &local->linkfile.loc, local->linkfile.xattr, 0); diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 583fb948378..971ea9cf5da 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -620,7 +620,7 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx)                  goto out;          } -        memcpy (req.gfid,  inode->gfid, 16); +        memcpy (req.gfid, inode->gfid, 16);          req.path  = (char *)local->loc.path;          gf_log (frame->this->name, GF_LOG_DEBUG, @@ -701,7 +701,7 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx)          path            = NULL;          frame->local    = local; -        memcpy (req.gfid,  inode->gfid, 16); +        memcpy (req.gfid, inode->gfid, 16);          req.flags    = gf_flags_from_flags (fdctx->flags);          req.wbflags  = fdctx->wbflags;          req.path     = (char *)local->loc.path; diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index 4195811f7f2..e6d7e60c2b5 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -2530,10 +2530,17 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        if (args->loc->parent) -                memcpy (req.pargfid, args->loc->parent->gfid, 16); -        else -                memcpy (req.gfid, args->loc->inode->gfid, 16); +        if (args->loc->parent) { +                if (!uuid_is_null (args->loc->parent->gfid)) +                        memcpy (req.pargfid, args->loc->parent->gfid, 16); +                else +                        memcpy (req.pargfid, args->loc->pargfid, 16); +        } else { +                if (!uuid_is_null (args->loc->inode->gfid)) +                        memcpy (req.gfid, args->loc->inode->gfid, 16); +                else +                        memcpy (req.gfid, args->loc->gfid, 16); +        }          if (args->dict) {                  content = dict_get (args->dict, GF_CONTENT_KEY); @@ -2640,7 +2647,11 @@ client3_1_stat (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          conf = this->private; @@ -2679,7 +2690,11 @@ client3_1_truncate (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          req.offset = args->offset; @@ -2780,7 +2795,11 @@ client3_1_access (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          req.mask = args->mask; @@ -2821,7 +2840,11 @@ client3_1_readlink (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          req.size = args->size;          conf = this->private; @@ -2864,7 +2887,11 @@ client3_1_unlink (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->parent))                  goto unwind; -        memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        if (!uuid_is_null (args->loc->parent->gfid)) +                memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        else +                memcpy (req.pargfid, args->loc->pargfid, 16); +          req.path  = (char *)args->loc->path;          req.bname = (char *)args->loc->name;          conf = this->private; @@ -2905,7 +2932,11 @@ client3_1_rmdir (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->parent))                  goto unwind; -        memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        if (!uuid_is_null (args->loc->parent->gfid)) +                memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        else +                memcpy (req.pargfid, args->loc->pargfid, 16); +          req.path  = (char *)args->loc->path;          req.bname = (char *)args->loc->name;          req.flags = args->flags; @@ -2956,7 +2987,11 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        if (!uuid_is_null (args->loc->parent->gfid)) +                memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        else +                memcpy (req.pargfid, args->loc->pargfid, 16); +          req.path     = (char *)args->loc->path;          req.linkname = (char *)args->linkname;          req.bname    = (char *)args->loc->name; @@ -3023,8 +3058,15 @@ client3_1_rename (call_frame_t *frame, xlator_t *this,                args->newloc->parent))                  goto unwind; -        memcpy (req.oldgfid,  args->oldloc->parent->gfid, 16); -        memcpy (req.newgfid, args->newloc->parent->gfid, 16); +        if (!uuid_is_null (args->oldloc->parent->gfid)) +                memcpy (req.oldgfid,  args->oldloc->parent->gfid, 16); +        else +                memcpy (req.oldgfid, args->oldloc->pargfid, 16); + +        if (!uuid_is_null (args->newloc->parent->gfid)) +                memcpy (req.newgfid, args->newloc->parent->gfid, 16); +        else +                memcpy (req.newgfid, args->newloc->pargfid, 16);          req.oldpath = (char *)args->oldloc->path;          req.oldbname =  (char *)args->oldloc->name; @@ -3069,8 +3111,15 @@ client3_1_link (call_frame_t *frame, xlator_t *this,                args->newloc->parent))                  goto unwind; -        memcpy (req.oldgfid,  args->oldloc->inode->gfid, 16); -        memcpy (req.newgfid, args->newloc->parent->gfid, 16); +        if (!uuid_is_null (args->oldloc->inode->gfid)) +                memcpy (req.oldgfid,  args->oldloc->inode->gfid, 16); +        else +                memcpy (req.oldgfid, args->oldloc->gfid, 16); + +        if (!uuid_is_null (args->newloc->parent->gfid)) +                memcpy (req.newgfid, args->newloc->parent->gfid, 16); +        else +                memcpy (req.newgfid, args->newloc->pargfid, 16);          local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t);          if (!local) { @@ -3131,7 +3180,11 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        if (!uuid_is_null (args->loc->parent->gfid)) +                memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        else +                memcpy (req.pargfid, args->loc->pargfid, 16); +          req.path   = (char *)args->loc->path;          req.bname  = (char *)args->loc->name;          req.mode   = args->mode; @@ -3209,7 +3262,11 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        if (!uuid_is_null (args->loc->parent->gfid)) +                memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        else +                memcpy (req.pargfid, args->loc->pargfid, 16); +          req.path  = (char *)args->loc->path;          req.bname = (char *)args->loc->name;          req.mode  = args->mode; @@ -3287,7 +3344,11 @@ client3_1_create (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        if (!uuid_is_null (args->loc->parent->gfid)) +                memcpy (req.pargfid,  args->loc->parent->gfid, 16); +        else +                memcpy (req.pargfid, args->loc->pargfid, 16); +          req.path  = (char *)args->loc->path;          req.bname = (char *)args->loc->name;          req.mode  = args->mode; @@ -3366,7 +3427,11 @@ client3_1_open (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.flags = gf_flags_from_flags (args->flags);          req.wbflags = args->wbflags;          req.path = (char *)args->loc->path; @@ -3774,7 +3839,11 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this,          loc_copy (&local->loc, args->loc);          frame->local = local; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          conf = this->private; @@ -3877,9 +3946,12 @@ client3_1_statfs (call_frame_t *frame, xlator_t *this,          if (!args->loc)                  goto unwind; -        if (args->loc->inode) -	        memcpy (req.gfid,  args->loc->inode->gfid, 16); -        else +        if (args->loc->inode) { +                if (!uuid_is_null (args->loc->inode->gfid)) +                        memcpy (req.gfid,  args->loc->inode->gfid, 16); +                else +                        memcpy (req.gfid, args->loc->gfid, 16); +        } else  		req.gfid[15] = 1;          req.path = (char *)args->loc->path; @@ -3922,7 +3994,11 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          if (args->dict) {                  ret = dict_allocate_and_serialize (args->dict,                                                     &req.dict.dict_val, @@ -4224,7 +4300,10 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,          local->iobref = rsp_iobref;          rsp_iobref = NULL; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16);          req.namelen = 1; /* Use it as a flag */          req.path = (char *)args->loc->path;          req.name = (char *)args->name; @@ -4343,7 +4422,11 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,          local->iobref = rsp_iobref;          rsp_iobref = NULL; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          if (args->dict) {                  ret = dict_allocate_and_serialize (args->dict,                                                     &req.dict.dict_val, @@ -4551,7 +4634,11 @@ client3_1_removexattr (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          req.name = (char *)args->name; @@ -4686,7 +4773,11 @@ client3_1_inodelk (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          if (args->cmd == F_GETLK || args->cmd == F_GETLK64)                  gf_cmd = GF_LK_GETLK;          else if (args->cmd == F_SETLK || args->cmd == F_SETLK64) @@ -4845,7 +4936,11 @@ client3_1_entrylk (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid,  args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid,  args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          req.cmd = args->cmd_entrylk;          req.type = args->type; @@ -5255,7 +5350,11 @@ client3_1_setattr (call_frame_t *frame, xlator_t *this,          if (!(args->loc && args->loc->inode))                  goto unwind; -        memcpy (req.gfid, args->loc->inode->gfid, 16); +        if (!uuid_is_null (args->loc->inode->gfid)) +                memcpy (req.gfid, args->loc->inode->gfid, 16); +        else +                memcpy (req.gfid, args->loc->gfid, 16); +          req.path = (char *)args->loc->path;          req.valid = args->valid;          gf_stat_from_iatt (&req.stbuf, args->stbuf);  | 
