summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-12-01 14:39:31 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-01 17:52:40 -0800
commit435b234325bdcdcea88c3e1c7e9d97deeee3eb9a (patch)
tree8de4f8c1c104a92355278682c73360819c2e8b50 /libglusterfsclient
parentb491da7cc5fdcebdf641c5768685061221643611 (diff)
libglusterfsclient/readv: break reads bigger than the iobuffer size into smaller ones.
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 334 (glusterfs_read/readv should break large-reads into 128Kb block sizes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=334
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c82
1 files changed, 55 insertions, 27 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index d6970ea2c..85c9e3c9e 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3729,25 +3729,23 @@ out:
ssize_t
-libgf_client_readv (libglusterfs_client_ctx_t *ctx,
- fd_t *fd,
- const struct iovec *dst_vector,
- int dst_count,
- off_t offset)
-{
- call_stub_t *stub = NULL;
- struct iovec *src_vector;
- int src_count = 0;
- int32_t op_ret = -1;
- libgf_client_local_t *local = NULL;
- size_t size = 0;
- int32_t i = 0;
- struct stat *stbuf = NULL;
-
- for (i = 0; i < dst_count; i++)
- {
- size += dst_vector[i].iov_len;
- }
+libgf_client_iobuf_readv (libglusterfs_client_ctx_t *ctx, fd_t *fd,
+ const struct iovec *dst_vector, int count,
+ size_t size, off_t offset, int *idx,
+ off_t *vec_offset)
+{
+ call_stub_t *stub = NULL;
+ struct iovec *src_vector = NULL;
+ int32_t op_ret = -1;
+ libgf_client_local_t *local = NULL;
+ int src = 0, dst = 0;
+ int src_count = 0, dst_count = 0;
+ int len = 0, src_len = 0, dst_len = 0;
+ off_t src_offset = 0, dst_offset = 0;
+ struct stat *stbuf = NULL;
+
+ dst = *idx;
+ dst_offset = *vec_offset;
local = CALLOC (1, sizeof (*local));
ERR_ABORT (local);
@@ -3759,12 +3757,7 @@ libgf_client_readv (libglusterfs_client_ctx_t *ctx,
src_count = stub->args.readv_cbk.count;
src_vector = stub->args.readv_cbk.vector;
if (op_ret > 0) {
- int src = 0, dst = 0;
- off_t src_offset = 0, dst_offset = 0;
-
while ((size != 0) && (dst < dst_count) && (src < src_count)) {
- int len = 0, src_len, dst_len;
-
src_len = src_vector[src].iov_len - src_offset;
dst_len = dst_vector[dst].iov_len - dst_offset;
@@ -3773,7 +3766,7 @@ libgf_client_readv (libglusterfs_client_ctx_t *ctx,
len = size;
}
- memcpy (dst_vector[dst].iov_base + dst_offset,
+ memcpy (dst_vector[dst].iov_base + dst_offset,
src_vector[src].iov_base + src_offset, len);
size -= len;
@@ -3795,13 +3788,48 @@ libgf_client_readv (libglusterfs_client_ctx_t *ctx,
libgf_transform_iattr (ctx, fd->inode, stbuf);
libgf_invalidate_iattr_cache (fd->inode, LIBGF_UPDATE_STAT);
}
-
+
+ *idx = dst;
+ *vec_offset = dst_offset;
+
call_stub_destroy (stub);
return op_ret;
}
-ssize_t
+ssize_t
+libgf_client_readv (libglusterfs_client_ctx_t *ctx, fd_t *fd,
+ const struct iovec *dst_vector, int dst_count, off_t offset)
+{
+ int32_t op_ret = -1;
+ size_t size = 0, tmp = 0;
+ int i = 0;
+ int dst_idx = 0;
+ off_t dst_offset = 0;
+
+ for (i = 0; i < dst_count; i++)
+ {
+ size += dst_vector[i].iov_len;
+ }
+
+ while (size != 0) {
+ tmp = ((size > LIBGF_IOBUF_SIZE) ? LIBGF_IOBUF_SIZE : size);
+ op_ret = libgf_client_iobuf_readv (ctx, fd, dst_vector,
+ dst_count, tmp, offset,
+ &dst_idx, &dst_offset);
+ if (op_ret <= 0) {
+ break;
+ }
+
+ offset += op_ret;
+ size -= op_ret;
+ }
+
+ return op_ret;
+}
+
+
+ssize_t
glusterfs_readv (glusterfs_file_t fd, const struct iovec *vec, int count)
{
int32_t op_ret = -1;