summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-22 23:50:33 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-23 01:47:27 -0700
commit56f1b4ed39201355553f9ac4f49c16809d8351e5 (patch)
treeef2be5bab184a5a7db384f4580b865d67a1f5308
parentf72e01fb1d98c7df99b42ae1cbabec0fb0ecfcbd (diff)
performance/write-behind: store currently aggregated data size in wb_file
- this helps us to not traverse the request list whenever we need currently aggregated data in the queue Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 276 (write behind needs to be optimized.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=276
-rw-r--r--xlators/performance/write-behind/src/write-behind.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 3f683aa3c8a..693457bfdbf 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -50,6 +50,7 @@ typedef struct wb_file {
uint64_t disable_till;
size_t window_conf;
size_t window_current;
+ size_t aggregate_current;
int32_t refcount;
int32_t op_ret;
int32_t op_errno;
@@ -240,6 +241,8 @@ wb_enqueue (wb_file_t *file, call_stub_t *stub)
/* reference for stack unwinding */
__wb_request_ref (request);
+
+ file->aggregate_current += request->write_size;
} else {
/*reference for resuming */
__wb_request_ref (request);
@@ -1049,7 +1052,7 @@ wb_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
size_t
-__wb_mark_wind_all (list_head_t *list, list_head_t *winds)
+__wb_mark_wind_all (wb_file_t *file, list_head_t *list, list_head_t *winds)
{
wb_request_t *request = NULL;
size_t size = 0;
@@ -1075,6 +1078,7 @@ __wb_mark_wind_all (list_head_t *list, list_head_t *winds)
size += request->write_size;
offset_expected += request->write_size;
+ file->aggregate_current -= request->write_size;
request->flags.write_request.stack_wound = 1;
list_add_tail (&request->winds, winds);
@@ -1086,12 +1090,10 @@ __wb_mark_wind_all (list_head_t *list, list_head_t *winds)
void
-__wb_can_wind (list_head_t *list, size_t aggregate_conf,
- char *other_fop_in_queue, char *non_contiguous_writes,
- char *incomplete_writes, char *enough_data_aggregated)
+__wb_can_wind (list_head_t *list, char *other_fop_in_queue,
+ char *non_contiguous_writes, char *incomplete_writes)
{
wb_request_t *request = NULL;
- size_t aggregate_current = 0;
char first_request = 1;
off_t offset_expected = 0;
@@ -1125,15 +1127,7 @@ __wb_can_wind (list_head_t *list, size_t aggregate_conf,
break;
}
- aggregate_current += request->write_size;
offset_expected += request->write_size;
-
- if (aggregate_current >= aggregate_conf) {
- if (enough_data_aggregated != NULL) {
- *enough_data_aggregated = 1;
- }
- break;
- }
}
}
@@ -1145,28 +1139,37 @@ size_t
__wb_mark_winds (list_head_t *list, list_head_t *winds, size_t aggregate_conf,
char wind_all, char enable_trickling_writes)
{
- size_t size = 0;
- char other_fop_in_queue = 0;
- char incomplete_writes = 1;
- char non_contiguous_writes = 0;
- char enough_data_aggregated = 0;
- char *trickling_writes = NULL;
+ size_t size = 0;
+ char other_fop_in_queue = 0;
+ char incomplete_writes = 1;
+ char non_contiguous_writes = 0;
+ char *trickling_writes = NULL;
+ wb_request_t *request = NULL;
+ wb_file_t *file = NULL;
- if (enable_trickling_writes) {
- trickling_writes = &incomplete_writes;
+ if (list_empty (list)) {
+ goto out;
}
- if (!wind_all) {
- __wb_can_wind (list, aggregate_conf, &other_fop_in_queue,
- &non_contiguous_writes, trickling_writes,
- &enough_data_aggregated);
+ request = list_entry (list->next, typeof (*request), list);
+ file = request->file;
+
+ if (!wind_all && (file->aggregate_current < aggregate_conf)) {
+ if (enable_trickling_writes) {
+ trickling_writes = &incomplete_writes;
+ }
+
+ __wb_can_wind (list, &other_fop_in_queue,
+ &non_contiguous_writes, trickling_writes);
}
if ((!incomplete_writes) || (wind_all) || (non_contiguous_writes)
- || (other_fop_in_queue) || (enough_data_aggregated)) {
- size = __wb_mark_wind_all (list, winds);
+ || (other_fop_in_queue)
+ || (file->aggregate_current >= aggregate_conf)) {
+ size = __wb_mark_wind_all (file, list, winds);
}
+out:
return size;
}