Refactor mmap(2) writepages (WIP)

The idea here is to pull the zfs_range_lock() out of writepage()
function and in to the writepages() function.  In theory, this
should reduce our overhead, improve performance, and simplify
the code.  In practice, the reworked code is still complicated
and the performance may be worse.

Moving the zfs_range_lock() outside writepages makes ensuring the
data-integrity semantics difficult.  We cannot rely on the generic
write_cache_pages() function in WB_SYNC_ALL mode because it can
deadlock as follows.

--- Process 1 ---    --- Process 2 ---
zfs_range_lock       sync_page
zfs_get_data         wait_on_page_bit
zil_commit           write_cache_pages
zfs_putpage          zfs_putpage
zpl_writepages       zpl_writepages

That means we need to implement our own logic which is similar
to that in write_cache_pages() to ensure pages which are already
in writeback and are redirtied do not get skipped.  This patch
accomplished that by tagging the pages with the TOWRITE tag but
this may offset any performance gains from the refactoring.  It
needs to be carefully profiled and benchmarked under relavant
workloads.  This is still a work in progress.

Original-patch-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>