tracer: rework tracer to work with master

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
tracer: fix trace-cat commind for empty trace file

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: use do_generic_subcommind in debug module

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
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>
util: enhance xmkdir

When the path exists but is a rgular file, we should also return -1

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: clean up path init functions

Use xmkdir will simlify the code a lot

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: move SD_OP_DEL_VDI as inter-protocol

QEMU needs it to implement 'loadvm' correctly.

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

We have a vdi_copy tree and we can get the vdi copy information for the tree
on the fly, no need to get it from inode.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: unify snapid passing and put it in vdi_iocb

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: pass vdi_iocb for vdi deletion

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