sheep: modify 'buf' member of deletion work

1, make it more readable

2, malloc size is not right, not multiply size of uint32_t

Signed-off-by: HaiTing Yao <wujue.yht@taobao.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: fix recovery logic

It can be cases that, in some epoch, sheepdog cannot maintain the
required copies of replications. When recovering from such epoch,
we'd better be conservative and double check.

Signed-off-by: Xinwei Hu <huxinwei@huawei.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
farm: fix put_entry() of trunk

There is race when trunk entry is put for hash list.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: drive object cache to work
sheep: add red black tree library

Red black tree is more scalable than hash lists if we
cannot predict the size of the data set.

This is excerpted from Linux kernel.
sheep: object cache proper

Object cache caches data and vdi objects on the local node. It is at 
higher level than backend store. This extra cache layer translate gateway 
requests into local requests, largely reducing the network traffic and highly
improve the IO performance.

Dirty objects will be flushed to cluster storage by 'sync' request from
guest OS.

- use red-black tree to track dirty objects
- use file lock to avoid RW race on object granularity
- use hash lists to maintain vdi space.
- each vid has its own independent object cache
sheep: teach sheep to use object cache

We only intrude IO code for gateway requests. Object IO path from
recovery logic is intact.
sheep: add flush_vdi operation

This is supposed to be initiated by Guest OS, but our collie
friend might also like it.

Flush operation is operated on vdi basis, that is, when one guest
flush its own dirty data, other guests are not affected.

- use forward_write_obj_req() to flush dirty objects
sheep: let object cache better interact with recovery logic

If the targeted object of the gateway request is cached already,
we can simply operate on it despite of node changes.
collie: flush the vdi before searching the object

'collie vdi object' need to read latest vdi object from backend
store to assist it to locate the object. Since the vdi object
is also cached in object cache, we need to flush it beforehand to
cluster.
object cache: implement vdi delete operation
sheep: add object list cache implemented by rb-tree

Added object list cache implemented by red-black tree,
everytime we creates a new object, we write the oid of the
object into the object list cache.

Signed-off-by: levin li <xingke.lwp@taobao.com>
sheep: object list cache applied to farm and simple store

Applied the object list cache to get_obj_list() which
walk through the rb-tree cache and return the cached list,
instead of calling sd_store->get_objlist(),
make it much faster to get the object list.

Signed-off-by: levin li <xingke.lwp@taobao.com>
farm: avoid unnecessary IO operation when recovering

When the cluster is recovering, we only need to write the objects
which no longer belong to the node to the snapshot, instead of writing
all the objects, by which we decreased the IO operation.

When we try to read an object, we first read it from the local
object directory, if not found, then read it from the snapshot.

Signed-off-by: levin li <xingke.lwp@taobao.com>
add a field nr_zones to cluster_info

In some path such as the object cache path, we need to determine the
copies count with the zones count, but we can't get the sd_vnodes list
to calucate the zones count, so it's better to include a nr_zones
field in cluster_info, everytime the cluster complete recovering, we
recalucate the nr_zones field.

Signed-off-by: levin li <xingke.lwp@taobao.com>