summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-03-30 03:57:20 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-03 19:24:35 +0530
commite60d2194840b78034db1ad5c8b385a691ab3ddb6 (patch)
treeb4ee712579d99caa53260c0a43af7f78d4c6f2cc /libglusterfsclient/src/libglusterfsclient.c
parent8b8448799cc43f20f5812bf5629c8670f76f78d3 (diff)
libglusterfsclient - change implementation of glusterfs_get
- remove redundent lookups happening in glusterfs_get. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient/src/libglusterfsclient.c')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 6eac2ecf437..01250f89c9b 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -269,10 +269,11 @@ libgf_client_loc_fill (loc_t *loc,
inode = inode_search (ctx->itable, par, name);
loc->inode = inode;
- if (inode)
- loc->ino = inode->ino;
}
+ if (inode)
+ loc->ino = inode->ino;
+
parent = loc->parent;
if (!parent) {
if (inode)
@@ -926,7 +927,7 @@ glusterfs_get (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 0);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -938,20 +939,18 @@ glusterfs_get (glusterfs_handle_t handle,
name = basename (pathname);
op_ret = libgf_client_loc_fill (&loc, ctx, 0, loc.parent->ino, name);
- if (op_ret < 0) {
- gf_log ("libglusterfsclient",
- GF_LOG_ERROR,
- "libgf_client_loc_fill returned -1, returning EINVAL");
- errno = EINVAL;
- goto out;
- }
-
- if (size < 0)
- size = 0;
+ if (op_ret < 0) {
+ gf_log ("libglusterfsclient",
+ GF_LOG_ERROR,
+ "libgf_client_loc_fill returned -1, returning EINVAL");
+ errno = EINVAL;
+ goto out;
+ }
- if (size > 0) {
+ if (size) {
xattr_req = dict_new ();
- op_ret = dict_set (xattr_req, "glusterfs.content", data_from_uint64 (size));
+ op_ret = dict_set (xattr_req, "glusterfs.content",
+ data_from_uint64 (size));
if (op_ret < 0) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -961,17 +960,16 @@ glusterfs_get (glusterfs_handle_t handle,
}
op_ret = libgf_client_lookup (ctx, &loc, stbuf, &dict, xattr_req);
-
- if (!op_ret && size && stbuf && stbuf->st_size && dict && buf) {
+ if (!op_ret && stbuf && (stbuf->st_size <= size) && dict && buf) {
data_t *mem_data = NULL;
void *mem = NULL;
-
+
mem_data = dict_get (dict, "glusterfs.content");
if (mem_data) {
mem = data_to_ptr (mem_data);
}
-
- if (mem && stbuf->st_size <= size) {
+
+ if (mem != NULL) {
memcpy (buf, mem, stbuf->st_size);
}
}
@@ -1160,7 +1158,7 @@ glusterfs_get_async (glusterfs_handle_t handle,
loc = CALLOC (1, sizeof (*loc));
loc->path = strdup (path);
- op_ret = libgf_client_path_lookup (loc, ctx);
+ op_ret = libgf_client_path_lookup (loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -1189,9 +1187,6 @@ glusterfs_get_async (glusterfs_handle_t handle,
local->fop.lookup_cbk.loc = loc;
local->cbk_data = cbk_data;
- if (size < 0)
- size = 0;
-
if (size > 0) {
xattr_req = dict_new ();
op_ret = dict_set (xattr_req, "glusterfs.content", data_from_uint64 (size));
@@ -1306,7 +1301,7 @@ glusterfs_getxattr (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -1546,7 +1541,7 @@ glusterfs_open (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -1825,7 +1820,7 @@ glusterfs_setxattr (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -3111,7 +3106,7 @@ glusterfs_stat (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -3381,7 +3376,7 @@ glusterfs_mkdir (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,
@@ -3441,7 +3436,7 @@ glusterfs_rmdir (glusterfs_handle_t handle,
}
loc.path = strdup (path);
- op_ret = libgf_client_path_lookup (&loc, ctx);
+ op_ret = libgf_client_path_lookup (&loc, ctx, 1);
if (op_ret == -1) {
gf_log ("libglusterfsclient",
GF_LOG_ERROR,