[Devel] [PATCH RHEL7 COMMIT] fuse kio: Kill fiemap_worker() thread

Konstantin Khorenko khorenko at virtuozzo.com
Wed Sep 5 13:06:36 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.11.6.vz7.71.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.11.6.vz7.71.8
------>
commit a6bdf0e709efd62504ba8456e70ebf220decb896
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Wed Sep 5 13:06:36 2018 +0300

    fuse kio: Kill fiemap_worker() thread
    
    This is a preparation to move iterations to workqueue.
    Here we just kill kthread, and make it synchronous.
    Next patches will do it async again.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    Acked-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
    
    =====================
    Patchset description:
    
    Optimize fiemap ioctl
    
    https://jira.sw.ru/browse/HCI-90
    
    Summary:
      This patch set optimizes fiemap ioctl by removing
      kthread creation. Instead of this, static work
      is used, so we safe some time on copy_process().
    
    Fiemap does not require separate kthread, since
    the most time the kthread is spending in waiting
    for fiter->ireq.iocount becomes 0. Instead of this,
    the generic kthread could queue another fiemap
    requests at this time. This is the thing the patch set
    introduces.
    
    Note, that we had a kthread for every fiemap request,
    and this may look more scalable. But this is not true,
    since the actions, fiemap does, is pretty small. So,
    I think for the most workload the single fiemap work
    is enough. If we meet a workload, where the single
    work is not enough, it will be pretty easy to make
    fiemap_work just as an array in struct pcs_cluster_core
    (to make it per-node or even per-cpu). But I think,
    it's not necessary at least till main_job or completion_job
    are per-node or per-cpu (fiemap requests are small subset
    of all requests going through main_job).
    
    https://github.com/shekkbuilder/fiemap/blob/master/fiemap.c
    code was taken as a base for the performance test and modified.
    The below is results and the test's code.
    
    Time of test execution on 3 extents-file (just randomly chosen
    number of extents):
    
    Before: real 0m11.069s
    After:  real 0m9.112s
    
    It became 17% faster, it was 21% slower.
    
    Kirill Tkhai (7):
          fuse kio: Extract fiemap iteration from fiemap_worker() to separate function
          fuse kio: Move it variable from stack to struct fiemap_iterator
          fuse kio: Kill fiemap_worker() thread
          fuse kio: Move position advance in fiemap_process_one()
          fuse kio: Move fiter ireq iocount assignment
          fuse kio: Introduce fiemap_work
          fuse kio: Async queueing of fiemap from work
---
 fs/fuse/kio/pcs/pcs_cluster.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cluster.c b/fs/fuse/kio/pcs/pcs_cluster.c
index 35b222c7de75..cd97db3640a8 100644
--- a/fs/fuse/kio/pcs/pcs_cluster.c
+++ b/fs/fuse/kio/pcs/pcs_cluster.c
@@ -232,9 +232,8 @@ static void fiemap_process_one(struct fiemap_iterator *fiter)
 	ireq_complete(orig_ireq);
 }
 
-static int fiemap_worker(void * arg)
+static void process_ireq_fiemap(struct pcs_int_request *orig_ireq)
 {
-	struct pcs_int_request * orig_ireq = arg;
 	struct pcs_dentry_info * di;
 	struct fiemap_iterator * fiter;
 	struct iov_iter *it;
@@ -243,7 +242,7 @@ static int fiemap_worker(void * arg)
 	if (fiter == NULL) {
 		pcs_set_local_error(&orig_ireq->error, PCS_ERR_NOMEM);
 		ireq_complete(orig_ireq);
-		return 0;
+		return;
 	}
 	it = &fiter->it;
 
@@ -263,15 +262,13 @@ static int fiemap_worker(void * arg)
 		pcs_set_local_error(&orig_ireq->error, PCS_ERR_NOMEM);
 		ireq_complete(orig_ireq);
 		kfree(fiter);
-		return 0;
+		return;
 	}
 	fiter->fiemap_max = orig_ireq->apireq.aux;
 	orig_ireq->apireq.req->get_iter(orig_ireq->apireq.req->datasource, 0, it);
 	fiter->mapped = &((struct fiemap*)it->data)->fm_mapped_extents;
 
 	fiemap_process_one(fiter);
-
-	return 0;
 }
 
 void pcs_cc_process_ireq_chunk(struct pcs_int_request *ireq)
@@ -369,18 +366,6 @@ static noinline void __pcs_cc_process_ireq_rw(struct pcs_int_request *ireq)
 		ireq_complete(ireq);
 }
 
-static void process_ireq_fiemap(struct pcs_int_request * ireq)
-{
-	struct task_struct * tsk;
-
-	tsk = kthread_run(fiemap_worker, ireq, "fiemap-worker");
-
-	if (IS_ERR(tsk)) {
-		pcs_set_local_error(&ireq->error, PCS_ERR_NOMEM);
-		ireq_complete(ireq);
-	}
-}
-
 static void pcs_cc_process_ireq_ioreq(struct pcs_int_request *ireq)
 {
 	if (ireq->apireq.req->type == PCS_REQ_T_SYNC) {


More information about the Devel mailing list