summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2017-06-02 16:28:40 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-07-06 14:04:34 +0000
commit3315740ef0dd3606206355dfd46a57f045cbd6b4 (patch)
tree239b81e133a7a8d74b15ca3bc9ed0c66a4b5dead
parente6477a4d4d52ed182763350949993143d2e932d3 (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> backport of> >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> Change-Id: Ie64141936fd294d8969c39e3bd4dbc73ee375c6b BUG: 1463528 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: https://review.gluster.org/17590 Smoke: Gluster Build System <jenkins@build.gluster.org> Tested-by: Shyamsundar Ranganathan <srangana@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
-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);