summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorAnand V. Avati <avati@amp.gluster.com>2009-04-11 23:22:26 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-04-12 11:33:48 +0530
commit6d94a368e061afeeac6fb57c5910c71f60791dc3 (patch)
tree1f25b6e4791fc5de5476d903380a23b6f19c778b /libglusterfsclient
parent77714c065d99767f5a3820bc1c62b22522681821 (diff)
updated libglusterfsclient with IOBUF/IOBREFs
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient-internals.h4
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c40
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.h3
3 files changed, 25 insertions, 22 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient-internals.h b/libglusterfsclient/src/libglusterfsclient-internals.h
index a547da3039e..b12c08efa06 100755
--- a/libglusterfsclient/src/libglusterfsclient-internals.h
+++ b/libglusterfsclient/src/libglusterfsclient-internals.h
@@ -160,11 +160,9 @@ typedef struct libglusterfs_client_async_local {
call_frame_t *frame = get_call_frame_for_req (ctx, 1); \
xlator_t *xl = frame->this->children ? \
frame->this->children->xlator : NULL; \
- dict_t *refs = frame->root->req_refs; \
frame->root->state = ctx; \
frame->local = local; \
STACK_WIND (frame, ret_fn, xl, xl->fops->op, args); \
- dict_unref (refs); \
} while (0)
#define LIBGF_CLIENT_FOP(ctx, stub, op, local, args ...) \
@@ -172,7 +170,6 @@ typedef struct libglusterfs_client_async_local {
call_frame_t *frame = get_call_frame_for_req (ctx, 1); \
xlator_t *xl = frame->this->children ? \
frame->this->children->xlator : NULL; \
- dict_t *refs = frame->root->req_refs; \
if (!local) { \
local = CALLOC (1, sizeof (*local)); \
} \
@@ -183,7 +180,6 @@ typedef struct libglusterfs_client_async_local {
pthread_mutex_init (&local->lock, NULL); \
LIBGF_STACK_WIND_AND_WAIT (frame, libgf_client_##op##_cbk, xl, \
xl->fops->op, args); \
- dict_unref (refs); \
stub = local->reply_stub; \
FREE (frame->local); \
frame->local = NULL; \
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index ae0b055ff7b..174eb7a27e0 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -297,14 +297,6 @@ get_call_frame_for_req (libglusterfs_client_ctx_t *ctx, char d)
frame->root->pid = getpid ();
frame->root->unique = ctx->counter++;
- if (d) {
- frame->root->req_refs = dict_ref (get_new_dict ());
- /*
- TODO
- dict_set (frame->root->req_refs, NULL, priv->buf);
- */
- }
-
return frame;
}
@@ -392,6 +384,7 @@ glusterfs_init (glusterfs_init_params_t *init_ctx)
/* FIXME: why is count hardcoded to 16384 */
ctx->gf_ctx.event_pool = event_pool_new (16384);
+ ctx->gf_ctx.iobuf_pool = iobuf_pool_new (64 * 1048576, 128 * 1024);
lim.rlim_cur = RLIM_INFINITY;
lim.rlim_max = RLIM_INFINITY;
@@ -1093,7 +1086,7 @@ out:
iobuf->vector = vector;
iobuf->count = 1;
- iobuf->ref = dict_ref (dict);
+ iobuf->dictref = dict_ref (dict);
}
}
@@ -2098,12 +2091,13 @@ libgf_client_readv_cbk (call_frame_t *frame,
int32_t op_errno,
struct iovec *vector,
int32_t count,
- struct stat *stbuf)
+ struct stat *stbuf,
+ struct iobref *iobref)
{
libgf_client_local_t *local = frame->local;
local->reply_stub = fop_readv_cbk_stub (frame, NULL, op_ret, op_errno,
- vector, count, stbuf);
+ vector, count, stbuf, iobref);
pthread_mutex_lock (&local->lock);
{
@@ -2374,12 +2368,16 @@ libgf_client_writev (libglusterfs_client_ctx_t *ctx,
call_stub_t *stub = NULL;
int op_ret = -1;
libgf_client_local_t *local = NULL;
+ struct iobref *iobref = NULL;
- LIBGF_CLIENT_FOP (ctx, stub, writev, local, fd, vector, count, offset);
+ iobref = iobref_new ();
+ LIBGF_CLIENT_FOP (ctx, stub, writev, local, fd, vector, count, offset,
+ iobref);
op_ret = stub->args.writev_cbk.op_ret;
errno = stub->args.writev_cbk.op_errno;
+ iobref_unref (iobref);
call_stub_destroy (stub);
return op_ret;
}
@@ -2707,7 +2705,8 @@ libglusterfs_readv_async_cbk (call_frame_t *frame,
int32_t op_errno,
struct iovec *vector,
int32_t count,
- struct stat *stbuf)
+ struct stat *stbuf,
+ struct iobref *iobref)
{
glusterfs_iobuf_t *buf;
libglusterfs_client_async_local_t *local = frame->local;
@@ -2723,8 +2722,8 @@ libglusterfs_readv_async_cbk (call_frame_t *frame,
buf->count = count;
- if (frame->root->rsp_refs) {
- buf->ref = dict_ref (frame->root->rsp_refs);
+ if (iobref) {
+ buf->iobref = iobref_ref (iobref);
}
if (op_ret > 0) {
@@ -2755,7 +2754,10 @@ glusterfs_free (glusterfs_iobuf_t *buf)
{
//iov_free (buf->vector, buf->count);
FREE (buf->vector);
- dict_unref ((dict_t *) buf->ref);
+ if (buf->iobref)
+ iobref_unref ((struct iobref *) buf->iobref);
+ if (buf->dictref)
+ dict_unref ((dict_t *) buf->dictref);
FREE (buf);
}
@@ -2862,6 +2864,7 @@ glusterfs_write_async (glusterfs_file_t fd,
libglusterfs_client_fd_ctx_t *fd_ctx = NULL;
data_t *fd_ctx_data = NULL;
int32_t op_ret = 0;
+ struct iobref *iobref = NULL;
local = CALLOC (1, sizeof (*local));
ERR_ABORT (local);
@@ -2890,6 +2893,7 @@ glusterfs_write_async (glusterfs_file_t fd,
pthread_mutex_unlock (&fd_ctx->lock);
}
+ iobref = iobref_new ();
LIBGF_CLIENT_FOP_ASYNC (ctx,
local,
libglusterfs_writev_async_cbk,
@@ -2897,7 +2901,9 @@ glusterfs_write_async (glusterfs_file_t fd,
__fd,
&vector,
1,
- __offset);
+ __offset,
+ iobref);
+ iobref_unref (iobref);
out:
return op_ret;
diff --git a/libglusterfsclient/src/libglusterfsclient.h b/libglusterfsclient/src/libglusterfsclient.h
index 40d08eced26..516a03a0891 100755
--- a/libglusterfsclient/src/libglusterfsclient.h
+++ b/libglusterfsclient/src/libglusterfsclient.h
@@ -32,7 +32,8 @@ __BEGIN_DECLS
typedef struct {
struct iovec *vector;
int count;
- void *ref;
+ void *iobref;
+ void *dictref;
} glusterfs_iobuf_t;
typedef struct {