summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/inode.c32
-rw-r--r--libglusterfs/src/inode.h3
-rw-r--r--libglusterfs/src/xlator.h6
3 files changed, 41 insertions, 0 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 6e4c2f11bc2..841f0b63f16 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -2504,3 +2504,35 @@ out:
return;
}
+
+size_t
+inode_ctx_size (inode_t *inode)
+{
+ int i = 0;
+ size_t size = 0;
+ xlator_t *xl = NULL, *old_THIS = NULL;
+
+ if (!inode)
+ goto out;
+
+ LOCK (&inode->lock);
+ {
+ for (i = 0; i < inode->table->ctxcount; i++) {
+ if (!inode->_ctx[i].xl_key)
+ continue;
+
+ xl = (xlator_t *)(long)inode->_ctx[i].xl_key;
+ old_THIS = THIS;
+ THIS = xl;
+
+ if (xl->cbks->ictxsize)
+ size += xl->cbks->ictxsize (xl, inode);
+
+ THIS = old_THIS;
+ }
+ }
+ UNLOCK (&inode->lock);
+
+out:
+ return size;
+}
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h
index 114aeae78bb..5289b15bca6 100644
--- a/libglusterfs/src/inode.h
+++ b/libglusterfs/src/inode.h
@@ -279,4 +279,7 @@ inode_needs_lookup (inode_t *inode, xlator_t *this);
int
inode_has_dentry (inode_t *inode);
+size_t
+inode_ctx_size (inode_t *inode);
+
#endif /* _INODE_H */
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index 70e6f0a108d..b11d1a96f32 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -847,6 +847,10 @@ typedef int32_t (*cbk_client_t)(xlator_t *this, client_t *client);
typedef void (*cbk_ictxmerge_t) (xlator_t *this, fd_t *fd,
inode_t *inode, inode_t *linked_inode);
+typedef size_t (*cbk_inodectx_size_t)(xlator_t *this, inode_t *inode);
+
+typedef size_t (*cbk_fdctx_size_t)(xlator_t *this, fd_t *fd);
+
struct xlator_cbks {
cbk_forget_t forget;
cbk_release_t release;
@@ -855,6 +859,8 @@ struct xlator_cbks {
cbk_client_t client_destroy;
cbk_client_t client_disconnect;
cbk_ictxmerge_t ictxmerge;
+ cbk_inodectx_size_t ictxsize;
+ cbk_fdctx_size_t fdctxsize;
};
typedef int32_t (*dumpop_priv_t) (xlator_t *this);