Add compatibility layer for {kmap,kunmap}_atomic

Starting from linux-2.6.37, {kmap,kunmap}_atomic takes 1 argument instead of 2.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Introduce ABD: linear/scatter dual typed buffer for ARC

zfsolinux currently uses vmalloc backed slab for ARC buffers. There are some
major problems with this approach. One is that 32-bit system have only a
handful of vmalloc space. Another is that the fragmentation in slab will easily
trigger OOM in busy system.

With ABD, we use scatterlist to allocate data buffers. In this approach we can
allocate in HIGHMEM, which alleviates vmalloc space pressure on 32-bit. Also,
we don't have to rely on slab, so there's no fragmentation issue.

But for metadata buffers, we still uses linear buffer from slab. The reason for
this is that there are a lot of *_phys pointers directly point to metadata
buffers. So it's kind of impractical to change all those code. And metadata
should only be a small percentage so we probably don't have to worry about
the 32-bit and fragmentation issue, right?

Currently, ABD is not enabled and its API will treat them as normal buffers.
We will enable it once all relevant code is modified to use the API.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Modify/Add incremental checksum function for abd_iterate_rfunc

Modify/Add incremental fletcher function prototype to match abd_iterate_rfunc
callback type. Also, reduce duplicated code a bit in zfs_fletcher.c.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Use abd_t in arc.h, dmu.h and zio.h

1. Use abd_t in arc_buf_t->b_data, dmu_buf_t->db_data, zio_t->io_data and
zio_transform_t->zt_orig_data
2. zio_* function take abd_t for data

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Convert zio_checksum to ABD version

1. Add checksum function for abd_t
2. Use abd_t version checksum function in zio_checksum_table
3. Make zio_checksum_compute and zio_checksum_error handle abd_t

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in arc.c, bpobj.c and bptree.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in dbuf.c, ddt.c, dmu*.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in dnode*.c, dsl_*.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in sa_impl.h, sa.c, spa.c, spa_history.c and zil.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in metaslab.c, zap*.c, zfs_fuid.c, zfs_sa.c and zfs_vnops.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in zio.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in vdev*.c sans vdev_raidz.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle abd_t in vdev_raidz.c

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Handle ABD in ztest and zdb

Use ABD API on related pointers and functions.(b_data, db_data, zio_*(), etc.)
Note that the userspace still only support linear ABD.

Suggested-by: DHE <git@dehacked.net>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Enable ABD

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Fix man zpool property feature_guid

The property name gets mangled with the explanation due to the property
length.  Fixed by putting the explanation on the next line.

Before:
  unsupported@feature_Info rmation about unsupported features that are
  enabled on the pool. See zpool-features(5) for details.

After:
  unsupported@feature_guid
  Information about unsupported features that are enabled on the pool. See
  zpool-features(5) for details.

Signed-off-by: SenH <sen@senhaerens.be>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2419
Add information about the -o option to zpool replace

Users need to be aware that when replacing devices in an existing
pool they may need to override automatically detected ashift value.
This will all depend on the exact hardware they are using.

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #2024
Improve differing sector size error

When adding or replacing a vdev with a different sector size the
error message should be more useful.  In addition to describing
the problem provide a hint that the '-o ashift' option can be
used to override the optimal default value.

Since using a non-optimal value may incur a significant performance
penalty we should issue this error.  But there a numerous reasons
why a administrator may wish to do this anyway.

Signed-off-by: Niklas Edmundsson <ZNikke@github>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2421
Comment the lack of real_LZ4_uncompress()

Added several comments regarding the removal of real_LZ4_uncompress()
which exists in the reference implementation but has been removed here
since it's not used.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Illumos #4936 fix potential overflow in lz4

4936 lz4 could theoretically overflow a pointer with a certain input
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>
Ported by: Tim Chase <tim@chase2k.com>

References:
  https://illumos.org/issues/4936
  https://github.com/illumos/illumos-gate/commit/58d0718

Porting notes:

This fixes the widely-reported "20-year-old vulnerability" in
LZO/LZ4 implementations which inherited said bug from the reference
implementation.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2429