summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-03-04 04:00:24 -0800
committerAnand V. Avati <avati@amp.gluster.com>2009-03-05 01:04:34 +0530
commit762b1f9aefe07971178e584e288833bf142f402b (patch)
tree75aa359b245ca2f95af82866abc937e47bdc6654 /libglusterfsclient
parentc8340e70f881dbb95d5238e588a7e985f6f04816 (diff)
code changes in the usage of inode_ctx_get and inode_ctx_put after their implementation is changed to hold inode->lock.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index db8407cbf..13afb9fac 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -836,14 +836,20 @@ libgf_client_lookup (libglusterfs_client_ctx_t *ctx,
uint64_t ptr = 0;
this = ctx->gf_ctx.graph;
- ret = inode_ctx_get (inode, this, &ptr);
- if (ret == -1) {
- inode_ctx = CALLOC (1, sizeof (*inode_ctx));
- ERR_ABORT (inode_ctx);
- pthread_mutex_init (&inode_ctx->lock, NULL);
- } else {
- inode_ctx = (libglusterfs_client_inode_ctx_t *)(long)ptr;
- }
+ LOCK (&inode->lock);
+ {
+ ret = __inode_ctx_get (inode, this, &ptr);
+ if (ret == -1) {
+ inode_ctx = CALLOC (1, sizeof (*inode_ctx));
+ ERR_ABORT (inode_ctx);
+ pthread_mutex_init (&inode_ctx->lock, NULL);
+ __inode_ctx_put (inode, this,
+ (uint64_t)(long)inode_ctx);
+ } else {
+ inode_ctx = (libglusterfs_client_inode_ctx_t *)(long)ptr;
+ }
+ }
+ UNLOCK (&inode->lock);
current = time (NULL);
@@ -856,11 +862,6 @@ libgf_client_lookup (libglusterfs_client_ctx_t *ctx,
}
pthread_mutex_unlock (&inode_ctx->lock);
- ret = inode_ctx_get (inode, this, NULL);
- if (ret == -1) {
- inode_ctx_put (inode, this, (uint64_t)(long)inode_ctx);
- }
-
if (stbuf)
*stbuf = stub->args.lookup_cbk.buf;
@@ -951,27 +952,33 @@ libgf_client_lookup_async_cbk (call_frame_t *frame,
glusterfs_lookup_cbk_t lookup_cbk = local->fop.lookup_cbk.cbk;
libglusterfs_client_ctx_t *ctx = frame->root->state;
dict_t *xattr_req = NULL;
+ uint64_t ptr = 0;
int32_t ret = 0;
if (op_ret == 0) {
time_t current = 0;
- data_t *inode_ctx_data = NULL;
libglusterfs_client_inode_ctx_t *inode_ctx = NULL;
/* flat directory structure */
inode_t *parent = inode_search (ctx->itable, 1, NULL);
- inode_link (inode, parent, local->fop.lookup_cbk.loc->path, buf);
-
- inode_ctx_data = dict_get (inode->ctx, XLATOR_NAME);
- if (inode_ctx_data) {
- inode_ctx = data_to_ptr (inode_ctx_data);
- }
-
- if (!inode_ctx) {
- inode_ctx = CALLOC (1, sizeof (*inode_ctx));
- pthread_mutex_init (&inode_ctx->lock, NULL);
+ inode_link (inode, parent, local->fop.lookup_cbk.loc->path,
+ buf);
+
+ LOCK (&inode->lock);
+ {
+ ret = __inode_ctx_get (inode, this, &ptr);
+ if (ret == -1) {
+ inode_ctx = CALLOC (1, sizeof (*inode_ctx));
+ ERR_ABORT (inode_ctx);
+ pthread_mutex_init (&inode_ctx->lock, NULL);
+ __inode_ctx_put (inode, this,
+ (uint64_t)(long)inode_ctx);
+ } else {
+ inode_ctx = (libglusterfs_client_inode_ctx_t *)(long)ptr;
+ }
}
+ UNLOCK (&inode->lock);
current = time (NULL);
@@ -983,11 +990,6 @@ libgf_client_lookup_async_cbk (call_frame_t *frame,
}
pthread_mutex_unlock (&inode_ctx->lock);
- ret = inode_ctx_get (inode, this, NULL);
- if (ret == -1) {
- inode_ctx_put (inode, this, (uint64_t)(long)inode_ctx);
- }
-
inode_lookup (inode);
inode_unref (parent);
} else {