diff options
author | Susant Palai <spalai@redhat.com> | 2018-05-18 12:20:08 +0530 |
---|---|---|
committer | Susant Palai <spalai@redhat.com> | 2018-05-24 09:32:09 +0000 |
commit | fc17daf2e6d665262ba12e6f6aab91678f124ab8 (patch) | |
tree | 3028aa3dd2600d05bf6d75ca05b2854db083a627 /api | |
parent | 9cc4ed624edb368d77d6bb7a5dfae1a79746e523 (diff) |
core: make glfs_iobuf_copy() consumable for general purpose.
Currently plugins for cloudsync will be using it to write back data
downloaded from remote store/cloud.
Change-Id: I59f10bebed21b19568c94cbf29e3d536d5570749
Updates: #387
Signed-off-by: Susant Palai <spalai@redhat.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/src/glfs-fops.c | 51 |
1 files changed, 4 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; |