Restrict release number to META version

When creating packages in a git repository the release number
can be automatically set by 'git describe'.  This normally works
well but if your repository has newer tags which match the form
NAME-VERSION* the release may be incorrectly calculated.  To
prevent this the match patten has been restricted to the contents
of the META file, NAME-VERSION.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Fix DKMS package upgrade and packager

Running 'yum upgrade zfs-dkms' package could appear to work properly
and still leave you with no zfs modules installed.  This will occur
when only the zfs release, and not the version, are incremented.
This may be the case for a fast moving zfs-testing repository.

During the upgrade process DKMS will realize that zfs-x.y.z is already
installed and remove it.  DKMS then correctly builds the new modules
for zfs-x.y.z.  However, as a final step when the old zfs-x.y.z-r is
removed the %preun script runs and removes the newly build modules.
To handle this case the %preun script has been updated to only run
when the installed version exactly matches the full spec file version.

This change also updated ChangeLog section based on the DKMS
reference spec file.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Allow building without ACLs

Some kernel definitions were buried inside the #if... #endif logic for
ACLs.  When ACLs are not available these definitions get lost causing
the build to fail.

Signed-off-by: Chris Wedgwood <cw@f00f.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2349
Fix memory leak in zpool_clear_label()

Clang's static analyzer reported a memory leak in zpool_clear_label().
Upon review, it turns out to be right. This should be a very short lived
leak because no daemons use this functionality, but that does not
preclude the possibility of third party daemons that do use it. Lets fix
it to be a good Samaritan.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #2330
Remove superfluous statement

Clang's static analyzer reported that the value assigned to pcksum is
never used. That is because we initialize both zc and pcksum to {{ 0 }}
and then do `pcksum = zc;`. That is fairly pointless. However, it has
the effect of generating a false positive in Clang's static analyzer.
Since noise from false positives can obscure real issues, we fix it
anyway.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #2330
Move the libraries into separate packages

From day one the various ZFS libraries should have been placed in their
own sub-packages.  Primarily this allows for multiple major versions of
the libraries to be concurrently installed.  It also facilitates a
smaller build environment by minimizing the required dependencies.

The specific changes required to split the libraries from the utilities
are as follows:

* libzpool2, libnvpair1, libuutil1, and libzfs2 packages were added
  and contain the versioned shared libraries.  The Fedora packaging
  guidelines discourage providing static libraries so they are not
  included in the packages.

  http://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Static_Libraries

* The zfs-devel package was renamed libzfs2-devel and the new package
  obsoletes the old zfs-devel package.   This package includes all
  the required headers for the libzpool2, libnvpair1, libuutil1, and
  libzfs2 libraries and their respective unversioned shared libraries.

  This package should eventually be split in to individual lib*-devel
  packages but it will still take some work to cleanly separate them.
  Therefore the libzfs2-devel package provides the expected lib*-devel
  packages so the all proper dependencies can still be created.

  http://fedoraproject.org/wiki/Packaging:Guidelines#Devel_Packages

* Moved '/sbin/ldconfig' execution from the zfs packge to each of the
  new library packages as described by the packaging guidelines.

  http://fedoraproject.org/wiki/Packaging:Guidelines#Shared_Libraries

* The /usr/share/doc/ files were moved in to the libzfs2-devel package.

* Updated config/deb.am to be aware of the packaging changes.  This
  ensures that 'deb-utils' make target converts all the resulting
  packages generated by the 'rpm-utils' target.

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes: #2329
Closes: #2341
Issue: #2145
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 and sha256 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.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>
Enable ABD

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>