tests/060: wait for master to start up

This is necessary to start sheepdog with all the nodes stably.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/048: fix vdi check output

Currently, 'collie vdi check' can repair objects in parallel, so we
cannot guarantee that sheep restores the first replica in this case.
This makes the test show the unique output in spite of the checked
order.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
[don't merge] tests: valgrind option for lower memory machine

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
[tmp] sheep: don't overwrite epoch log

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
[tmp] sheep/group: remove unnecessary log write

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: introduce xfallocate and xftruncate helpers

These helpers retry the syscalls while the error is retry-able.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
use 4KB for trim_zero_sectors instead of 512B

Most filesystems use 4KB for their block sizes and trimming 512B may
be meaningless.  It's better to use the block size for faster
comparison.

This also allows for the caller to specify the offset of buffer so
that it can get the block-aligned offset and length.  It is in
preparation for allowing sparse objects.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: introduce generational reference counting for object reclaim

Generational reference counting is an algorithm to reclaim data
efficiently without race conditions on distributed system.  This
extends vdi objects structure to store generational reference counts,
and increments the counts when creating snapshots.

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

This introduces ledger objects, which keeps track of the number of
outstanding references of each generation.  Sheep decrements a
generational reference count with a gateway request SD_OP_DECREF_OBJ,
and reclaims objects when there is no generational reference.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: decrement generational reference count on vdi deletion

This removes old vdi deletion code, which reclaims objects only when
all relevant snapshots are deleted, and uses a generational reference
counting algorithm.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: decrement generational reference count on copy-on-write

This decrements a reference count of the old data object when
allocating a new data object on CoW.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: remove max children limit

We no longer need it.  This also reduces the vdi header size.

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

We don't need to care about a fragmentation when
 - the object is unlikely to be accessed sequentially, and
 - the object is read-only.

In that sense, we can make the objects sparse if they are not data
objects and writable ones.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: caluculate actually allocated size

Now we allow sparse objects, it's better to calculate the actually
allocated sizes.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests: update outputs of testcases for reclaim and new vdi object size

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