lib: Remove executable stack comming from sha1_ssse3.S

Executable stack can be security hole, EX stack prevents working of NX.
More information can be found here:
https://wiki.gentoo.org/wiki/Project:Hardened/GNU_stack_quickstart
https://wiki.gentoo.org/wiki/Hardened/PaX_Utilities#Introduction

i686 architecture wasn't affected.

Signed-off-by: Marcin Mirosław <marcin@mejor.pl>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/http: add option 'buffer=' to adjust size of buffer for kv

In some testing environment, large size of buffer will make
the performance of swift bad because kv will split buffer into too many
requests and send out, which lead to congestion in network; but small size
of buffer will make the speed of receiving http request slow. After all,
we found out that 8MB is the best value for our environment.

Even the 8MB is good, the size of buffer is difficult to choose in different
environment (different hardware of servers, different number of nodes, etc.),
so we should add this option to let users choose buffer size.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/http: add check for return value of http_request_read()

When users kill the curl which is uploading large files, the http_request_read()
will return 0 and lead to dead loop, so we should check it.
We also add code to free space of alloc after error happens.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
rpm: make dependencies of zookeeper and fuse packages optional

Current "make rpm" requires zookeeper-lib-devel and fuse-devel
unconditionally. When users don't want zookeeper driver or sheepfs,
they should be disabled.

Related issue:
https://bugs.launchpad.net/sheepdog-project/+bug/1264253

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
deb: create deb package from raw source archive

This patch makes it possible for users to create debian package from
raw source archive.

Related issue:
https://bugs.launchpad.net/sheepdog-project/+bug/1264255

Reported-by: Bastian Scholz <scholzb@t-online.de>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: fix error in sheepdog cluster recovery

Sheepdog failed to recover object when we running it on 5 servers cluster with
about 20G data by erasure-code mode.

The reason is in default_create_and_write(): it rename() obj to data-directory
and then set xattr of ec-index for it, this will leave a time-window for another
process to read the data-object but can't get xattr of ec-index. Then the
process will report get-xattr fail and remove the disk as it think it's an
io-error event.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: fix compiler error in logger.c

When build sheepdog in centos6, it will report:

    logger.c: In function ‘gdb_cmd’:
    logger.c:746: error: ‘ARG_MAX’ undeclared (first use in this function)
    logger.c:746: error: (Each undeclared identifier is reported only once
    logger.c:746: error: for each function it appears in.)
    logger.c:746: warning: unused variable ‘cmd_str’
    logger.c: In function ‘sd_backtrace’:
    logger.c:797: error: ‘ARG_MAX’ undeclared (first use in this function)
    logger.c:797: warning: unused variable ‘cmd’

the reason has been explained here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518858
and the standard revolution is using 'sysconf()'.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: fix memory leak in _invert_mat()

First run swift interface on sheepdog, thean kill a node and wait for
recovery. After it, the RSS of sheep daemon will increase to about 8GB
which is a sign of memory leak.

Then we use valgrind to check sheepdog daemon and finally find out the
leak point: _invert_mat() in lib/fec.c

Signed-off-by: Robin DOng <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: fix memory leak in local_req_async_main()

We find out a memory-leak point in local_req_async_main() by valgrind.
After fix it, the RSS of sheep daemon could keep stablely for press-testing.

Signed-off-by: Robin DOng <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: fix memory leak in B-tree

When the depth of B-tree for sd_inode becomes 2, and last ext-node is full, there
is a memory leak in routine of search_whole_btree() -- we only free memory in
path->p_ext_header but its value will be NULL in this case.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: make depth of ext-node right

When depth of B-tree become 2, the value of 'depth' for ext-node
should be 1 (the 'depth' of idx-node is 2).

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: write correct data of inode

To write 'btree_counter' back, we should give memory of 'inode->btree_counter'
to writer instead of 'inode'.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/func: add a test for massive clone

Master can't pass it and following patch fixes it.

Reviewed-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: clear child vdi for deletion

This will fix a bug that after deletion of clones, we fail to create clones
with the snapshot that we previousy cloned.

Reviewed-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib/option: support 'B' notation for byte

Reviewed-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib/work: kill a possible memory leaker

Though in reality, this wouldn't happen.

Reviewed-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/func: fix spurious errors due to nfs files

Reviewed-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: create new function set_vid_for_btree()

Create new function set_vid_for_btree() to replace some codes in
sd_inode_set_vid(), so the structure of code will be better.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: change interface sd_inode_set_vid()

sd_inode_set_vid() only set one 'vid' at before, we change it
to support 'set range of vids'.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: add cache version of writer and reader

Add new functions to repleace default writer and reader so it can cache
entire ext-node when set_vid_for_btree() need to access ext-node.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>