zfs.git
10 years agoFix the comment in zfs.h
Shen Yan [Wed, 3 Jul 2013 01:55:16 +0000 (09:55 +0800)]
Fix the comment in zfs.h

The path to code is also changed in zfsonlinux.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issues #1566

10 years agoAdd zfs_autoimport_disable tunable
Brian Behlendorf [Wed, 3 Jul 2013 16:55:39 +0000 (09:55 -0700)]
Add zfs_autoimport_disable tunable

There are times when it is desirable for zfs to not automatically
populate the spa namespace at module load time using the pools
in the /etc/zfs/zpool.cache file.  The zfs_autoimport_disable
module option has been added to control this behavior.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #330

10 years agoExplicitly flush output at end of each zevent
Craig Loomis [Fri, 5 Jul 2013 14:51:36 +0000 (10:51 -0400)]
Explicitly flush output at end of each zevent

For "zpool events -f" flush stdout to ensure the last zevent
is always printed immediately.

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

10 years ago3.10 API change: block_device_operations->release() returns void
Chris Dunlop [Mon, 3 Jun 2013 06:58:52 +0000 (16:58 +1000)]
3.10 API change: block_device_operations->release() returns void

Linux kernel commit torvalds/linux@db2a144 changed the return type
of block_device_operations->release() to void.  Detect the expected
prototype and defined our callout accordingly.

Signed-off-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1494

10 years agoAdd conditional chkconfig to packaging
Brian Behlendorf [Thu, 4 Jul 2013 04:38:45 +0000 (21:38 -0700)]
Add conditional chkconfig to packaging

Unconditionally exit with zero to avoid returning failures
from the scriptlets.  This should have been part of the
previous ba661a6 commit.

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

10 years agoAdd conditional chkconfig to packaging
Brian Behlendorf [Wed, 3 Jul 2013 23:12:37 +0000 (16:12 -0700)]
Add conditional chkconfig to packaging

Prior to adopting the kmod style packaging the zfs packages
would conditionally invoke /sbin/chkconfig to create the
proper links for the init script.  This is done conditionally
because many distributions are moving away from SysV style
init scripts and we don't want to cause errors on those.

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

10 years agoRemove zfs-dracut and zfs-test dependencies
Brian Behlendorf [Wed, 3 Jul 2013 21:22:34 +0000 (14:22 -0700)]
Remove zfs-dracut and zfs-test dependencies

Remove from the zfs package the depenencies on the zfs-dracut and
zfs-test subpackages.  Neither of these packages are required for
normal operation and they bring in many unnecessary dependencies
during installation.

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

10 years agoOpen pools asynchronously after module load
Brian Behlendorf [Tue, 2 Jul 2013 18:59:51 +0000 (11:59 -0700)]
Open pools asynchronously after module load

One of the side effects of calling zvol_create_minors() in
zvol_init() is that all pools listed in the cache file will
be opened.  Depending on the state and contents of your pool
this operation can take a considerable length of time.

Doing this at load time is undesirable because the kernel
is holding a global module lock.  This prevents other modules
from loading and can serialize an otherwise parallel boot
process.  Doing this after module inititialization also
reduces the chances of accidentally introducing a race
during module init.

To ensure that /dev/zvol/<pool>/<dataset> devices are
still automatically created after the module load completes
a udev rules has been added.  When udev notices that the
/dev/zfs device has been create the 'zpool list' command
will be run.  This then will cause all the pools listed
in the zpool.cache file to be opened.

Because this process in now driven asynchronously by udev
there is the risk of problems in downstream distributions.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #756
Issue #1020
Issue #1234

10 years agoCleanup zvol initialization code
Richard Yao [Tue, 2 Jul 2013 18:59:10 +0000 (11:59 -0700)]
Cleanup zvol initialization code

The following error will occur on some (possibly all) kernels
because blk_init_queue() will try to take the spinlock before
we initialize it.

  BUG: spinlock bad magic on CPU#0, zpool/4054
   lock: 0xffff88021a73de60, .magic: 00000000,
   .owner: <none>/-1, .owner_cpu: 0
  Pid: 4054, comm: zpool Not tainted 3.9.3 #11
  Call Trace:
   [<ffffffff81478ef8>] spin_dump+0x8c/0x91
   [<ffffffff81478f1e>] spin_bug+0x21/0x26
   [<ffffffff812da097>] do_raw_spin_lock+0x127/0x130
   [<ffffffff8147d851>] _raw_spin_lock_irq+0x21/0x30
   [<ffffffff812c2c1e>] cfq_init_queue+0x1fe/0x350
   [<ffffffff812aacb8>] elevator_init+0x78/0x140
   [<ffffffff812b2677>] blk_init_allocated_queue+0x87/0xb0
   [<ffffffff812b26d5>] blk_init_queue_node+0x35/0x70
   [<ffffffff812b271e>] blk_init_queue+0xe/0x10
   [<ffffffff8125211b>] __zvol_create_minor+0x24b/0x620
   [<ffffffff81253264>] zvol_create_minors_cb+0x24/0x30
   [<ffffffff811bd9ca>] dmu_objset_find_spa+0xea/0x510
   [<ffffffff811bda71>] dmu_objset_find_spa+0x191/0x510
   [<ffffffff81253ea2>] zvol_create_minors+0x92/0x180
   [<ffffffff811f8d80>] spa_open_common+0x250/0x380
   [<ffffffff811f8ece>] spa_open+0xe/0x10
   [<ffffffff8122817e>] pool_status_check.part.22+0x1e/0x80
   [<ffffffff81228a55>] zfsdev_ioctl+0x155/0x190
   [<ffffffff8116a695>] do_vfs_ioctl+0x325/0x5a0
   [<ffffffff8116a950>] sys_ioctl+0x40/0x80
   [<ffffffff814812c9>] ? do_page_fault+0x9/0x10
   [<ffffffff81483929>] system_call_fastpath+0x16/0x1b
   zd0: unknown partition table

We fix this by calling spin_lock_init before blk_init_queue.

The manner in which zvol_init() initializes structures is
suspectible to a race between initialization and a probe on
a zvol. We reorganize zvol_init() to prevent that.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoCall zvol_create_minors() in spa_open_common() when initializing pool
Pawel Jakub Dawidek [Tue, 28 May 2013 11:50:38 +0000 (07:50 -0400)]
Call zvol_create_minors() in spa_open_common() when initializing pool

There is an extremely odd bug that causes zvols to fail to appear on
some systems, but not others. Recently, I was able to consistently
reproduce this issue over a period of 1 month. The issue disappeared
after I applied this change from FreeBSD.

This is from FreeBSD's pool version 28 import, which occurred in
revision 219089.

Ported-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #441
Issue #599

10 years agoFix parse_dataset error handling
Brian Behlendorf [Wed, 3 Jul 2013 16:16:46 +0000 (09:16 -0700)]
Fix parse_dataset error handling

A mount failure was accidentally introduced by commit 0c1171d
which reworked the parse_dataset() function to read pool names
from devices.  The error case where a label is read from the
device but the pool name/value pair doesn't exist was not
handled properly.  In this case we should fall back to the
previous behavior.

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

10 years agoIllumos #3498 panic in arc_read()
George Wilson [Tue, 2 Jul 2013 20:26:24 +0000 (13:26 -0700)]
Illumos #3498 panic in arc_read()

3498 panic in arc_read(): !refcount_is_zero(&pbuf->b_hdr->b_refcnt)
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  illumos/illumos-gate@1b912ec7100c10e7243bf0879af0fe580e08c73d
  https://www.illumos.org/issues/3498

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1249

10 years agoIllumos #3122 zfs destroy filesystem should prefetch blocks
Matthew Ahrens [Tue, 2 Jul 2013 20:20:02 +0000 (13:20 -0700)]
Illumos #3122 zfs destroy filesystem should prefetch blocks

3122 zfs destroy filesystem should prefetch blocks
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
  illumos/illumos-gate@b4709335aa83dcbfd0dba33c9be21fcabebd28e4
  https://www.illumos.org/issues/3122

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1565

10 years agoUse MAXPATHLEN instead of sizeof in snprintf
Richard Yao [Tue, 2 Jul 2013 04:07:15 +0000 (00:07 -0400)]
Use MAXPATHLEN instead of sizeof in snprintf

This silences a GCC 4.8.0 warning by fixing a programming error
caught by static analysis:

../../cmd/ztest/ztest.c: In function ‘ztest_vdev_aux_add_remove’:
../../cmd/ztest/ztest.c:2584:33: error: argument to ‘sizeof’
  in ‘snprintf’ call is the same expression as the destination;
  did you mean to provide an explicit length?
  [-Werror=sizeof-pointer-memaccess]
  (void) snprintf(path, sizeof (path), ztest_aux_template,
                                 ^

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1480

10 years agoAdd zfs_sync_pass_* tunable parameters
Cyril Plisko [Tue, 4 Jun 2013 09:25:22 +0000 (12:25 +0300)]
Add zfs_sync_pass_* tunable parameters

Commit 55d85d5a8c45c4559a4a0e675c37b0c3afb19c2f (backport of
the upstream changes) replaced three hardcoded constants:

    #define SYNC_PASS_DEFERRED_FREE 2 /* defer frees after this pass */
    #define SYNC_PASS_DONT_COMPRESS 4 /* don't compress after this pass */
    #define SYNC_PASS_REWRITE       1 /* rewrite new bps after this pass */

with a tunable parameters:

    int zfs_sync_pass_deferred_free = 2; /* defer frees starting in this pass */
    int zfs_sync_pass_dont_compress = 5; /* don't compress starting in this pass */
    int zfs_sync_pass_rewrite = 2;       /* rewrite new bps starting in this pass */

This commit makes these tunables available as module parameters
in Linux.  They should only be used for performance analysis
because changing them can result in subtle and pathological
performance problems.

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

10 years agoAdd SEEK_DATA/SEEK_HOLE to lseek()/llseek()
Li Dongyang [Thu, 13 Jun 2013 17:51:09 +0000 (13:51 -0400)]
Add SEEK_DATA/SEEK_HOLE to lseek()/llseek()

The approach taken was the rework zfs_holey() as little as
possible and then just wrap the code as needed to ensure
correct locking and error handling.

Tested with xfstests 285 and 286.  All tests pass except for
7-9 of 285 which try to reserve blocks first via fallocate(2)
and fail because fallocate(2) is not yet supported.

Note that the filp->f_lock spinlock did not exist prior to
Linux 2.6.30, but we avoid the need for autotools check by
virtue of the fact that SEEK_DATA/SEEK_HOLE support was not
added until Linux 3.1.

An autoconf check was added for lseek_execute() which is
currently a private function but the expectation is that it
will be exported perhaps as early as Linux 3.11.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1384

10 years agoReadd zfs_holey() from OpenSolaris
Matthew Ahrens [Mon, 1 Jul 2013 16:24:43 +0000 (09:24 -0700)]
Readd zfs_holey() from OpenSolaris

This patch restores the zfs_holey() function from OpenSolaris.
This was removed by commit 3558fd7 because it wasn't clear we
had a use for it in ZoL.  However, this functionality is a
prerequisite for adding SEEK_DATA/SEEK_HOLE support to the ZPL.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Issue #1384

10 years agokmem_zalloc(..., KM_SLEEP) will never fail
shenyan1 [Sat, 29 Jun 2013 11:07:45 +0000 (19:07 +0800)]
kmem_zalloc(..., KM_SLEEP) will never fail

By definitition these allocations will never fail.  For
consistency with the rest of the code remove this dead error
handling code.

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

10 years agoFix zfs_sb_teardown/zfs_resume_fs NULL dereference
Tim Chase [Tue, 25 Jun 2013 03:03:56 +0000 (22:03 -0500)]
Fix zfs_sb_teardown/zfs_resume_fs NULL dereference

Fix a pair of conditions in which a concurrent umount can cause
NULL pointer dereferences:

* zfs_sb_teardown - prevent a NULL dereference by not calling
                    dmu_objset_pool with a null z_os.

* zfs_resume_fs - don't try to unmount with a null z_os.  This
                  change makes the ZoL code more consistent
                  with both Illumos and FreeBSD.

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

10 years agoOverride default SPA config location via environment
Cyril Plisko [Mon, 24 Jun 2013 06:45:20 +0000 (09:45 +0300)]
Override default SPA config location via environment

When using zdb with non-default SPA config file it is not convenient
to add -U <non-default-config-file-path> all the time. This commit
introduces support for setting/overriding SPA config location via
environment variable 'SPA_CONFIG_PATH'.

If -U flag is specified in the command line it will override any other
value as usual.

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

10 years agoAdd absent \n at the end of the help text line
Cyril Plisko [Mon, 24 Jun 2013 06:10:56 +0000 (09:10 +0300)]
Add absent \n at the end of the help text line

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1545

10 years agoFormating changes for zpool manpage
Steven Burgess [Fri, 28 Jun 2013 00:35:11 +0000 (20:35 -0400)]
Formating changes for zpool manpage

Some of these entries were hidden before.

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

10 years agoAdd error message for missing /etc/mtab
Aaron Fineman [Thu, 27 Jun 2013 19:19:25 +0000 (15:19 -0400)]
Add error message for missing /etc/mtab

The zpool command should not silently fail when the /etc/mtab
file does not exist.  This can occur in an initramfs environment
when the /etc/mtab file hasn't yet been generated.

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

10 years agoFix module probe failure on 32-bit systems
Ying Zhu [Thu, 27 Jun 2013 11:41:30 +0000 (19:41 +0800)]
Fix module probe failure on 32-bit systems

Previous commit 7ef5e54e2e28884a04dc800657967b891239e933 caused
module probe failure on 32-bit systems, dmesg showed

  Unknown symbol __moddi3

This was caused by the modulo operation 'gethrtime() % tqs->stqs_count'
in the committed code.  Instead of implementing __moddi3 for all 32-bit
systems, Behlendorf advised we can just cast the return value of
gethrtime() into a uint64_t, since gethrtime does not return negative
value on all circumstances we need not care about the potential overflow.

Signed-off-by: Ying Zhu <casualfisher@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1551

10 years agoReturn -EOPNOTSUPP for ZFS_IOC_{GET|SET}FLAGS
Brian Behlendorf [Wed, 26 Jun 2013 19:53:04 +0000 (12:53 -0700)]
Return -EOPNOTSUPP for ZFS_IOC_{GET|SET}FLAGS

Until these hooks are fully implemented return the expected
-EOPNOTSUPP error to indicate they are not functional.  This
allows test suites such as xfstests to cleanly skip testing
this functionality until it's implemented.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #229

10 years agoAllow fetching the pool from the device at mount
Brian Behlendorf [Tue, 25 Jun 2013 22:43:09 +0000 (15:43 -0700)]
Allow fetching the pool from the device at mount

To simplify integration with the xfstests test suite the
mount.zfs helper has been extended.  When passed a block
device (/dev/sdX) to mount, instead of a pool/dataset,
the pool name will be read from any existing zfs label
and used.  This allows you to mount the root dataset of
a zfs filesystem by specifing any of the member vdevs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoMake spl directory setable when building rpms and add --buildroot
Nathaniel Clark [Thu, 18 Apr 2013 20:57:29 +0000 (16:57 -0400)]
Make spl directory setable when building rpms and add --buildroot

This adds ability to set the location of spl via defines when
building from the spec files.  This is useful for build systems
that build spl and zfs together without installing the actual rpms.

Signed-off-by: Nathaniel Clark <Nathaniel.Clark@misrule.us>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1486

10 years agoRegister correct handlers in nvlist_alloc()
Brian Behlendorf [Tue, 18 Jun 2013 17:15:33 +0000 (10:15 -0700)]
Register correct handlers in nvlist_alloc()

The non-blocking allocation handlers in nvlist_alloc() would be
mistakenly assigned if any flags other than KM_SLEEP were passed.
This meant that nvlists allocated with KM_PUSHPUSH or other KM_*
debug flags were effectively always using atomic allocations.

While these failures were unlikely it could lead to assertions
because KM_PUSHPAGE allocations in particular are guaranteed to
succeed or block.  They must never fail.

Since the existing API does not allow us to pass allocation
flags to the private allocators the cleanest thing to do is to
add a KM_PUSHPAGE allocator.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/spl#249

10 years agoIllumos #3805 arc shouldn't cache freed blocks
Matthew Ahrens [Thu, 6 Jun 2013 22:46:55 +0000 (18:46 -0400)]
Illumos #3805 arc shouldn't cache freed blocks

3805 arc shouldn't cache freed blocks
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Richard Elling <richard.elling@dey-sys.com>
Reviewed by: Will Andrews <will@firepipe.net>
Approved by: Dan McDonald <danmcd@nexenta.com>

References:
  illumos/illumos-gate@6e6d5868f52089b9026785bd90257a3d3f6e5ee2
  https://www.illumos.org/issues/3805

ZFS should proactively evict freed blocks from the cache.

On dcenter, we saw that we were caching ~256GB of metadata, while the
pool only had <4GB of metadata on disk.  We were wasting about half the
system's RAM (252GB) on blocks that have been freed.

Even though these freed blocks will never be used again, and thus will
eventually be evicted, this causes us to use memory inefficiently for 2
reasons:

1. A block that is freed has no chance of being accessed again, but will
be kept in memory preferentially to a block that was accessed before it
(and is thus older) but has not been freed and thus has at least some
chance of being accessed again.

2. We partition the ARC into several buckets:
user data that has been accessed only once (MRU)
metadata that has been accessed only once (MRU)
user data that has been accessed more than once (MFU)
metadata that has been accessed more than once (MFU)

The user data vs metadata split is somewhat arbitrary, and the primary
control on how much memory is used to cache data vs metadata is to
simply try to keep the proportion the same as it has been in the past
(each bucket "evicts against" itself).  The secondary control is to
evict data before evicting metadata.

Because of this bucketing, we may end up with one bucket mostly
containing freed blocks that are very old, while another bucket has more
recently accessed, still-allocated blocks.  Data in the useful bucket
(with still-allocated blocks) may be evicted in preference to data in
the useless bucket (with old, freed blocks).

On dcenter, we saw that the MFU metadata bucket was 230MB, while the MFU
data bucket was 27GB and the MRU metadata bucket was 256GB.  However,
the vast majority of data in the MRU metadata bucket (256GB) was freed
blocks, and thus useless.  Meanwhile, the MFU metadata bucket (230MB)
was constantly evicting useful blocks that will be soon needed.

The problem of cache segmentation is a larger problem that needs more
investigation.  However, if we stop caching freed blocks, it should
reduce the impact of this more fundamental issue.

Ported-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1503

10 years agoFix compile warning on 32-bit systems
Ying Zhu [Sat, 15 Jun 2013 14:25:48 +0000 (22:25 +0800)]
Fix compile warning on 32-bit systems

The definition of zfs_vdev_holder casts VDEV_HOLDER into a function pointer
passing to linux kernel's block layer function blkdev_get_by_path.
However current VDEV_HOLDER is defined to be wider than 32 bits and the compiler
warns about potential overflows. Instead of specifying different values for 32-bit and
64-bit systems using ifdefs, choose the common factor 32-bit addresses.
Redefine VDEV_HOLDER to 0x2401de7("zholder") here.

Signed-off-by: Ying Zhu <casualfisher@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1520

10 years agoIllumos #3552, #3564
George Wilson [Sat, 15 Jun 2013 03:30:35 +0000 (22:30 -0500)]
Illumos #3552, #3564

3552 condensing one space map burns 3 seconds of CPU in spa_sync() thread
3564 spa_sync() spends 5-10% of its time in metaslab_sync() (when not condensing)
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  illumos/illumos-gate@16a4a8074274d2d7cc408589cf6359f4a378c861
  https://www.illumos.org/issues/3552
  https://www.illumos.org/issues/3564

Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1513

10 years agoIllumos #3006
Madhav Suresh [Fri, 10 May 2013 21:17:03 +0000 (14:17 -0700)]
Illumos #3006

3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first
     argument is zero

Reviewed by Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by George Wilson <george.wilson@delphix.com>
Approved by Eric Schrock <eric.schrock@delphix.com>

References:
  illumos/illumos-gate@fb09f5aad449c97fe309678f3f604982b563a96f
  https://illumos.org/issues/3006

Requires:
  zfsonlinux/spl@1c6d149feb4033e4a56fb987004edc5d45288bcb

Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1509

10 years agoImprove OpenRC init script
Richard Yao [Wed, 29 May 2013 00:08:15 +0000 (20:08 -0400)]
Improve OpenRC init script

The current zfs OpenRC script's dependencies cause OpenRC to attempt to
unmount ZFS filesystems at shutdown while things were still using them,
which would fail. This is a cosmetic issue, but it should still be
addressed. It probably does not affect systems where the rootfs is a
legacy filesystem, but any system with the rootfs on ZFS needs to run
the ZFS init script after the system is ready to shutdown filesystems.

OpenRC's shutdown process occurs in the reverse order of the startup
process. Therefore running the ZFS shutdown procedure after filesystems
are ready to be unmounted requires running the startup procedure before
fstab. This patch changes the dependencies of the script to expliclty
run before fstab at boot when the rootfs is ZFS and to run after fstab
at boot whenever the rootfs is not ZFS. This should cover most use
cases.

The only cases not covered well by this are systems with legacy
root filesystems where people want to configure fstab to mount a non-ZFS
filesystem off a zvol and possibly also systems whose pools are stored
on network block devices. The former requires that the ZFS script run
before fstab, which could cause ZFS datasets to mount too early and
appear under the fstab mount points. The latter requires that the ZFS
script run after networking starts, which precludes the ability to store
any system information on ZFS. An additional OpenRC script could be
written to handle non-root pools on network block devices, but that will
depend on user demand and developer time.

Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1479

10 years agoModified arcstat.py to run on linux
Christ Schlacta [Fri, 7 Jun 2013 04:33:01 +0000 (21:33 -0700)]
Modified arcstat.py to run on linux

* Modified kstat_update() to read arcstats from proc.
* Fix shebang.
* Added Makefile.am entries for arcstat.py

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

10 years agoAdded arcstat.py from FreeNAS
Christ Schlacta [Fri, 7 Jun 2013 04:31:18 +0000 (21:31 -0700)]
Added arcstat.py from FreeNAS

Original source:
  http://support.freenas.org/browser/nanobsd/Files/usr/local/bin/arcstat.py

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1506

10 years agoDon't leak mount flags into kernel
Ned Bass [Tue, 14 May 2013 02:48:24 +0000 (19:48 -0700)]
Don't leak mount flags into kernel

When calling mount(), care must be taken to avoid passing in flags
that are used only by the user space utilities.  Otherwise we may
stomp on flags that are reserved for other purposes in the kernel.

In particular, openSUSE 12.3 kernels have added a new MS_RICHACL
super-block flag whose value conflicts with our MS_COMMENT flag. This
causes incorrect behavior such as the umask being ignored.  The
MS_COMMENT flag essentially serves as a placeholder in the option_map
data structure of zfs_mount.c, but its value is never used. Therefore
we can avoid the conflict by defining it to 0.

The MS_USERS, MS_OWNER, and MS_GROUP flags also conflict with reserved
flags in the kernel. While this is not known to have caused any
problems, it is nevertheless incorrect.  For the purposes of the
mount.zfs helper, the "users", "owner", and "group" options just serve
as hints to set additional implied options.  Therefore we now define
their associated mount flags in terms of the options that they imply
rather than giving them unique values.

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

10 years agoAdds zpool split to man page
Steven Burgess [Sun, 12 May 2013 17:14:44 +0000 (13:14 -0400)]
Adds zpool split to man page

Adds zpool split documentation to the zpool man page.  I only documented
the options that I could get to work.   While it is documented on some
sun blogs that devices can be specified for split, I was not able to get
that to work during my testing.

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

11 years agoOnly check directory xattr on ENOENT
Brian Behlendorf [Wed, 8 May 2013 16:20:04 +0000 (09:20 -0700)]
Only check directory xattr on ENOENT

When SA xattrs are enabled only fallback to checking the directory
xattrs when the name is not found as a SA xattr.  Otherwise, the SA
error which should be returned to the caller is overwritten by the
directory xattr errors.  Positive return values indicating success
will also be immediately returned.

In the case of #1437 the ERANGE error was being correctly returned
by zpl_xattr_get_sa() only to be overridden with ENOENT which was
returned by the subsequent unnessisary call to zpl_xattr_get_dir().

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

11 years agozfs_scrub_limit tunable is not used anywhere
Cyril Plisko [Wed, 24 Oct 2012 10:26:56 +0000 (12:26 +0200)]
zfs_scrub_limit tunable is not used anywhere

As a part of scrub/resilver tuning zfs_scrub_limit fell out of use,
but the definition of the variable remained in place.
Moreover various guides still (misleadingly) mention it as a way
to influence resilver/scrub behavior.
This commit removes its finally.

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1444

11 years agoFix incorrect assertions in ddt_phys_decref and ddt_sync_entry
Ying Zhu [Tue, 30 Apr 2013 03:15:12 +0000 (11:15 +0800)]
Fix incorrect assertions in ddt_phys_decref and ddt_sync_entry

The assertions in ddt_phys_decref and ddt_sync_entry cast ddp->ddp_refcnt
from uint64_t to int64_t, with a reference count bigger than 2^63, e.g. the
reference count of zero blocks commonly available in spare files, we may
mistakenly hit these assertations, so drop the type conversions here.

Signed-off-by: Ying Zhu <casualfisher@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1436

11 years agoUse taskq for dump_bytes()
Brian Behlendorf [Fri, 3 May 2013 21:17:21 +0000 (14:17 -0700)]
Use taskq for dump_bytes()

The vn_rdwr() function performs I/O by calling the vfs_write() or
vfs_read() functions.  These functions reside just below the system
call layer and the expectation is they have almost the entire 8k of
stack space to work with.  In fact, certain layered configurations
such as ext+lvm+md+multipath require the majority of this stack to
avoid stack overflows.

To avoid this posibility the vn_rdwr() call in dump_bytes() has been
moved to the ZIO_TYPE_FREE, taskq.  This ensures that all I/O will be
performed with the majority of the stack space available.  This ends
up being very similiar to as if the I/O were issued via sys_write()
or sys_read().

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

11 years agoIllumos #3581 spa_zio_taskq[ZIO_TYPE_FREE][ZIO_TASKQ_ISSUE]->tq_lock contention
Adam Leventhal [Mon, 6 May 2013 19:24:30 +0000 (12:24 -0700)]
Illumos #3581 spa_zio_taskq[ZIO_TYPE_FREE][ZIO_TASKQ_ISSUE]->tq_lock contention

3581 spa_zio_taskq[ZIO_TYPE_FREE][ZIO_TASKQ_ISSUE]->tq_lock is piping hot

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  illumos/illumos-gate@ec94d32
  https://illumos.org/issues/3581

Notes for Linux port:

Earlier commit 08d08eb reduced contention on this taskq lock by simply
reducing the number of z_fr_iss threads from 100 to one-per-CPU.  We
also optimized the taskq implementation in zfsonlinux/spl@3c6ed54.
These changes significantly improved unlink performance to acceptable
levels.

This patch further reduces time spent spinning on this lock by
randomly dispatching the work items over multiple independent task
queues.  The Illumos ZFS developers stated that this lock contention
only arose after "3329 spa_sync() spends 10-20% of its time in
spa_free_sync_cb()" was landed.  It's not clear if 3329 affects the
Linux port or not.  I didn't see spa_free_sync_cb() show up in
oprofile sessions while unlinking large files, but I may just not
have used the right test case.

I tested unlinking a 1 TB of data with and without the patch and
didn't observe a meaningful difference in elapsed time.  However,
oprofile showed that the percent time spent in taskq_thread() was
reduced from about 16% to about 5%.  Aside from a possible slight
performance benefit this may be worth landing if only for the sake of
maintaining consistency with upstream.

Ported-by: Ned Bass <bass6@llnl.gov>
Closes #1327

11 years agoIllumos #3329, #3330, #3331, #3335
George Wilson [Mon, 6 May 2013 17:14:52 +0000 (10:14 -0700)]
Illumos #3329, #3330, #3331, #3335

3329 spa_sync() spends 10-20% of its time in spa_free_sync_cb()
3330 space_seg_t should have its own kmem_cache
3331 deferred frees should happen after sync_pass 1
3335 make SYNC_PASS_* constants tunable

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Eric Schrock <eric.schrock@delphix.com>

References:
  illumos/illumos-gate@01f55e48fb4d524eaf70687728aa51b7762e2e97
  https://www.illumos.org/issues/3329
  https://www.illumos.org/issues/3330
  https://www.illumos.org/issues/3331
  https://www.illumos.org/issues/3335

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #3306, #3321
George Wilson [Thu, 2 May 2013 23:36:32 +0000 (16:36 -0700)]
Illumos #3306, #3321

3306 zdb should be able to issue reads in parallel
3321 'zpool reopen' command should be documented in the man
     page and help

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
  illumos/illumos-gate@31d7e8fa33fae995f558673adb22641b5aa8b6e1
  https://www.illumos.org/issues/3306
  https://www.illumos.org/issues/3321

The vdev_file.c implementation in this patch diverges significantly
from the upstream version.  For consistenty with the vdev_disk.c
code the upstream version leverages the Illumos bio interfaces.
This makes sense for Illumos but not for ZoL for two reasons.

1) The vdev_disk.c code in ZoL has been rewritten to use the
   Linux block device interfaces which differ significantly
   from those in Illumos.  Therefore, updating the vdev_file.c
   to use the Illumos interfaces doesn't get you consistency
   with vdev_disk.c.

2) Using the upstream patch as is would requiring implementing
   compatibility code for those Solaris block device interfaces
   in user and kernel space.  That additional complexity could
   lead to confusion and doesn't buy us anything.

For these reasons I've opted to simply move the existing vn_rdwr()
as is in to the taskq function.  This has the advantage of being
low risk and easy to understand.  Moving the vn_rdwr() function
in to its own taskq thread also neatly avoids the possibility of
a stack overflow.

Finally, because of the additional work which is being handled by
the free taskq the number of threads has been increased.  The
thread count under Illumos defaults to 100 but was decreased to 2
in commit 08d08e due to contention.  We increase it to 8 until
the contention can be address by porting Illumos #3581.

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1354

11 years agoEnsure --with-spl-timeout waits for spl_config.h and symvers
Carlos Alberto Lopez Perez [Sat, 27 Apr 2013 18:18:11 +0000 (20:18 +0200)]
Ensure --with-spl-timeout waits for spl_config.h and symvers

The previous code was only waiting for the symver file. But the
postinst target of the DKMS script for SPL will not only create
the symvers file, but also the header spl_config.h.

If we are waiting in the configure script of ZFS for the SPL
symvers file, then we also need to wait for spl_config.h.
Otherwise the configure script will abort because the spl_config.h
is not yet available.

On top of that, the function ZFS_AC_SPL_MODULE_SYMVERS is moved
to the end of the function ZFS_AC_SPL to allow both checks share
the with-spl-timeout parameter.

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

11 years agoSilence 'old_umask' uninit variable warning
Brian Behlendorf [Mon, 29 Apr 2013 21:07:46 +0000 (14:07 -0700)]
Silence 'old_umask' uninit variable warning

Recent changes have caused older versions of gcc to mistakenly
flag 'old_umask' in vn_open() as an unitialized variable.  To
silence the warning initialize it.

  kernel.c: In function 'vn_open':
  kernel.c:525:6: error: 'old_umask' may be used uninitialized
  in this function

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix zinject list handlers
Brian Behlendorf [Wed, 1 May 2013 16:38:49 +0000 (09:38 -0700)]
Fix zinject list handlers

The zfs_fd must be opened before calling print_all_handlers() or
the ioctl() cannot be used to the zfs control device.  This brings
the zinject code back in sync with the Illumos implementation.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years ago3246 ZFS I/O deadman thread
George.Wilson [Mon, 29 Apr 2013 22:49:23 +0000 (15:49 -0700)]
3246 ZFS I/O deadman thread

Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>

NOTES: This patch has been reworked from the original in the
following ways to accomidate Linux ZFS implementation

*) Usage of the cyclic interface was replaced by the delayed taskq
   interface.  This avoids the need to implement new compatibility
   code and allows us to rely on the existing taskq implementation.

*) An extern for zfs_txg_synctime_ms was added to sys/dsl_pool.h
   because declaring externs in source files as was done in the
   original patch is just plain wrong.

*) Instead of panicing the system when the deadman triggers a
   zevent describing the blocked vdev and the first pending I/O
   is posted.  If the panic behavior is desired Linux provides
   other generic methods to panic the system when threads are
   observed to hang.

*) For reference, to delay zios by 30 seconds for testing you can
   use zinject as follows: 'zinject -d <vdev> -D30 <pool>'

References:
  illumos/illumos-gate@283b84606b6fc326692c03273de1774e8c122f9a
  https://www.illumos.org/issues/3246

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1396

11 years agoFix txg_quiesce thread deadlock
Brian Behlendorf [Thu, 25 Apr 2013 23:29:22 +0000 (16:29 -0700)]
Fix txg_quiesce thread deadlock

A deadlock was accidentally introduced by commit e95853a which
can occur when the system is under memory pressure.  What happens
is that while the txg_quiesce thread is holding the tx->tx_cpu
locks it enters memory reclaim.  In the context of this memory
reclaim it then issues synchronous I/O to a ZVOL swap device.
Because the txg_quiesce thread is holding the tx->tx_cpu locks
a new txg cannot be opened to handle the I/O.  Deadlock.

The fix is straight forward.  Move the memory allocation outside
the critical region where the tx->tx_cpu locks are held.  And for
good measure change the offending allocation to KM_PUSHPAGE to
ensure it never attempts to issue I/O during reclaim.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1274

11 years agoIgnore *.{deb,rpm,tar.gz} files in the top directory.
Turbo Fredriksson [Sat, 13 Apr 2013 19:38:37 +0000 (21:38 +0200)]
Ignore *.{deb,rpm,tar.gz} files in the top directory.

These are build products and should be ignored.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Issue #1402

11 years agoSet RPM_DEFINE_COMMON options
Brian Behlendorf [Tue, 23 Apr 2013 23:40:47 +0000 (16:40 -0700)]
Set RPM_DEFINE_COMMON options

When the kmod packaging was introduced the ability to pass the
--enable-debug and --enable-dmu-tx options from configure all
the way through to `make rpm|deb` was accidenally lost.  Update
ZFS_AC_RPM to explicitlu set RPM_DEFINE_COMMON with these
rpmbuild defines.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1402

11 years agoAdd --bump=0 to alien
Turbo Fredriksson [Sat, 13 Apr 2013 16:59:19 +0000 (18:59 +0200)]
Add --bump=0 to alien

Preserve the release field when creating Debian packages.  The
--keep-version option was not used because it results in a failure
when the git '<commit>_<hash>' syntax is used for the release.
The '_' is a valid character for RPM packages but not for DEBs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Issue #1402
Issue #928

11 years agoSupport .nogitrelease file
Turbo Fredriksson [Sat, 20 Apr 2013 05:24:15 +0000 (07:24 +0200)]
Support .nogitrelease file

When building a custom release in a git tree provide the ability
to prevent the release field from being overwritten by the
`git describe` output.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1402

11 years agoPossibility to disable (not start) zfs at bootup.
Turbo Fredriksson [Sun, 14 Apr 2013 15:41:51 +0000 (17:41 +0200)]
Possibility to disable (not start) zfs at bootup.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1402

11 years agoFix various generic kmod RPM spec issues.
Etienne Dechamps [Sun, 21 Apr 2013 19:03:12 +0000 (20:03 +0100)]
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

11 years agoCorrectly return ERANGE in getxattr(2)
Brian Behlendorf [Wed, 17 Apr 2013 20:07:36 +0000 (13:07 -0700)]
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

11 years agoTrivial spelling fix
Chris Dunlop [Thu, 18 Apr 2013 01:49:25 +0000 (11:49 +1000)]
Trivial spelling fix

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

11 years agoRemove .readdir from zpl_file_operations table
Caleb James DeLisle [Tue, 16 Apr 2013 09:23:39 +0000 (05:23 -0400)]
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

11 years agoAllow setting a lower ashift with -o ashift
Martin Matuska [Fri, 12 Apr 2013 17:26:03 +0000 (10:26 -0700)]
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

11 years agoIllumos #3422, #3425
George Wilson [Wed, 10 Apr 2013 23:58:22 +0000 (16:58 -0700)]
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

11 years agoAdd additional dependencies for DKMS package
Brian Behlendorf [Tue, 2 Apr 2013 20:35:32 +0000 (13:35 -0700)]
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

11 years agoReplace the ZFS_AC_META perl dependency with awk
Brian Behlendorf [Tue, 2 Apr 2013 20:31:42 +0000 (13:31 -0700)]
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

11 years agoOnly require spl-devel-kmod = %{version}
Brian Behlendorf [Tue, 2 Apr 2013 21:37:47 +0000 (14:37 -0700)]
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>
11 years agoAutomake 1.10.1 compat: AM_SILENT_RULES
Brian Behlendorf [Tue, 2 Apr 2013 22:16:39 +0000 (15:16 -0700)]
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>
11 years agobuild: do not call boilerplate ourself
Jan Engelhardt [Sat, 30 Mar 2013 02:33:09 +0000 (03:33 +0100)]
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>
11 years agogitignore: anchor entries at their respective directory
Jan Engelhardt [Sat, 30 Mar 2013 02:31:52 +0000 (03:31 +0100)]
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>
11 years agobuild: use CPPFLAGS
Jan Engelhardt [Sat, 30 Mar 2013 02:30:25 +0000 (03:30 +0100)]
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>
11 years agobuild: resolve orthographic and other grammatical errors
Jan Engelhardt [Sat, 30 Mar 2013 02:27:50 +0000 (03:27 +0100)]
build: resolve orthographic and other grammatical errors

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoMan page updates for SMB
Turbo Fredriksson [Tue, 2 Apr 2013 17:36:25 +0000 (10:36 -0700)]
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

11 years agoAdd smb_available() sanity checks
Turbo Fredriksson [Tue, 2 Apr 2013 16:27:52 +0000 (09:27 -0700)]
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

11 years agoCorrect typos in renaming example
Nick Garvey [Tue, 26 Mar 2013 20:52:22 +0000 (17:52 -0300)]
Correct typos in renaming example

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

11 years agoTag zfs-0.6.1
Brian Behlendorf [Mon, 25 Mar 2013 20:46:37 +0000 (13:46 -0700)]
Tag zfs-0.6.1

META file and release log updated.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoInclude init scripts in packages
Brian Behlendorf [Tue, 26 Mar 2013 15:40:44 +0000 (08:40 -0700)]
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>
11 years agoProvide ${kmodname}-devel-kmod for yum-builddep
Brian Behlendorf [Mon, 25 Mar 2013 18:28:18 +0000 (11:28 -0700)]
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>
11 years agoUse 'git describe' for working builds
Brian Behlendorf [Fri, 22 Mar 2013 21:46:11 +0000 (14:46 -0700)]
Use 'git describe' for working builds

When building from an arbitrary commit in the git tree it's useful
for the resulting packages to be uniquely identifiable.  Therefore,
the build system has been updated to detect if your compiling in
git tree.

If you are building in a git tree, and there are commits after the
last annotated tag.  Then the <id>-<hash> component of 'git describe'
will be used to overwrite the 'Release:' field in the META file.

The only tricky part is that to ensure the 'make dist' tarball is
built using the correct release.  A dist-hook was added to the top
level make file to rewrite the META file using the correct release.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix minor typos and update marketing copy.
Darik Horn [Thu, 21 Mar 2013 03:52:53 +0000 (22:52 -0500)]
Fix minor typos and update marketing copy.

Correct spelling mistakes in the AUTHORS and DISCLAIMER files, and
update the README.markdown file to credit Illumos and mention that
the ZPL is finished.

The README.markdown file is also the first impression for a handful
of new users that discover ZoL through a web search because it
doubles as the splash page for the Github repository. The build blurbs
are therefore removed because these people should be encouraged to
visit the regular home page before installing the product.

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

11 years agoUse requested kernel for dkms builds
Brian Behlendorf [Wed, 20 Mar 2013 22:15:05 +0000 (15:15 -0700)]
Use requested kernel for dkms builds

The --with-linux and --with-linux-obj options must be specified
as part of the dkms build otherwise the package will be built
against the running kernel.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoUse BUILD_DEPENDS option for dkms builds
Brian Behlendorf [Wed, 20 Mar 2013 18:01:48 +0000 (11:01 -0700)]
Use BUILD_DEPENDS option for dkms builds

Support was added to dkms so build dependencies can be specified.
This allows us to ensure that the spl package will always be built
before the zfs package.  Those patches have not yet been merged
upstream but they are available in the zfsonlinux/dkms repository.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRemove zfs-dkms conflict with zfs-kmod
Brian Behlendorf [Wed, 20 Mar 2013 18:28:00 +0000 (11:28 -0700)]
Remove zfs-dkms conflict with zfs-kmod

Because the zfs-dkms package also provides zfs-kmod for the
zfs user package yum flags this as a conflict.  To avoid the
problem remove the Conflicts tag from zfs-dkms and just rely
on the one in zfs-kmod.

  zfs-dkms-0.6.0-rc14.fc18.noarch has installed conflicts
    zfs-kmod: zfs-dkms-0.6.0-rc14.fc18.noarch

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRefresh dracut module setup
Brian Behlendorf [Wed, 20 Mar 2013 18:25:50 +0000 (11:25 -0700)]
Refresh dracut module setup

60-zpool.rules was retired some time ago in favor of 69-vdev.rules.
Additionally, there is no guarentee a zpool.cache file exists so
only install it conditionally upon its existance.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd missing dependencies
Brian Behlendorf [Wed, 20 Mar 2013 02:25:01 +0000 (19:25 -0700)]
Add missing dependencies

The spl, zfs-test, and zfs-dracut packages should be pulled in
by the core zfs package.  This allows all the required zfs packages
to be installed from a yum repository by running:

  yum install zfs

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd spl-dkms dependency to zfs-dkms
Brian Behlendorf [Tue, 19 Mar 2013 22:55:44 +0000 (15:55 -0700)]
Add spl-dkms dependency to zfs-dkms

Adding the 'spl-dkms = VERSION' dependency to the zfs-dkms
package ensures the spl will be installed before zfs.  This
cleanly handles the initial 'yum localinstall' case.

However, this does not address the dkms rebuilds caused by
a new kernel being installed.  For that we still rely on the
clunky  --with-spl-timeout=<timeout> configure option which
allows the zfs compilation to be briefly delayed while the
spl components are built.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoCreate fsck.zfs and zhack man pages.
Darik Horn [Sat, 16 Mar 2013 20:54:32 +0000 (15:54 -0500)]
Create fsck.zfs and zhack man pages.

The automake templates have been updated to install them,
and the existing packaging will automatically include them.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Supplements #518

11 years agoAdd zio_ddt_free()+ddt_phys_decref() error handling
Brian Behlendorf [Tue, 19 Mar 2013 19:05:08 +0000 (12:05 -0700)]
Add zio_ddt_free()+ddt_phys_decref() error handling

The assumption in zio_ddt_free() is that ddt_phys_select() must
always find a match.  However, if that fails due to a damaged
DDT or some other reason the code will NULL dereference in
ddt_phys_decref().

While this should never happen it has been observed on various
platforms.  The result is that unless your willing to patch the
ZFS code the pool is inaccessible.  Therefore, we're choosing
to more gracefully handle this case rather than leave it fatal.

http://mail.opensolaris.org/pipermail/zfs-discuss/2012-February/050972.html

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

11 years agoAdd metaslab_debug option
Brian Behlendorf [Mon, 18 Mar 2013 20:03:09 +0000 (13:03 -0700)]
Add metaslab_debug option

Enabling metaslab debugging will prevent space maps from being
automatically unloaded.  This can significantly increase the
memory footprint but being able to dynamically control this is
helpful for debugging and certain performance testing.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRefresh RPM packaging
Brian Behlendorf [Sun, 17 Feb 2013 20:10:17 +0000 (12:10 -0800)]
Refresh RPM packaging

Refresh the existing RPM packaging to conform to the 'Fedora
Packaging Guidelines'.  This includes adopting the kmods2
packaging standard which is used fod kmods distributed by
rpmfusion for Fedora/RHEL.

  http://fedoraproject.org/wiki/Packaging:Guidelines
  http://rpmfusion.org/Packaging/KernelModules/Kmods2

While the spec files have been entirely rewritten from a
user perspective the only major changes are:

* The Fedora packages now have a build dependency on the
  rpmfusion repositories.  The generic kmod packages also
  have a new dependency on kmodtool-1.22 but it is bundled
  with the source rpm so no additional packages are needed.

* The kernel binary module packages have been renamed from
  zfs-modules-* to kmod-zfs-* as specificed by kmods2.

* The is now a common kmod-zfs-devel-* package in addition
  to the per-kernel devel packages.  The common package
  contains the development headers while the per-kernel
  package contains kernel specific build products.

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

11 years agoConfigure --with-spl{-obj} auto-detect cleanup
Brian Behlendorf [Fri, 22 Feb 2013 23:50:00 +0000 (15:50 -0800)]
Configure --with-spl{-obj} auto-detect cleanup

Because the install location for the spl/zfs-devel headers was
changed we need to refresh the auto-detect code.  Note that
for packaging which already explicitly calls --with-spl{-obj}
nothing has changed.

The updated code is now structured like that in ZFS_AC_KERNEL
and should be cleaner and easier to maintain.  In addition,
it's stricter about detecting a valid source and object
directory.  It requires:

* The source directory contains the file 'spl.release'
* The object directory contains the file 'spl_config.h'
* The following paths will be checked.  Notice the /var/lib/
  and /usr/src paths require that the spl and zfs version be
  matched.  This is done to prevent accidentally mixing releases.

        dnl # 1) /var/lib/dkms/spl/<version>/build
        dnl # 2) /usr/src/spl-<version>/<kernel-version>
        dnl # 3) /usr/src/spl-<version>
        dnl # 4) ../spl
        dnl # 5) /usr/src/kernels/<kernel-version>

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoChange zfs-kmod-devel install path
Brian Behlendorf [Thu, 21 Feb 2013 23:10:11 +0000 (15:10 -0800)]
Change zfs-kmod-devel install path

Install the common zfs kernel development headers under
/usr/src/zfs-<version>/ rather than in a kernel specific
directory.  The kernel specific build products such as
zfs_config.h and Modules.symvers are left installed under
/usr/src/zfs-<version>/<kernel>.

This was done to be consistent with where dkms expects
kernel module source to be packaged.  It also allows for
a common zfs-kmod-devel package which includes the headers,
and per-kernel zfs-kmod-devel-<kernel> packages.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRemove COPYING
Brian Behlendorf [Fri, 8 Mar 2013 21:06:04 +0000 (13:06 -0800)]
Remove COPYING

There's no reason to keep this file around it's redundant with
the COPYRIGHT and OPENSOLARIS.LICENSE files and causes lintian
to emit an extra-license-file warning.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoCreate mount.zfs, zinject, and zpios man pages.
Darik Horn [Tue, 12 Mar 2013 19:40:55 +0000 (14:40 -0500)]
Create mount.zfs, zinject, and zpios man pages.

And update the automake templates to install them.

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

11 years agoImport ztest.1 man page.
Michael Gebetsroither [Tue, 12 Mar 2013 20:26:50 +0000 (15:26 -0500)]
Import ztest.1 man page.

Create a nroff man page for ZoL from:

  http://grml.org/online-docs/ztest.1.html

Which itself was derived from:

  http://opensolaris.org/os/community/zfs/ztest/

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #518

11 years agoLinux 3.9 compat: Undefine GCC_VERSION
Richard Yao [Mon, 4 Mar 2013 20:52:11 +0000 (15:52 -0500)]
Linux 3.9 compat: Undefine GCC_VERSION

The mainline kernel started defining GCC_VERSION with commit
torvalds/linux@3f3f8d2f48acfd8ed3b8e6b7377935da57b27b16.
Unfortunately, LZ4 also defines this macro, but the two
defintions are incompatible. We undefine GCC_VERSION in lz4.c
to handle this.

Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1339

11 years agoMerge branch 'build-system'
Brian Behlendorf [Wed, 6 Mar 2013 23:47:38 +0000 (15:47 -0800)]
Merge branch 'build-system'

11 years agoFix zdb.8 macro warning
Brian Behlendorf [Fri, 22 Feb 2013 19:28:28 +0000 (11:28 -0800)]
Fix zdb.8 macro warning

Detected by rpmlint the 'rpool/export/home' section was being
interpretted by troff as an undefined macro.  This resulted
in the 'rpool/export/home' output being omitted from 'man zdb'.

This was caused by starting the line with a ' character.  By
moving the 'in' down to the next line we're able to fix it.

  zfs.x86_64: W: manual-page-warning /usr/share/man/man8/zdb.8.gz
  450: warning: macro `rpool/export/home'' not defined

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRefresh links to web site
Ned Bass [Sun, 17 Feb 2013 19:31:20 +0000 (11:31 -0800)]
Refresh links to web site

A few files still refer to @behlendorf's private fork on
github.  Use the primary web site URL instead.  Two typos
are also corrected.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRetire ZFS.RELEASE file
Brian Behlendorf [Sun, 17 Feb 2013 19:16:22 +0000 (11:16 -0800)]
Retire ZFS.RELEASE file

The ZFS.RELEASE file was originally added to document which
version of OpenSolaris the ZoL code was based on.  However,
that's no longer particularly important or useful.  We'll
likely never see a new onnv_* drop from Solaris, and even
if we do the ZoL changes are now extensive enough they
could not be easily applied.  We now treat Illumos as the
official upstream and cherry pick the patches we need.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRemove ARCH packaging
Brian Behlendorf [Sun, 17 Feb 2013 19:11:41 +0000 (11:11 -0800)]
Remove ARCH packaging

The kernel modules are now available in the Arch User Repository
(AUR) via zfs.  Since their packaging is maintained and superior
to ours it is being removed from the tree.

  https://wiki.archlinux.org/index.php/ZFS

Now that various distributions are picking up the packages we
should eventually be able to remove most of this infrastructure.
Packaging belongs with the distributions not upstream.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd --with-dracutdir configure option
Brian Behlendorf [Fri, 22 Feb 2013 18:16:16 +0000 (10:16 -0800)]
Add --with-dracutdir configure option

The standard dracut directory has moved from /usr/share/dracut to
/usr/lib/dracut.  To ensure the dracut modules get installed in
the correct location provide a --with-dracutdir configure option
to set the path.

The default install location has been updated to /usr/lib/dracut
which is used by more current versions of Fedora.  However, this
default is overriden by the RPM packaging for consistency.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd KMODDIR to install target
Brian Behlendorf [Sun, 17 Feb 2013 19:05:11 +0000 (11:05 -0800)]
Add KMODDIR to install target

Provide a mechanism to control the directory name the modules
are installed in.  The kernel privdes INSTALL_MOD_DIR for
this but it was hardcoded to be 'addon/zfs'.

Add a KMODDIR variable which can be passed to 'make install'
to override the default directory name.  While we're here
change the default from 'addon/zfs' to 'extra' which is the
kernel.org default.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix zfs_config.h install permissions
Brian Behlendorf [Fri, 8 Feb 2013 21:51:27 +0000 (13:51 -0800)]
Fix zfs_config.h install permissions

The default permissions used by install are 755.  Since this
file isn't executable 644 is more appropriate.

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