Fix hash() for inode hash on userland

On 32bit arch, GOLDEN_RATIO_PRIME is 32bit, but hash() is using higher
bits than 32bits. We should use GOLDEN_RATIO_PRIME_64.

So, this fixes hash() by just using hash_64(). (we should use
hash_long(), instead?)

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Adjust insert_inode_hash() position

We are better to insert inode into hash after setup inode completely.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Fix for kernel v3.7

- rcu_barrier() was pushed down to fs drivers on destroy_inode() path.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Fixes for kernel v3.8

- We don't need this change though. To make close to
  __block_{write_begin,commit_write}(), this removes usage of
  inode->i_blkbits from __tux3_{write_begin,commit_write}().

- Convert balance_dirty_pages_ratelimited_nr() to
  balance_dirty_pages_ratelimited().

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Disable vtable inode for now

Current vtable inode is implemented only for mkfs. This bothers
replay. So, instead to implement vtable now, disable vtable for now.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Fix atable flush order

Deletion of normal inodes may dirty the atable. So, we have to flush
atable after normal inodes.

So, this flushes atable via tux3_flush_inode_internal() by hand.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Sort inodes by inum for flushing

To make fs traverse by efficient order, this sorts inodes by inum.

With it, inodes are flushed by inum order. So, even if current linear
block allocation, blocks are allocated more fs traverse friendly
order.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Fix allocation order of cursor_redirect()

Current cursor_redirect() allocates blocks from leaf to root. This is
not good for fs traverse (for current linear block allocation).

Instead, this allocates blocks from root to leaf.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Fix allocation order of data extent and dleaf

Currently, we allocates blocks for data extent before dleaf. But, we
would want to allocate block for dleaf before data extent.

With this order, it is fs traverse friendly.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Rename struct seg to struct block_segment

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Use struct block_segment for block allocation

To allow multiple non-contiguous segments, this changes API for
balloc().

With this change, we can allocate multiple non-contiguous segments at
once.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Find free blocks from whole bitmap by balloc_from_range()

For Current balloc_from_range(), we have to call twice. 1) from middle
to last, 2) from first to middle.

This way is inefficient. So, this allow to find free blocks from whole
bitmap at once.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Allow partial block allocation

This allow to allocate blocks partially by balloc(). I.e. even if
specified blocks by contiguous blocks, this returns to be allocated
blocks partially.

This is needed to work for fragmented volume.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Add partial block allocation test to test/balloc.c

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Teach partial allocation to logblock flush

tux3_logmap_io() tries to allocate contiguous blocks, but it can be
fail if volume was fragmented.

This teaches about partial allocation to tux3_logmap_io().

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Add test for partial allocate on tux3_logmap_io() to test/commit.c

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Prepare to teach partial allocation to data extent

This is cleanup, and has no logical change.

Rename some dleaf_req fields.

	nr_seg   => seg_idx
	max_segs => seg_cnt

and introduce new seg_max for tell seg[] buffer size.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cleanup dleaf2_read(), and use rq->seg_max

Now rq->seg_max is used to tell seg[] size. So, this uses rq->seg_max
instead of rq->seg_cnt on dleaf2_read().

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Teach partial allocation to data extent

->seg_alloc() tries to allocate contiguous blocks, but it can be
fail if volume was fragmented.

This teaches about partial allocation to ->seg_alloc().

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Rename ->nextalloc to ->nextblock

As preparation, to introduce ->nextinum for inumber allocation. This
renames ->nextalloc to ->nextblock.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>