summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/inode.c94
-rw-r--r--libglusterfs/src/inode.h30
2 files changed, 98 insertions, 26 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 18a5a85db50..ee8b3ece83a 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -1102,8 +1102,10 @@ inode_from_path (inode_table_t *itable, const char *path)
return inode;
}
+
int
-__inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value)
+__inode_ctx_put2 (inode_t *inode, xlator_t *xlator, uint64_t value1,
+ uint64_t value2)
{
int ret = 0;
int index = 0;
@@ -1116,25 +1118,28 @@ __inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value)
/* dont break, to check if key already exists
further on */
}
- if (inode->_ctx[index].key == (uint64_t)(long) xlator) {
+ if (inode->_ctx[index].xl_key == xlator) {
put_idx = index;
break;
}
}
-
+
if (put_idx == -1) {
ret = -1;
goto out;;
}
- inode->_ctx[put_idx].key = (uint64_t)(long) xlator;
- inode->_ctx[put_idx].value = value;
+ inode->_ctx[put_idx].xl_key = xlator;
+ inode->_ctx[put_idx].value1 = value1;
+ inode->_ctx[put_idx].value2 = value2;
out:
return ret;
}
+
int
-inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value)
+inode_ctx_put2 (inode_t *inode, xlator_t *xlator, uint64_t value1,
+ uint64_t value2)
{
int ret = 0;
@@ -1143,21 +1148,23 @@ inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value)
LOCK (&inode->lock);
{
- ret = __inode_ctx_put (inode, xlator, value);
+ ret = __inode_ctx_put2 (inode, xlator, value1, value2);
}
UNLOCK (&inode->lock);
return ret;
}
+
int
-__inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value)
+__inode_ctx_get2 (inode_t *inode, xlator_t *xlator, uint64_t *value1,
+ uint64_t *value2)
{
int index = 0;
int ret = 0;
for (index = 0; index < xlator->ctx->xl_count; index++) {
- if (inode->_ctx[index].key == (uint64_t)(long)xlator)
+ if (inode->_ctx[index].xl_key == xlator)
break;
}
@@ -1166,15 +1173,20 @@ __inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value)
goto out;
}
- if (value)
- *value = inode->_ctx[index].value;
+ if (value1)
+ *value1 = inode->_ctx[index].value1;
+
+ if (value2)
+ *value2 = inode->_ctx[index].value2;
out:
return ret;
}
-int
-inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value)
+
+int
+inode_ctx_get2 (inode_t *inode, xlator_t *xlator, uint64_t *value1,
+ uint64_t *value2)
{
int ret = 0;
@@ -1183,7 +1195,7 @@ inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value)
LOCK (&inode->lock);
{
- ret = __inode_ctx_get (inode, xlator, value);
+ ret = __inode_ctx_get2 (inode, xlator, value1, value2);
}
UNLOCK (&inode->lock);
@@ -1191,8 +1203,9 @@ inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value)
}
-int
-inode_ctx_del (inode_t *inode, xlator_t *xlator, uint64_t *value)
+int
+inode_ctx_del2 (inode_t *inode, xlator_t *xlator, uint64_t *value1,
+ uint64_t *value2)
{
int index = 0;
int ret = 0;
@@ -1203,7 +1216,7 @@ inode_ctx_del (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)
+ if (inode->_ctx[index].xl_key == xlator)
break;
}
@@ -1212,11 +1225,14 @@ inode_ctx_del (inode_t *inode, xlator_t *xlator, uint64_t *value)
goto unlock;
}
- if (value)
- *value = inode->_ctx[index].value;
+ if (value1)
+ *value1 = inode->_ctx[index].value1;
+ if (value2)
+ *value2 = inode->_ctx[index].value2;
- inode->_ctx[index].key = 0;
- inode->_ctx[index].value = 0;
+ inode->_ctx[index].key = 0;
+ inode->_ctx[index].value1 = 0;
+ inode->_ctx[index].value2 = 0;
}
unlock:
UNLOCK (&inode->lock);
@@ -1224,6 +1240,42 @@ unlock:
return ret;
}
+
+int
+__inode_ctx_put (inode_t *inode, xlator_t *key, uint64_t value)
+{
+ return __inode_ctx_put2 (inode, key, value, 0);
+}
+
+
+int
+inode_ctx_put (inode_t *inode, xlator_t *key, uint64_t value)
+{
+ return inode_ctx_put2 (inode, key, value, 0);
+}
+
+
+int
+__inode_ctx_get (inode_t *inode, xlator_t *key, uint64_t *value)
+{
+ return __inode_ctx_get2 (inode, key, value, 0);
+}
+
+
+int
+inode_ctx_get (inode_t *inode, xlator_t *key, uint64_t *value)
+{
+ return inode_ctx_get2 (inode, key, value, 0);
+}
+
+
+int
+inode_ctx_del (inode_t *inode, xlator_t *key, uint64_t *value)
+{
+ return inode_ctx_del2 (inode, key, value, 0);
+}
+
+
void
inode_dump (inode_t *inode, char *prefix)
{
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h
index d1486ca3165..520df7dbcbe 100644
--- a/libglusterfs/src/inode.h
+++ b/libglusterfs/src/inode.h
@@ -73,11 +73,19 @@ struct _dentry {
inode_t *parent; /* directory of the entry */
};
-//#define ZR_INODE_CTX_VALUE_LEN 2
struct _inode_ctx {
- uint64_t key;
- uint64_t value;
- //uint64_t value[ZR_INODE_CTX_VALUE_LEN];
+ union {
+ uint64_t key;
+ xlator_t *xl_key;
+ };
+ union {
+ uint64_t value1;
+ void *ptr1;
+ };
+ union {
+ uint64_t value2;
+ void *ptr2;
+ };
};
struct _inode {
@@ -155,7 +163,7 @@ __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
+int
__inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value);
int
@@ -164,4 +172,16 @@ inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value);
int
inode_ctx_del (inode_t *inode, xlator_t *xlator, uint64_t *value);
+int
+inode_ctx_put2 (inode_t *inode, xlator_t *xlator, uint64_t value1,
+ uint64_t value2);
+
+int
+inode_ctx_get2 (inode_t *inode, xlator_t *xlator, uint64_t *value1,
+ uint64_t *value2);
+
+int
+inode_ctx_del2 (inode_t *inode, xlator_t *xlator, uint64_t *value1,
+ uint64_t *value2);
+
#endif /* _INODE_H */