From e60d2194840b78034db1ad5c8b385a691ab3ddb6 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 30 Mar 2009 03:57:20 -0700 Subject: libglusterfsclient - change implementation of glusterfs_get - remove redundent lookups happening in glusterfs_get. Signed-off-by: Anand V. Avati --- libglusterfsclient/src/libglusterfsclient-dentry.c | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'libglusterfsclient/src/libglusterfsclient-dentry.c') diff --git a/libglusterfsclient/src/libglusterfsclient-dentry.c b/libglusterfsclient/src/libglusterfsclient-dentry.c index f2e1e17ff02..8500827faf7 100644 --- a/libglusterfsclient/src/libglusterfsclient-dentry.c +++ b/libglusterfsclient/src/libglusterfsclient-dentry.c @@ -322,7 +322,8 @@ out: /* resolves loc->path to loc->parent and loc->inode */ int32_t libgf_client_path_lookup (loc_t *loc, - libglusterfs_client_ctx_t *ctx) + libglusterfs_client_ctx_t *ctx, + char lookup_basename) { char *pathname = NULL; char *directory = NULL; @@ -345,19 +346,30 @@ libgf_client_path_lookup (loc_t *loc, } libgf_client_loc_wipe (&new_loc); - inode = inode_from_path (ctx->itable, loc->path); pathname = strdup (loc->path); directory = dirname (pathname); parent = inode_from_path (ctx->itable, directory); - - if (inode && parent) { - gf_log ("libglusterfsclient", - GF_LOG_DEBUG, - "resolved path(%s) to %"PRId64"/%"PRId64"(%s)", - loc->path, parent->ino, inode->ino, loc->name); - loc->inode = inode; + + if (parent != NULL) { loc->parent = parent; - goto out; + + if (!lookup_basename) { + gf_log ("libglusterfsclient", + GF_LOG_DEBUG, + "resolved dirname(%s) to %"PRId64, + loc->path, parent->ino); + goto out; + } else { + inode = inode_from_path (ctx->itable, loc->path); + if (inode != NULL) { + gf_log ("libglusterfsclient", + GF_LOG_DEBUG, + "resolved path(%s) to %"PRId64"/%"PRId64, + loc->path, parent->ino, inode->ino); + loc->inode = inode; + goto out; + } + } } else { gf_log ("libglusterfsclient", GF_LOG_DEBUG, -- cgit