collie: ranme SUBCMD_FLAG_XXX as CMD_XXX

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie/trace: move trace_cat to graph subcommand

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional: make qemu commands specifiable

Current scripts under tests/functional use qemu-io and qemu-img
directly. This patch makes these commands specifiable via environment
variables: QEMU_IO_PROG and QEMU_IMG_PROG. This is important for
testing stable branches because output format of these commands can be
changed during update of qemu.

Example:
$ sudo QEMU_IO_PROG=/usr/local/qemu-stable-1.5/qemu-io DRIVER=local ./check 39

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/func: test restart with missing object in stale directory

Current stable-0.6 can't pass this script but master can.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
remove wrong comments about early_log_init

We can call our print functions before early_log_init() since
default_log_formatter is enabled by default.

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

This abort() was used to debug the commit 10d0e60 and I forgot to
remove it before sending the patch.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
collie: remove redundant "\n" from the help message

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

We removed a master node from cluster drivers, so the master column in
the node list is meaningless now.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
collie: don't use a negative value for a zone id

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

If cpg_initialize() returns CS_ERR_SECURITY, the error reason is sheep
doesn't have a privilege to use corosync because of corosync
configuration.  In this case, printing "Permission denied" is better.

In the other cases, corosync is actually running and there is another
error reason.  This removes "is corosync running?" from the error
message in the default cases.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
make file local variables static

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
collie: specify void if there is no argument

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
net: skip memset for IPv6 in str_to_addr()

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
collie: use byte array for sdhost

This simplifies code a bit, and also, fixes a problem that collie
doesn't show an error when an invalid address is specified to '-a'.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
simplify addr_to_str with thread local storage

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: make node_to_str and lnode_to_str thread-safe

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
bitops: simplify fls with gcc builtin functions

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sha1: force inline rol()

rol (rotate a 32-bit value left) is called a lot of times for each
sha1 calculation, and it becomes a bottleneck when inline expansion is
turned off (with debug build) and tracer is enabled.  It's not so
important to profile the function, so let's inline it forcely.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
util: add list_sort()

This function sort the list, taken from linux kernel.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie/trace: add graph stat function

This is useful to get how much time each function takes during the trace.

$ collie trace graph stat
   Total (s)   Per Call (ms)   Calls   Name
   100.659       51.356         1960   eventfd_xread
    79.315       68.790         1153   do_process_work
    76.645      348.388          220   do_push_object
    76.637      348.349          220   push_cache_object
    74.611      185.139          403   gateway_create_and_write_obj
    74.338      345.757          215   exec_local_req
    74.276      350.361          212   gateway_forward_request
    35.555       34.722         1024   xpwrite
    35.547        7.119         4993   event_loop
    35.538        7.118         4993   do_event_loop
    34.299      385.380           89   sheep_do_op_work
    33.778      427.565           79   peer_create_and_write_obj
    33.776      427.547           79   default_create_and_write
    26.324     2632.399           10   object_cache_push
    26.259     2917.706            9   do_background_push
     2.525        2.701          935   object_cache_handle_request
...

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