summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/iobuf.c42
-rw-r--r--libglusterfs/src/iobuf.h4
2 files changed, 46 insertions, 0 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index a10dc6f847d..84e3b5efec6 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -570,3 +570,45 @@ iobref_merge (struct iobref *to, struct iobref *from)
return ret;
}
+
+
+size_t
+iobuf_size (struct iobuf *iobuf)
+{
+ size_t size = 0;
+
+ if (!iobuf)
+ goto out;
+
+ if (!iobuf->iobuf_arena)
+ goto out;
+
+ if (!iobuf->iobuf_arena->iobuf_pool)
+ goto out;
+
+ size = iobuf->iobuf_arena->iobuf_pool->page_size;
+out:
+ return size;
+}
+
+
+size_t
+iobref_size (struct iobref *iobref)
+{
+ size_t size = 0;
+ int i = 0;
+
+ if (!iobref)
+ goto out;
+
+ LOCK (&iobref->lock);
+ {
+ for (i = 0; i < 8; i++) {
+ if (iobref->iobrefs[i])
+ size += iobuf_size (iobref->iobrefs[i]);
+ }
+ }
+ UNLOCK (&iobref->lock);
+out:
+ return size;
+}
diff --git a/libglusterfs/src/iobuf.h b/libglusterfs/src/iobuf.h
index 2ad640bbc5a..4c34770849e 100644
--- a/libglusterfs/src/iobuf.h
+++ b/libglusterfs/src/iobuf.h
@@ -109,4 +109,8 @@ void iobref_unref (struct iobref *iobref);
int iobref_add (struct iobref *iobref, struct iobuf *iobuf);
int iobref_merge (struct iobref *to, struct iobref *from);
+
+size_t iobuf_size (struct iobuf *iobuf);
+size_t iobref_size (struct iobref *iobref);
+
#endif /* !_IOBUF_H_ */