summaryrefslogtreecommitdiffstats
path: root/xlators/performance/write-behind
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-02-22 23:58:35 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-22 23:26:47 -0800
commitb7c361c6c387fe858a51e65cbc6e3be0724bb088 (patch)
tree5e6324216e283bad9e4ae11595a9e4f2318bd150 /xlators/performance/write-behind
parent30207094c563e7e4f2d6e1f4c54abd7e918c22d4 (diff)
performance/write-behind: refactor __wb_collapse_write_bufs
- refactor done to remove duplicated code. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 542 (write-behind crashes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=542
Diffstat (limited to 'xlators/performance/write-behind')
-rw-r--r--xlators/performance/write-behind/src/write-behind.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index d602eb50af7..f5227684c94 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -1653,69 +1653,71 @@ out:
}
+inline void
+__wb_copy_into_holder (wb_request_t *holder, wb_request_t *request)
+{
+ char *ptr = NULL;
+
+ ptr = holder->stub->args.writev.vector[0].iov_base + holder->write_size;
+
+ iov_unload (ptr,
+ request->stub->args.writev.vector,
+ request->stub->args.writev.count);
+
+ holder->stub->args.writev.vector[0].iov_len += request->write_size;
+ holder->write_size += request->write_size;
+
+ request->flags.write_request.stack_wound = 1;
+ list_move_tail (&request->list, &request->file->passive_requests);
+
+ return;
+}
+
+
/* this procedure assumes that write requests have only one vector to write */
void
__wb_collapse_write_bufs (list_head_t *requests, size_t page_size)
{
-
off_t offset_expected = 0;
- size_t space_left = 0, *iov_len = NULL, *write_size = NULL;
- char *ptr = NULL, first_request = 1;
- wb_request_t *request = NULL, *tmp = NULL;
+ size_t space_left = 0;
+ wb_request_t *request = NULL, *tmp = NULL, *holder = NULL;
list_for_each_entry_safe (request, tmp, requests, list) {
if ((request->stub == NULL)
|| (request->stub->fop != GF_FOP_WRITE)
|| (request->flags.write_request.stack_wound)) {
- space_left = 0;
- ptr = NULL;
- first_request = 1;
+ holder = NULL;
continue;
}
if (request->flags.write_request.write_behind) {
- if (first_request) {
- first_request = 0;
- offset_expected = request->stub->args.writev.off;
+ if (holder == NULL) {
+ holder = request;
+ continue;
}
-
+
+ offset_expected = holder->stub->args.writev.off
+ + holder->write_size;
+
if (request->stub->args.writev.off != offset_expected) {
- offset_expected = request->stub->args.writev.off
- + request->write_size;
- space_left = page_size - request->write_size;
- ptr = request->stub->args.writev.vector[0].iov_base
- + request->write_size;
- iov_len = &request->stub->args.writev.vector[0].iov_len;
- write_size = &request->write_size;
+ holder = request;
continue;
}
- if (space_left >= request->write_size) {
- iov_unload (ptr,
- request->stub->args.writev.vector,
- request->stub->args.writev.count);
- space_left -= request->write_size;
- ptr += request->write_size;
- *iov_len = *iov_len + request->write_size;
- *write_size = *write_size + request->write_size;
-
- list_move_tail (&request->list,
- &request->file->passive_requests);
+ space_left = page_size - holder->write_size;
+ if (space_left >= request->write_size) {
+ __wb_copy_into_holder (holder, request);
__wb_request_unref (request);
} else {
- space_left = page_size - request->write_size;
- ptr = request->stub->args.writev.vector[0].iov_base
- + request->write_size;
- iov_len = &request->stub->args.writev.vector[0].iov_len;
- write_size = &request->write_size;
+ holder = request;
}
} else {
break;
}
-
- offset_expected += request->write_size;
}
+
+ return;
}