From 7e2de9c4acbc0c8c44c4ed3691a1f900054f6059 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Sat, 25 Feb 2017 17:42:37 +0100 Subject: [PATCH] copy: speed up by hinting --- kernel/mars_copy.c | 14 ++++++++++++++ kernel/mars_copy.h | 1 + 2 files changed, 15 insertions(+) diff --git a/kernel/mars_copy.c b/kernel/mars_copy.c index 87d55103..cade8cf3 100644 --- a/kernel/mars_copy.c +++ b/kernel/mars_copy.c @@ -223,6 +223,8 @@ void copy_endio(struct generic_callback *cb) brick = mref_a->brick; CHECK_PTR(brick, err); + brick->check_hint = mref->ref_pos; + queue = mref_a->queue; index = GET_INDEX(mref->ref_pos); st = &GET_STATE(brick, index); @@ -775,6 +777,7 @@ static int _copy_thread(void *data) brick->copy_error_count = 0; brick->verify_ok_count = 0; brick->verify_error_count = 0; + brick->check_hint = 0; _update_percent(brick, true); @@ -784,9 +787,18 @@ static int _copy_thread(void *data) loff_t old_start = brick->copy_start; loff_t old_end = brick->copy_end; int progress = 0; + loff_t check_hint; if (old_end > 0) { progress = _run_copy(brick, -1); + /* This is racy, deliberately. + * Missing some events does no harm. + */ + check_hint = brick->check_hint; + if (check_hint > 0) { + brick->check_hint = 0; + progress += _run_copy(brick, check_hint); + } /* abort when no progress is made for a longer time */ if (progress > 0) { last_progress = CURRENT_TIME; @@ -928,6 +940,7 @@ char *copy_statistics(struct copy_brick *brick, int verbose) "copy_last = %lld " "copy_dirty = %lld " "copy_end = %lld " + "check_hint = %lld " "copy_error = %d " "copy_error_count = %d " "verify_ok_count = %d " @@ -943,6 +956,7 @@ char *copy_statistics(struct copy_brick *brick, int verbose) brick->copy_last, brick->copy_dirty, brick->copy_end, + brick->check_hint, brick->copy_error, brick->copy_error_count, brick->verify_ok_count, diff --git a/kernel/mars_copy.h b/kernel/mars_copy.h index 75c06856..a3303752 100644 --- a/kernel/mars_copy.h +++ b/kernel/mars_copy.h @@ -101,6 +101,7 @@ struct copy_brick { atomic_t copy_read_flight; atomic_t copy_write_flight; long long last_jiffies; + loff_t check_hint; wait_queue_head_t event; struct task_struct *thread; struct copy_state **st;