corosync: fix comparism in event_is_confchg

event_is_confchg needs to check for COROSYNC_EVENT_TYPE_NOTIFY instead of
COROSYNC_MSG_TYPE_NOTIFY as it operates on the higher level events.

Right now we never search for a notify event so it's not a problem in
practice.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
remove the unused SD_OP_GET_VM_LIST and SD_OP_KILL_NODE opcodes

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
remove the unused SD_FLAG_CMD_WEAK_CONSISTENCY flag

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
renumber local flags and errors to be above 0x80

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
add strict versioning

Enforce that all internal commands have the SD_SHEEP_PROTO_VER protocol
version, and any external command that has a protocol version has the
right (0x01) one.  Also bump SD_SHEEP_PROTO_VER to 0x05 for the upcoming
0.4.0 release which has lots of internal protocol changes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: simplify client_decref() and move it into free_request() and add a helper function

1) In previous code, sheep calls client_incref() in alloc_request(), but
free_request() does not call client_desref() in it, as a result it's difficult
to keep ci->refcnt with correct value. Now I drop client_incref/client_decref
and call ci->refcnt++/ci->refcnt-- in alloc_request/free_request directly.

2) A bug in put_request(): before calling client_decref(), we should do some
clear actions like client_handler().

3) ci->refcnt should only be increased by alloc_request(), let's initialize
   it with 0 in create_client().

4) remove error message in unregister_event() when lookup_event() failed,
   as this function may be called several times in new helper function which
   named clear_client() before ci->refcnt reach zero.

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: free all requests when connection is dead

It's important to free all requests when connection is dead(especially when
EPOLLERR occur, some requests might be not cleared correctly), or it will lead
to memory leak and sys->nr_outstanding_reqs would be always larger than 0 as a
result sheep could not be shutdown.

Conneciont's request is created by alloc_request() and will be kept in four
places:
  1) ci->rx_req       -- after alloc_request()
  2) inflight         -- after reset ci->rx_req and queue_request()
  3) ci->dones_reqs   -- after put_request() added to ci->dones_reqs list
  4) ci->tx_req       -- after init_tx_hdr() and assigned to ci->tx_req
When request is inflight, ci->refcnt will always be larger than 0, but it will
be added to ci->dones_reqs after work_fn finished.

As long as we can promise that one request only be kept in one of these four
places, than we can free it correctly.

This patch do this clear work in clear_client().

BTW: add and update some log info

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
man: fix some typos

This patch is based on the github pull request from Takashi.

  https://github.com/collie/sheepdog/pull/31

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
cluster/local: process multiple events in local_handler

Currently, the local driver doesn't retry performing the blocked
events after they are unblocked.  This patch fixes the problem.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: increment req->refcnt correctly in object deletion

We need to increment the reference counter even if the deletion work
doesn't start immediately.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: avoid setting proto_ver outside sd_init_req

This fixes a version mismatch problem of collie vdi getattr and
setattr commands.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
add a helper function to calculate the max size of objects

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>
farm: fix support for vdi attribute objects

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
update bash completion file for collie

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