summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2017-06-02 16:28:40 +0530
committerNiels de Vos <ndevos@redhat.com>2017-06-09 11:58:36 +0000
commitd95aa04e482ebe4306df721fe0aa3697a0426a85 (patch)
tree7c97564c3c3cc87ec7ea0343249398eb5bc05f7e /api
parent149db390fd89beee1e8a3d946d4224ba2a9b4711 (diff)
gfapi: change root lookup from nameless to named lookup
Problem: During component resolve we do lookup on root based on root gfid. If we are doing nameless lookup, then md-cache won't be able to serve those lookup. Solution: With this patch, we covert nameless lookup to named lookup on root. Credits: Poornima G <pgurusid@redhat.com> Change-Id: Ie64141936fd294d8969c39e3bd4dbc73ee375c6b BUG: 1458768 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: https://review.gluster.org/17465 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-internal.h1
-rw-r--r--api/src/glfs-resolve.c36
2 files changed, 35 insertions, 2 deletions
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index 6b964b57304..14268f4b3b2 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -363,6 +363,7 @@ int __glfs_cwd_set (struct glfs *fs, inode_t *inode);
int glfs_resolve_base (struct glfs *fs, xlator_t *subvol, inode_t *inode,
struct iatt *iatt);
+
int glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at,
const char *origpath, loc_t *loc, struct iatt *iatt,
int follow, int reval)
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index a2be87f1c1e..44d013ce0bc 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -227,7 +227,39 @@ out:
return ret;
}
+/*
+ * This function can be used to call named lookup on root.
+ * If you use glfs_resolve_base, that will be a nameless lookup.
+ */
+static int
+glfs_resolve_root (struct glfs *fs, xlator_t *subvol, inode_t *inode,
+ struct iatt *iatt)
+{
+ loc_t loc = {0, };
+ int ret = -1;
+ char *path = NULL;
+
+ loc.inode = inode_ref (inode);
+
+ ret = inode_path (loc.inode, NULL, &path);
+ loc.path = path;
+ loc.name = "";
+ /* Having a value in loc.name will help to bypass md-cache check for
+ * nameless lookup.
+ * TODO: Re-visit on nameless lookup and md-cache.
+ * Github issue : https://github.com/gluster/glusterfs/issues/232
+ */
+ loc.parent = inode_ref (inode);
+ if (ret < 0)
+ goto out;
+ ret = syncop_lookup (subvol, &loc, iatt, NULL, NULL, NULL);
+ DECODE_SYNCOP_ERR (ret);
+out:
+ loc_wipe (&loc);
+
+ return ret;
+}
inode_t *
glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent,
@@ -255,7 +287,7 @@ glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent,
if (!force_lookup) {
inode = inode_ref (parent);
} else {
- ret = glfs_resolve_base (fs, subvol, parent, &ciatt);
+ ret = glfs_resolve_root (fs, subvol, parent, &ciatt);
if (!ret)
inode = inode_ref (parent);
}
@@ -398,7 +430,7 @@ priv_glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at,
inode = inode_ref (subvol->itable->root);
if (strcmp (path, "/") == 0)
- glfs_resolve_base (fs, subvol, inode, &ciatt);
+ glfs_resolve_root (fs, subvol, inode, &ciatt);
}
for (component = strtok_r (path, "/", &saveptr);