]> git.proxmox.com Git - mirror_zfs-debian.git/log
mirror_zfs-debian.git
11 years agozfs-0.6.0-rc12
Brian Behlendorf [Tue, 13 Nov 2012 22:35:44 +0000 (14:35 -0800)]
zfs-0.6.0-rc12

11 years agoFix hard coded path in 60-vdev.rules.in
Richard Yao [Mon, 12 Nov 2012 17:34:45 +0000 (12:34 -0500)]
Fix hard coded path in 60-vdev.rules.in

The udev data directory was hard coded in 60-vdev.rules.in. That causes
a problem when a distribution changes the location of the directory.
This was not an issue in the past because virtually all distributions
used the same path, but that is beginning to change following a decision
by the systemd developers to change the directory location to reflect
their take-over of udev maintainership. The testing branch of Gentoo
Linux adopted this change, which enabled the hardcoded directory
location to trigger a regression.

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

11 years agoFix "allocating allocated segment" panic
Brian Behlendorf [Wed, 31 Oct 2012 17:06:34 +0000 (10:06 -0700)]
Fix "allocating allocated segment" panic

Gunnar Beutner did all the hard work on this one by correctly
identifying that this issue is a race between dmu_sync() and
dbuf_dirty().

Now in all cases the caller is responsible for preventing this
race by making sure the zfs_range_lock() is held when dirtying
a buffer which may be referenced in a log record.  The mmap
case which relies on zfs_putpage() was not taking the range
lock.  This code was accidentally dropped when the function
was rewritten for the Linux VFS.

This patch adds the required range locking to zfs_putpage().

It also adds the missing ZFS_ENTER()/ZFS_EXIT() macros which
aren't strictly required due to the VFS holding a reference.
However, this makes the code more consistent with the upsteam
code and there's no harm in being extra careful here.

Original-patch-by: Gunnar Beutner <gunnar@beutner.name>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #541

11 years agoFix zvol+btrfs hang
Brian Behlendorf [Thu, 8 Nov 2012 22:18:22 +0000 (14:18 -0800)]
Fix zvol+btrfs hang

When using a zvol to back a btrfs filesystem the btrfs mount
would hang.  This was due to the bio completion callback used
in btrfs assuming that lower level drivers would never modify
the bio->bi_io_vecs after they were submitted via bio_submit().
If they are modified btrfs will miscalculate which pages need
to be unlocked resulting in a hang.

It's worth mentioning that other file systems such as ext[234]
and xfs work fine because they do not make the same assumption
in the bio completion callback.

The most straight forward way to fix the issue is to present
the semantics expected by btrfs.  This is done by cloning the
bios attached to each request and then using the clones bvecs
to perform the required accounting.  The clones are freed after
each read/write and the original unmodified bios are linked back
in to the request.

Signed-off-by: Chris Wedgwood <cw@f00f.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #469

11 years agoMerge remote branch 'eris/stats'
Brian Behlendorf [Tue, 6 Nov 2012 22:44:07 +0000 (14:44 -0800)]
Merge remote branch 'eris/stats'

Bring in support for the new KSTAT_TYPE_TXG type.  This allows for
additional visibility in to the txg handling.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoLog I/Os longer than zio_delay_max (30s default)
Brian Behlendorf [Thu, 25 Oct 2012 20:02:31 +0000 (13:02 -0700)]
Log I/Os longer than zio_delay_max (30s default)

There have been reports of ZFS deadlocking due to what appears to
be a lost IO.  This patch addes some debugging to determine the
exact state of the IO which neither 1) completed, 2) failed, or
3) timed out after zio_delay_max (30) seconds.

This information will be logged using the ZFS FMA infrastructure
as a 'delay' event and posted to the internal zevent log.  By
default the last 64 events will be kept in the log but the limit
is configurable via the zfs_zevent_len_max module option.

To dump the contents of the log use the 'zpool events -v' command
and look for the resource.fs.zfs.delay event.  It will include
various information about the pool, vdev, and zio which may shed
some light on the issue.

In the context of this change the 120 second kernel blocked thread
watchdog has been disabled for synchronous IOs.

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

11 years agoAdd txgs-<pool> kstat file
Brian Behlendorf [Tue, 23 Oct 2012 20:48:22 +0000 (13:48 -0700)]
Add txgs-<pool> kstat file

Create a kstat file which contains useful statistics about the
last N txgs processed.  This can be helpful when analyzing pool
performance.  The new KSTAT_TYPE_TXG type was added for this
purpose and it tracks the following statistics per-txg.

  txg          - Unique txg number
  state        - State (O)pen/(Q)uiescing/(S)yncing/(C)ommitted
  birth;       - Creation time
  nread        - Bytes read
  nwritten;    - Bytes written
  reads        - IOPs read
  writes       - IOPs write
  open_time;   - Length in nanoseconds the txg was open
  quiesce_time - Length in nanoseconds the txg was quiescing
  sync_time;   - Length in nanoseconds the txg was syncing

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoAdd ddt_object_count() error handling
Brian Behlendorf [Fri, 26 Oct 2012 17:01:49 +0000 (10:01 -0700)]
Add ddt_object_count() error handling

The interface for the ddt_zap_count() function assumes it can
never fail.  However, internally ddt_zap_count() is implemented
with zap_count() which can potentially fail.  Now because there
was no way to return the error to the caller a VERIFY was used
to ensure this case never happens.

Unfortunately, it has been observed that pools can be damaged in
such a way that zap_count() fails.  The result is that the pool can
not be imported without hitting the VERIFY and crashing the system.

This patch reworks ddt_object_count() so the error can be safely
caught and returned to the caller.  This allows a pool which has
be damaged in this way to be safely rewound for import.

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

11 years agoRevert "Don't ashift-align vdev read requests."
Brian Behlendorf [Wed, 24 Oct 2012 22:22:31 +0000 (15:22 -0700)]
Revert "Don't ashift-align vdev read requests."

This reverts commit a5c20e2a0a9046c06d86615fbf51dc04f12bba14 which
accidentally introduced a regression for real 4k sector devices.
See issue #1065 for details.

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

11 years agoRemove 'Resized bio's/dio' warning
Brian Behlendorf [Mon, 22 Oct 2012 17:07:24 +0000 (10:07 -0700)]
Remove 'Resized bio's/dio' warning

The following warning was originally added to provide visibility
in to how often a dio gets heavily fragmented in to over 16 bios.
This can happen due to constraints imposed by the block device
and may have a negitive impact on performance but is otherwise
harmless.  To prevent needless confusion and worry the message
has been removed.

  kernel: WARNING: Resized bio's/dio to 32

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoUpdate spare and cache device names on import
Brian Behlendorf [Fri, 19 Oct 2012 04:36:07 +0000 (21:36 -0700)]
Update spare and cache device names on import

During 'zpool import' all ZPOOL_CONFIG_PATH names are supposed
to be updated by fix_paths().  This was not happening for spare
and cache devices because the proper names were getting filtered
out of the pool_list_t->names.  Interestingly, the names were
being filtered because the spare and cache devices do not
contain the pool name in their vdev label.

The fix is to exclude the device path from the list only if:

  1) has a valid ZPOOL_CONFIG_POOL_NAME key in the label, and
  2) that pool name does not match the specified pool name.

Since the label is valid and because it does properly store the
vdev guid it will be correctly assembled without the pool name.

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

11 years agoAllow 'zpool replace' to use short device names
Brian Behlendorf [Wed, 17 Oct 2012 23:58:54 +0000 (16:58 -0700)]
Allow 'zpool replace' to use short device names

The 'zpool replace' command would fail when given a short name
because unlike on other platforms the short name cannot be
deterministically expanded to a single path.  Multiple path
prefixes must be checked and in addition the partition suffix
for whole disks is determined by the prefix.

To handle this complexity a zfs_strcmp_pathname() function was
added which takes either a short or fully qualified device name.
Short names will be expanded using the prefixes in the default
import search path, or the ZPOOL_IMPORT_PATH environment variable
if it's defined.  All posible expansions are then compared against
the comparison path.  Care is taken to strip redundant slashes to
ensure legitimate matches are not missed.

In the context of this work the existing zfs_resolve_shortname()
function was extended to consider the ZPOOL_IMPORT_PATH when set.
The zfs_append_partition() interface was also simplified to take
only a single buffer.

The vast majority of these changes rework existing Linux specific
code which was originally written to accomidate udev.  However,
there is some minimal cleanup which removes Illumos specific code.
This was done to improve readability but the basic flow and intent
of the upstream code was maintained.

These changes are the logical conclusion of the previos work to
adjust the 'zpool import' search behavior, see commit 44867b6a.

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

11 years agoQuote snapshot and mountpoint for .zfs automount
Brian Behlendorf [Wed, 17 Oct 2012 20:23:09 +0000 (13:23 -0700)]
Quote snapshot and mountpoint for .zfs automount

When automounting a snapshot in the .zfs/snapshot directory
make sure to quote both the dataset name and the mount point.
This ensures that if either component contains spaces, which
are allowed, they get handled correctly.

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

11 years agoMerge branch 'zil-performance'
Brian Behlendorf [Wed, 17 Oct 2012 15:57:14 +0000 (08:57 -0700)]
Merge branch 'zil-performance'

This brnach brings some ZIL performance optimizations, with
significant increases in synchronous write performance for
some workloads and pool configurations.

See the individual commit messages for details.

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

11 years agoUse the slog even with logbias=throughput.
Etienne Dechamps [Thu, 28 Jun 2012 10:30:07 +0000 (12:30 +0200)]
Use the slog even with logbias=throughput.

In the current code, logbias=throughput implies the following:
 1) All synchronous writes are logged in indirect mode.
 2) The slog is not used.

(1) makes sense because it avoids writing the data twice, which is
obviously a good thing when the user wants maximum pool throughput.

(2), however, is a surprising decision. Considering all writes are
indirect, the log record doesn't contain the actual data, only pointers
to DMU blocks. As a result, log records written in logbias=throughput
mode are quite small, and as such, it doesn't make any sense to write
them to the main pool since slogs are usually optimized for small
synchronous writes.

In fact, the current behavior is actually harmful for performance,
because log blocks and data blocks from dmu_sync() seldom have the same
allocation size and as a result are usually allocated from different
metaslabs. This means that if a spindle has to write both log blocks and
DMU blocks (which is likely to happen under heavy load), it will have to
seek between the two. Allocating the log blocks from the slog pool
instead of the main pool avoids these unnecessary seeks.

This commit makes ZFS use the slog on datasets with logbias=throughput.
Real-life performance testing shows a 50% synchronous write performance
increase with some large commit sizes, and no negative effect in other
cases.

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

11 years agoAdd FASTWRITE algorithm for synchronous writes.
Etienne Dechamps [Wed, 27 Jun 2012 13:20:20 +0000 (15:20 +0200)]
Add FASTWRITE algorithm for synchronous writes.

Currently, ZIL blocks are spread over vdevs using hint block pointers
managed by the ZIL commit code and passed to metaslab_alloc(). Spreading
log blocks accross vdevs is important for performance: indeed, using
mutliple disks in parallel decreases the ZIL commit latency, which is
the main performance metric for synchronous writes. However, the current
implementation suffers from the following issues:

1) It would be best if the ZIL module was not aware of such low-level
details. They should be handled by the ZIO and metaslab modules;

2) Because the hint block pointer is managed per log, simultaneous
commits from multiple logs might use the same vdevs at the same time,
which is inefficient;

3) Because dmu_write() does not honor the block pointer hint, indirect
writes are not spread.

The naive solution of rotating the metaslab rotor each time a block is
allocated for the ZIL or dmu_sync() doesn't work in practice because the
first ZIL block to be written is actually allocated during the previous
commit. Consequently, when metaslab_alloc() decides the vdev for this
block, it will do so while a bunch of other allocations are happening at
the same time (from dmu_sync() and other ZILs). This means the vdev for
this block is chosen more or less at random. When the next commit
happens, there is a high chance (especially when the number of blocks
per commit is slightly less than the number of the disks) that one disk
will have to write two blocks (with a potential seek) while other disks
are sitting idle, which defeats spreading and increases the commit
latency.

This commit introduces a new concept in the metaslab allocator:
fastwrites. Basically, each top-level vdev maintains a counter
indicating the number of synchronous writes (from dmu_sync() and the
ZIL) which have been allocated but not yet completed. When the metaslab
is called with the FASTWRITE flag, it will choose the vdev with the
least amount of pending synchronous writes. If there are multiple vdevs
with the same value, the first matching vdev (starting from the rotor)
is used. Once metaslab_alloc() has decided which vdev the block is
allocated to, it updates the fastwrite counter for this vdev.

The rationale goes like this: when an allocation is done with
FASTWRITE, it "reserves" the vdev until the data is written. Until then,
all future allocations will naturally avoid this vdev, even after a full
rotation of the rotor. As a result, pending synchronous writes at a
given point in time will be nicely spread over all vdevs. This contrasts
with the previous algorithm, which is based on the implicit assumption
that blocks are written instantaneously after they're allocated.

metaslab_fastwrite_mark() and metaslab_fastwrite_unmark() are used to
manually increase or decrease fastwrite counters, respectively. They
should be used with caution, as there is no per-BP tracking of fastwrite
information, so leaks and "double-unmarks" are possible. There is,
however, an assert in the vdev teardown code which will fire if the
fastwrite counters are not zero when the pool is exported or the vdev
removed. Note that as stated above, marking is also done implictly by
metaslab_alloc().

ZIO also got a new FASTWRITE flag; when it is used, ZIO will pass it to
the metaslab when allocating (assuming ZIO does the allocation, which is
only true in the case of dmu_sync). This flag will also trigger an
unmark when zio_done() fires.

A side-effect of the new algorithm is that when a ZIL stops being used,
its last block can stay in the pending state (allocated but not yet
written) for a long time, polluting the fastwrite counters. To avoid
that, I've implemented a somewhat crude but working solution which
unmarks these pending blocks in zil_sync(), thus guaranteeing that
linguering fastwrites will get pruned at each sync event.

The best performance improvements are observed with pools using a large
number of top-level vdevs and heavy synchronous write workflows
(especially indirect writes and concurrent writes from multiple ZILs).
Real-life testing shows a 200% to 300% performance increase with
indirect writes and various commit sizes.

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

11 years agoAdd atomic_sub_* functions to libspl.
Etienne Dechamps [Wed, 27 Jun 2012 08:26:49 +0000 (10:26 +0200)]
Add atomic_sub_* functions to libspl.

Both the SPL and the ZFS libspl export most of the atomic_* functions,
except atomic_sub_* functions which are only exported by the SPL, not by
libspl. This patch remedies that by implementing atomic_sub_* functions
in libspl.

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

11 years agoMerge branch 'condvar'
Brian Behlendorf [Wed, 17 Oct 2012 15:47:07 +0000 (08:47 -0700)]
Merge branch 'condvar'

Auditing the code to verify that all instances of cv_signal() and
cv_broadcast() are called under the proper associated mutex turned
up several races. None of these have been conclusively seen in the
wild but the following patch set resolves them.

For reference, from the cv_signal(9F) man page:

  cv_signal() signals the condition and wakes one blocked thread.
  All blocked threads can be unblocked by calling cv_broadcast().
  You must acquire the mutex passed into cv_wait() before calling
  cv_signal() or cv_broadcast()

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

11 years agoCondition variable usage, zp->r_{rd,wr}_cv
Brian Behlendorf [Mon, 15 Oct 2012 20:41:44 +0000 (13:41 -0700)]
Condition variable usage, zp->r_{rd,wr}_cv

The following incorrect usage of cv_broadcast() was caught by
code inspection.  The cv_broadcast() function must be called
under the associated mutex to preventing racing with cv_wait().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoCondition variable usage, zilog->zl_cv_batch
Brian Behlendorf [Mon, 15 Oct 2012 20:40:07 +0000 (13:40 -0700)]
Condition variable usage, zilog->zl_cv_batch

The following incorrect usage of cv_signal and cv_broadcast()
was caught by code inspection.  The cv_signal and cv_broadcast()
functions must be called under the associated mutex to preventing
racing with cv_wait().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoCondition variable usage, zevent_cv
Brian Behlendorf [Mon, 15 Oct 2012 20:36:26 +0000 (13:36 -0700)]
Condition variable usage, zevent_cv

The following incorrect usage of cv_broadcast() was caught by
code inspection.  The cv_broadcast() function must be called
under the associated mutex to preventing racing with cv_wait().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoDo not return /dev/loop-control in unused_loop_device
Andrew Reid [Sat, 13 Oct 2012 15:03:59 +0000 (12:03 -0300)]
Do not return /dev/loop-control in unused_loop_device

The function unused_loop_device in /usr/libexec/zfs/common.sh
returns /dev/loop-control on the first call. This device is NOT
a loop device (https://github.com/torvalds/linux/commit/770fe30)
it is a control device. This in turn causes the script zconfig.sh
to fail with:

  zpool-create.sh: Error 1 creating /tmp/zpool-vdev0 ->
  /dev/loop-control loopback

The patch makes the function return /dev/loop[0-9]* which are
loop devices.

Signed-off-by: Andrew Reid <ColdCanuck@nailedtotheperch.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #797

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Massimo Maggi [Thu, 11 Oct 2012 22:55:42 +0000 (00:55 +0200)]
Switch KM_SLEEP to KM_PUSHPAGE

In this particular instance the allocation occurred in the context
of sys_msync()->...->zpl_putpage() where we must be careful not to
initiate additional I/O.

Signed-off-by: Massimo Maggi <massimo@mmmm.it>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1038

11 years agoLimit zfs_vdev_aggregation_limit to SPA_MAXBLOCKSIZE
Brian Behlendorf [Mon, 15 Oct 2012 16:27:48 +0000 (09:27 -0700)]
Limit zfs_vdev_aggregation_limit to SPA_MAXBLOCKSIZE

Prevent users from setting the zfs_vdev_aggregation_limit tuning
larger than SPA_MAXBLOCKSIZE.

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

11 years agoReturn positive error number in zfsctl_shares_lookup.
Yuxuan Shui [Sun, 14 Oct 2012 09:01:26 +0000 (17:01 +0800)]
Return positive error number in zfsctl_shares_lookup.

Otherwise it will cause zpl_shares_lookup() to return a invalid
pointer when an error occurs.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Closes #626 #885 #947 #977

11 years agoDisable ztest deadman timer
Brian Behlendorf [Mon, 15 Oct 2012 02:21:49 +0000 (19:21 -0700)]
Disable ztest deadman timer

The ztest deadman timer has been causing false positives in the
testing VMs.  To make it easier to spot possible regressions
I'm disabling this timer.  The buildbot test infrastructure
will still mark ztest instances which take to long to complete
as failures.

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

11 years agoMerge branch 'linux-3.6'
Brian Behlendorf [Sun, 14 Oct 2012 23:27:22 +0000 (16:27 -0700)]
Merge branch 'linux-3.6'

This branch adds the required compatibility code to support the
Linux 3.6 kernel.

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

11 years agoLinux 3.6 compat, iops->mkdir()
Richard Yao [Thu, 16 Aug 2012 23:31:54 +0000 (19:31 -0400)]
Linux 3.6 compat, iops->mkdir()

Use .mkdir instead of .create in 3.3 compatibility check.  Linux 3.6
modifies inode_operations->create's function prototype. This causes
an autotools Linux 3.3. compatibility check for a function prototype
change in create, mkdir and mknode to fail. Since mkdir and mknode
are unchanged, we modify the check to examine it instead.

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

11 years agoLinux 3.6 compat, iops->create()
Yuxuan Shui [Fri, 12 Oct 2012 15:20:58 +0000 (23:20 +0800)]
Linux 3.6 compat, iops->create()

As of Linux commit ebfc3b49a7ac25920cb5be5445f602e51d2ea559 the
struct nameidata is no longer passed to iops->create.  Instead
only the result of (inamedata->flags & LOOKUP_EXCL) is passed.

ZFS like almost all Linux fileystems never made use of this so
only the prototype needs to be wrapped for compatibility.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #873

11 years agoLinux 3.6 compat, iops->lookup()
Yuxuan Shui [Fri, 12 Oct 2012 14:41:06 +0000 (22:41 +0800)]
Linux 3.6 compat, iops->lookup()

As of Linux commit 00cd8dd3bf95f2cc8435b4cac01d9995635c6d0b the
struct nameidata is no longer passed to iops->lookup.  Instead
only the inamedata->flags are passed.

ZFS like almost all Linux fileystems never made use of this so
only the prototype needs to be wrapped for compatibility.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #873

11 years agoLinux 3.6 compat, sget()
Yuxuan Shui [Fri, 12 Oct 2012 13:40:53 +0000 (21:40 +0800)]
Linux 3.6 compat, sget()

As of Linux commit 9249e17fe094d853d1ef7475dd559a2cc7e23d42 the
mount flags are now passed to sget() so they can be used when
initializing a new superblock.

ZFS never uses sget() in this fashion so we can simply pass a
zero and add a zpl_sget() compatibility wrapper.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #873

11 years agoLinux 3.6 compat, sops->write_super() removed
Yuxuan Shui [Sun, 14 Oct 2012 01:44:15 +0000 (18:44 -0700)]
Linux 3.6 compat, sops->write_super() removed

The .write_super callback was removed the the super_operations
structure by Linux commit f0cd2dbb6cf387c11f87265462e370bb5469299e.
All file systems are now expected to self manage writing any dirty
state assoicated with their super block.

ZFS never made use of this callback so it can simply be removed
from the super_operations structure.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #873

11 years agoDon't ashift-align vdev read requests.
Etienne Dechamps [Sun, 7 Oct 2012 19:30:23 +0000 (21:30 +0200)]
Don't ashift-align vdev read requests.

Currently, the size of read and write requests on vdevs is aligned
according to the vdev's ashift, allocating a new ZIO buffer and padding
if need be.

This makes sense for write requests to prevent read/modify/write if the
write happens to be smaller than the device's internal block size.

For reads however, the rationale is less clear. It seems that the
original code aligns reads because, on Solaris, device drivers will
outright refuse unaligned requests.

We don't have that issue on Linux. Indeed, Linux block devices are able
to accept requests of any size, and take care of alignment issues
themselves.

As a result, there's no point in enforcing alignment for read requests
on Linux. This is a nice optimization opportunity for two reasons:
- We remove a memory allocation in a heavily-used code path;
- The request gets aligned in the lowest layer possible, which shrinks
  the path that the additional, useless padding data has to travel.
  For example, when using 4k-sector drives that lie about their sector
  size, using 512b read requests instead of 4k means that there will
  be less data traveling down the ATA/SCSI interface, even though the
  drive actually reads 4k from the platter.

The only exception is raidz, because raidz needs to read the whole
allocated block for parity.

This patch removes alignment enforcement for read requests, except on
raidz. Note that we also remove an assertion that checks that we're
aligning a top-level vdev I/O, because that's not the case anymore for
repair writes that results from failed reads.

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

11 years agoRemove vmem_size() consumers
Richard Yao [Thu, 11 Oct 2012 22:51:25 +0000 (15:51 -0700)]
Remove vmem_size() consumers

There are currently three vmem_size() consumers all of which are
part of the ARC implemention.  However, since the expected behavior
of the Linux and Solaris virtual memory subsystems are so different
the behavior in each of these instances needs to be reevaluated.

* arc_evict_needed() - This is actually dead code.  Arena support
was never added to the SPL and zio_arena is always NULL.  This
support isn't needed so we simply remove this dead code.

* arc_memory_throttle() - On Solaris where virtual memory constitutes
almost all of the address space we can reasonably expect there to be
a fairly large amount free.  However, on Linux by default we only
have about 100MB total and that's heavily used by the ARC.  So the
expectation on Linux is that this will usually be a small value.
Therefore we remove the vmem_size() check for i386 systems because
the expectation is that it will be less than the zfs_write_limit_max.

* arc_init() - Here vmem_size() is used to initially size the ARC.
Since the ARC is currently backed by the virtual address space it
makes sense to use this as a limit on the ARC for 32-bit systems.
This code can be removed when the ARC is backed by the page cache.

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

11 years agoFix zfs_txg_timeout module parameter
Brian Behlendorf [Thu, 11 Oct 2012 20:56:32 +0000 (13:56 -0700)]
Fix zfs_txg_timeout module parameter

Allow the zfs_txg_timeout variable to be dynamically tuned at run
time.  By pulling it down out of the variable declaration it will
be evaluted each time through the loop.

The zfs_txg_timeout variable is now declared extern in a the common
sys/txg.h header rather than locally in dsl_scan.c.  This prevents
potential type mismatches if the global variable needs to be used
elsewhere.

Move the module_param() code in to the same source file where
zfs_txg_timeout is declared.  This is the most logical location.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix zfs_write_limit_max integer size mismatch on 32-bit systems
Richard Yao [Thu, 11 Oct 2012 03:57:45 +0000 (23:57 -0400)]
Fix zfs_write_limit_max integer size mismatch on 32-bit systems

Commit c409e4647f221ab724a0bd10c480ac95447203c3 introduced a
number of module parameters.  This required several types to be
changed to accomidate the required module parameters Linux macros.

Unfortunately, arc.c contained its own extern definition of the
zfs_write_limit_max variable and its type was not updated to be
consistent with its dsl_pool.c counterpart.  If the variable had
been properly marked extern in a common header, then gcc would
have generated a warning and this would not have slipped through.

The result of this was that the ARC unconditionally expected
zfs_write_limit_max to be 64-bit. Unfortunately, the largest size
integer module parameter that Linux supports is unsigned long, which
varies in size depending on the host system's native word size. The
effect was that on 32-bit systems, ARC incorrectly performed 64-bit
operations on a 32-bit value by reading the neighboring 32 bits as
the upper 32 bits of the 64-bit value.

We correct that by changing the extern declaration to use the unsigned
long type and move these extern definitions in to the common arc.h
header. This should make ARC correctly treat zfs_write_limit_max as a
32-bit value on 32-bit systems.

Reported-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #749

11 years agoMake zfs_immediate_write_sz a module paramater
Cyril Plisko [Mon, 8 Oct 2012 18:02:20 +0000 (20:02 +0200)]
Make zfs_immediate_write_sz a module paramater

zfs_immediate_write_sz variable is a tunable, but lacks proper
module_param() instrumentation.

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

11 years agotxg is spelled as tgx in places
Cyril Plisko [Tue, 9 Oct 2012 03:58:35 +0000 (05:58 +0200)]
txg is spelled as tgx in places

Term 'transaction group' is commonly abbreviated as txg in ZFS sources.
There are some places (Linux specific MODULE_PARAM_DESC() macros)
where it is incorrectly spelled as 'tgx'.

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

11 years agozfs.8: add missing info about dedup, mlslabel
KORN Andras [Tue, 9 Oct 2012 08:26:38 +0000 (10:26 +0200)]
zfs.8: add missing info about dedup, mlslabel

These sections were missing from the `zfs.8` man page.  Add them.

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Massimo Maggi [Sun, 7 Oct 2012 19:54:06 +0000 (21:54 +0200)]
Switch KM_SLEEP to KM_PUSHPAGE

Prevent snapshot_check to initiate I/O during memory allocation.

Signed-off-by: Massimo Maggi <massimo@mmmm.it>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1023

11 years agoSet default zvol elevator to noop
Brian Behlendorf [Fri, 5 Oct 2012 17:39:35 +0000 (10:39 -0700)]
Set default zvol elevator to noop

It doesn't make sense for a zvol to use the default system I/O
scheduler because it is a virtual device.  Therefore, we change
the default scheduler to 'noop' for zvols provided that the
elevator_change() function is available.  This interface has
been available since Linux 2.6.36 and appears in the RHEL 6.x
kernels.

We deliberately do not implement the method for older kernels
because it was racy and could result in system crashes.  It's
better to simply manually tune the scheduler for these kernels.

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

11 years agoAlign DISCARD requests on zvols.
Etienne Dechamps [Thu, 4 Oct 2012 08:38:55 +0000 (10:38 +0200)]
Align DISCARD requests on zvols.

Currently, when processing DISCARD requests, zvol_discard() calls
dmu_free_long_range() with the precise offset and size of the request.

Unfortunately, this is not optimal for requests that are not aligned to
the zvol block boundaries. Indeed, in the case of an unaligned range,
dnode_free_range() will zero out the unaligned parts. Not only is this
useless since we are not freeing any space by doing so, it is also slow
because it translates to a read-modify-write operation.

This patch fixes the issue by rounding up the discard start offset to
the next volume block boundary, and rounding down the discard end
offset to the previous volume block boundary.

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

11 years agoMerge branch 'illumos-ztest'
Brian Behlendorf [Thu, 4 Oct 2012 21:37:53 +0000 (14:37 -0700)]
Merge branch 'illumos-ztest'

This branch is a port of the ztest backwards compatibility
testing option.  It includes the original upstream Illumos
patch plus several followup patches to address concerns in
the original change.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRealpath arg 2 must be a minimum of PATH_MAX
Brian Behlendorf [Thu, 4 Oct 2012 19:54:47 +0000 (12:54 -0700)]
Realpath arg 2 must be a minimum of PATH_MAX

The realpath(3) function expects that when a buffer is passed
for the 'resolved_path' that it be at least PATH_MAX in length.
If it's not a buffer overflow may occur.

Therefore the passed buffer size is changed from MAXNAMELEN to
MAXPATHLEN.  We also take this opertunity to dynamically allocate
the buffer to keep it off the stack.

  warning: call to '__realpath_chk_warn' declared with attribute
  warning: second argument of realpath must be either NULL or at
  least PATH_MAX bytes long buffer [enabled by default]

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoVerify the return value for warn_unused_result functions
Brian Behlendorf [Thu, 4 Oct 2012 19:30:16 +0000 (12:30 -0700)]
Verify the return value for warn_unused_result functions

Under Linux the following functions are flagged with the
attribute warn_unused_result, this triggers a warning when
ever they are used without checking the return value.

To handle this case we check the result VERIFY().  It's
better to detect this immediately on failure rather than
segfault farther down in the function.

  ../../cmd/ztest/ztest.c:6033:2: warning:
  ignoring return value of 'asprintf', declared with
  attribute warn_unused_result [-Wunused-result]
  ../../cmd/ztest/ztest.c:739:3: warning:
  ignoring return value of 'realpath', declared with
  attribute warn_unused_result [-Wunused-result]

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoReplace tempnam() with mkstemp()
Brian Behlendorf [Thu, 4 Oct 2012 18:36:52 +0000 (11:36 -0700)]
Replace tempnam() with mkstemp()

The use of tempnam() is racy and it should be avoided in favor of
mkstemp().  According to the Linux tempnam(3) man page.

  "Although tempnam() generates names that are difficult to guess,
  it is nevertheless possible that between the time that tempnam()
  returns a pathname, and the time that the program opens it, another
  program might create that pathname using open(2), or create it as
  a symbolic link.  This can lead to security holes.  To avoid such
  possibilities, use the open(2) O_EXCL flag to open the  pathname.
  Or better yet, use mkstemp(3) or tmpfile(3)."

This issue was flagged by gcc.

  ztest.o: In function `setup_data_fd': cmd/ztest/ztest.c:5822:
  warning: the use of `tempnam' is dangerous, better use `mkstemp'

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoMinimize ztest stack frame size
Brian Behlendorf [Thu, 4 Oct 2012 18:14:04 +0000 (11:14 -0700)]
Minimize ztest stack frame size

To ensure ztest behaves as similarly as possible to the kernel
implementation of ZFS we attempt to honor the kernel stack limits.
This includes keeping the individual stack frame sizes under 1K
in size.  We currently use gcc to detect and enforce this limit.

Therefore to get this building cleanly with full debugging enabled
the stack usage in the following functions has been reduced by
moving the buffer to the heap.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoUse dynamic file descriptor numbers in ztest.
Etienne Dechamps [Thu, 4 Oct 2012 14:09:12 +0000 (16:09 +0200)]
Use dynamic file descriptor numbers in ztest.

Currently, ztest expects to get 3 and 4 as the file descriptors for
data and random files, respectively. This is quite fragile and breaks
easily if ztest is run with these file descriptors already opened
(e.g. in a complex shell script).

This patch fixes the issue by removing the assumptions on the file
descriptor numbers that open() returns.

For the random file (/dev/urandom), the new code doesn't rely on a
shared file descriptor; instead, it reopens the file in the child.

For the data file, the new code writes the file descriptor number into
a "ZTEST_FD_DATA" environment variable so that it can be recovered
after the execv() call.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoFix mmap() usage in ztest.
Christopher Siden [Mon, 21 May 2012 19:11:39 +0000 (12:11 -0700)]
Fix mmap() usage in ztest.

illumos/illumos-gate@ad135b5d644628e791c3188a6ecbd9c257961ef8
Illumos changeset: 13700:2889e2596bd6

Note that this is only a partial port of the aforementioned Illumos
changeset.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <gwilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>
Approved by: Eric Schrock <Eric.Schrock@delphix.com>

Ported to zfsonlinux by: Etienne Dechamps <etienne.dechamps@ovh.net>

11 years agoIllumos #1950: ztest backwards compatibility testing option.
Chris Siden [Tue, 24 Jan 2012 02:43:32 +0000 (18:43 -0800)]
Illumos #1950: ztest backwards compatibility testing option.

illumos/illumos-gate@420dfc9585ff67e83ee7800a7ad2ebe1a9145983
Illumos changeset: 13571:a5771a96228c

1950 ztest backwards compatibility testing option

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Eric Schrock <eric.schrock@delphix.com>

Ported-by: Etienne Dechamps <etienne.dechamps@ovh.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Chris Dunlop [Thu, 4 Oct 2012 06:19:17 +0000 (16:19 +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 b8d06fc 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>
Closes #1002

11 years agoIllumos #3100: zvol rename fails with EBUSY when dirty.
Matthew Ahrens [Fri, 24 Aug 2012 14:12:46 +0000 (07:12 -0700)]
Illumos #3100: zvol rename fails with EBUSY when dirty.

illumos/illumos-gate@2e2c135528b3edfe9aaf67d1f004dc0202fa1a54
Illumos changeset: 13780:6da32a929222

3100 zvol rename fails with EBUSY when dirty

Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: Adam H. Leventhal <ahl@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Eric Schrock <eric.schrock@delphix.com>

Ported-by: Etienne Dechamps <etienne.dechamps@ovh.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #995

11 years agoIllumos #2399: zfs manual page does not document use of "zfs diff".
Richard Lowe [Thu, 16 Aug 2012 17:08:53 +0000 (13:08 -0400)]
Illumos #2399: zfs manual page does not document use of "zfs diff".

illumos/illumos-gate@3b8be6bf4fd2c744dfb8b5ce2a6c85ad0a2c8f75
Illumos changeset: 13773:00c2a08cf1bb

2399 zfs manual page does not document use of "zfs diff"

Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Approved by: Robert Mustacchi <rm@joyent.com>

Ported-by: Etienne Dechamps <etienne.dechamps@ovh.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #940

11 years agoIllumos #3129, #3130
George Wilson [Sat, 1 Sep 2012 20:44:00 +0000 (16:44 -0400)]
Illumos #3129, #3130

illumos/illumos-gate@d6afdce20f8481c95471dd821bc8ec0dbde66213
Illumos changeset: 13794:7c5e0e746b2c

3129 'zpool reopen' restarts resilvers
3130 ztest failure: Assertion failed:
     0 == dmu_objset_destroy(name, B_FALSE) (0x0 == 0x10)

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

References:
  https://www.illumos.org/issues/3129
  https://www.illumos.org/issues/3130

Ported by: Etienne Dechamps <etienne.dechamps@ovh.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #994

11 years agoTemporarily disable the reguid test.
Etienne Dechamps [Fri, 28 Sep 2012 13:55:03 +0000 (15:55 +0200)]
Temporarily disable the reguid test.

Currently, ztest fails with the following error:

    error: Pool 'ztest' has encountered an uncorrectable I/O failure
    and the failure mode property for this pool is set to panic.

We know how to fix it (see issue #939), but it may take some time
before we get around to merging the fix, which has some heavy
dependencies.

In the mean time, it is not ideal to be unable to use ztest just
because of a small isolated issue, so this patch works around the
problem by disabling the reguid test. This is just a temporary hack to
keep ztest usable.

The reguid test will be enabled again when the proper fix is merged.

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

11 years agoFix ztest vdev file paths.
Etienne Dechamps [Mon, 1 Oct 2012 14:34:52 +0000 (16:34 +0200)]
Fix ztest vdev file paths.

Currently, in several instances (but not all), ztest generates vdev
file paths using a statement similar to this:

    snprintf(path, sizeof (path), ztest_dev_template, ...);

This worked fine until 40b84e7aec6392187722e61e5a4a853b530bf60f, which
changed path to be a pointer to the heap instead of an array allocated
on the stack. Before this change, sizeof(path) would return the size of
the array; now, it returns the size of the pointer instead.

As a result, the aforementioned sprintf statement uses the wrong size
and truncates the vdev file path to the first 4 or 8 bytes (depending
on the architecture). Typically, with default settings, the file path
will become "/tmp/zt" instead of "/test/ztest.XXX".

This issue only exists in ztest_vdev_attach_detach() and
ztest_fault_inject(), which explains why ztest doesn't fail right away.

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

11 years agoFix VOP_CLOSE() in userspace.
Etienne Dechamps [Thu, 27 Sep 2012 14:05:15 +0000 (16:05 +0200)]
Fix VOP_CLOSE() in userspace.

Currently, for unknown reasons, VOP_CLOSE() is a no-op in userspace.
This causes file descriptor leaks. This is especially problematic with
long ztest runs, since zpool.cache is opened repeatedly and never
closed, resulting in resource exhaustion (EMFILE errors).

This patch fixes the issue by making VOP_CLOSE() do what it is supposed
to do.

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

11 years agoCreate threads in detached state in userspace.
Etienne Dechamps [Thu, 27 Sep 2012 11:31:46 +0000 (13:31 +0200)]
Create threads in detached state in userspace.

Currently, thread_create(), when called in userspace, creates a
joinable (i.e. not detached thread). This is the pthread default.

Unfortunately, this does not reproduce kthreads behavior (kthreads
are always detached). In addition, this contradicts the original
Solaris code which creates userspace threads in detached mode.

These joinable threads are never joined, which leads to a leakage of
pthread thread objects ("zombie threads"). This in turn results in
excessive ressource consumption, and possible ressource exhaustion in
extreme cases (e.g. long ztest runs).

This patch fixes the issue by creating userspace threads in detached
mode. The only exception is ztest worker threads which are meant to be
joinable.

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

11 years agoModify vdev_elevator_switch() to use elevator_change()
Brian Behlendorf [Sun, 26 Aug 2012 20:38:06 +0000 (03:38 +0700)]
Modify vdev_elevator_switch() to use elevator_change()

As of Linux 2.6.36 an elevator_change() interface was added.
This commit updates vdev_elevator_switch() to use this interface
when available, otherwise it falls back to the usermodehelper
method.

Original-patch-by: foobarz <sysop@xeon.(none)>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #906

11 years agoForce 4K blocksize when testing ext2 on zvol.
Etienne Dechamps [Thu, 20 Sep 2012 10:00:50 +0000 (12:00 +0200)]
Force 4K blocksize when testing ext2 on zvol.

Currently, mkfs.ext2 on zconfig.sh zvols tries to use a 8K blocksize,
probably because by default zvol exposes an optimal I/O size of 8K.

Unfortunately, a ext2 blocksize of 8K is not supported by the kernel,
so the resulting filesystem is unmountable.

This patch fixes the issue by making sure the blocksize is 4K. We have
to use -F to force it else mkfs.ext2 won't allow us to use a blocksize
smaller than the optimal I/O size.

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

11 years agoImplement .commit_metadata hook for NFS export
Cyril Plisko [Sun, 16 Sep 2012 06:03:04 +0000 (09:03 +0300)]
Implement .commit_metadata hook for NFS export

In order to implement synchronous NFS metadata semantics ZFS
needs to provide the .commit_metadata hook.  All it takes there
is to make sure changes are committed to ZIL.  Fortunately
zfs_fsync() does just that, so simply calling it from
zpl_commit_metadata() does the trick.

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

11 years agozvol_probe should return NULL when the device isn't found.
Chris Wedgwood [Mon, 24 Sep 2012 17:30:18 +0000 (10:30 -0700)]
zvol_probe should return NULL when the device isn't found.

Previously we returned ERR_PTR(-ENOENT) which the rest of the kernel
doesn't expect and as such we can oops.

Signed-off-by: Chris Wedgwood <cw@f00f.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #949
Closes #931
Closes #789
Closes #743
Closes #730

11 years agoIllumos #2703: add mechanism to report ZFS send progress
Bill Pijewski [Wed, 9 May 2012 22:05:14 +0000 (15:05 -0700)]
Illumos #2703: add mechanism to report ZFS send progress

Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Eric Schrock <Eric.Schrock@delphix.com>

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

Ported by: Martin Matuska <martin@matuska.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #1948: zpool list should show more detailed pool info
Chris Siden [Tue, 24 Jan 2012 02:43:32 +0000 (18:43 -0800)]
Illumos #1948: zpool list should show more detailed pool info

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Eric Schrock <eric.schrock@delphix.com>

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

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Brian Behlendorf [Wed, 19 Sep 2012 18:50:22 +0000 (11:50 -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 #973

11 years agoSeg fault 'zpool import -d /dev/disk/by-id -a'
Brian Behlendorf [Tue, 18 Sep 2012 19:33:00 +0000 (12:33 -0700)]
Seg fault 'zpool import -d /dev/disk/by-id -a'

Introduced by commit 44867b6d6effc1628dd00c36821ab044f89fb988.
We should of course check to ensure best isn't NULL before
attempting to dereference it.

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

11 years agozfs-0.6.0-rc11
Brian Behlendorf [Tue, 18 Sep 2012 18:30:24 +0000 (11:30 -0700)]
zfs-0.6.0-rc11

11 years agoIllumos #2088 zdb could use a reasonable manual page
Richard Lowe [Sat, 4 Feb 2012 05:44:53 +0000 (05:44 +0000)]
Illumos #2088 zdb could use a reasonable manual page

Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: George Wilson <gwilson@zfsmail.com>
Reviewed by: Steve Gonczi <gonczi@comcast.net>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Approved by: Garrett D'Amore <garrett@damore.org>

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

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

11 years agoImprove `zpool import` search behavior
Brian Behlendorf [Sat, 15 Sep 2012 20:25:21 +0000 (13:25 -0700)]
Improve `zpool import` search behavior

The goal of this change is to make 'zpool import' prefer to use
the peristent /dev/mapper or /dev/disk/by-* paths.  These are far
preferable to the devices in /dev/ whos names are not persistent
and are determined by the order in which a device is detected.

This patch improves things by changing the default search path from
just to the top level /dev/ directory to (in order):

  /dev/disk/by-vdev   - Custom rules, use first if they exist
  /dev/disk/zpool     - Custom rules, use first if they exist
  /dev/mapper         - Use multipath devices before components
  /dev/disk/by-uuid   - Single unique entry and persistent
  /dev/disk/by-id     - May be multiple entries and persistent
  /dev/disk/by-path   - Encodes physical location and persistent
  /dev/disk/by-label  - Custom persistent labels
  /dev                - UNSAFE device names will change

The default search path can be overriden by setting the
ZPOOL_IMPORT_PATH environment variable.  This must be a colon
delimited list of paths which are searched for vdevs.  If the
'zpool import -d' option is specified only those listed paths
will be searched.

Finally, when multiple paths to the same device are found.  If one
of the paths is an exact match for the path used last time to import
the pool it will be used.  When there are no exact matches the
prefered path will be determined by the provided search order.

This means you can still import a pool and force specific names by
providing the -d <path> option.  And the prefered names will persist
as long as those paths exist on your system.

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Brian Behlendorf [Mon, 17 Sep 2012 18:22:23 +0000 (11:22 -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 agoZFS replay transaction error 5
Cyril Plisko [Thu, 13 Sep 2012 20:25:15 +0000 (23:25 +0300)]
ZFS replay transaction error 5

When zfs_replay_write() replays TX_WRITE records from ZIL
it calls zpl_write_common() to perform the actual write.
zpl_write_common() returns the number of bytes written
(similar to write() system call) or an (negative) error.
However, the code expects the positive return value to be
a residual counter. Thus when zpl_write_common() successfully
completes it is mistakenly considered to be a partial write and
the error code delivered further. At this point the ZIL processing
is aborted with famous "ZFS replay transaction error 5" error
message given to the message buffer.

The fix is to compare the zpl_write_commmon() return value with
the buffer size and flag error only when they disagree.

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

11 years agoClear PG_writeback for sync I/O error case
Brian Behlendorf [Fri, 14 Sep 2012 16:36:40 +0000 (09:36 -0700)]
Clear PG_writeback for sync I/O error case

Commit 2b2861362f7dd09cc3167df8fddb6e2cb475018a accidentally
introduced this issue by only conditionally registering the
commit callback in the async case.

The error handing code for the dmu_tx_assign() failure case
relied on there always being a registered commit callback to
clear the PG_writeback bit.  Since that is no longer strictly
true for the synchronous case we must explicitly invoke the
callback.

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

11 years agoFix zdb printf format string for ZIL data blocks
Cyril Plisko [Wed, 12 Sep 2012 09:15:40 +0000 (12:15 +0300)]
Fix zdb printf format string for ZIL data blocks

Without this fix the zdb printouts of ZIL data blocks look full of FF
due to printf() handling its arguments as int by default.

Here is the output before the fix

                TX_WRITE            len   4136, txg 1093817, seq 149231
                        foid 4242, offset 0, length f68
                        G FFFFFF8EFFFFFF87FFFFFF91FFFFFFCC 1c
FFFFFFAFFFFFFFC9FFFFFFBAZ FFFFFFC3

And the same after the fix

                TX_WRITE            len   4136, txg 1093817, seq 149231
                        foid 4242, offset 0, length f68
                        G 8E8791CC 1cAFC9BAZ C3

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

11 years agoMove iput() after zfs_inode_update()
Brian Behlendorf [Wed, 12 Sep 2012 18:16:08 +0000 (11:16 -0700)]
Move iput() after zfs_inode_update()

When replaying an unlink/remove operation via zfs_rmdir() the object
being removed will be instantiated by a call to zfs_dirent_lock().
This means that there is a single reference protecting the object.
Right before the call to zfs_inode_update() this reference is dropped
which may cause the object to be destroyed.  This will result in a
NULL dereference as shown by the stack trace is issue #782.

This likely isn't an issue during normal operation because there is
always an additional reference held on the object by the VFS.

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

11 years agoRevert "Improve AF hard disk detection"
Brian Behlendorf [Tue, 11 Sep 2012 18:26:25 +0000 (11:26 -0700)]
Revert "Improve AF hard disk detection"

This reverts commit 395350c85d9903beba43bac7ae79092ae25f1526 which
accidentally introduced issue #955.

Pools using AF drives which were originally created with a sector
size of 512 bytes will now be correctly detected to have physical
sector size of 4096.  This is desirable for a new pool, however for
an existing pool abruptly changing the sector size causes problems.

For this reason, this change is being reverted until the additional
logic can be added to detect the existing pool case.  Existing
pools must use the ashift size stored in the label regardless of
what the disk reports.  This is critical for compatibility.

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

11 years agoAvoid running exportfs on each zfs/zpool command invocation
Cyril Plisko [Wed, 5 Sep 2012 16:44:53 +0000 (19:44 +0300)]
Avoid running exportfs on each zfs/zpool command invocation

Delay executing exportfs command until its results are actually
required.

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
Signed-off-by: Gunnar Beutner <gunnar@beutner.name>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoIllumos #3064: usr/src/cmd/zpool/zpool_main.c misspells "successful"
Cyril Plisko [Wed, 8 Aug 2012 06:59:53 +0000 (09:59 +0300)]
Illumos #3064: usr/src/cmd/zpool/zpool_main.c misspells "successful"

Reviewed by: Andrew Stormont <Andrew.Stormont@nexenta.com>
Reviewed by: Kartik Mistry <kartik.mistry@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

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

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoRemove autotools products
Chris Dunlop [Tue, 11 Sep 2012 17:14:26 +0000 (10:14 -0700)]
Remove autotools products

spl_config.h.in is a generated file: remove and .gitignore it

Signed-off-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoSilence "setting dataset to sync always" message in ztest.
Etienne Dechamps [Mon, 10 Sep 2012 14:23:21 +0000 (16:23 +0200)]
Silence "setting dataset to sync always" message in ztest.

ztest outputs a message when testing sync=always no matter what the
verbosity level is. There is no point outputting this message for low
verbosity levels.

With this patch the message is only displayed at verbosity level 5 or
above. The result is less output pollution.

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

11 years agoRemove zvol device node
Brian Behlendorf [Fri, 7 Sep 2012 23:04:22 +0000 (16:04 -0700)]
Remove zvol device node

The 'zfs destroy' changes in 330d06f disrupted how zvol devices
get removed on ZoL.  However, it basically boils down to the
fact that we are no longer reliably calling zvol_remove_minor()
via zfs_ioc_destroy_snaps().

Therefore we add the missing call and handle things similarly
to the existing zfs_unmount_snap() case.  Ideally we would check
if this is of type DMU_OST_ZFS or DMU_OST_ZVOL and just do the
right thing as in zfs_ioc_destroy().  However, it looks like
it would be fairly expensive to get the type, and it's harmless
to simply attempt the umount and minor removal.

This is also an issue in the latest FreeBSD and Illumos code.
It was being tracked under the following issue, and we may want
to refresh our code when they settle on what they want to do
about it upstream.

  https://www.illumos.org/issues/3170

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

11 years agoAdd zstreamdump .gitignore
Brian Behlendorf [Thu, 6 Sep 2012 21:21:59 +0000 (14:21 -0700)]
Add zstreamdump .gitignore

When zstreamdump was merged in commit b79fc3f we failed to add
the needed .gitignore file.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
11 years agoMake ZFS filesystem id persistent across different machines
Cyril Plisko [Fri, 24 Aug 2012 12:38:55 +0000 (15:38 +0300)]
Make ZFS filesystem id persistent across different machines

Use ZFS dataset fsid guid as a unique file system id, similar to what is
done on Illumos/OpenSolaris.

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

11 years agoIncrease the stack space in userspace.
Etienne Dechamps [Thu, 6 Sep 2012 09:06:05 +0000 (11:06 +0200)]
Increase the stack space in userspace.

In 1e33ac1e2677c898a0b5ef6207048c692cb51bf4, the maximum stack size for
userspace tools was set to 8k to mimic the available kernel stack size.

Unfortunately, due to differences in how the stack is used in userspace
vs kernel space, spurious stack overflows could occur in userspace
tools due to the limited stack size. This is especially true in ztest
when debugging is enabled.

This patch multiplies the userspace stack size by 4, which fixes the
stack overflow issues. This comes at the price of not being able to
catch stack size issues in userspace, but the previous solution proved
unreliable anyway.

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

11 years agoDisable page allocation warnings for ARC buffers
Brian Behlendorf [Wed, 5 Sep 2012 02:00:59 +0000 (19:00 -0700)]
Disable page allocation warnings for ARC buffers

Buffers for the ARC are normally backed by the SPL virtual slab.
However, if memory is low, AND no slab objects are available,
AND a new slab cannot be quickly constructed a new emergency
object will be directly allocated.

These objects can be as large as order 5 on a system with 4k
pages.  And because they are allocated with KM_PUSHPAGE, to
avoid a potential deadlock, they are not allowed to initiate I/O
to satisfy the allocation.  This can result in the occasional
allocation failure.

However, since these allocations are allowed to block and
perform operations such as memory compaction they will eventually
succeed.  Since this is not unexpected (just unlikely) behavior
this patch disables the warning for the allocation failure.

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

11 years agoFix missing vdev names in zpool status output
Michael Martin [Wed, 5 Sep 2012 16:46:29 +0000 (09:46 -0700)]
Fix missing vdev names in zpool status output

Commit 858219c makes more sense down below in the 'if (verbose)'
section of the code.  Initially, buf and path will never point
to the same location.  Once 'path = buf' is set on a raidz vdev,
the code may drop into the verbose section depending on the
verbose flag.  In here, using a tmpbuf makes sense since now
'buf == path'.

This issue does not occur in the upstream Solaris code because
their implementations of snprintf() allow for buf and path to
be the same address.

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

11 years agoSwitch KM_SLEEP to KM_PUSHPAGE
Brian Behlendorf [Wed, 5 Sep 2012 02:54:20 +0000 (19:54 -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 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