summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-22 23:50:17 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-23 01:47:23 -0700
commitf72e01fb1d98c7df99b42ae1cbabec0fb0ecfcbd (patch)
treee1730b0339fe9b3df7ee751f9a5f0500d54b5c23 /xlators
parent8b76f7c394e99f35463fc508984c6c532ddf4a8f (diff)
performance/write-behind: store the current window size in wb_file.
- this would increase the performance since we don't have to traverse the request list every time we need the current window size. 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
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/write-behind/src/write-behind.c84
1 files changed, 40 insertions, 44 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 6ba5fafa2db..3f683aa3c8a 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -48,7 +48,8 @@ struct wb_file;
typedef struct wb_file {
int disabled;
uint64_t disable_till;
- size_t window_size;
+ size_t window_conf;
+ size_t window_current;
int32_t refcount;
int32_t op_ret;
int32_t op_errno;
@@ -57,7 +58,7 @@ typedef struct wb_file {
fd_t *fd;
gf_lock_t lock;
xlator_t *this;
-}wb_file_t;
+} wb_file_t;
typedef struct wb_request {
@@ -268,6 +269,7 @@ wb_file_create (xlator_t *this, fd_t *fd)
file->disable_till = conf->disable_till;
file->this = this;
file->refcount = 1;
+ file->window_conf = conf->window_size;
fd_ctx_set (fd, this, (uint64_t)(long)file);
@@ -322,6 +324,10 @@ wb_sync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
per_request_local->op_errno = op_errno;
}
+ if (request->flags.write_request.write_behind) {
+ file->window_current -= request->write_size;
+ }
+
__wb_request_unref (request);
}
@@ -958,7 +964,7 @@ wb_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
|| ((flags & O_ACCMODE) == O_RDONLY)
|| (((flags & O_SYNC) == O_SYNC)
&& (conf->enable_O_SYNC == _gf_true))) {
- file->window_size = 0;
+ file->window_conf = 0;
}
}
@@ -1013,7 +1019,7 @@ wb_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|| ((flags & O_ACCMODE) == O_RDONLY)
|| (((flags & O_SYNC) == O_SYNC)
&& (conf->enable_O_SYNC == _gf_true))) {
- file->window_size = 0;
+ file->window_conf = 0;
}
}
@@ -1165,45 +1171,19 @@ __wb_mark_winds (list_head_t *list, list_head_t *winds, size_t aggregate_conf,
}
-char
-__wb_can_unwind (list_head_t *list, size_t window_conf,
- size_t *window_current_ptr)
-{
- wb_request_t *request = NULL;
- size_t window_current = 0;
- char can_unwind = 1;
-
- list_for_each_entry (request, list, list)
- {
- if ((request->stub == NULL)
- || (request->stub->fop != GF_FOP_WRITE)) {
- continue;
- }
-
- if (request->flags.write_request.write_behind
- && !request->flags.write_request.got_reply)
- {
- window_current += request->write_size;
- if (window_current > window_conf) {
- can_unwind = 0;
- break;
- }
- }
- }
-
- if (can_unwind && (window_current_ptr != NULL)) {
- *window_current_ptr = window_current;
- }
-
- return can_unwind;
-}
-
-
size_t
__wb_mark_unwind_till (list_head_t *list, list_head_t *unwinds, size_t size)
{
size_t written_behind = 0;
- wb_request_t *request = NULL;
+ wb_request_t *request = NULL;
+ wb_file_t *file = NULL;
+
+ if (list_empty (list)) {
+ goto out;
+ }
+
+ request = list_entry (list->next, typeof (*request), list);
+ file = request->file;
list_for_each_entry (request, list, list)
{
@@ -1217,25 +1197,41 @@ __wb_mark_unwind_till (list_head_t *list, list_head_t *unwinds, size_t size)
written_behind += request->write_size;
request->flags.write_request.write_behind = 1;
list_add_tail (&request->unwinds, unwinds);
+
+ if (!request->flags.write_request.got_reply) {
+ file->window_current += request->write_size;
+ }
}
} else {
break;
}
}
+out:
return written_behind;
}
void
-__wb_mark_unwinds (list_head_t *list, list_head_t *unwinds, size_t window_conf)
+__wb_mark_unwinds (list_head_t *list, list_head_t *unwinds)
{
- size_t window_current = 0;
+ wb_request_t *request = NULL;
+ wb_file_t *file = NULL;
+
+ if (list_empty (list)) {
+ goto out;
+ }
- if (__wb_can_unwind (list, window_conf, &window_current)) {
+ request = list_entry (list->next, typeof (*request), list);
+ file = request->file;
+
+ if (file->window_current <= file->window_conf) {
__wb_mark_unwind_till (list, unwinds,
- window_conf - window_current);
+ file->window_conf - file->window_current);
}
+
+out:
+ return;
}
@@ -1431,7 +1427,7 @@ wb_process_queue (call_frame_t *frame, wb_file_t *file, char flush_all)
* an iobuf) are packed properly so that iobufs are filled to
* their maximum capacity, before calling __wb_mark_winds.
*/
- __wb_mark_unwinds (&file->request, &unwinds, conf->window_size);
+ __wb_mark_unwinds (&file->request, &unwinds);
__wb_collapse_write_bufs (&file->request,
file->this->ctx->page_size);