tests/func/058: fix supurious failure

Reviewed-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
lib: change xmalloc() to xvalloc() in sd_inode.c

The default_read_from_path() returned "Invalid argument" when we running
sheepdog cluster in test environment with sheep option "-D". The reason
is that the allocating memory for reading and writing btree-object is not
aligned. Therefore we should use xvalloc() instead of xmalloc() to allocate
aligned memory.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: go to panic if using unaligned memory in direct-io mode

When startup sheep with option "-D", the plain_store will check alignment of
read/write buffer, but if the buffer is not aligned, it will do nothing if
it dose not choose "--enable-debug" for configuration. Then sheep will open
file with "O_DIRECT" and call pread() with unaligned buffer, it will cause
error io and remove the disk from md which is totally wrong behavior.
So, we should make the check strong enough: sheep will panic directlly if
finding unaligned buffer.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: cleaning vdi deletion process, round 2

This patch cleans the vdi deletion process of sheep. Current vdi
deletion code creates one work for one deletion. It seems that there
is no reason to create so many work. This patch lets the code to
create only one work for vdi deletion request.

With this change, this patch improves simplicity of the code. For
example, the queue of struct deletion_info and related code are
removed.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: fix some compile errors

Both MIN/MAX and roundup are provided by glibc and would cause compile error
when we #include <sys/param.h>. Just use GNU version.

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: introduce NFSv3 transport

We use glibc's RPC to build NFS daemon and rpcgen for NFS marshing and
unmarshing.

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/nfs: add mount protocol stub

This is a preparation patch

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
dog: add nfs command

We support allocate as many nfs backend storage as you want.

usage:
 dog nfs create $name # create a nfs backend named $name
 dog nfs delete $name # delete a nfs backend named $name

$name is the name for users to mount at client in $IP:$NAME

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
util: add PTR_ERR helpers

Sometimes we need to return ERROR code from pointers

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/nfs: add basic file system framework

Add basic inode, dentry structures and just support 'ls' /mntpoint operation.

For inode management, we use the hash scheme as in http implementation. This
will save us a lots of code on inode allocation and deallocation and management.

We also make use the simiar concepts found in traditional UNIX systems
- inode, represent files
- dentry, directry entry that map name components to 'inode numbers'
- extents, to manage free space for file data
- directory, a plain file that contains dentries, giving us tree structure

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: clean up sd_inode btree error code

These error codes are used internally, not for client communication.

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/nfs: support lookup/create/setattr nfs operation

Now we support 'touch' command.

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/nfs: implement read/write nfs operation

Now we support more bash command such as cp, mv, echo, cat ...

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/nfs: add mkdir support

Now we support 'mkdir' command and gain hierarchical structure support.

TODO:
 - make dentry operation operate on top of 'file' operation
 - add hash or btree based dentries management

 Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: make stat_data_objs a generic function

and rename it as sd_inode_stat()

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep/nfs: implement nfs3_fsstat operation

Now we support 'df' command to get file system stats.

Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
add INFO level operation logging on each node.

Administrator couldn't track operation on each node without this function.
This function logs only administrative operation at rx_main and tx_main.
Operations that is not related to administrative operation are not
logged in this function. such as read/write etc.

Signed-off-by: Yoshinori Matsuo <matsuo.yoshinori@lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep/md: check oid more strictly in oid ieration

This add some more infomation and useful for debugging if something unexpected
happened.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/func: add tests for object misplacement

Current master can't pass it and following patch will solve it

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/func: fix spurious error for 032

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