farm: clean up trunk.c

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

Slice is a fixed chunk of one object to be stored in farm. We slice
the object into smaller chunks to get better deduplication.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
farm: use slice_{read, write} to read/write object

For a test with 200M cluster with 2 copies (so roughly 100M data to backup),
I got the following resualt:

                   size  time
w/ slice (64K)  :  51M   2.037s
w/ slice (128K) :  53M   1.223s
w/ slice (256K) :  57M   1.216s
w/ slice (512K) :  61M   1.205s
w/o slice (4M)  :  97M   1.174s

This is why I choose 128K as slice size.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: move show_progress to common.c

- support non-vdi user

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
farm: show progress bar for load/save operations

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
cache: add more debug info to push_cache_object()

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: don't use direct write for 'vdi snapshot'

- also remove an unnecessary tag check

Direct write will ask cache layer to flush_and_delete cache blindly
(set create = 1), which will be a time consuming process and lead
'collie vdi snapshot' easily timeout and cause unexpected behavior thereafter.

Use non-direct write to be cache friendly. 'collie vdi snapshot' will be boosted
a lot with cache enabled.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional/058: refine the test to catch more bug

This found bug will be addressed by later patch

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>
cache: add oid_to_entry helper

This is a prepare patch

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>
sheep: remove cache object for discard operation

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>