From 1e0a2cb94650f39903ec087c691c9c8461b6247a Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Fri, 2 Jun 2017 16:28:40 +0530 Subject: [PATCH 501/509] 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 Backport of> >Change-Id: Ie64141936fd294d8969c39e3bd4dbc73ee375c6b >BUG: 1458768 >Signed-off-by: Mohammed Rafi KC >Reviewed-on: https://review.gluster.org/17465 >Smoke: Gluster Build System >CentOS-regression: Gluster Build System >NetBSD-regression: NetBSD Build System >Reviewed-by: Niels de Vos Change-Id: Ie64141936fd294d8969c39e3bd4dbc73ee375c6b BUG: 1450830 Signed-off-by: Mohammed Rafi KC Reviewed-on: https://code.engineering.redhat.com/gerrit/108901 Reviewed-by: Atin Mukherjee --- api/src/glfs-internal.h | 1 + api/src/glfs-resolve.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h index a428224..f78fcfd 100644 --- a/api/src/glfs-internal.h +++ b/api/src/glfs-internal.h @@ -357,6 +357,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 a2be87f..44d013c 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); -- 1.8.3.1