Provide ${kmodname}-devel-kmod for yum-builddep

In order to ensure that yum-builddep pulls in all the build
requirements a generic ${kmodname}-devel-kmod provides line is
added.  This allows a version of the development headers to be
included without requiring knowledge of the kernel version.

This is important because unlike rpmbuild which does correctly
expand the source rpm spec file, yum-builddep does not.  Without
this generic provides line mock which relies on yum-builddep is
unable to automatically satisfy the dependency.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Include init scripts in packages

The distribution specific init scripts where excluded from the
packaging when it was reworked.  The intention is to replace
them with systemd equivilants.  However, that work has not yet
been done and the init scripts are still useful so they have
been added back in to the packaging.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Tag zfs-0.6.1

META file and release log updated.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Correct typos in renaming example

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1373
Add smb_available() sanity checks

Do basic sanity checks in smb_available() to verify that the 'net'
command and the usershare directory exists.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1124
Man page updates for SMB

* Update manpage with more information about the ACL, guest access
  and that samba needs to be able to authenticate user(s).
* Add information that 'net' can be used to modify the share after
  ZFS sharing and that it will be undone with a 'zfs unshare'.
* Give an example on how to mount a SMB filesystem shared via ZFS.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1181
Issue #1170
build: resolve orthographic and other grammatical errors

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
build: use CPPFLAGS

-D and -I are preprocessor flags, so should preferably be in the
appropriate variable.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
gitignore: anchor entries at their respective directory

.ko is specific to module, .m4 to config, etc.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
build: do not call boilerplate ourself

Rationale see section 3.5 "Using `autoreconf' to Update `configure'
Scripts" of the autoconf manual.

http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/autoreconf-Invocation.html

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Automake 1.10.1 compat: AM_SILENT_RULES

Part of the automated testing involves building the source on Debian Lenny
which ships an ancient version of automake (1.10.1).  Historically, this
has caused a non-fatal warning about AM_SILENT_RULES not being defined.
But when the autogen.sh script was updated to use autoreconf the warning
became fatal.

  configure.ac:31: warning: macro `AM_SILENT_RULES' not found in library
  autoreconf: running: /usr/bin/autoconf --force
  configure.ac:34: error: possibly undefined macro: AM_SILENT_RULES
        If this token and others are legitimate, please use m4_pattern_allow.

To resolve this build issue the call to AM_SILENT_RULES has been wrapped
by m4_ifdef().  This prevents the macro from being expanded on platforms
where it's undefined.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Only require spl-devel-kmod = %{version}

Commit f6fb7651a0d05b357dc179cc4853263ce15da6ed introduced the idea
of working builds which work correctly.  However, because the zfs-kmod
depends on a specific 'spl-devel-kmod = {version}-%{release}' package
and the release component is unique the dependency is never satisfied.

This requires line was introduced to ensure the correct version of the
spl is always used.  In this context only the version number is required
so the release component has been dropped to satisfy the dependency.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Replace the ZFS_AC_META perl dependency with awk

The only remaining perl dependency is part of the ZFS_AC_META macro.
By eliminating this and replacing it with awk we can avoid the need
to pull in perl to rebuild the packages.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1380
Add additional dependencies for DKMS package

For the DKMS package to successfully build the kernel-devel
headers must be included along gcc, make, and perl.  The ZFS
code never directly invokes perl but the kernel build system
depends on it.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1380
Illumos #3422, #3425

3422 zpool create/syseventd race yield non-importable pool
3425 first write to a new zvol can fail with EFBIG

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
  illumos/illumos-gate@bda8819455defbccd06981d9a13b240b682a3d50
  https://www.illumos.org/issues/3422
  https://www.illumos.org/issues/3425

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1390
Allow setting a lower ashift with -o ashift

Previous patches have allowed you to set an increased ashift to
avoid doing 512b IO with 4k sector devices.  However, it was not
possible to set the ashift lower than the reported physical sector
size even when a smaller logical size was supported.  In practice,
there are several cases where settong a lower ashift is useful:

* Most modern drives now correctly report their physical sector
  size as 4k.  This causes zfs to correctly default to using a 4k
  sector size (ashift=12).  However, for some usage models this
  new default ashift value causes an unacceptable increase in
  space usage.  Filesystems with many small files may see the
  total available space reduced to 30-40% which is unacceptable.

* When replacing a drive in an existing pool which was created
  with ashift=9 a modern 4k sector drive cannot be used.  The
  'zpool replace' command will issue an error that the new drive
  has an 'incompatible sector alignment'.  However, by allowing
  the ashift to be manual specified as smaller, non-optimal,
  value the device may still be safely used.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1381
Closes #1328
Issue #967
Issue #548
Remove .readdir from zpl_file_operations table

The zpl_readdir() function shouldn't be registered as part of
the zpl_file_operations table, it must only be part of the
zpl_dir_file_operations table.  By removing this callback
the VFS will now correctly return ENOTDIR when calling
getdents() on a file.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1404
Trivial spelling fix

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1411
Correctly return ERANGE in getxattr(2)

According to the getxattr(2) man page the ERANGE errno should be
returned when the size of the value buffer is to small to hold the
result.  Prior to this patch the implementation would just truncate
the value to size bytes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1408
Fix various generic kmod RPM spec issues.

There are a number of issues with the generic kmod RPM spec in its
current state:
 - The "%{__id_u}" macro seems to not be available on some systems (e.g.
   Debian squeeze). It appears it has been deprecated. Use "${__id} -u"
   instead.
 - The way the "--with-linux=" configure option is generated in the
   non-RHEL/Fedora case is completely wrong with various newline and
   escaping issues (also, $kernel_version is not available in the
   generator context).

The second issue made the generator shell snippet (almost) silently
fail, which under specific circumstances can result in broken builds
against the wrong kernel sources.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1416