summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2009-10-18 14:05:40 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-18 12:39:13 -0700
commit11ddca1cd151479243fe23e579b76c5984f422c3 (patch)
tree04d7f60b390c44aafdf45be84673ade0826b0a82 /libglusterfs/src
parent3d09fb99093a84a303edc443b68bdf9eb10096b4 (diff)
inode_ctx_{get,put,del}2 API support
support for storing multiple values for a key in inode context - used for storing inode and generation number pairs on the server in protocol/client inode ctx Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 315 (generation number support) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=315
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 18a5a85db..ee8b3ece8 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 d1486ca31..520df7dbc 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 */