From 3315740ef0dd3606206355dfd46a57f045cbd6b4 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Fri, 2 Jun 2017 16:28:40 +0530 Subject: 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: 1463528 Signed-off-by: Mohammed Rafi KC Reviewed-on: https://review.gluster.org/17590 Smoke: Gluster Build System Tested-by: Shyamsundar Ranganathan CentOS-regression: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- 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 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); -- cgit