summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-02-23 00:04:23 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-22 23:27:02 -0800
commitaf004cdf11918901ac6a79d32cdef3f6cc67525b (patch)
treec40fadbc33a08ef2ed2c136725068a13dbabd05b
parent781e390dcf0d2e4af8d8882131292a544fbb2288 (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
-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 faa3239..4f72e6e 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -1336,69 +1336,71 @@ wb_do_ops (call_frame_t *frame, wb_file_t *file, list_head_t *winds,
}
+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;
}