summaryrefslogtreecommitdiffstats
path: root/xlators/performance/quick-read
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-18 05:53:52 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-22 06:12:52 -0700
commit578e42399fa86f15dffffd5d35f96f3a248d651d (patch)
tree7acf197914a36560efb3b6d226d8c1fdddefc960 /xlators/performance/quick-read
parentc98c65c940a8120982aeaf5f15d0522a002c5b80 (diff)
performance/quick-read: refine logic of qr_readv.
- An extra vector was being allocated when the number of bytes being read from cache were equal to the iobuf size. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 274 (Memory corruption in Apache running on booster) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=274
Diffstat (limited to 'xlators/performance/quick-read')
-rw-r--r--xlators/performance/quick-read/src/quick-read.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 57f30948f3e..c7d282affcb 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -794,7 +794,10 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
content = dict_get (file->xattr,
GLUSTERFS_CONTENT_KEY);
+
+ stbuf = file->stbuf;
content_cached = 1;
+
if (offset > content->len) {
op_ret = 0;
end = content->len;
@@ -810,7 +813,17 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
}
ctx = this->ctx;
- count = (op_ret / iobuf_pool->page_size) + 1;
+ count = (op_ret / iobuf_pool->page_size);
+ if ((op_ret % iobuf_pool->page_size)
+ != 0) {
+ count++;
+ }
+
+ if (count == 0) {
+ op_ret = 0;
+ goto unlock;
+ }
+
vector = CALLOC (count,
sizeof (*vector));
if (vector == NULL) {
@@ -857,8 +870,6 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
vector[i].iov_base = iobuf->ptr;
vector[i].iov_len = len;
}
-
- stbuf = file->stbuf;
}
}
unlock: