Whamcloud - gitweb
LU-8964 libcfs: Introduce parallel tasks framework 74/24474/26
authorDmitry Eremin <dmitry.eremin@intel.com>
Tue, 20 Dec 2016 09:10:05 +0000 (12:10 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 30 May 2017 13:28:08 +0000 (13:28 +0000)
commiteca949bf83dfec5be33dc6230f55823376aef65a
treefa8573453be3ef07d5ffa7672ddd95955361a231
parentb58fcb7fe4f63830ccc3e6c1747cb1b361d481dd
LU-8964 libcfs: Introduce parallel tasks framework

In this patch new API for parallel tasks execution is introduced.
This API based on Linux kernel padata API which is used to perform
encryption and decryption on large numbers of packets without
reordering those packets.

It was adopted for general use in Lustre for parallelization of
various functionality. The first place of its usage is parallel I/O
implementation.

The first step in using it is to set up a cfs_ptask structure to
control of how this task are to be run:

    #include <libcfs/libcfs_ptask.h>

    int cfs_ptask_init(struct cfs_ptask *ptask, cfs_ptask_cb_t cbfunc,
                       void *cbdata, unsigned int flags, int cpu);

The cbfunc function with cbdata argument will be called in the process
of getting the task done. The cpu specifies which CPU will be used for
the final callback when the task is done.

The submission of task is done with:

    int cfs_ptask_submit(struct cfs_ptask *ptask,
                         struct cfs_ptask_engine *engine);

The task is submitted to the engine for execution.

In order to wait for result of task execution you should call:

    int cfs_ptask_wait_for(struct cfs_ptask *ptask);

The tasks with flag PTF_ORDERED are executed in parallel but complete
into submission order. So, waiting for last ordered task you can be sure
that all previous tasks were done before this task complete.

Test-Parameters: trivial
Change-Id: I36d9802226f9b6fae627594a86ad1a83f7bc6b0c
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: https://review.whamcloud.com/24474
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/libcfs_ptask.h [new file with mode: 0644]
libcfs/libcfs/Makefile.in
libcfs/libcfs/libcfs_ptask.c [new file with mode: 0644]