]> git.proxmox.com Git - mirror_zfs-debian.git/log
mirror_zfs-debian.git
11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Brian Behlendorf [Tue, 4 Sep 2012 22:52:36 +0000 (15:52 -0700)]
Switch KM_SLEEP to KM_PUSHPAGE

This warning indicates the incorrect use of KM_SLEEP in a call
path which must use KM_PUSHPAGE to avoid deadlocking in direct
reclaim.  See commit b8d06fca089fae4680c3a552fc55c512bfb02202
for additional details.

  SPL: Fixing allocation for task txg_sync (6093) which
  used GFP flags 0x297bda7c with PF_NOFS set

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

11 years agoImprove AF hard disk detection
Brian Behlendorf [Sun, 2 Sep 2012 23:34:12 +0000 (16:34 -0700)]
Improve AF hard disk detection

Use the bdev_physical_block_size() interface to determine the
minimize write size which can be issued without incurring a
read-modify-write operation.  This is used to set the ashift
correctly to prevent a performance penalty when using AF hard
disks.

Unfortunately, this interface isn't entirely reliable because
it's not uncommon for disks to misreport this value.  For this
reason you may still need to manually set your ashift with:

  zpool create -o ashift=12 ...

The solution to this in the upstream Illumos source was to add
a while list of known offending drives.  Maintaining such a list
will be a burden, but it still may be worth doing if we can
detect a large number of these drives.  This should be considered
as future work.

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Brian Behlendorf [Mon, 3 Sep 2012 20:05:19 +0000 (13:05 -0700)]
Switch KM_SLEEP to KM_PUSHPAGE

This warning indicates the incorrect use of KM_SLEEP in a call
path which must use KM_PUSHPAGE to avoid deadlocking in direct
reclaim.  See commit b8d06fca089fae4680c3a552fc55c512bfb02202
for additional details.

  SPL: Fixing allocation for task txg_sync (6093) which
  used GFP flags 0x297bda7c with PF_NOFS set

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

11 years agoAdd libnvpair to mount_zfs dependencies
Etienne Dechamps [Sun, 2 Sep 2012 20:09:01 +0000 (22:09 +0200)]
Add libnvpair to mount_zfs dependencies

Commit e6f290535c2fff8b940c4eacb1c90cbc2cfc7508 added libzpool to
the mount_zfs dependencies.  This brought in the nvpair symbols
which are used by libzpool.  To resolve this include the libnvpair
library for mount_zfs even though mount_zfs doesn't directly
require any of these symbols.

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

11 years agoAdd zstreamdump(8) command to examine ZFS send streams.
Martin Matuska [Wed, 29 Aug 2012 19:23:12 +0000 (21:23 +0200)]
Add zstreamdump(8) command to examine ZFS send streams.

Obtained from: illumos-gate revision 11935:538c866aaac6
Source: ssh://anonhg@hg.illumos.org/illumos-gate

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Chris Dunlop [Sat, 1 Sep 2012 04:44:13 +0000 (14:44 +1000)]
Switch KM_SLEEP to KM_PUSHPAGE

This warning indicates the incorrect use of KM_SLEEP in a call
path which must use KM_PUSHPAGE to avoid deadlocking in direct
reclaim.  See commit b8d06fca089fae4680c3a552fc55c512bfb02202
for additional details.

  SPL: Fixing allocation for task txg_sync (6093) which
  used GFP flags 0x297bda7c with PF_NOFS set

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Brian Behlendorf [Fri, 31 Aug 2012 14:45:27 +0000 (07:45 -0700)]
Switch KM_SLEEP to KM_PUSHPAGE

This warning indicates the incorrect use of KM_SLEEP in a call
path which must use KM_PUSHPAGE to avoid deadlocking in direct
reclaim.  See commit b8d06fca089fae4680c3a552fc55c512bfb02202
for additional details.

  SPL: Fixing allocation for task txg_sync (6093) which
  used GFP flags 0x297bda7c with PF_NOFS set

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

11 years agoClear PG_writeback after zil_commit() for sync I/O
Brian Behlendorf [Wed, 29 Aug 2012 18:52:47 +0000 (11:52 -0700)]
Clear PG_writeback after zil_commit() for sync I/O

When writing via ->writepage() the writeback bit was always cleared
as part of the txg commit callback.  However, when the I/O is also
being written synchronsously to the zil we can immediately clear this
bit.  There is no need to wait for the subsequent TXG sync since the
data is already safe on stable storage.

This has been observed to reduce the msync(2) delay from up to 5
seconds down 10s of miliseconds.  One workload which is expected
to benefit from this are the intermittent samba hands described
in issue #700.

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

11 years agoFix mount_zfs dependency on libzpool.
Etienne Dechamps [Thu, 30 Aug 2012 10:15:10 +0000 (12:15 +0200)]
Fix mount_zfs dependency on libzpool.

mount_zfs depends on libzpool for zfs_prop_written since
330d06f90d143b41b276796526a66a1c1fff046d. Unfortunately, the Makefile
for mount_zfs has not been modified to reflect this. As a result,
libtool doesn't know about the dependency, which may result in the wrong
libzpool being used during the build (e.g. the libzpool from the system
instead of the libzpool from the build directory).

This patch adds the dependency to fix the issue.

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Richard Yao [Mon, 7 May 2012 17:49:51 +0000 (13:49 -0400)]
Switch KM_SLEEP to KM_PUSHPAGE

Differences between how paging is done on Solaris and Linux can cause
deadlocks if KM_SLEEP is used in any the following contexts.

  * The txg_sync thread
  * The zvol write/discard threads
  * The zpl_putpage() VFS callback

This is because KM_SLEEP will allow for direct reclaim which may result
in the VM calling back in to the filesystem or block layer to write out
pages.  If a lock is held over this operation the potential exists to
deadlock the system.  To ensure forward progress all memory allocations
in these contexts must us KM_PUSHPAGE which disables performing any I/O
to accomplish the memory allocation.

Previously, this behavior was acheived by setting PF_MEMALLOC on the
thread.  However, that resulted in unexpected side effects such as the
exhaustion of pages in ZONE_DMA.  This approach touchs more of the zfs
code, but it is more consistent with the right way to handle these cases
under Linux.

This is patch lays the ground work for being able to safely revert the
following commits which used PF_MEMALLOC:

  21ade34 Disable direct reclaim for z_wr_* threads
  cfc9a5c Fix zpl_writepage() deadlock
  eec8164 Fix ASSERTION(!dsl_pool_sync_context(tx->tx_pool))

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

11 years agomzap_upgrade() must use kmem_alloc()
Brian Behlendorf [Wed, 22 Aug 2012 03:53:01 +0000 (20:53 -0700)]
mzap_upgrade() must use kmem_alloc()

These allocations in mzap_update() used to be kmem_alloc() but
were changed to vmem_alloc() due to the size of the allocation.
However, since it turns out this function may be called in the
context of the txg_sync thread they must be changed back to use
a kmem_alloc() to ensure the KM_PUSHPAGE flag is honored.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAnnotate KM_PUSHPAGE call paths with PF_NOFS
Brian Behlendorf [Sat, 18 Aug 2012 18:17:23 +0000 (11:17 -0700)]
Annotate KM_PUSHPAGE call paths with PF_NOFS

The txg_sync(), zfs_putpage(), zvol_write(), and zvol_discard()
call paths must only use KM_PUSHPAGE to avoid potential deadlocks
during direct reclaim.

This patch annotates these call paths so any accidental use of
KM_SLEEP will be quickly detected.   In the interest of stability
if debugging is disabled the offending allocation will have its
GFP flags automatically corrected.  When debugging is enabled
any misuse will be treated as a fatal error.

This patch is entirely for debugging.  We should be careful to
NOT become dependant on it fixing up the incorrect allocations.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoPre-allocate vdev I/O buffers
Brian Behlendorf [Mon, 20 Aug 2012 00:17:02 +0000 (17:17 -0700)]
Pre-allocate vdev I/O buffers

The vdev queue layer may require a small number of buffers
when attempting to create aggregate I/O requests.  Rather than
attempting to allocate them from the global zio buffers, which
is slow under memory pressure, it makes sense to pre-allocate
them because...

1) These buffers are short lived.  They are only required for
the life of a single I/O at which point they can be used by
the next I/O.

2) The maximum number of concurrent buffers needed by a vdev is
small.  It's roughly limited by the zfs_vdev_max_pending tunable
which defaults to 10.

By keeping a small list of these buffer per-vdev we can ensure
one is always available when we need it.  This significantly
reduces contention on the vq->vq_lock, because we no longer
need to perform a slow allocation under this lock.  This is
particularly important when memory is already low on the system.

It would probably be wise to extend the use of these buffers beyond
aggregate I/O and in to the raidz implementation.  The inability
to quickly allocate buffer for the parity stripes could result in
similiar problems.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRevert Disable direct reclaim for z_wr_* threads
Richard Yao [Wed, 16 May 2012 22:16:02 +0000 (18:16 -0400)]
Revert Disable direct reclaim for z_wr_* threads

This commit used PF_MEMALLOC to prevent a memory reclaim deadlock.
However, commit 49be0ccf1fdc2ce852271d4d2f8b7a9c2c4be6db eliminated
the invocation of __cv_init(), which was the cause of the deadlock.
PF_MEMALLOC has the side effect of permitting pages from ZONE_DMA
to be allocated.  The use of PF_MEMALLOC was found to cause stability
problems when doing swap on zvols. Since this technique is known to
cause problems and no longer fixes anything, we revert it.

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

11 years agoRevert Fix zpl_writepage() deadlock
Richard Yao [Mon, 7 May 2012 18:14:45 +0000 (14:14 -0400)]
Revert Fix zpl_writepage() deadlock

The commit, cfc9a5c88f91f7b4d606fce89505e1f404691ea5, to fix deadlocks
in zpl_writepage() relied on PF_MEMALLOC.   That had the effect of
disabling the direct reclaim path on all allocations originating from
calls to this function, but it failed to address the actual cause of
those deadlocks.  This led to the same deadlocks being observed with
swap on zvols, but not with swap on the loop device, which exercises
this code.

The use of PF_MEMALLOC also had the side effect of permitting
allocations to be made from ZONE_DMA in instances that did not require
it.  This contributes to the possibility of panics caused by depletion
of pages from ZONE_DMA.

As such, we revert this patch in favor of a proper fix for both issues.

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

11 years agoRevert Fix ASSERTION(!dsl_pool_sync_context(tx->tx_pool))
Richard Yao [Wed, 16 May 2012 03:19:32 +0000 (23:19 -0400)]
Revert Fix ASSERTION(!dsl_pool_sync_context(tx->tx_pool))

Commit eec8164771bee067c3cd55ed0a16dadeeba276de worked around an issue
involving direct reclaim through the use of PF_MEMALLOC.   Since we
are reworking thing to use KM_PUSHPAGE so that swap works, we revert
this patch in favor of the use of KM_PUSHPAGE in the affected areas.

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

11 years agoRemove autoconf check for CONFIG_PREEMPT
Prakash Surya [Fri, 24 Aug 2012 18:37:44 +0000 (11:37 -0700)]
Remove autoconf check for CONFIG_PREEMPT

The autoconf macro which failed if CONFIG_PREEMPT was set in the kernel
config was removed. With the inclusion of a few previous patches
targeting support for preempt enabled kernels, it is now safe to run
with this kernel config option enabled.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #83

11 years agoRemove autotools products
Brian Behlendorf [Mon, 27 Aug 2012 01:10:24 +0000 (18:10 -0700)]
Remove autotools products

Remove all of the generated autotools products from the repository
and update the .gitignore files accordingly.

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

11 years agormdir(2) should return ENOTEMPTY
Brian Behlendorf [Sat, 25 Aug 2012 22:01:39 +0000 (15:01 -0700)]
rmdir(2) should return ENOTEMPTY

Under Solaris the behavior for rmdir(2) is to return EEXIST when
a directory still contains entries.  However, on Linux ENOTEMPTY
is the expected return value with EEXIST being technically allowed.
According to rmdir(2):

ENOTEMPTY
   pathname contains entries other than . and .. ; or, pathname has
   ..  as its final component.  POSIX.1-2001 also allows EEXIST for
   this condition.

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

11 years agoConsistent menuconfig name
Richard Yao [Sat, 25 Aug 2012 21:16:23 +0000 (17:16 -0400)]
Consistent menuconfig name

Make name in Linux menuconfig consistent with those of other filesystems

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

11 years agoCheck kernel source directory for SPL
Richard Yao [Sat, 25 Aug 2012 22:32:54 +0000 (18:32 -0400)]
Check kernel source directory for SPL

ZFS fails to build when SPL is built into the kernel on unless
--with-spl=/path/to/kernel/sources is specified. We fallback to the
kernel sources directory when SPL is not found elsewhere to resolve
that.

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

11 years agoIllumos #3085: zfs diff panics, then panics in a loop on booting
Christopher Siden [Fri, 24 Aug 2012 13:10:22 +0000 (15:10 +0200)]
Illumos #3085: zfs diff panics, then panics in a loop on booting

Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/3085

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #2901: zfs receive fails for exabyte sparse files
Simon Klinkert [Fri, 22 Jun 2012 14:17:50 +0000 (10:17 -0400)]
Illumos #2901: zfs receive fails for exabyte sparse files

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@nexenta.com>

References:
  https://www.illumos.org/issues/2901

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoDrop spill buffer reference
Javen Wu [Sat, 25 Aug 2012 02:24:48 +0000 (19:24 -0700)]
Drop spill buffer reference

When calling sa_update() and friends it is possible that a spill
buffer will be needed to accomidate the update.  When this happens
a hold is taken on the new dbuf and that hold must be released
before calling dmu_tx_commit().  Failing to release the hold will
cause a copy of the dbuf to be made in dbuf_sync_leaf().  This is
done to ensure further updates to the dbuf never sneak in to the
syncing txg.

This could be left to the sa_update() caller.  But then the caller
would need to be aware of this internal SA implementation detail.
It is therefore preferable to handle this all internally in the
SA implementation.

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

11 years agoRevert "Use SA_HDL_PRIVATE for SA xattrs"
Brian Behlendorf [Fri, 24 Aug 2012 03:46:38 +0000 (20:46 -0700)]
Revert "Use SA_HDL_PRIVATE for SA xattrs"

This reverts commit ec2626ad3f695a2ced3946c4197ef64cbcac4959 which
caused consistency problems between the shared and private handles.
Reverting this change should resolve issues #709 and #727.  It
will also reintroduce an arc_anon memory leak which is addressed
by the next commit.

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

11 years agoWrap smp_processor_id in kpreempt_[dis|en]able
Prakash Surya [Fri, 24 Aug 2012 00:45:31 +0000 (17:45 -0700)]
Wrap smp_processor_id in kpreempt_[dis|en]able

After surveying the code, the few places where smp_processor_id is used
were deemed to be safe to use with a preempt enabled kernel. As such, no
core logic had to be changed. These smp_processor_id call sites are simply
are wrapped in kpreempt_disable and kpreempt_enabled to prevent the
Linux kernel from emitting scary warnings.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Issue #83

11 years agoFix snapshot automounting with GrSecurity constify plugin.
Massimo Maggi [Thu, 23 Aug 2012 12:52:45 +0000 (14:52 +0200)]
Fix snapshot automounting with GrSecurity constify plugin.

./configure erroneously detects absence of dops->d_automount
when built against a GrSecurity patched kernel.

Summerized error message found in config.log:

  checking whether dops->d_automount() exists
  ...
  In function 'main': ... error: constified variable 'dops'
  cannot be local

The "dops" variable cannot be a local variable, so it's
moved to the global scope.

This test also fails if the prototype of the dops->d_automount
function pointer is changed.

Signed-off-by: Massimo Maggi <massimo@mmmm.it>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Closes #884

11 years agoIllumos #2803: zfs get guid pretty-prints the output
Garrett D'Amore [Wed, 6 Jun 2012 17:01:43 +0000 (10:01 -0700)]
Illumos #2803: zfs get guid pretty-prints the output

Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Richard Elling <richard.elling@gmail.com>
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Approved by: Dan McDonald <danmcd@nexenta.com>

References:
  https://www.illumos.org/issues/2803

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #1796, #2871, #2903, #2957
Christopher Siden [Thu, 12 Jul 2012 12:32:45 +0000 (05:32 -0700)]
Illumos #1796, #2871, #2903, #2957

1796 "ZFS HOLD" should not be used when doing "ZFS SEND" from a read-only pool
2871 support for __ZFS_POOL_RESTRICT used by ZFS test suite
2903 zfs destroy -d does not work
2957 zfs destroy -R/r sometimes fails when removing defer-destroyed snapshot
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Eric Schrock <Eric.Schrock@delphix.com>

References:
  https://www.illumos.org/issues/1796
  https://www.illumos.org/issues/2871
  https://www.illumos.org/issues/2903
  https://www.illumos.org/issues/2957

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #2635: 'zfs rename -f' to perform force unmount
Eric Schrock [Fri, 27 Apr 2012 18:14:46 +0000 (11:14 -0700)]
Illumos #2635: 'zfs rename -f' to perform force unmount

Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: George Wilson <George.Wilson@delphix.com>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/2635

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #717

11 years agoIllumos #1936: add support for "-t <datatype>" argument to zfs get
Andrew Stormont [Thu, 16 Feb 2012 22:14:36 +0000 (22:14 +0000)]
Illumos #1936: add support for "-t <datatype>" argument to zfs get

Reviewed by: Kartik Mistry <kartik@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Richard Elling <richard.elling@gmail.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/1936

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #681

11 years agoIllumos #1726: Removal of pyzfs broke delegation for volumes
Alexander Eremin [Mon, 28 Nov 2011 10:13:54 +0000 (02:13 -0800)]
Illumos #1726: Removal of pyzfs broke delegation for volumes

Reviewed by: Andrew Stormont <andyjstormont@googlemail.com>
Reviewed by: Garrett D'Amore <garrett@nexenta.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: Garrett D'Amore <garrett@nexenta.com>

References:
  https://www.illumos.org/issues/1726

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #1977: zfs allow arguments not parsed correctly after pyzfs removal
Alexander Eremin [Mon, 16 Jan 2012 13:07:04 +0000 (17:07 +0400)]
Illumos #1977: zfs allow arguments not parsed correctly after pyzfs removal

Reviewed by: Garrett D'Amore <garrett.damore@gmail.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/1977

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd copy-builtin to EXTRA_DIST
Brian Behlendorf [Thu, 23 Aug 2012 16:49:54 +0000 (09:49 -0700)]
Add copy-builtin to EXTRA_DIST

The copy-builtin script was accidentally not being included in
the tarballs.

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

11 years agoProperly initialize and free destroydata
Martin Matuska [Tue, 21 Aug 2012 21:42:00 +0000 (23:42 +0200)]
Properly initialize and free destroydata

This regression was accidentally introduced by commit
330d06f90d143b41b276796526a66a1c1fff046d due to ZoL
specific code.  The fix is to simply ensure the passed
nvlist is initialized and freed.

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

11 years agoZFS 0.6.0-rc10
Brian Behlendorf [Mon, 13 Aug 2012 17:20:51 +0000 (10:20 -0700)]
ZFS 0.6.0-rc10

11 years agoExport dmu_buf_rele() symbol
Brian Behlendorf [Tue, 14 Aug 2012 15:35:32 +0000 (08:35 -0700)]
Export dmu_buf_rele() symbol

While I'd like to remove the various pragmas in module/zfs/dbuf.c.
There are consumers such as Lustre which still depend on dmu_buf_*
versions of the symbols.  Until all consumers can be converted to
use only the dbuf_* names leave this symbol exported.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoCleanly remove zfs-modules-devel headers
Brian Behlendorf [Mon, 13 Aug 2012 22:47:18 +0000 (15:47 -0700)]
Cleanly remove zfs-modules-devel headers

Add the /usr/src/zfs-<version>-<release>/<kernel> directory to
the zfs-modules-devel package.  This ensures that this directory
will be removed when the package is removed.

We do not include the higher level /usr/src/zfs-<version>-<release>
directory since there may be builds for multiple kernels.  Instead,
a %postun rmdir is added which attempts to remove this directory.
It will only succeed when the last zfs-modules-devel-* package
for this specific release is removed.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoSuppress 'zfs_sb_create' memory warning
Brian Behlendorf [Fri, 10 Aug 2012 23:39:39 +0000 (16:39 -0700)]
Suppress 'zfs_sb_create' memory warning

When mutex debugging is enabled in your kernel the increased
size of the mutex structures can push the zfs_sb_t type beyond
the 8k warning threshold.  This isn't harmful so we suppress
the warning for this case.

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

11 years agoIllumos #1888: zfs(8) should mention zfs recv -e
Brian Behlendorf [Fri, 10 Aug 2012 23:30:13 +0000 (16:30 -0700)]
Illumos #1888:  zfs(8) should mention zfs recv -e

Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/1888

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

11 years agoFix man page installation path
Ned Bass [Fri, 10 Aug 2012 18:47:07 +0000 (11:47 -0700)]
Fix man page installation path

RPM versions 4.8 and 4.9 differ in the definition of macro %_mandir:

$ rpm --version ; rpm --showrc | grep ^-14:._mandir
RPM version 4.9.0
-14: _mandir %{_prefix}/share/man

$ rpm --version ; rpm --showrc | grep ^-14:._mandir
RPM version 4.8.0
-14: _mandir /usr/share/man

zfs.spec.in defines %_prefix as /, so man pages end up getting
installed in /share/man on RPM 4.9 systems.  To fix this, define
%_mandir relative to %_datadir in the spec file.

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

11 years agoExport dbuf_* symbols
Brian Behlendorf [Fri, 10 Aug 2012 23:28:37 +0000 (16:28 -0700)]
Export dbuf_* symbols

Export these symbols so they may be used by other ZFS consumers
besides the ZPL.

Remove three stale prototype definites from dbuf.h.  The actual
implementations of these functions were removed/renamed long ago.

It would be good in the long term to remove the existing pragmas
we inherited from Solaris and simply use the dbuf_* names.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoSupport building a zfs-modules-dkms sub package
Prakash Surya [Tue, 7 Aug 2012 20:13:17 +0000 (13:13 -0700)]
Support building a zfs-modules-dkms sub package

This commit adds support for building a zfs-modules-dkms sub package
built around Dynamic Kernel Module Support. This is to allow building
packages using the DKMS infrastructure which is intended to ease the
burden of kernel version changes, upgrades, etc.

By default zfs-modules-dkms-* sub package will be built as part of
the 'make rpm' target.  Alternately, you can build only the DKMS
module package using the 'make rpm-dkms' target.

Examples:

    # To build packaged binaries as well as a dkms packages
    $ ./configure && make rpm

    # To build only the packaged binary utilities and dkms packages
    $ ./configure && make rpm-utils rpm-dkms

Note: Only the RHEL 5/6, CHAOS 5, and Fedora distributions are
      supported for building the dkms sub package.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #535

11 years agoAdd '--with-spl-timeout' option
Prakash Surya [Wed, 8 Aug 2012 00:07:55 +0000 (17:07 -0700)]
Add '--with-spl-timeout' option

When checking for the SPL Module.symvers file, a timeout can now be
passed in which will pause the configure step while it waits for this
file to be generated. By default, the configure behavior is unchanged as
a timeout of 0 is used. If a positive number of seconds is passed,
configure will wait that number of seconds for the Module.symvers file
before moving on.

The main motivation for this change was to support parallel execution of
'./configure && make' for the SPL and ZFS packages in preparation of
supporting DKMS based packages.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #1693: persistent 'comment' field for a zpool
Dan McDonald [Tue, 15 Nov 2011 19:01:27 +0000 (14:01 -0500)]
Illumos #1693: persistent 'comment' field for a zpool

Reviewed by: George Wilson <gwilson@zfsmail.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/1693

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #678

11 years agoSet zvol discard_granularity to the volblocksize.
Etienne Dechamps [Wed, 1 Aug 2012 08:29:59 +0000 (10:29 +0200)]
Set zvol discard_granularity to the volblocksize.

Currently, zvols have a discard granularity set to 0, which suggests to
the upper layer that discard requests of arbirarily small size and
alignment can be made efficiently.

In practice however, ZFS does not handle unaligned discard requests
efficiently: indeed, it is unable to free a part of a block. It will
write zeros to the specified range instead, which is both useless and
inefficient (see dnode_free_range).

With this patch, zvol block devices expose volblocksize as their discard
granularity, so the upper layer is aware that it's not supposed to send
discard requests smaller than volblocksize.

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

11 years agoAdd missing dependencies to ./copy-builtin
Richard Yao [Sun, 29 Jul 2012 09:43:57 +0000 (05:43 -0400)]
Add missing dependencies to ./copy-builtin

ZFS depends on EFI_PARTITION, ZLIB_DEFLATE and ZLIB_INFLATE, but when
ZFS is integrated with the kernel source tree, menuconfig does not
enforce these dependencies. This can cause build failures in the case of
ZLIB_DEFLATE and ZLIB_INFLATE where symbols are not found. This can also
cause runtime failures in the case of EFI_PARTITION, where the kernel
will not understand GPT partitions when creating pools from raw disks.
We solve this by making menuconfig aware of these dependencies.

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

11 years agoLimit the number of blocks to discard at once.
Etienne Dechamps [Tue, 31 Jul 2012 08:45:37 +0000 (10:45 +0200)]
Limit the number of blocks to discard at once.

The number of blocks that can be discarded in one BLKDISCARD ioctl on a
zvol is currently unlimited. Some applications, such as mkfs, discard
the whole volume at once and they use the maximum possible discard size
to do that. As a result, several gigabytes discard requests are not
uncommon.

Unfortunately, if a large amount of data is allocated in the zvol, ZFS
can be quite slow to process discard requests. This is especially true
if the volblocksize is low (e.g. the 8K default). As a result, very
large discard requests can take a very long time (seconds to minutes
under heavy load) to complete. This can cause a number of problems, most
notably if the zvol is accessed remotely (e.g. via iSCSI), in which case
the client has a high probability of timing out on the request.

This patch solves the issue by adding a new tunable module parameter:
zvol_max_discard_blocks. This indicates the maximum possible range, in
zvol blocks, of one discard operation. It is set by default to 16384
blocks, which appears to be a good tradeoff. Using the default
volblocksize of 8K this is equivalent to 128 MB. When using the maximum
volblocksize of 128K this is equivalent to 2 GB.

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

11 years agoIllumos #1644, #1645, #1646, #1647, #1708
Matthew Ahrens [Thu, 17 Nov 2011 18:14:36 +0000 (10:14 -0800)]
Illumos #1644, #1645, #1646, #1647, #1708

1644 add ZFS "clones" property
1645 add ZFS "written" and "written@..." properties
1646 "zfs send" should estimate size of stream
1647 "zfs destroy" should determine space reclaimed by
     destroying multiple snapshots
1708 adjust size of zpool history data

References:
  https://www.illumos.org/issues/1644
  https://www.illumos.org/issues/1645
  https://www.illumos.org/issues/1646
  https://www.illumos.org/issues/1647
  https://www.illumos.org/issues/1708

This commit modifies the user to kernel space ioctl ABI.  Extra
care should be taken when updating to ensure both the kernel
modules and utilities are updated.  This change has reordered
all of the new ioctl()s to the end of the list.  This should
help minimize this issue in the future.

Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: George Wilson <gwilson@zfsmail.com>
Reviewed by: Albert Lee <trisk@opensolaris.org>
Approved by: Garrett D'Amore <garret@nexenta.com>

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #826
Closes #664

11 years agoAdding grub2 mkconfig support patch
Manuel Amador (Rudd-O) [Mon, 23 Jul 2012 19:26:17 +0000 (12:26 -0700)]
Adding grub2 mkconfig support patch

Added simply for convenience until this, or an equivilant, change
is merged in the upstream grub2 source.

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

11 years agoAllow '-o remount' for non-legacy datasets
Brian Behlendorf [Mon, 30 Jul 2012 22:38:02 +0000 (15:38 -0700)]
Allow '-o remount' for non-legacy datasets

This is done for compatibility with existing Linux infrastructure.

In particular, when using zfs as a root filesystem there are init
scripts which as part of shutdown remount root read-only.  Also,
the new systemd infrastructure being used by Fedora expects to be
able to remount a file system read-write.

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

11 years agoMerge branch 'builtin-clean'
Brian Behlendorf [Thu, 26 Jul 2012 22:37:13 +0000 (15:37 -0700)]
Merge branch 'builtin-clean'

Support in-tree builtin module building.

These commits add support for compiling the ZFS module as a built-in
kernel module by copying the module code into the kernel source tree.
Here's the procedure:

  - Create your kernel configuration (`.config` file) as usual. This
    has to be done first so that ZFS's configure script is able to
    detect kernel features correctly.
  - Run `make prepare scripts` inside the kernel source tree.
  - Run `./configure --enable-linux-builtin --with-linux=/usr/src/linux-...`
    inside the ZFS directory.
  - Run `./copy-builtin /usr/src/linux-...` inside the ZFS directory.
  - In the kernel source tree, enable the `CONFIG_ZFS` option (e.g. using
    `make menuconfig`). Note that this option depends on `CONFIG_SPL`
    (see zfsonlinux/spl@744038069d3dc65e721b5b8cc5c37d8c7fcbd8c0).
  - Build the kernel as usual.

ZFS module parameters can be set at boot time using the following syntax
on the kernel command line: `zfs.parameter_name=parameter_value`.

Note that you also need to rebuild the userspace tools (see
zfsonlinux/zfs@f09398cec665259a4c2f96726680fbd3b0a3bac3).

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

11 years agoUse /sys/module instead of /proc/modules.
Etienne Dechamps [Wed, 4 Jul 2012 13:56:40 +0000 (15:56 +0200)]
Use /sys/module instead of /proc/modules.

When libzfs checks if the module is loaded or not, it currently reads
/proc/modules and searches for a line matching the module name.

Unfortunately, if the module is included in the kernel itself (built-in
module), then /proc/modules won't list it, so libzfs will wrongly conclude
that the module is not loaded, thus making all ZFS userspace tools unusable.

Fortunately, all loaded modules appear as directories in /sys/module, even
built-in ones. Thus we can use /sys/module in lieu of /proc/modules to fix
the issue.

As a bonus, the code for checking becomes much simpler.

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

11 years agoAdd script for builtin module building.
Etienne Dechamps [Mon, 9 Jul 2012 09:23:00 +0000 (11:23 +0200)]
Add script for builtin module building.

This commit introduces a "copy-builtin" script designed to prepare a
kernel source tree for building ZFS as a builtin module. The script
makes a full copy of all needed files, thus making the kernel source
tree fully independent of the zfs source package.

To achieve that, some compilation flags (-include, -I) have been moved
to module/Makefile. This Makefile is only used when compiling external
modules; when compiling builtin modules, a Kbuild file generated by the
configure-builtin script is used instead. This makes sure Makefiles
inside the kernel source tree does not contain references to the zfs
source package.

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

11 years agoWhen checking for symbol exports, try compiling.
Etienne Dechamps [Wed, 25 Jul 2012 21:38:58 +0000 (14:38 -0700)]
When checking for symbol exports, try compiling.

This patch adds a new autoconf function: ZFS_LINUX_TRY_COMPILE_SYMBOL.
This new function does the following:

 - Call LINUX_TRY_COMPILE with the specified parameters.
 - If unsuccessful, return false.
 - If successful and we're configuring with --enable-linux-builtin,
   return true.
 - Else, call CHECK_SYMBOL_EXPORT with the specified parameters and
   return the result.

All calls to CHECK_SYMBOL_EXPORT are converted to
LINUX_TRY_COMPILE_SYMBOL so that the tests work even when configuring
for builtin on a kernel which doesn't have loadable module support, or
hasn't been built yet.

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

11 years agoFake modpost stage for LINUX_COMPILE.
Etienne Dechamps [Mon, 16 Jul 2012 07:37:38 +0000 (09:37 +0200)]
Fake modpost stage for LINUX_COMPILE.

Currently, when building a test case, we're compiling an entire Linux
module from beginning to end. This includes the MODPOST stage, which
generates a "conftest.mod.c" file with some boilerplate module
declaration code.

This poses a problem when configuring for built-in on kernels which have
loadable module support disabled. In this case conftest.mod.c is
referencing disabled code, resulting in a compilation failure, thus
breaking the tests.

This patch fixes the issue by faking the modpost stage when the
--enable-linux-builtin option is provided.  It does so by forcing the
modpost command to be /bin/true, and using an empty conftest.mod.c file.
The test module still compiles fine, although the result isn't loadable,
but we don't really care at this point.

Note it is important to preserve the modpost stage when building out of
tree.  The ZFS_AC_KERNEL_BLK_END_REQUEST, ZFS_AC_KERNEL_BLK_QUEUE_FLUSH,
and ZFS_AC_KERNEL_BLK_RQ_BYTES configure checks all depend on it to
identify GPL-only symbols.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #851

11 years agoMake configure builtin-aware.
Etienne Dechamps [Tue, 17 Jul 2012 08:36:43 +0000 (10:36 +0200)]
Make configure builtin-aware.

This patch adds a new option to configure: --enable-linux-builtin. When
this option is used, the following happens:

 - Compilation of kernel modules is disabled.

 - A failure to find UTS_RELEASE is followed by a suggestion to run
   "make prepare" on the kernel source tree.

This patch also adds a new test which tries to compile an empty module
as a basic toolchain sanity test. If it fails and the option was
specified, the error is followed by a suggestion to run "make scripts"
on the kernel source tree.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #851

11 years agoDon't build packages that haven't been selected.
Etienne Dechamps [Tue, 17 Jul 2012 09:23:09 +0000 (11:23 +0200)]
Don't build packages that haven't been selected.

Currently, when configure --with-config is used, selective compilation
is only effective for the simple "make" case. Package builders (e.g.
make rpm) still build everything (utils and modules). This patch fixes
that.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #851

11 years agoLinux 3.5 compat, end_writeback() changed to clear_inode()
Richard Yao [Mon, 23 Jul 2012 18:39:25 +0000 (11:39 -0700)]
Linux 3.5 compat, end_writeback() changed to clear_inode()

The end_writeback() function was changed by moving the call to
inode_sync_wait() earlier in to evict().   This effecitvely changes
the ordering of the sync but it does not impact the details of
the zfs implementation.

However, as part of this change end_writeback() was renamed to
clear_inode() to reflect the new semantics.  This change does
impact us and clear_inode() now maps to end_writeback() for
kernels prior to 3.5.

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

11 years agoLinux 3.5 compat, iops->truncate_range() removed
Richard Yao [Mon, 23 Jul 2012 18:11:25 +0000 (11:11 -0700)]
Linux 3.5 compat, iops->truncate_range() removed

The vmtruncate_range() support has been removed from the kernel in
favor of using the fallocate method in the file_operations table.

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

11 years agoLinux 3.5 compat, eops->encode_fh() takes inodes
Richard Yao [Mon, 23 Jul 2012 17:55:48 +0000 (10:55 -0700)]
Linux 3.5 compat, eops->encode_fh() takes inodes

The export_operations member ->encode_fh() has been updated to
take both the child and parent inodes.  This interface used to
take the child dentry and a bool describing if the parent is needed.

NOTE: While updating this code I noticed that we do not currently
cleanly handle the case where we're passed a connectable parent.
This code should be audited to make sure we're doing the right thing.

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

11 years agoFix NULL pointer dereference on PaX/GRSecurity patched Linux 3.3 and later kernels
Richard Yao [Thu, 19 Jul 2012 22:37:56 +0000 (18:37 -0400)]
Fix NULL pointer dereference on PaX/GRSecurity patched Linux 3.3 and later kernels

Support for PaX/GRSecurity patched kernels was developed against Linux
3.2.  Unfortunately, an autotools check introduced for a Linux 3.3 API
fails on PaX/GRSecurity patched kernels. This causes the module to be
built against the Linux 3.2 ABI, which results in a NULL pointer
dereference at runtime.

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

11 years agoDisable .zfs directory on 32-bit systems
Brian Behlendorf [Thu, 19 Jul 2012 21:50:25 +0000 (14:50 -0700)]
Disable .zfs directory on 32-bit systems

The .zfs control directory implementation currently relies on
the fact that there is a direct 1:1 mapping from an object id
to its inode number.  This works well as long as the system
uses a 64-bit value to store the inode number.

Unfortunately, the Linux kernel defines the inode number as
an 'unsigned long' type.  This means that for 32-bit systems
will only have 32-bit inode numbers but we still have 64-bit
object ids.

This problem is particularly acute for the .zfs directories
which leverage those upper 32-bits.  This is done to avoid
conflicting with object ids which are allocated monotonically
starting from 0.  This is likely to also be a problem for
datasets on 32-bit systems with more than ~2 billion files.

The right long term fix must remove the simple 1:1 mapping.
Until that's done the only safe thing to do is to disable the
.zfs directory on 32-bit systems.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd ddt_object_load() error handling
Brian Behlendorf [Thu, 19 Jul 2012 21:50:25 +0000 (14:50 -0700)]
Add ddt_object_load() error handling

Add the missing error handling to ddt_object_load().  There's no
good reason this needs to be fatal.  It is preferable that an
error be returned.  This will allow 'zpool import -FX' to safely
attempt to rollback through previous txgs looking for a good one.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd 'inline' keyword
Brian Behlendorf [Wed, 18 Jul 2012 23:56:24 +0000 (16:56 -0700)]
Add 'inline' keyword

The '__attribute__((always_inline))' does not strictly imply
'inline'.  Newer versions of gcc detect this misuse and issue
the following warning.  Including the missing 'inline' resolves
the build warning.

    ./module/zfs/dsl_scan.c:758:1:error: always_inline function
    might not be inlinable [-Werror=attributes]

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix build failures on PaX/GRSecurity patched kernels
Richard Yao [Thu, 31 May 2012 03:25:31 +0000 (23:25 -0400)]
Fix build failures on PaX/GRSecurity patched kernels

Gentoo Hardened kernels include the PaX/GRSecurity patches. They use a
dialect of C that relies on a GCC plugin. In particular, struct
file_operations has been marked do_const in the PaX/GRSecurity dialect,
which causes GCC to consider all instances of it as const. This caused
failures in the autotools checks and the ZFS source code.

To address this, we modify the autotools checks to take into account
differences between the PaX C dialect and the regular C dialect. We also
modify struct zfs_acl's z_ops member to be a pointer to a function
pointer table. Lastly, we modify zpl_put_link() to address a PaX change
to the function prototype of nd_get_link().  This avoids compiler errors
in the PaX/GRSecurity dialect.

Note that the change in zpl_put_link() causes a warning that becomes a
build failure when debugging is enabled. Fixing that warning requires
ryao/spl@5ca50ef459c59bc74b7a7cd3af7311da2b1cd2c3.

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

11 years agoMove partition scanning from userspace to module.
Etienne Dechamps [Wed, 11 Jul 2012 13:06:32 +0000 (15:06 +0200)]
Move partition scanning from userspace to module.

Currently, zpool online -e (dynamic vdev expansion) doesn't work on
whole disks because we're invoking ioctl(BLKRRPART) from userspace
while ZFS still has a partition open on the disk, which results in
EBUSY.

This patch moves the BLKRRPART invocation from the zpool utility to the
module. Specifically, this is done just before opening the device in
vdev_disk_open() which is called inside vdev_reopen(). This requires
jumping through some hoops to get to the disk device from the partition
device, and to make sure we can still open the partition after the
BLKRRPART call.

Note that this new code path is triggered on dynamic vdev expansion
only; other actions, like creating a new pool, are unchanged and still
call BLKRRPART from userspace.

This change also depends on API changes which are available in 2.6.37
and latter kernels.  The build system has been updated to detect this,
but there is no compatibility mode for older kernels.  This means that
online expansion will NOT be available in older kernels.  However, it
will still be possible to expand the vdev offline.

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

11 years agoMove zfs.release generation to configure step
Brian Behlendorf [Thu, 12 Jul 2012 19:21:25 +0000 (12:21 -0700)]
Move zfs.release generation to configure step

Previously, the zfs.release file was created at 'make install' time.
This is slightly problematic when the file is needed without running
'make install'. Because of this, the step creating the file was removed
from 'make install' and replaced with a more appropriate zfs.release.in
file.

As a result, the zfs.release file will now be created earlier as part
of the 'configure' step as opposed to the 'make install' step.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd PowerPC to supported VTOCs
Brian Behlendorf [Thu, 12 Jul 2012 18:34:43 +0000 (11:34 -0700)]
Add PowerPC to supported VTOCs

This code was was inherited from Solaris which was careful to define
the expected VTOC for various supported architectures.  While this
check may have made sense there it's something we should be able to
safely drop under Linux.

However, I'm not quite ready to do that yet.  So for the moment I'm
just doing the very safe thing of adding PowerPC as a supported type.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix efi_use_whole_disk() when efi_nparts == 128.
Etienne Dechamps [Wed, 11 Jul 2012 15:47:10 +0000 (17:47 +0200)]
Fix efi_use_whole_disk() when efi_nparts == 128.

Commit e5dc681a changed EFI_NUMPAR from 9 to 128. This means that the
on-disk EFI label has efi_nparts = 128 instead of 9. The index of the
reserved partition, however, is still 8. This breaks
efi_use_whole_disk(), which uses efi_nparts-1 as the index of the
reserved partition.

This commit fixes efi_use_whole_disk() when the index of the reserved
partition is not efi_nparts-1. It rewrites the algorithm and makes it
more robust by using the order of the partitions instead of their
numbering. It assumes that the last non-empty partition is the reserved
partition, and that the non-empty partition before that is the data
partition.

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

11 years agoUse the right device path when relabeling.
Etienne Dechamps [Fri, 6 Jul 2012 14:22:03 +0000 (16:22 +0200)]
Use the right device path when relabeling.

Currently, zpool_vdev_online() calls zpool_relabel_disk() with a short
partition device name, which is obviously wrong because (1)
zpool_relabel_disk() expects a full, absolute path to use with open()
and (2) efi_write() must be called on an opened disk device, not a
partition device.

With this patch, zpool_relabel_disk() gets called with a full disk
device path. The path is determined using the same algorithm as
zpool_find_vdev().

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

11 years agoFix error handling for "zpool online -e".
Etienne Dechamps [Fri, 6 Jul 2012 13:44:14 +0000 (15:44 +0200)]
Fix error handling for "zpool online -e".

The error handling code around zpool_relabel_disk() is either inexistent
or wrong. The function call itself is not checked, and
zpool_relabel_disk() is generating error messages from an unitialized
buffer.

Before:

    # zpool online -e homez sdb; echo $?
    `: cannot relabel 'sdb1': unable to open device: 2
    0

After:

    # zpool online -e homez sdb; echo $?
    cannot expand sdb: cannot relabel 'sdb1': unable to open device: 2
    1

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

11 years agoIllumos #1949, #1953
George Wilson [Wed, 11 Jul 2012 20:02:44 +0000 (13:02 -0700)]
Illumos #1949, #1953

1949 crash during reguid causes stale config
1953 allow and unallow missing from zpool history since removal of pyzfs

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Garrett D'Amore <garrett.damore@gmail.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Steve Gonczi <gonczi@comcast.net>
Approved by: Eric Schrock <eric.schrock@delphix.com>

References:
  https://www.illumos.org/issues/1949
  https://www.illumos.org/issues/1953

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

11 years agoIllumos #1748: desire support for reguid in zfs
Garrett D'Amore [Fri, 11 Nov 2011 22:07:54 +0000 (14:07 -0800)]
Illumos #1748: desire support for reguid in zfs

Reviewed by: George Wilson <gwilson@zfsmail.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Reviewed by: Alexander Stetsenko <ams@nexenta.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/1748

This commit modifies the user to kernel space ioctl ABI.  Extra
care should be taken when updating to ensure both the kernel
modules and utilities are updated.  If only the user space
component is updated both the 'zpool events' command and the
'zpool reguid' command will not work until the kernel modules
are updated.

Ported by:     Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #665

11 years agoRelicense zfs.gentoo.in from GPLv2 to 2-clause BSD
Richard Yao [Tue, 10 Jul 2012 13:27:09 +0000 (09:27 -0400)]
Relicense zfs.gentoo.in from GPLv2 to 2-clause BSD

As the Gentoo sys-fs/zfs maintainer, I receive license compatibility
questions and at times, those questions can be harassing. I feel that
the presence of the GPL in Gentoo's package metadata promotes such
questions.  zfs.gentoo.in is the only GPLv2 licensed file in ZFS, so I
have taken the liberty of contacting all contributors to this file to
request permission to relicense it.

All of the contributors to this file have agreed to relicense it under
the 2-clause BSD license. I have added their Signed-offs to this commit,
in order of first contribution. Thank you everyone for being so
understanding.

Signed-off-by: devsk <devsku@gmail.com>
Signed-off-by: Alexey Shvetsov <alexxy@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Andrew Tselischev <andrewtselischev@gmail.com>
Signed-off-by: Zachary Bedell <zac@thebedells.org>
Signed-off-by: Gunnar Beutner <gunnar@beutner.name>
Signed-off-by: Kyle Fuller <inbox@kylefuller.co.uk>
Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Closes #819

11 years agoUse ULL suffix in constants
Richard Yao [Mon, 9 Jul 2012 23:41:28 +0000 (19:41 -0400)]
Use ULL suffix in constants

The lack of the ULL suffix causes warnings such as the following on
32-bit systems:

  In function 'zfsctl_is_snapdir':
  zfs-0.6.0//module/zfs/zfs_ctldir.c:151: warning: integer constant
  is too large for 'long' type

We add the ULL suffix to fix that.

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

11 years agoUpdate incorrect ddt_zap_lookup() assertion
Brian Behlendorf [Tue, 3 Jul 2012 21:47:57 +0000 (14:47 -0700)]
Update incorrect ddt_zap_lookup() assertion

When the ddt_zap_lookup() function was updated to dynamically
allocate memory for the cbuf variable, to save stack space, the
'csize <= sizeof (cbuf)' assertion was not updated.  The result
of this was that the size of the pointer was being used in the
comparison rather than the buffer size.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
11 years agoRemove Chaos 4.x RPM support
Brian Behlendorf [Mon, 2 Jul 2012 22:16:05 +0000 (15:16 -0700)]
Remove Chaos 4.x RPM support

The Chaos 4.x distribution is based on RHEL 5.x which is no longer
supported by ZoL since it uses a 2.6.18 kernel.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoSupport debug and debug-devel sub packages
Prakash Surya [Fri, 11 May 2012 19:12:08 +0000 (12:12 -0700)]
Support debug and debug-devel sub packages

This commit adds support for building debug and debug-devel sub packages
of the zfs-modules main package. This is to allow building packages
which are built against a debug kernel. By default, only packages are
built against a regular non-debug kernel. This can be toggled by passing
the '--with kernel-debug' parameter to rpmbuild.

Examples:

    # To build packages against only the non-debug kernel
    $ rpmbuild --rebuild --with kernel --without kernel-debug $SRPM

    # To build packages against only the debug kernel
    $ rpmbuild --rebuild --without kernel --with kernel-debug $SRPM

    # To build packages against debug and non-debug kernel
    $ rpmbuild --rebuild --with kernel --with kernel-debug $SRPM

Note: Only the RHEL 5/6, CHAOS 5, and Fedora distributions are supported
      for building the debug and debug-devel packages.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd ZIL statistics.
Etienne Dechamps [Fri, 15 Jun 2012 14:22:14 +0000 (16:22 +0200)]
Add ZIL statistics.

The performance of the ZIL is usually the main bottleneck when dealing with
synchronous, write-heavy workloads (e.g. databases). Understanding the
behavior of the ZIL is required to diagnose performance issues for these
workloads, and to tune ZIL parameters (like zil_slog_limit) accordingly.

This commit adds a new kstat page dedicated to the ZIL with some counters
which, hopefully, scheds some light into what the ZIL is doing, and how it is
doing it.

Currently, these statistics are available in /proc/spl/kstat/zfs/zil.
A description of the fields can be found in zil.h.

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

11 years agoZFS 0.6.0-rc9
Brian Behlendorf [Thu, 14 Jun 2012 18:46:40 +0000 (11:46 -0700)]
ZFS 0.6.0-rc9

11 years agoSpeed up 'zfs list -t snapshot -o name -s name'
Pawel Jakub Dawidek [Tue, 29 May 2012 17:50:50 +0000 (10:50 -0700)]
Speed up 'zfs list -t snapshot -o name -s name'

FreeBSD #xxx:  Dramatically optimize listing snapshots when user
requests only snapshot names and wants to sort them by name, ie.
when executes:

  # zfs list -t snapshot -o name -s name

Because only name is needed we don't have to read all snapshot
properties.

Below you can find how long does it take to list 34509 snapshots
from a single disk pool before and after this change with cold and
warm cache:

    before:

        # time zfs list -t snapshot -o name -s name > /dev/null
        cold cache: 525s
        warm cache: 218s

    after:

        # time zfs list -t snapshot -o name -s name > /dev/null
        cold cache: 1.7s
        warm cache: 1.1s

NOTE: This patch only appears in FreeBSD.  If/when Illumos picks up
the change we may want to drop this patch and adopt their version.
However, for now this addresses a real issue.

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #450

11 years agoAdd zvol_inhibit_dev module option.
Darik Horn [Sat, 2 Jun 2012 01:49:10 +0000 (20:49 -0500)]
Add zvol_inhibit_dev module option.

ZoL can create more zvols at runtime than can be configured during
system start, which hangs the init stack at reboot.

When a slow system has more than a few hundred zvols, udev will
fork bomb during system start and spend too much time in device
detection routines, so upstart kills it.

The zfs_inhibit_dev option allows an affected system to be rescued
by skipping /dev/zd* creation and thereby avoiding the udev
overload. All zvols are made inaccessible if this option is set, but
the `zfs destroy` and `zfs send` commands still work, and ZFS
filesystems can be mounted.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoMake zvol_remove_link() print a more useful error message
Richard Yao [Tue, 24 Apr 2012 19:13:47 +0000 (15:13 -0400)]
Make zvol_remove_link() print a more useful error message

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoMark zdev.conf as a config file
Brian Behlendorf [Wed, 13 Jun 2012 19:58:27 +0000 (12:58 -0700)]
Mark zdev.conf as a config file

Prevent 'rpm -Uvh *.rpm" from automatically replacing your vdev.conf
file by flagging it as a non replacable config file.

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

11 years agoWorkaround for failing zvol_id
Brian Behlendorf [Wed, 13 Jun 2012 18:21:16 +0000 (11:21 -0700)]
Workaround for failing zvol_id

This is not a proper fix.  It is just a workaround for the stack
smashing detected by gcc in zvol_id.  We simply disable the gcc
stack protector for now when building the zvol_id udev helper.
Once the root cause is resolved this patch should be reverted.

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

11 years agoMake zil_slog_limit a tunable module parameter.
Etienne Dechamps [Tue, 12 Jun 2012 09:40:36 +0000 (11:40 +0200)]
Make zil_slog_limit a tunable module parameter.

zil_slog_limit specifies the maximum commit size to be written to the separate
log device. Larger commits bypass the separate log device and go directly to
the data devices.

The optimal value for zil_slog_limit directly depends on the latency and
throughput characteristics of both the separate log device and the data disks.
Small synchronous writes are faster on low-latency separate log devices (e.g.
SSDs) whereas large synchronous writes are faster on high-latency data disks
(e.g. spindles) because of higher throughput, especially with a large array.
The point is, the line between "small" and "large" synchronous writes in this
scenario is heavily dependent on the hardware used. That's why it should be
made configurable.

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

11 years agoRetry removal of busy minors
Daniel Verite [Sat, 9 Jun 2012 02:16:11 +0000 (04:16 +0200)]
Retry removal of busy minors

When failing to remove a zvol device link because it's busy, wait
a bit and retry in a loop instead of giving up immediately.  This
technique is similar to the loop in zpool_label_disk_wait(), with
the same goal: waiting for the asynchronous udev processes to finish
their work.

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

11 years agoInclude <locale.h> to avoid error: 'LC_ALL' undeclared.
Daniel Verite [Fri, 8 Jun 2012 20:30:39 +0000 (22:30 +0200)]
Include <locale.h> to avoid error: 'LC_ALL' undeclared.

When compiling ZFS with CFLAGS=-O0 it will trigger the following error.
Resolve the issue by properly including locale.h.

  ../../cmd/mount_zfs/mount_zfs.c: In function 'main':
  ../../cmd/mount_zfs/mount_zfs.c:318:2: warning: implicit declaration
      of function 'setlocale' [-Wimplicit-function-declaration]
  ../../cmd/mount_zfs/mount_zfs.c:318:19: error: 'LC_ALL' undeclared
      (first use in this function)

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

11 years agoLinux 3.4 compat, d_make_root() replaces d_alloc_root()
Richard Yao [Wed, 6 Jun 2012 17:08:00 +0000 (17:08 +0000)]
Linux 3.4 compat, d_make_root() replaces d_alloc_root()

torvalds/linux@adc0e91ab142abe93f5b0d7980ada8a7676231fe introduced
introduced d_make_root() as a replacement for d_alloc_root(). Further
commits appear to have removed d_alloc_root() from the Linux source
tree. This causes the following failure:

  error: implicit declaration of function 'd_alloc_root'
  [-Werror=implicit-function-declaration]

To correct this we update the code to use the current d_make_root()
interface for readability.  Then we introduce an autotools check
to determine if d_make_root() is available.  If it isn't then we
define some compatibility logic which used the older d_alloc_root()
interface.

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

11 years agoHonor logbias when writing to ZVOLs.
Etienne Dechamps [Wed, 6 Jun 2012 09:30:24 +0000 (11:30 +0200)]
Honor logbias when writing to ZVOLs.

The logbias option is not taken into account when writing to ZVOLs. We fix
that by using the same logic as in the zfs filesystem write code
(see zfs_log.c).

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

11 years agoImprove CONFIG_DEBUG_LOCK_ALLOC error message
Ned Bass [Tue, 5 Jun 2012 19:45:37 +0000 (12:45 -0700)]
Improve CONFIG_DEBUG_LOCK_ALLOC error message

The configure script error message for kernels built with
CONFIG_DEBUG_LOCK_ALLOC may give the impression that the issue is
strictly with license compliance.  To avoid confusion add some words
indicating that the linking stage will fail if the build continues.

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

11 years agoImprove 'zpool import' EBUSY error message
Brian Behlendorf [Thu, 31 May 2012 19:42:51 +0000 (12:42 -0700)]
Improve 'zpool import' EBUSY error message

When a device is already open O_EXCL by another process the
`zpool import` will correctly fail.  However, the default failure
message isn't very helpful.  It may in fact be harmful if you
take its advise and destroy your pool.

    cannot import 'tank': pool is busy
            Destroy and re-create the pool from
            a backup source.

Improve the error message in the EBUSY case to simply print a
message indicating that the devices are current in use.  The user
will need to manually identify which process has the device open
exclusively and why.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd /dev/mapper/ to search path
Brian Behlendorf [Fri, 25 May 2012 21:52:56 +0000 (14:52 -0700)]
Add /dev/mapper/ to search path

When creating pools short device names may be used when those
devices appear in certain well known locations under /dev/.
This change adds /dev/mapper/ to that list.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd vdev_id for JBOD-friendly udev aliases
Ned A. Bass [Sat, 21 Apr 2012 00:32:30 +0000 (17:32 -0700)]
Add vdev_id for JBOD-friendly udev aliases

vdev_id parses the file /etc/zfs/vdev_id.conf to map a physical path
in a storage topology to a channel name.  The channel name is combined
with a disk enclosure slot number to create an alias that reflects the
physical location of the drive.  This is particularly helpful when it
comes to tasks like replacing failed drives.  Slot numbers may also be
re-mapped in case the default numbering is unsatisfactory.  The drive
aliases will be created as symbolic links in /dev/disk/by-vdev.

The only currently supported topologies are sas_direct and sas_switch:

o  sas_direct - a channel is uniquely identified by a PCI slot and a
   HBA port

o  sas_switch - a channel is uniquely identified by a SAS switch port

A multipath mode is supported in which dm-mpath devices are handled by
examining the first running component disk, as reported by 'multipath
-l'.  In multipath mode the configuration file should contain a
channel definition with the same name for each path to a given
enclosure.

vdev_id can replace the existing zpool_id script on systems where the
storage topology conforms to sas_direct or sas_switch.  The script
could be extended to support other topologies as well.  The advantage
of vdev_id is that it is driven by a single static input file that can
be shared across multiple nodes having a common storage toplogy.
zpool_id, on the other hand, requires a unique /etc/zfs/zdev.conf per
node and a separate slot-mapping file.  However, zpool_id provides the
flexibility of using any device names that show up in
/dev/disk/by-path, so it may still be needed on some systems.

vdev_id's functionality subsumes that of the sas_switch_id script, and
it is unlikely that anyone is using it, so sas_switch_id is removed.

Finally, /dev/disk/by-vdev is added to the list of directories that
'zpool import' will scan.

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

11 years agoExtend CONFIG_DEBUG_LOCK_ALLOC check
Brian Behlendorf [Mon, 21 May 2012 19:59:58 +0000 (12:59 -0700)]
Extend CONFIG_DEBUG_LOCK_ALLOC check

The CONFIG_DEBUG_LOCK_ALLOC check at configure time was added to
detect when mutex_lock() is defined as a GPL-only symbol.  However,
the check as written only inferred this from this configuration
setting, it never actually checked.  This change introduces that
missing check to prevent false positives.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
12 years agoDefine the needed ISA types for ARM
Jorgen Lundman [Sat, 28 Apr 2012 06:31:20 +0000 (06:31 +0000)]
Define the needed ISA types for ARM

Add the minimum required ISA types to support the ARM architecture.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
12 years agoRevert "Disable direct reclaim on zvols"
Brian Behlendorf [Mon, 30 Apr 2012 21:24:39 +0000 (14:24 -0700)]
Revert "Disable direct reclaim on zvols"

This reverts commit ce90208cf9e04df966429f115d8831371ea9afce.  This
change was observed to cause problems when using a zvol to back a VM
under 2.6.32.59 kernels.  This issue was filed as #710.

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

12 years agoAdd mdadm and bc dependencies
Brian Behlendorf [Mon, 30 Apr 2012 20:31:05 +0000 (13:31 -0700)]
Add mdadm and bc dependencies

The zfs-test package additionally depends on mdadm and bc to
run the zfault.sh tests.

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

12 years agoLinux 3.3 compat, iops->create()/mkdir()/mknod()
Brian Behlendorf [Mon, 30 Apr 2012 19:01:49 +0000 (12:01 -0700)]
Linux 3.3 compat, iops->create()/mkdir()/mknod()

The mode argument of iops->create()/mkdir()/mknod() was changed from
an 'int' to a 'umode_t'.  To prevent a compiler warning an autoconf
check was added to detect the API change and then correctly set a
zpl_umode_t typedef.  There is no functional change.

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