sheep: add helper functions to check the current thread

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: fix comment of put_vnode_info

We can call this function in the worker threads because urcu atomics
guard vnode_info.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep/recovery: guard next_rw with RCU

We have to manipulate next_rw atomically because next_rw can be
accessed by both main and worker threads.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: introduce helpers to handle thread-unsafe variables

We have some variables that can be accessed only in the main thread.
This patch introduces the macro 'thrad_unsafe' to guard it with
assert().

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: define some thread unsafe variables as thread_unsafe

This declares current_vnode_info, sys->pending_block_list,
sys->pending_notify_list, and recovering_work as thread_unsafe
variables.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: set vnode_info even against force operation

We usually call force operation even after the cluster starts up, so
this patch gives a chance for it to access vnode_info.  With this
patch, get_vnode_info() returns NULL if cluster is not started yet.

This prepares for the next patch.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: don't call get_vnode_info in epoch_log_read_remote()

We cannot call get_vnode_info() in epoch_log_read_remote() (in the
worker thread).  We already have the current vnode info, so let's use
it.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
work: don't call get_node_info in the worker thread

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: assert when exec_req are called in the main thread

Calling these functions in the main thread lead to dead-lock and must
be avoided.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: allow process_work to set response data when SD_FLAG_CMD_WRITE is not set

Currently, we assume that process_main sets the response data when
SD_FLAG_CMD_WRITE is not set.  This also allows process_work to set
the data and notify it to all the nodes.

This prepares for the next patch.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: fix dead lock problem of cluster_force_recover

We cannot call exec_req in cluster_force_recover (in the main thread).
With this patch, sheep gets epoch info in the worker thread, and
notifies it to all the node.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>