diff options
Diffstat (limited to 'xlators/mount/fuse/src/fuse-helpers.c')
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 115 |
1 files changed, 108 insertions, 7 deletions
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index d4dcc2e61bd..4ea3094d1b5 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -317,12 +317,31 @@ get_call_frame_for_req (fuse_state_t *state) return frame; } +inode_t * +fuse_ino_to_inode_gfid_mount (uint64_t ino, xlator_t *fuse) +{ + inode_t **ptr = NULL, *inode = NULL; + xlator_t *active_subvol = NULL; + + if (ino == 1) { + active_subvol = fuse_active_subvol (fuse); + if (active_subvol) + inode = active_subvol->itable->root; + } else { + ptr = (void *)ino; + + if (ptr != NULL) + inode = inode_ref (*ptr); + } + + return inode; +} inode_t * -fuse_ino_to_inode (uint64_t ino, xlator_t *fuse) +fuse_ino_to_inode_normal_mount (uint64_t ino, xlator_t *fuse) { - inode_t *inode = NULL; xlator_t *active_subvol = NULL; + inode_t *inode = NULL; if (ino == 1) { active_subvol = fuse_active_subvol (fuse); @@ -336,17 +355,98 @@ fuse_ino_to_inode (uint64_t ino, xlator_t *fuse) return inode; } -uint64_t -inode_to_fuse_nodeid (inode_t *inode) +inode_t * +fuse_ino_to_inode (uint64_t ino, xlator_t *fuse) +{ + inode_t *inode = NULL; + fuse_private_t *priv = NULL; + + priv = fuse->private; + + if (priv->aux_gfid_mount) { + inode = fuse_ino_to_inode_gfid_mount (ino, fuse); + } else { + inode = fuse_ino_to_inode_normal_mount (ino, fuse); + } + + return inode; +} + +inline uint64_t +inode_to_fuse_nodeid_gfid_mount (xlator_t *this, inode_t *inode, + gf_lookup_namespace_t ns) +{ + inode_t **ptr = NULL; + gf_fuse_nodeid_t *nodeid = NULL; + fuse_private_t *priv = NULL; + uint64_t value = 0; + int32_t ret = 0; + + priv = this->private; + + LOCK (&inode->lock); + { + __inode_ctx_get (inode, this, &value); + nodeid = (void *)value; + + if (nodeid == NULL) { + nodeid = mem_get0 (priv->fuse_nodeid_pool); + if (nodeid == NULL) + goto unlock; + + ret = __inode_ctx_set (inode, this, (uint64_t *)nodeid); + if (ret < 0) + goto unlock; + + nodeid->inode_path_ns = nodeid->inode_gfid_ns = inode; + } + } +unlock: + UNLOCK (&inode->lock); + + if (ret < 0) { + mem_put (nodeid); + nodeid = NULL; + } + + if (nodeid != NULL) { + if (ns == GF_FUSE_GFID_NAMESPACE) + ptr = &nodeid->inode_gfid_ns; + else + ptr = &nodeid->inode_path_ns; + } + + return (uint64_t) ptr; +} + +inline uint64_t +inode_to_fuse_nodeid_normal_mount (inode_t *inode) { - if (!inode) - return 0; if (__is_root_gfid (inode->gfid)) return 1; return (unsigned long) inode; } +uint64_t +inode_to_fuse_nodeid (xlator_t *this, inode_t *inode, gf_lookup_namespace_t ns) +{ + fuse_private_t *priv = NULL; + uint64_t ino = 0; + + priv = this->private; + + if (!inode) + return 0; + + if (priv->aux_gfid_mount) + ino = inode_to_fuse_nodeid_gfid_mount (this, inode, ns); + else + ino = inode_to_fuse_nodeid_normal_mount (inode); + + return ino; +} + GF_MUST_CHECK int32_t fuse_loc_fill (loc_t *loc, fuse_state_t *state, ino_t ino, @@ -580,7 +680,8 @@ fuse_ignore_xattr_set (fuse_private_t *priv, char *key) || (fnmatch ("*.glusterfs.volume-mark", key, FNM_PERIOD) == 0) || (fnmatch ("*.glusterfs.volume-mark.*", - key, FNM_PERIOD) == 0))) + key, FNM_PERIOD) == 0) + || (fnmatch ("glusterfs.gfid.newfile", key, FNM_PERIOD) == 0))) ret = -1; out: |