trace: fix compile error without --enable-trace

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
test: consolidate 012 to git rid of spurious failure

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: split notification messages into two queues

Currently, the corosync driver uses two queues, confchg_list and
notify_list.  However, this causes problems because some messages
(e.g. format, shutdown, cluster snapshot, ...) needs to be ordered
with confchg events.

This patch splits multicast messages into two queues, block_list and
nonblock_list.  All block messages (e.g. vdi creation, etc) are linked
into block_list queue, and other notification messages and confchg
events are linked into nonblock_list.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: save store driver name outside storage driver

Storage drivers shouldn't care about config file.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: save config before logging current epoch

If sheep exits after writing epoch info and before saving config in
cluster_make_fs(), it will send a wrong config to master and fail to
join Sheepdog when it restarts.

This patch saves config before logging epoch info to avoid the
problem.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
tests: ensure that sheep processes exit after calling pkill

After send a signal, there is a delay until sheep exits.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
trace: don't do patching while short_thread_running

When the code patcher wakes up, there is still chances that short thread is
running. We simply return to wait for next eventfd notification until we are
safe to do patching.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
trace: run trace cat as a worker

The subtle case is that when tracer is in patching, we should return AGAIN to
buffer reader to ask him to try again until patching is down.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
trace: fix random crash for enable command

We should wait for all the worker's signal handler running like old code, or we
will get random crash when signal handler is called after patching.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: fix eventfd_read() error handling

This is motivated by a crash log:
...
Sep 01 21:53:50 [block] suspend(64) going to resume
Sep 01 21:53:50 [block] exec_local_req(449) event fd read error Interrupted system call
Sep 01 21:53:50 [block] do_process_work(1245) failed: 12, 0 , 1, 8
Sep 01 21:53:50 [main] cluster_op_done(283) LOCK_VDI (0xc7a790)
Sep 01 21:53:50 [gway 4] do_process_work(1238) 83, c7c850, 32580
...

that eventfd_read() get EINTR without proper handling and then mess up the next
process.

- retry read in exec_local_req() (worker thread)
- return in enable/disable_tracer() (main thread)

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: add vdi rollback support

This adds a new command 'vdi rollback' to rollback to the requested
snapshot.

Here is an example:

  $ collie vdi create test 4G
  $ echo snap1 | collie vdi write test 0 512
  $ collie vdi snapshot test -s snap1
  $ echo snap2 | collie vdi write test 0 512
  $ collie vdi snapshot test -s snap2
  $ collie vdi read test 0 512
  snap2
  $ collie vdi rollback test -s snap1
  $ collie vdi read test 0 512
  snap1
  $ collie vdi rollback test -s snap2
  $ collie vdi read test 0 512
  snap2
  $ collie vdi list
    Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
  s test         1  4.0 GB  4.0 MB  0.0 MB 2012-09-01 09:29   7c2b25     1         snap1
  s test         2  4.0 GB  4.0 MB  0.0 MB 2012-09-01 09:30   7c2b26     1         snap2
    test         3  4.0 GB  0.0 MB  4.0 MB 2012-09-01 09:30   7c2b29     1

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests: add test of vdi rollback

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests: check message order between vdi creation and object recovery

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
cluster/corosync: order unblock messsage with confchg events

Multicast messages after block operations also must be ordered with
confchg events.  For example, if an unblock event of SD_OP_NEW_VDI is
not ordered with confchg events, post_cluster_new_vdi() may not be
called on newly added nodes.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: wait for vdi copies to be updated in recovery process

If node membership changes between process_work and process_main of
SD_OP_NEW_VDI, we cannot get the vdi copies in recovery process.  In
that case, we need to wait for post_cluster_new_vdi to finish.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
store: return SD_RES_NO_OBJ when object size is zero

If clients read objects which is just being created, the size of read
data can be zero and clients get a SD_RES_EIO error.  Sheep leaves
cluster when the SD_RES_EIO error happens, so we should return
SD_RES_NO_OBJ in this case.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: check return value of get_vdis_from

A newly added node sends SD_GET_VDI_COPIES to only one node, so if the
node is not available, the added node cannot get vdi copies info.  We
should try another node in such case.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: fix uninitialized variables

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>