tests/functional/060: wait for recovery before listing vdis

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: wait until there is no get_vdis work in wait_get_vdis_done()

There is a race condition like as follows:

 1. Node A, B, and C start up.
 2. Node A receives accept events from B and C, and calls
    start_recovery().
 3. Node A calls wait_get_vdis_done in the recovery thread, but there
    are two get_vdis works in sys->block_wqueue.
 4. When the first get_vdis_done() is called, is_vdi_list_ready will
    be set to false.
 5. Node A starts object recovery without receiving vdi state from C.

To fix the problem, this patch counts the number of get_vdi works in
the block_wqueue.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/functional: add test for temporary object lost

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: use default copy number when vdi state is not available

Currently, screen_object_list() drops an object from the recovery list
when its copy number is not available.  This can happen, e.g., when we
lost all the inode replicas temporary.  To fix the problem, this patch
makes get_vdi_copy_number() return the default copy number when sheep
doesn't have the vdi state.

This patch is necessary to pass test/functional/074.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: check gateway request as early as possible

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: set bit in vdi_inuse in atomic manner

sys->vdi_inuse must be operated in atomic manner because it is
manipulated by multiple threads. This patch implements a new bit
operator atomic_set_bit() and let get_vdis_from() use this.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheepfs: use big_writes option only when the version of libfuse is equal or greater than 2.8.0

When using sheepfs on rhel5 environment, it will report:

    fuse: unknown option `big_writes'

because the 'big_writes' option is only supported by libfuse with version >= 2.8.0.

So we should add check for version of libfuse in configure.ac.

Signed-off-by: RobinDong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: call stat_request_end() only when stat_request_begin() was called

When sheepdog is not formated yet, sheep can call stat_request_end()
without calling stat_request_begin() and it leads to a segfault.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/functional: add test for live snapshot under heavy workload

This reproduces the bug reported by Valerio in

  http://lists.wpkg.org/pipermail/sheepdog-users/2013-August/001209.html

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
dog: fix check of snapshot vdi

This fixes a bug introduced by the commit 996751b.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/unit: use strnumber instead of size_to_str

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
logger: use gdb commands to dump stack and variable

This patch uses gdb features to dump stack and variable, and
simplifies logger.c a lot.  With this patch, gdb outputs will be
logged to gdb.txt instead of sheep.txt.

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

FNV hash author says that a expression of shifts and adds is faster
than the FNV_prime multiply (*).  However, with the recent GCC and
hardware, it looks like the FNV_prime multiply generates much faster
code.

This patch uses FNV_64_PRIME to generate codes, and adds fnv_64a_64 to
create a hash value from 64 bit integers faster.  Note that this patch
will not change the generated values.

(*) http://www.isthe.com/chongo/tech/comp/fnv/#gcc-O3

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

snapid

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: split create_vdi_obj() into 4 functions

create_vdi_obj() is very complex because it contains four kinds of
operations:

 - create fresh vdi
 - clone vdi
 - snapshot vdi
 - rebase vdi (rollback)

Splitting them apart make the code much easier to read.

This patch is just a cleanup and doesn't change its logic at all.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
add sd_hash to generate more dispersed hash values

I noticed that adding one more fnv_64a like

  hval = fnv_64a_64(hval, hval)

generates much more dispersed hash values.

This patch introduces sd_hash(), which does the above calculation
before returning a result.  This also add sd_hash_next(), which is
intended to be used for calculating virtual nodes and virtual disks.

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

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
increase the default number of virtual nodes

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

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

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