farm: use PRIx64 to print oid

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
cache: reclaim cow objects after sheep restart

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: retry forever to execute requests

This patch add a 'max_retry_count' to exec_req() helper. sheep and sheepfs
still retry MAX_RETRY_COUNT for the rquests. But collie retry forever (UINT32_MAX)

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
import debian directory maintained by debian package team

This copies the debian patches to build a deb package from
  http://patch-tracker.debian.org/package/sheepdog

The changelog files are not imported since they are auto-generated by
the next patch, and the translation files are not imported since it's
difficult for our community to maintain them.  Some style problems
detected by our checkpatch.pl are also fixed.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Makefile: add support for deb package generation

This patch allows us to generate a deb package by running command
"make deb".

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
debian: update outdated information

We don't depend on any KVM features and don't use the sourceforge tree
now.  In addition, the upstream contact is updated with the current
maintainers.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
debian: add missing db_stop

This fixes a problem that the deb package installation hangs.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
debian: disable automatic start by default

The sheep daemon tries to join the existing cluster autonomously, so
starting sheepdog by default can cause a problem which the user
doesn't expect.  This disables automatic start by default and adds a
bit higher priority to the flag.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
debian: output deb to the current directory

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
util: clean work.h

work.h depends on external stuff like linked list, gettid(), etc. So
including work.h directly causes compile errors. This patch fixes this
problem.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
recovery: check node before try to connect to

This check exist in the old code but was accidentally refactored out by some
ghost commit.

Check node validity before connecting will save a lot of unnecessary network
traffic during recovery. Let's summon it back.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
zk: remove annoying debug information

ZNONODE and ZNODEEXISTS are very high volume operation error code. And not
useful even for debug. So just git rid of them.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
lib: remove unused macros in sha1.c

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: clean up error messages

- don't duplicate error message in collie_exec_req
- print oid in vdi_check failure

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: remove master node

The current procedure to handle sheep join is as follows.

 1. The joining node sends a join request.
 2. The master node accepts the request.
 3. All the nodes update cluster members.

This procedure has some problems:

 - The master election is too complex to maintain.
   It is very difficult to make sure that the implementation is
   correct.

 - The master node can fail while it is accepting the joining node.
   The newly elected master has to take over the process, but it's
   usually difficult to implement because we have to know what the
   previous master did and what it did not before its failure.

This patch changes the sheep join procedure to the following.

 1. The joining node sends a join request.
 2. Some of the existing nodes accept the request.
 3. All the nodes update cluster members.

It is allowed for the multiple nodes to call sd_join_handler() against
the same join request, but at least one node must have to do it.  With
this change, we can eliminate a master, and node failure while
accepting node join is also allowed.

Removing a master from zookeeper is not easy since it doesn't expect
that multiple nodes send EVENT_ACCEPT.  I'll leave this for another
day.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
recovery: wait until getting the previous epoch's vdi bitmap

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: optimize getting vdi bitmap

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional: wait_for_sheep_recovery outside of simulate_sheep_..

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional: add test for qemu reconnection

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
util: add find_zero_blocks()

This adds a helper function which does the similar thing as
trim_zero_blocks() but doesn't update the given buffer.

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