object cache: cleanup strbuf usage

Don't use strbuf for hot path because it relys on the malloc(2) to allocate
memory and will add more presure to the glibc's ptmalloc layer.

This is a defensive patch because we observed segfault of malloc or other glibc
library calls (for e.g, opendir(2)) on top of malloc(2).

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
object cache: enable external cache location

Then we can specify external cache local as:
 $ sheep /store -w object:dir=/path/to/cache

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
net: don't use keepalive for sockfd

Since we already use timeout for IO requests, there is no need to use keepalive
to detect weather the target node is alive or not. For a busy network,
keepalive will false report the connection is broken.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: add option for dual nic support

This is a prepare patch, add one option to add another nic for IO requests.

Usage:
 sheep -i ip{,port} ...

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

We'd better embed inet type in it, then reduce one parameter passed in.

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

This is a prepare patch for redundant nic support.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sockfd cache: support dual connections for a single node

This patch adds dual network card support.

- use one dedicated connection for IO requests
- if IO connection fails, then fallback to non-IO one

Redundant connection is supposed to make Sheepdog more reliable.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests: suppress false errors for zookeeper

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests: add 050 for IO NIC

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: fix hang when IO NIC is down only

If IO NIC is down but sheep alive, epoch isn't incremented, so we can't retry
poll for ever.

This problem can be demonstrated by 050.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sockfd_cache: add macro to calculate a watermark

This removes some magic numbers.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
use boolean where it is appropriate

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
net: remove redundant argument from tx

We don't pass any flags to send/2, so we can simply use write/2
instead of it.

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

script/checkpatch.pl seems to be imported from linux kernel directly,
so it contains lots of obsolete checks only for linux source tree.

This patch reduces clearly obsolete checks and make the script a
little bit faster (e.g. with this patch, checking the 4th patch of the
shephered (near 2000 lines) can be executed about 0.1 second faster)
and cleaner.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: support disk more than 2T

Currently we only support disk as backend storage less than 2T due to hardcoded
4M list buffer. The underlying object list cache already return error code when
passed buffer is too small. Simply retry with larger buffer for this case will
allow us enjoy however big disk is and remove this limit.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
tests/035: teach it to catch more bugs

Teach test read halt-closed connection. Current master will fail the case.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
net: add read timeout for sockfd

This fixes the hang problem demenstated by refined 035 on sheep side.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: retry read for eagain

Collie should retry read for eagain to fix the false-timeout case.

This fix the 035 failure on collie side.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
checkpatch.pl: reduce an obsolete check

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
object cache: drop dirty tree

We don't need it because we can rely object tree to find cache entry. And we
don't search dirty tree.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>