summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-12-01 14:18:16 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-01 19:15:46 -0800
commite75c2667db1c5a4f35f18406130b87325537edf3 (patch)
treed2644b0d9fd5435cf5cb667593c5030572c25134 /libglusterfsclient/src/libglusterfsclient.c
parent21abd303c84f7d36aeee90ecefb2a09091c706b5 (diff)
libglusterfsclient/read: 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/src/libglusterfsclient.c')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index af69178..1392f4b 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3540,7 +3540,7 @@ glusterfs_lremovexattr (glusterfs_handle_t handle,
return -1;
}
-int
+int
glusterfs_fremovexattr (glusterfs_file_t fd,
const char *name)
{
@@ -3567,19 +3567,16 @@ libgf_client_readv_cbk (call_frame_t *frame,
return 0;
}
-int
-libgf_client_read (libglusterfs_client_ctx_t *ctx,
- fd_t *fd,
- void *buf,
- size_t size,
- off_t offset)
+int
+libgf_client_iobuf_read (libglusterfs_client_ctx_t *ctx, fd_t *fd, void *buf,
+ size_t size, off_t offset)
{
- call_stub_t *stub;
- struct iovec *vector;
- int32_t op_ret = -1;
- int count = 0;
+ call_stub_t *stub = NULL;
+ struct iovec *vector = NULL;
+ int32_t op_ret = -1;
+ int count = 0;
libgf_client_local_t *local = NULL;
- struct stat *stbuf = NULL;
+ struct stat *stbuf = NULL;
local = CALLOC (1, sizeof (*local));
ERR_ABORT (local);
@@ -3594,7 +3591,7 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx,
int i = 0;
op_ret = 0;
while (size && (i < count)) {
- int len = (size < vector[i].iov_len) ?
+ int len = (size < vector[i].iov_len) ?
size : vector[i].iov_len;
memcpy (buf, vector[i++].iov_base, len);
buf += len;
@@ -3612,10 +3609,31 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx,
return op_ret;
}
-ssize_t
-glusterfs_read (glusterfs_file_t fd,
- void *buf,
- size_t nbytes)
+int
+libgf_client_read (libglusterfs_client_ctx_t *ctx, fd_t *fd, void *buf,
+ size_t size, off_t offset)
+{
+ int32_t op_ret = -1;
+ size_t tmp = 0;
+
+ while (size != 0) {
+ tmp = ((size > LIBGF_IOBUF_SIZE) ? LIBGF_IOBUF_SIZE :
+ size);
+ op_ret = libgf_client_iobuf_read (ctx, fd, buf, tmp, offset);
+ if (op_ret <= 0) {
+ break;
+ }
+
+ size -= op_ret;
+ offset += op_ret;
+ buf = (char *)buf + op_ret;
+ }
+
+ return op_ret;
+}
+
+ssize_t
+glusterfs_read (glusterfs_file_t fd, void *buf, size_t nbytes)
{
int32_t op_ret = -1;
off_t offset = 0;
@@ -3666,7 +3684,6 @@ out:
return op_ret;
}
-
ssize_t
libgf_client_iobuf_readv (libglusterfs_client_ctx_t *ctx, fd_t *fd,
const struct iovec *dst_vector, int count,