diff options
author | Raghavendra G <raghavendra@zresearch.com> | 2009-03-04 04:00:24 -0800 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-03-05 01:04:34 +0530 |
commit | 762b1f9aefe07971178e584e288833bf142f402b (patch) | |
tree | 75aa359b245ca2f95af82866abc937e47bdc6654 /libglusterfs | |
parent | c8340e70f881dbb95d5238e588a7e985f6f04816 (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 'libglusterfs')
-rw-r--r-- | libglusterfs/src/inode.c | 76 | ||||
-rw-r--r-- | libglusterfs/src/inode.h | 6 |
2 files changed, 53 insertions, 29 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 1b028ef3063..c62d7ca9e7c 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -1105,9 +1105,31 @@ inode_from_path (inode_table_t *itable, const char *path) } int +__inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value) +{ + int ret = 0; + int index = 0; + + for (index = 0; index < xlator->ctx->xl_count; index++) { + if (!inode->_ctx[index].key || + (inode->_ctx[index].key == (uint64_t)(long)xlator)) + break; + } + + if (index == xlator->ctx->xl_count) { + ret = -1; + goto out;; + } + + inode->_ctx[index].key = (uint64_t)(long) xlator; + inode->_ctx[index].value = value; +out: + return ret; +} + +int inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value) { - int index = 0; int ret = 0; if (!inode || !xlator) @@ -1115,30 +1137,38 @@ inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value) LOCK (&inode->lock); { - for (index = 0; index < xlator->ctx->xl_count; index++) { - if (!inode->_ctx[index].key || - (inode->_ctx[index].key == (uint64_t)(long)xlator)) - break; - } - - if (index == xlator->ctx->xl_count) { - ret = -1; - goto unlock; - } - - inode->_ctx[index].key = (uint64_t)(long) xlator; - inode->_ctx[index].value = value; + ret = __inode_ctx_put (inode, xlator, value); } -unlock: UNLOCK (&inode->lock); return ret; } +int +__inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value) +{ + int index = 0; + int ret = 0; + for (index = 0; index < xlator->ctx->xl_count; index++) { + if (inode->_ctx[index].key == (uint64_t)(long)xlator) + break; + } + + if (index == xlator->ctx->xl_count) { + ret = -1; + goto out; + } + + if (value) + *value = inode->_ctx[index].value; + +out: + return ret; +} + int inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value) { - int index = 0; int ret = 0; if (!inode || !xlator) @@ -1146,20 +1176,8 @@ inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value) LOCK (&inode->lock); { - for (index = 0; index < xlator->ctx->xl_count; index++) { - if (inode->_ctx[index].key == (uint64_t)(long)xlator) - break; - } - - if (index == xlator->ctx->xl_count) { - ret = -1; - goto unlock; - } - - if (value) - *value = inode->_ctx[index].value; + ret = __inode_ctx_get (inode, xlator, value); } -unlock: UNLOCK (&inode->lock); return ret; diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index afcc1552e4c..d434668a3b4 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -149,8 +149,14 @@ inode_from_path (inode_table_t *table, const char *path); int +__inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value); + +int inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value); +int +__inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value); + int inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value); |