summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs-fops.c51
-rw-r--r--libglusterfs/src/common-utils.h2
-rw-r--r--libglusterfs/src/iobuf.c43
-rw-r--r--libglusterfs/src/iobuf.h6
-rw-r--r--libglusterfs/src/libglusterfs.sym1
5 files changed, 56 insertions, 47 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 1c2b4c798ef..e9eae04a0ac 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -1231,51 +1231,6 @@ pub_glfs_readv_async (struct glfs_fd *glfd, const struct iovec *iov, int count,
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_readv_async, future);
-
-static int
-glfs_buf_copy (xlator_t *subvol, const struct iovec *iovec_src, int iovcnt,
- struct iobref **iobref, struct iobuf **iobuf,
- struct iovec *iov_dst)
-{
- size_t size = -1;
- int ret = 0;
-
- size = iov_length (iovec_src, iovcnt);
-
- *iobuf = iobuf_get2 (subvol->ctx->iobuf_pool, size);
- if (!(*iobuf)) {
- ret = -1;
- errno = ENOMEM;
- goto out;
- }
-
- *iobref = iobref_new ();
- if (!(*iobref)) {
- iobuf_unref (*iobuf);
- errno = ENOMEM;
- ret = -1;
- goto out;
- }
-
- ret = iobref_add (*iobref, *iobuf);
- if (ret) {
- iobuf_unref (*iobuf);
- iobref_unref (*iobref);
- errno = ENOMEM;
- ret = -1;
- goto out;
- }
-
- iov_unload (iobuf_ptr (*iobuf), iovec_src, iovcnt); /* FIXME!!! */
-
- iov_dst->iov_base = iobuf_ptr (*iobuf);
- iov_dst->iov_len = size;
-
-out:
- return ret;
-}
-
-
static ssize_t
glfs_pwritev_common (struct glfs_fd *glfd, const struct iovec *iovec,
int iovcnt, off_t offset, int flags,
@@ -1309,7 +1264,8 @@ glfs_pwritev_common (struct glfs_fd *glfd, const struct iovec *iovec,
goto out;
}
- ret = glfs_buf_copy (subvol, iovec, iovcnt, &iobref, &iobuf, &iov);
+ ret = iobuf_copy (subvol->ctx->iobuf_pool, iovec, iovcnt, &iobref,
+ &iobuf, &iov);
if (ret)
goto out;
@@ -1499,7 +1455,8 @@ glfs_pwritev_async_common (struct glfs_fd *glfd, const struct iovec *iovec,
goto out;
}
- ret = glfs_buf_copy (subvol, iovec, count, &iobref, &iobuf, gio->iov);
+ ret = iobuf_copy (subvol->ctx->iobuf_pool, iovec, count, &iobref,
+ &iobuf, gio->iov);
if (ret)
goto out;
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 2bad5b4736e..68805055534 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -45,6 +45,8 @@ void trap (void);
#include "uuid.h"
#include "libglusterfs-messages.h"
#include "protocol-common.h"
+#include "iobuf.h"
+
#define STRINGIFY(val) #val
#define TOSTRING(val) STRINGIFY(val)
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index d4f0d89c338..c59b079b90a 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -1217,3 +1217,46 @@ iobuf_to_iovec(struct iobuf *iob, struct iovec *iov)
out:
return;
}
+
+int
+iobuf_copy (struct iobuf_pool *iobuf_pool, const struct iovec *iovec_src,
+ int iovcnt, struct iobref **iobref, struct iobuf **iobuf,
+ struct iovec *iov_dst)
+{
+ size_t size = -1;
+ int ret = 0;
+
+ size = iov_length (iovec_src, iovcnt);
+
+ *iobuf = iobuf_get2 (iobuf_pool, size);
+ if (!(*iobuf)) {
+ ret = -1;
+ errno = ENOMEM;
+ goto out;
+ }
+
+ *iobref = iobref_new ();
+ if (!(*iobref)) {
+ iobuf_unref (*iobuf);
+ errno = ENOMEM;
+ ret = -1;
+ goto out;
+ }
+
+ ret = iobref_add (*iobref, *iobuf);
+ if (ret) {
+ iobuf_unref (*iobuf);
+ iobref_unref (*iobref);
+ errno = ENOMEM;
+ ret = -1;
+ goto out;
+ }
+
+ iov_unload (iobuf_ptr (*iobuf), iovec_src, iovcnt);
+
+ iov_dst->iov_base = iobuf_ptr (*iobuf);
+ iov_dst->iov_len = size;
+
+out:
+ return ret;
+}
diff --git a/libglusterfs/src/iobuf.h b/libglusterfs/src/iobuf.h
index 830904c2fe9..e47c342dc8c 100644
--- a/libglusterfs/src/iobuf.h
+++ b/libglusterfs/src/iobuf.h
@@ -173,4 +173,10 @@ iobuf_get2 (struct iobuf_pool *iobuf_pool, size_t page_size);
struct iobuf *
iobuf_get_page_aligned (struct iobuf_pool *iobuf_pool, size_t page_size,
size_t align_size);
+
+int
+iobuf_copy (struct iobuf_pool *iobuf_pool, const struct iovec *iovec_src,
+ int iovcnt, struct iobref **iobref, struct iobuf **iobuf,
+ struct iovec *iov_dst);
+
#endif /* !_IOBUF_H_ */
diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym
index c4027a759f7..465bb63eb5c 100644
--- a/libglusterfs/src/libglusterfs.sym
+++ b/libglusterfs/src/libglusterfs.sym
@@ -816,6 +816,7 @@ iobuf_pool_new
iobuf_size
iobuf_to_iovec
iobuf_unref
+iobuf_copy
is_data_equal
__is_fuse_call
is_gf_log_command