summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient.c
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-06-03 01:05:42 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-08 06:31:56 -0700
commitc6d33dfbdc9db147fa6028d8c3daa8e79b0b4276 (patch)
tree0a4581331204d1a65affe42ac277262c0216ab15 /libglusterfsclient/src/libglusterfsclient.c
parent6a0ab0b2edca89da524b7dcf29994033f98c8552 (diff)
libglusterfsclient: Avoid dirent copies in readdir cbk
We can avoid memory allocation, de-allocation and data copies by just using the entries passed to us from a lower layer and by de-linking the entries from the original list. Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfsclient/src/libglusterfsclient.c')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index c05918e21..9399d2c29 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3489,9 +3489,15 @@ libgf_client_readdir_cbk (call_frame_t *frame,
{
libgf_client_local_t *local = frame->local;
+ /* Note, we dont let entries reach the stub because there it gets copied
+ * while we can simply delink the entries here and link them into our
+ * dcache, thereby avoiding the need to perform more allocations and
+ * copies.
+ */
local->reply_stub = fop_readdir_cbk_stub (frame, NULL, op_ret, op_errno,
- entries);
-
+ NULL);
+ if (op_ret > 0)
+ libgf_dcache_update (frame->root->state, local->dirfd, entries);
LIBGF_REPLY_NOTIFY (local);
return 0;
}
@@ -3506,16 +3512,14 @@ libgf_client_readdir (libglusterfs_client_ctx_t *ctx, fd_t *fd,
if (libgf_dcache_readdir (ctx, fd, dirp, offset))
return 1;
-
+ local = CALLOC (1, sizeof (*local));
+ ERR_ABORT (local);
+ local->dirfd = fd;
LIBGF_CLIENT_FOP (ctx, stub, readdir, local, fd,
LIBGF_READDIR_BLOCK, *offset);
- op_ret = stub->args.readdir_cbk.op_ret;
errno = stub->args.readdir_cbk.op_errno;
- if (op_ret > 0)
- libgf_dcache_update (ctx, fd, &stub->args.readdir_cbk.entries);
-
op_ret = libgf_dcache_readdir (ctx, fd, dirp, offset);
call_stub_destroy (stub);
return op_ret;