Merge branch 'master' into user

* hirofumi:
  tux3: Add .map_pages handler for kernel v3.15
  tux3: Add .rename2 stub for kernel v3.15
  tux3: Push down sync_filesystem() to ->remount() for kernel v3.15
  tux3: Use truncate_inode_pages_final() for kernel v3.15
  tux3: Add tux3 to fs makefile and config
  tux3: Track api change to __generic_file_aio_write
  tux3: Fix missing i_ctime update for xattr
  tux3: Fix timestamp update for special files
tux3: Add truncate_inodes_pages_final() interface to userland

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: use bool in err.h for userland

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Merge branch 'master' into user

* hirofumi:
  tux3: Remove writeback hack using new writeback
  Add writeback super operation
tux3: Userland build fix for writeback hook

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Remove PTE modification for forked page

With copy-on-write aware ->page_mkwrite(), we don't need to update PFN
of PTE on faulted address (caller of ->page_mkwrite() takes care of it).

So, this removes the modification of PTE on faulted address from
current ->page_mkwrite() related code. (I.e. pass vma of faulted
address to page_cow_file(), and if vma is for faulted address, it
doesn't update PFN in that vma.)

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Add page forking page_cow_file() helper for ->page_mkwrite() handler

This copies helpers from tux3.

When do page forking, we have to update PFN in PTEs of target page. To
do it, this adds page_cow_file() helper (and page_cow_one()).

page_cow_file() takes old and new pages, and updates PFN on related
PTEs of oldpage to newpage. If orig_vma was passed, it excludes to
update PFN (caller of ->page_mkwrite() takes care of it).

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Remove page_cow_file() helper was moved to core

This removes page_cow_file() was moved to core. With this, we don't
need to hack of unexported functions anymore.

So, remove some hacks for it too.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Add handler for page truncation on truncate_inode_pages_range()

truncate_inode_pages_range() is assuming, FS has to wait the
PageWriteback(), but it is not true if page is handled by page forking
at least. (Also, data=journal may be able to do some if want.)  And
there are some unexported functions in truncate_inode_pages_range(),
so FS can't replace it with per-FS code.

So, this adds handler (->truncatepage) to allow implement per-FS way
to truncate and release page.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Replace own implements with ->truncatepage() handler

Currently, we are walking pages once before truncate_inode_pages_range()
(so, walking twice include truncate_inode_pages_range()).
And we forks the page to avoid to wait I/O if need.

With ->truncatepage() handler, we don't need to walk pages before
truncate_inode_pages_range() anymore.

In ->truncatepage(), we checks state of the page. If need page fork,
do it. If not need, do normal truncate page.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Merge branch 'master' into user

* hirofumi:
  tux3: Replace own implements with ->truncatepage() handler
  Add handler for page truncation on truncate_inode_pages_range()
  tux3: Remove page_cow_file() helper was moved to core
  Add page forking page_cow_file() helper for ->page_mkwrite() handler
  tux3: Remove PTE modification for forked page
  tux3: Use change of copy-on-write aware ->page_mkwrite()
  Allow to copy-on-write the page by ->page_mkwrite() handler
tux3: Remove tux3_truncate_pagecache() doesn't need anymore

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

This adds the following 3 helpers for page forking.

	cow_replace_page_cache()
	cow_delete_from_page_cache()
	cow_clone_page()

cow_replace_page_cache(): this is similar to
replace_page_cache_page(), but using radix_tree_replace_slot(), and
page forking aware.

cow_delete_from_page_cache(): this is similar to
delete_from_page_cache(), but deleted page is still used for I/O, not
freeing.

cow_clone_page(): this makes copy of original page.

All of above needs to be in core, because of unexported functions.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Remove page forking helpers was moved to core

This removes the following helpers, and replaces new helpers

	tux3_replace_page_cache() => cow_replace_page_cache()
	tux3_delete_from_page_cache() => cow_delete_from_page_cache()
	clone_page() => cow_clone_page() + tux3_clone_page()

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Make save_sb() static

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Merge branch 'master' into user

* hirofumi:
  tux3: Add async I/O helper
  tux3: Use bio_end_io_t instead of void (*end_io)(struct bio *, int)
  tux3: Make save_sb() static
  tux3: Remove page forking helpers was moved to core
  Add page forking helpers
tux3: Add same I/O APIs with kernel

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Use bio_end_io_t instead of void (*end_io)(struct bio *, int)

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Add async I/O helper

To submit buffer_head easily, this adds APIs for it.

At first, renames some sync APIs

	blockio()	=> blockio_sync()
	devio()		=> devio_sync()

Then, adds async API as blockio().

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
tux3: Support random order I/O on volmap (volmap 2 phases I/O)

We want to submit I/O by random order (not logical/physical order)
for volmap. Because, for example, we want to flush dleaf with
nearby data pages earlier than ileaf.

But random order has the issue of dirty => clean state on the page.
Because we can't know when random order buffer I/O is done finally.
(while checking last I/O, another I/O can be started.)  This means
we would need some sort of IRQ safe locking for each submit_io and
end_io.

To avoid IRQ safe locking for each buffers, this uses 2 phases I/O.

The 1st phase just submits I/O and increment number of I/O in the delta,
and the 1st phase doesn't touch state of buffer or page at all.
With this, we just update on-disk data without modify in-core state.

After the 1st phase was done, and confirmed all I/O in the delta
was done, we start the 2nd phase to update in-core state.  We know
all state can be clean in the delta.

Because we have stable in-core state in the delta. If frontend
tried to re-dirty same buffer, frontend has to page forking then.
So at the 2nd phase, we walk all buffers, and we set all
buffers/pages pages clean.

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