]> git.proxmox.com Git - mirror_zfs.git/log
mirror_zfs.git
8 years agoIllumos 5141 - zfs minimum indirect block size is 4K
Matthew Ahrens [Sat, 9 Jan 2016 18:33:11 +0000 (19:33 +0100)]
Illumos 5141 - zfs minimum indirect block size is 4K

5141 zfs minimum indirect block size is 4K
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Elling <richard.elling@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/5141
  https://github.com/illumos/illumos-gate/commit/e94f268

Porting notes:
- GRUB  --  GRand Unified Bootloader change wasn't merged (not applicable)

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 5438 - zfs_blkptr_verify should continue after zfs_panic_recover
Justin Gibbs [Sat, 9 Jan 2016 17:29:05 +0000 (18:29 +0100)]
Illumos 5438 - zfs_blkptr_verify should continue after zfs_panic_recover

5438 zfs_blkptr_verify should continue after zfs_panic_recover
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Xin LI <delphij@freebsd.org>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/5438
  https://github.com/illumos/illumos-gate/commit/5897eb4

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 5515 - dataset user hold doesn't reject empty tags
Josef 'Jeff' Sipek [Sat, 9 Jan 2016 17:37:15 +0000 (18:37 +0100)]
Illumos 5515 - dataset user hold doesn't reject empty tags

5515 dataset user hold doesn't reject empty tags
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>

References:
  https://www.illumos.org/issues/5515
  https://github.com/illumos/illumos-gate/commit/752fd8d

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6281 - prefetching should apply to 1MB reads
George Wilson [Sat, 9 Jan 2016 16:19:10 +0000 (17:19 +0100)]
Illumos 6281 - prefetching should apply to 1MB reads

6281 prefetching should apply to 1MB reads
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Alexander Motin <mav@freebsd.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Justin Gibbs <gibbs@scsiguy.com>
Reviewed by: Xin Li <delphij@freebsd.org>
Approved by: Gordon Ross <gordon.ross@nexenta.com>

References:
  https://www.illumos.org/issues/6281
  https://github.com/illumos/illumos-gate/commit/6328027

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6358 - A faulted pool with only unavailable vdevs
Dan Vatca [Sat, 9 Jan 2016 17:42:21 +0000 (18:42 +0100)]
Illumos 6358 - A faulted pool with only unavailable vdevs

6358 A faulted pool with only unavailable vdevs triggers assertion
failure in libzfs
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Reviewed by: Serban Maduta <serban.maduta@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://illumos.org/issues/6358
  https://github.com/illumos/illumos-gate/commit/b289d04

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6367 - spa_config_tryenter incorrectly handles the multiple-lock case
Saso Kiselkov [Wed, 23 Dec 2015 20:02:43 +0000 (21:02 +0100)]
Illumos 6367 - spa_config_tryenter incorrectly handles the multiple-lock case

6367 spa_config_tryenter incorrectly handles the multiple-lock case
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Prashanth Sreenivasa <prashksp@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Approved by: Matthew Ahrens <mahrens@delphix.com>

References:
  https://www.illumos.org/issues/6367
  https://github.com/illumos/illumos-gate/commit/e495b6e

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6295 - metaslab_condense's dbgmsg should include vdev id
Joe Stein [Wed, 23 Dec 2015 19:51:02 +0000 (20:51 +0100)]
Illumos 6295 - metaslab_condense's dbgmsg should include vdev id

6295 metaslab_condense's dbgmsg should include vdev id
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andriy Gapon <avg@freebsd.org>
Reviewed by: Xin Li <delphij@freebsd.org>
Reviewed by: Justin Gibbs <gibbs@scsiguy.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/6295
  https://github.com/illumos/illumos-gate/commit/daec38e

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6268 - zfs diff confused by moving a file to another directory
Joshua M. Clulow [Thu, 12 Nov 2015 02:33:52 +0000 (03:33 +0100)]
Illumos 6268 - zfs diff confused by moving a file to another directory

6268 zfs diff confused by moving a file to another directory
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Justin Gibbs <gibbs@scsiguy.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/6268
  https://github.com/illumos/illumos-gate/commit/aab0441

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6171 - dsl_prop_unregister() slows down dataset eviction.
Justin T. Gibbs [Wed, 4 Nov 2015 23:00:58 +0000 (00:00 +0100)]
Illumos 6171 - dsl_prop_unregister() slows down dataset eviction.

6171 dsl_prop_unregister() slows down dataset eviction.
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/6171
  https://github.com/illumos/illumos-gate/commit/03bad06

Porting notes:
  - Conflicts
    - 3558fd7 Prototype/structure update for Linux
    - 2cf7f52 Linux compat 2.6.39: mount_nodev()
    - 13fe019 Illumos #3464
    - 241b541 Illumos 5959 - clean up per-dataset feature count code
  - dsl_prop_unregister() preserved until out of tree consumers
    like Lustre can transition to dsl_prop_unregister_all().
  - Fixing 'space or tab at end of line' in include/sys/dsl_dataset.h

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6288 - dmu_buf_will_dirty could be faster
Matthew Ahrens [Wed, 4 Nov 2015 20:37:33 +0000 (21:37 +0100)]
Illumos 6288 - dmu_buf_will_dirty could be faster

6288 dmu_buf_will_dirty could be faster
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Justin Gibbs <gibbs@scsiguy.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Robert Mustacchi <rm@joyent.com>

References:
  https://www.illumos.org/issues/6288
  https://github.com/illumos/illumos-gate/commit/0f2e7d0

Porting notes:
- [module/zfs/dbuf.c]
  - Fix 'warning: ISO C90 forbids mixed declarations and code'
    by moving 'dbuf_dirty_record_t *dr' to start of code block.

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6292 - exporting a pool while an async destroy
George Wilson [Wed, 4 Nov 2015 20:12:40 +0000 (21:12 +0100)]
Illumos 6292 - exporting a pool while an async destroy

6292 exporting a pool while an async destroy is running can leave
entries in the deferred tree
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: Fabian Keil <fk@fabiankeil.de>
Approved by: Gordon Ross <gordon.ross@nexenta.com>

References:
  https://www.illumos.org/issues/6292
  https://github.com/illumos/illumos-gate/commit/a443cc8

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6319 - assertion failed in zio_ddt_write: bp->blk_birth == txg
Matthew Ahrens [Wed, 4 Nov 2015 20:19:17 +0000 (21:19 +0100)]
Illumos 6319 - assertion failed in zio_ddt_write: bp->blk_birth == txg

6319 assertion failed in zio_ddt_write: bp->blk_birth == txg
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/6319
  https://github.com/illumos/illumos-gate/commit/b39b744

Porting notes:
- Re-enabled ztest for CentOS test slaves.

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3449

8 years agoIllumos 5987 - zfs prefetch code needs work
Matthew Ahrens [Sat, 26 Dec 2015 21:10:31 +0000 (22:10 +0100)]
Illumos 5987 - zfs prefetch code needs work

5987 zfs prefetch code needs work
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>

References:
  https://www.illumos.org/issues/5987 zfs prefetch code needs work
  illumos/illumos-gate@cf6106c 5987 zfs prefetch code needs work

Porting notes:
- [module/zfs/dbuf.c]
  - 5f6d0b6 Handle block pointers with a corrupt logical size
- [module/zfs/dmu_zfetch.c]
  - c65aa5b Fix gcc missing parenthesis warnings
  - 428870f Update core ZFS code from build 121 to build 141.
  - 79c76d5 Change KM_PUSHPAGE -> KM_SLEEP
  - b8d06fc Switch KM_SLEEP to KM_PUSHPAGE
  - Account for ISO C90 - mixed declarations and code - warnings
  - Module parameters (new/changed):
    - Replaced zfetch_block_cap with zfetch_max_distance
      (Max bytes to prefetch per stream (default 8MB; 8 * 1024 * 1024))
    - Preserved zfs_prefetch_disable as 'int' for consistency with
      existing Linux module options.
- [include/sys/trace_arc.h]
  - Added new tracepoints
    - DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__sync__wait__for__async);
    - DEFINE_ARC_BUF_HDR_EVENT(zfs_arc__demand__hit__predictive__prefetch);
- [man/man5/zfs-module-parameters.5]
  - Updated man page

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 6293 - ztest failure: error == 28 (0xc == 0x1c) in ztest_tx_assign()
Brian Behlendorf [Mon, 11 Jan 2016 21:52:17 +0000 (13:52 -0800)]
Illumos 6293 - ztest failure: error == 28 (0xc == 0x1c) in ztest_tx_assign()

6293 ztest failure: error == 28 (0xc == 0x1c) in ztest_tx_assign()
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/6293
  https://github.com/illumos/illumos-gate/commit/8fe00bf

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 5039 - ztest should default to larger device sizes
Brian Behlendorf [Mon, 11 Jan 2016 21:23:04 +0000 (13:23 -0800)]
Illumos 5039 - ztest should default to larger device sizes

5039 ztest should default to larger device sizes
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Max Grossman <max.grossman@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/5039
  https://github.com/illumos/illumos-gate/commit/539eed8

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoRevert "Illumos 3749 - zfs event processing should work on R/O root filesystems"
Brian Behlendorf [Mon, 11 Jan 2016 21:46:29 +0000 (13:46 -0800)]
Revert "Illumos 3749 - zfs event processing should work on R/O root filesystems"

This reverts commit b47637ecdc7b647ec5bd9dfca888179eecfaa72d which
introduced a regression in ztest.

$ ./cmd/ztest/ztest -V
5 vdevs, 7 datasets, 23 threads, 300 seconds...
*** Error in `/rpool/home/behlendo/src/git/zfs/cmd/ztest/.libs/lt-ztest':
double free or corruption (fasttop): 0x0000000000d339f0 ***

8 years agoFix vn_rdwr() compiler warning
Brian Behlendorf [Mon, 11 Jan 2016 22:09:00 +0000 (14:09 -0800)]
Fix vn_rdwr() compiler warning

kernel.c: In function 'vn_rdwr':
kernel.c:736:8: warning: unused variable 'status' [-Wunused-variable]

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoFix 'prevsnap property' build failure
Brian Behlendorf [Mon, 11 Jan 2016 21:33:28 +0000 (13:33 -0800)]
Fix 'prevsnap property' build failure

Fix build failure accidentally introduced by 1715493.  This only
results in a failure when debugging is disabled.

dsl_dataset.c: In function 'dsl_dataset_stats':
dsl_dataset.c:1698:45: error: 'dp' undeclared (first use in this function)

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 4929 - want prevsnap property
Matthew Ahrens [Fri, 1 Jan 2016 13:15:31 +0000 (14:15 +0100)]
Illumos 4929 - want prevsnap property

4929 want prevsnap property
Reviewed by: Adam Leventhal <adam.leventhal@delphix.com>
Reviewed by: Matt Amdur <matt.amdur@delphix.com>
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Reviewed by: Boris Protopopov <bprotopopov@hotmail.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Dan McDonald <danmcd@omniti.com>

References:
  https://www.illumos.org/issues/4929
  https://github.com/illumos/illumos-gate/commit/b461c74

Porting notes:
- [include/sys/fs/zfs.h]
  - f67d70 Create an 'overlay' property
  - 11b9ec Add full SELinux support
- [fs/zfs/dsl_dataset.c]
  - This increases the stack size of dsl_dataset_stats() but
    nothing has been changed until this is shown to be an issue.

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 4891 - want zdb option to dump all metadata
Matthew Ahrens [Fri, 1 Jan 2016 13:42:58 +0000 (14:42 +0100)]
Illumos 4891 - want zdb option to dump all metadata

4891 want zdb option to dump all metadata
Reviewed by: Sonu Pillai <sonu.pillai@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Garrett D'Amore <garrett@damore.org>

We'd like a way for zdb to dump metadata in a machine-readable
format, so that we can bring that back from a customer site for
in-house diagnosis.  Think of it as a crash dump for zpools,
which can be used for post-mortem analysis of a malfunctioning
pool

References:
  https://www.illumos.org/issues/4891
  https://github.com/illumos/illumos-gate/commit/df15e41

Porting notes:
- [cmd/zdb/zdb.c]
  - a5778ea zdb: Introduce -V for verbatim import
  - In main() getopt 'opt' variable removed and the code was
    brought back in line with illumos.
- [lib/libzpool/kernel.c]
  - 1e33ac1 Fix Solaris thread dependency by using pthreads
  - f0e324f Update utsname support
  - 4d58b69 Fix vn_open/vn_rdwr error handling
  - In vn_open() allocate 'dumppath' on heap instead of stack
  - Properly handle 'dump_fd == -1' error path
  - Free 'realpath' after added vn_dumpdir_code block

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 4638 - Panic in ZFS via rfs3_setattr()/rfs3_write(): dirtying snapshot!
Marcel Telka [Sun, 10 Jan 2016 22:31:24 +0000 (23:31 +0100)]
Illumos 4638 - Panic in ZFS via rfs3_setattr()/rfs3_write(): dirtying snapshot!

4638 Panic in ZFS via rfs3_setattr()/rfs3_write(): dirtying snapshot!
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Ilya Usvyatsky <ilya.usvyatsky@nexenta.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
  https://www.illumos.org/issues/4638
  https://github.com/illumos/illumos-gate/commit/2144b12

Porting notes:
- [module/zfs/zfs_vnops.c]
  - 3558fd7 Prototype/structure update for Linux
  - 2cf7f52 Linux compat 2.6.39: mount_nodev()
  - Use zfs_is_readonly() wrapper
  - Remove first line of comment which doesn't apply

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoMan page whitespace
nathancheek [Fri, 8 Jan 2016 18:45:40 +0000 (13:45 -0500)]
Man page whitespace

Signed-off-by: nathancheek <myself@nathancheek.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4184

8 years agoIllumos 3749 - zfs event processing should work on R/O root filesystems
Will Andrews [Thu, 31 Dec 2015 16:38:59 +0000 (17:38 +0100)]
Illumos 3749 - zfs event processing should work on R/O root filesystems

3749 zfs event processing should work on R/O root filesystems
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Approved by: Christopher Siden <christopher.siden@delphix.com>

References:
  https://www.illumos.org/issues/3749
  https://github.com/illumos/illumos-gate/commit/3cb69f7

Porting notes:
- [include/sys/spa_impl.h]
  - ffe9d38 Add generic errata infrastructure
  - 1421c89 Add visibility in to arc_read
- [include/sys/fm/fs/zfs.h]
  - 2668527 Add linux events
  - 6283f55 Support custom build directories and move includes
- [module/zfs/spa_config.c]
  - Updated spa_config_sync() to match illumos with the exception
    of a Linux specific block.

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoAllow 16M send/recv blocks
Brian Behlendorf [Sat, 9 Jan 2016 00:21:56 +0000 (19:21 -0500)]
Allow 16M send/recv blocks

Fix an off by one error introduced by fcff0f3 which triggers an
assertion when 16M blocks are used with send/recv.  This fix was
intentionally not folder in to the Illumos commit so it can be
easily cherry-picked by upstream.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 5960, 5925
Paul Dagnelie [Tue, 22 Dec 2015 01:31:57 +0000 (02:31 +0100)]
Illumos 5960, 5925

5960 zfs recv should prefetch indirect blocks
5925 zfs receive -o origin=
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

References:
  https://www.illumos.org/issues/5960
  https://www.illumos.org/issues/5925
  https://github.com/illumos/illumos-gate/commit/a2cdcdd

Porting notes:
- [lib/libzfs/libzfs_sendrecv.c]
  - b8864a2 Fix gcc cast warnings
  - 325f023 Add linux kernel device support
  - 5c3f61e Increase Linux pipe buffer size on 'zfs receive'
- [module/zfs/zfs_vnops.c]
  - 3558fd7 Prototype/structure update for Linux
  - c12e3a5 Restructure zfs_readdir() to fix regressions
- [module/zfs/zvol.c]
  - Function @zvol_map_block() isn't needed in ZoL
  - 9965059 Prefetch start and end of volumes
- [module/zfs/dmu.c]
  - Fixed ISO C90 - mixed declarations and code
  - Function dmu_prefetch() 'int i' is initialized before
    the following code block (c90 vs. c99)
- [module/zfs/dbuf.c]
  - fc5bb51 Fix stack dbuf_hold_impl()
  - 9b67f60 Illumos 4757, 4913
  - 34229a2 Reduce stack usage for recursive traverse_visitbp()
- [module/zfs/dmu_send.c]
  - Fixed ISO C90 - mixed declarations and code
  - b58986e Use large stacks when available
  - 241b541 Illumos 5959 - clean up per-dataset feature count code
  - 77aef6f Use vmem_alloc() for nvlists
  - 00b4602 Add linux kernel memory support

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoAdd missing -V option to zdb
Brian Behlendorf [Wed, 6 Jan 2016 21:32:32 +0000 (16:32 -0500)]
Add missing -V option to zdb

Add missing getopt specifier for `zdb -V` verbatim option and
set flag with correct bitwise operator.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoFix casesensitivity=insensitive deadlock
Richard Sharpe [Mon, 28 Dec 2015 00:08:05 +0000 (16:08 -0800)]
Fix casesensitivity=insensitive deadlock

When casesensitivity=insensitive is set for the
file system, we can deadlock in a rename if the user uses different case
for each path. For example rename("A/some-file.txt", "a/some-file.txt").

The simple test for this is:

1. mkdir some-dir in a ZFS file system
2. touch some-dir/some-file.txt
3. mv Some-dir/some-file.txt some-dir/some-other-file.txt

This last request deadlocks trying to relock the i_mutex on the inode for
the parent directory.

The solution is to use d_add_ci in zpl_lookup if we are on a file system
that has the casesensitivity=insensitive attribute set.

This patch checks if we are working on a case insensitive file system and if
so, allocates storage for the case insensitive name and passes it to
zfs_lookup and then calls d_add_ci instead of d_splice_alias.

The performance impact seems to be minimal even though we have introduced a
kmalloc and kfree in the lookup path.

The problem was found when running Microsoft's FSCT against Samba on top of
ZFS On Linux.

Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4136

8 years agoMake arc_summary.py and dbufstat.py compatible with python3
Hajo Möller [Fri, 1 Jan 2016 01:20:43 +0000 (02:20 +0100)]
Make arc_summary.py and dbufstat.py compatible with python3

To make arc_summary.py and dbufstat.py compatible with python3
some minor fixes were required, this was done automatically by
`2to3 -w arc_summary.py` and `2to3 -w dbufstat.py`.

Signed-off-by: Hajo Möller <dasjoe@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Reviewed-by: Richard Laager <rlaager@wiktel.com>
8 years agoIllumos 3604 - zdb should print bpobjs more verbosely (fix zdb hang)
Matthew Ahrens [Thu, 31 Dec 2015 15:57:11 +0000 (16:57 +0100)]
Illumos 3604 - zdb should print bpobjs more verbosely (fix zdb hang)

3604 zdb should print bpobjs more verbosely (fix zdb hang)
References:
  https://github.com/illumos/illumos-gate/commit/7706186
  https://www.illumos.org/issues/3604
  https://lists.freebsd.org/pipermail/svn-src-vendor/2015-August/002411.html
  https://lists.freebsd.org/pipermail/svn-src-head/2015-August/075195.html

Porting notes:
In ZoL "5810 zdb should print details of bpobj" was merged
prior to this change so it must be applied to the new location.

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 3139 - zdb dies when it tries to determine path of unlinked file
Jeremy Jones [Thu, 31 Dec 2015 15:41:52 +0000 (16:41 +0100)]
Illumos 3139 - zdb dies when it tries to determine path of unlinked file

3139 zdb dies when it tries to determine path of unlinked file
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Approved by: Dan McDonald <danmcd@nexenta.com>

References:
  https://github.com/illumos/illumos-gate/commit/1ce39b5
  https://www.illumos.org/issues/3139

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 2077 - lots of unreachable breaks in illumos gate
Milan Jurik [Wed, 30 Dec 2015 22:43:27 +0000 (14:43 -0800)]
Illumos 2077 - lots of unreachable breaks in illumos gate

2077 lots of unreachable breaks in illumos gate
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/2077
  https://github.com/illumos/illumos-gate/commit/33f5ff1

Porting notes:
- Only one file of the original patch applied to ZFS
- Minor formating change to align copyright block with upstream

Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoIllumos 5746 - more checksumming in zfs send
Matthew Ahrens [Mon, 6 Jul 2015 03:20:31 +0000 (05:20 +0200)]
Illumos 5746 - more checksumming in zfs send

5746 more checksumming in zfs send
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Bayard Bell <buffer.g.overflow@gmail.com>
Approved by: Albert Lee <trisk@omniti.com>

References:
  https://www.illumos.org/issues/5746
  https://github.com/illumos/illumos-gate/commit/98110f0
  https://github.com/zfsonlinux/zfs/issues/905

Porting notes:
- Minor conflicts due to:
  - https://github.com/zfsonlinux/zfs/commit/2024041
  - https://github.com/zfsonlinux/zfs/commit/044baf0
  - https://github.com/zfsonlinux/zfs/commit/88904bb
- Fix ISO C90 warnings (-Werror=declaration-after-statement)
  - arc_buf_t *abuf;
  - dmu_buf_t *bonus;
  - zio_cksum_t cksum_orig;
  - zio_cksum_t *cksump;
- Fix format '%llx' format specifier warning
- Align message in zstreamdump safe_malloc() with upstream

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3611

8 years agoPrevent SA length overflow
Ned Bass [Wed, 30 Dec 2015 02:41:22 +0000 (18:41 -0800)]
Prevent SA length overflow

The function sa_update() accepts a 32-bit length parameter and
assigns it to a 16-bit field in sa_bulk_attr_t, potentially
truncating the passed-in value. This could lead to corrupt system
attribute (SA) records getting written to the pool. Add a VERIFY to
sa_update() to detect cases where overflow would occur. The SA length
is limited to 16-bit values by the on-disk format defined by
sa_hdr_phys_t.

The function zfs_sa_set_xattr() is vulnerable to this bug if the
unpacked nvlist of xattrs is less than 64k in size but the packed
size is greater than 64k. Fix this by appropriately checking the
size of the packed nvlist before calling sa_update(). Add error
handling to zpl_xattr_set_sa() to keep the cached list of SA-based
xattrs consistent with the data on disk.

Lastly, zfs_sa_set_xattr() calls dmu_tx_abort() on an assigned
transaction if sa_update() returns an error, but the DMU only allows
unassigned transactions to be aborted. Wrap the sa_update() call in a
VERIFY0, remove the transaction abort, and call dmu_tx_commit()
unconditionally. This is consistent practice with other callers
of sa_update().

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

8 years agoIllumos 5745 - zfs set allows only one dataset property to be set at a time
Chris Williamson [Sun, 5 Jul 2015 23:11:09 +0000 (01:11 +0200)]
Illumos 5745 - zfs set allows only one dataset property to be set at a time

5745 zfs set allows only one dataset property to be set at a time
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Bayard Bell <buffer.g.overflow@gmail.com>
Reviewed by: Richard PALO <richard@NetBSD.org>
Reviewed by: Steven Hartland <killing@multiplay.co.uk>
Approved by: Rich Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/5745
  https://github.com/illumos/illumos-gate/commit/3092556

Porting notes:
- Fix the missing braces around initializer, zfs_cmd_t zc = {"\0"};
- Remove extra format argument in zfs_do_set()
- Declare at the top:
  - zfs_prop_t prop;
  - nvpair_t *elem;
  - nvpair_t *next;
  - int i;
- Additionally initialize:
  - int added_resv = 0;
  - zfs_prop_t prop = 0;
- Assign 0 install of NULL for uint64_t types.
  - zc->zc_nvlist_conf = '\0';
  - zc->zc_nvlist_src = '\0';
  - zc->zc_nvlist_dst = '\0';

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3574

8 years agoMake xattr dir truncate and remove in one tx
Chunwei Chen [Mon, 21 Dec 2015 19:57:18 +0000 (11:57 -0800)]
Make xattr dir truncate and remove in one tx

We need truncate and remove be in the same tx when doing zfs_rmnode on xattr
dir. Otherwise, if we truncate and crash, we'll end up with inconsistent zap
object on the delete queue. We do this by skipping dmu_free_long_range and let
zfs_znode_delete to do the work.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4114
Issue #4052
Issue #4006
Issue #3018
Issue #2861

8 years agoFix empty xattr dir causing lockup
Chunwei Chen [Fri, 18 Dec 2015 19:39:41 +0000 (11:39 -0800)]
Fix empty xattr dir causing lockup

During zfs_rmnode on a xattr dir, if the system crash just after
dmu_free_long_range, we would get empty xattr dir in delete queue. This would
cause blkid=0 be passed into zap_get_leaf_byblk when doing zfs_purgedir during
mount, and would try to do rw_enter on a wrong structure and cause system
lockup.

We fix this by returning ENOENT when blkid is zero in zap_get_leaf_byblk.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4114
Closes #4052
Closes #4006
Closes #3018
Closes #2861

8 years agoFix z_xattr_lock/z_teardown_lock inversion
Brian Behlendorf [Mon, 21 Dec 2015 17:27:24 +0000 (09:27 -0800)]
Fix z_xattr_lock/z_teardown_lock inversion

There exists a lock inversion between the z_xattr_lock and the
z_teardown_lock.  Resolve this by taking the z_teardown_lock in
all registered xattr callbacks prior to taking the z_xattr_lock.
This ensures the locks are always taken is the same order thus
preventing a deadlock.  Note the z_teardown_lock is taken again
in zfs_lookup() and this is safe because the z_teardown lock is
a re-entrant read reader/writer lock.

* process-1
zpl_xattr_get -> Takes zp->z_xattr_lock
  __zpl_xattr_get
    zfs_lookup -> Takes zsb->z_teardown_lock in ZFS_ENTER macro

* process-2
zfs_ioc_recv -> Takes zsb->z_teardown_lock in zfs_suspend_fs()
  zfs_resume_fs
    zfs_rezget -> Takes zp->z_xattr_lock

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #3943
Closes #3969
Closes #4121

8 years agoRevert "Fix z_xattr_lock/z_teardown_lock lock inversion"
Brian Behlendorf [Mon, 21 Dec 2015 17:12:37 +0000 (09:12 -0800)]
Revert "Fix z_xattr_lock/z_teardown_lock lock inversion"

This reverts commit 6b32ef572f754efc3f9edb20d022450f8e6b02d9.

8 years agoFix ztest truncated cache file
Brian Behlendorf [Mon, 21 Dec 2015 22:02:22 +0000 (17:02 -0500)]
Fix ztest truncated cache file

Commit efc412b updated spa_config_write() for Linux 4.2 kernels to
truncate and overwrite rather than rename the cache file.  This is
the correct fix but it should have only been applied for the kernel
build.  In user space rename(2) is needed because ztest depends on
the cache file.

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

8 years agoIdentify locks flagged by lockdep
Olaf Faaland [Thu, 15 Oct 2015 20:08:27 +0000 (13:08 -0700)]
Identify locks flagged by lockdep

When running a kernel with CONFIG_LOCKDEP=y, lockdep reports possible
recursive locking in some cases and possible circular locking dependency
in others, within the SPL and ZFS modules.

This patch uses a mutex type defined in SPL, MUTEX_NOLOCKDEP, to mark
such mutexes when they are initialized.  This mutex type causes
attempts to take or release those locks to be wrapped in lockdep_off()
and lockdep_on() calls to silence the dependency checker and allow the
use of lock_stats to examine contention.

For RW locks, it uses an analogous lock type, RW_NOLOCKDEP.

The goal is that these locks are ultimately changed back to type
MUTEX_DEFAULT or RW_DEFAULT, after the locks are annotated to reflect
their relationship (e.g. z_name_lock below) or any real problem with the
lock dependencies are fixed.

Some of the affected locks are:

tc_open_lock:
=============
This is an array of locks, all with same name, which txg_quiesce must
take all of in order to move txg to next state.  All default to the same
lockdep class, and so to lockdep appears recursive.

zp->z_name_lock:
================
In zfs_rmdir,
        dzp = znode for the directory (input to zfs_dirent_lock)
        zp  = znode for the entry being removed (output of zfs_dirent_lock)

zfs_rmdir()->zfs_dirent_lock() takes z_name_lock in dzp
zfs_rmdir() takes z_name_lock in zp

Since both dzp and zp are type znode_t, the locks have the same default
class, and lockdep considers it a possible recursive lock attempt.

l->l_rwlock:
============
zap_expand_leaf() sometimes creates two new zap leaf structures, via
these call paths:

zap_deref_leaf()->zap_get_leaf_byblk()->zap_leaf_open()
zap_expand_leaf()->zap_create_leaf()->zap_expand_leaf()->zap_create_leaf()

Because both zap_leaf_open() and zap_create_leaf() initialize
l->l_rwlock in their (separate) leaf structures, the lockdep class is
the same, and the linux kernel believes these might both be the same
lock, and emits a possible recursive lock warning.

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3895

8 years agoAdd lock types RW_NOLOCKDEP and MUTEX_NOLOCKDEP
Olaf Faaland [Fri, 6 Nov 2015 17:38:27 +0000 (09:38 -0800)]
Add lock types RW_NOLOCKDEP and MUTEX_NOLOCKDEP

Both lock types were introduced in SPL to allow some locks to be
taken/released with linux lockdep turned off.  See SPL commit for
details.

Add the new lock types to zfs_context.h to allow user space compilation.

Depends on SPL commit 692ae8d
SPL pull request refs/pull/480/head

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3895

8 years agoSkip GPL-only symbols test when cross-compiling
Kamil Domański [Wed, 16 Dec 2015 16:24:28 +0000 (17:24 +0100)]
Skip GPL-only symbols test when cross-compiling

Signed-off-by: Kamil Domański <kamil@domanski.co>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4107

8 years agoMake zio_taskq_batch_pct user configurable
DHE [Wed, 16 Dec 2015 19:22:32 +0000 (14:22 -0500)]
Make zio_taskq_batch_pct user configurable

Adds zio_taskq_batch_pct as an exported module parameter,
allowing users to modify it at module load time.

Signed-off-by: DHE <git@dehacked.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4110

8 years agoActivate LVM volume groups before looking for zpools.
Benjamin Albrecht [Fri, 20 Nov 2015 16:48:54 +0000 (17:48 +0100)]
Activate LVM volume groups before looking for zpools.

Original-patch-by: @jgoerzen
Signed-off-by: Benjamin Albrecht <git@albrecht.io>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/pkg-zfs#102
Closes #4029

8 years agoMan page white space and spelling corrections
Ned Bass [Thu, 17 Dec 2015 01:45:15 +0000 (17:45 -0800)]
Man page white space and spelling corrections

Correct some misspelled words and grammatical errors, and remove
trailing white space in the man pages.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4115

8 years agoFix zfs_vdev_aggregation_limit bounds checking
Brian Behlendorf [Thu, 17 Dec 2015 17:26:05 +0000 (09:26 -0800)]
Fix zfs_vdev_aggregation_limit bounds checking

Update the bounds checking for zfs_vdev_aggregation_limit so that
it has a floor of zero and a maximum value of the supported block
size for the pool.

Additionally add an early return when zfs_vdev_aggregation_limit
equals zero to disable aggregation.  For very fast solid state or
memory devices it may be more expensive to perform the aggregation
than to issue the IO immediately.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoFix vdev_queue_aggregate() deadlock
Brian Behlendorf [Wed, 16 Dec 2015 19:28:15 +0000 (11:28 -0800)]
Fix vdev_queue_aggregate() deadlock

This deadlock may manifest itself in slightly different ways but
at the core it is caused by a memory allocation blocking on file-
system reclaim in the zio pipeline.  This is normally impossible
because zio_execute() disables filesystem reclaim by setting
PF_FSTRANS on the thread.  However, kmem cache allocations may
still indirectly block on file system reclaim while holding the
critical vq->vq_lock as shown below.

To resolve this issue zio_buf_alloc_flags() is introduced which
allocation flags to be passed.  This can then be used in
vdev_queue_aggregate() with KM_NOSLEEP when allocating the
aggregate IO buffer.  Since aggregating the IO is purely a
performance optimization we want this to either succeed or fail
quickly.  Trying too hard to allocate this memory under the
vq->vq_lock can negatively impact performance and result in
this deadlock.

* z_wr_iss
zio_vdev_io_start
  vdev_queue_io -> Takes vq->vq_lock
    vdev_queue_io_to_issue
      vdev_queue_aggregate
        zio_buf_alloc -> Waiting on spl_kmem_cache process

* z_wr_int
zio_vdev_io_done
  vdev_queue_io_done
    mutex_lock -> Waiting on vq->vq_lock held by z_wr_iss

* txg_sync
spa_sync
  dsl_pool_sync
    zio_wait -> Waiting on zio being handled by z_wr_int

* spl_kmem_cache
spl_cache_grow_work
  kv_alloc
    spl_vmalloc
      ...
      evict
        zpl_evict_inode
          zfs_inactive
            dmu_tx_wait
              txg_wait_open -> Waiting on txg_sync

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes #3808
Closes #3867

8 years agoFix z_xattr_lock/z_teardown_lock lock inversion
Brian Behlendorf [Wed, 16 Dec 2015 22:17:49 +0000 (14:17 -0800)]
Fix z_xattr_lock/z_teardown_lock lock inversion

There exists a lock inversion between the z_xattr_lock and the
z_teardown_lock.  Detect this case and return EBUSY so zfs_resume_fs()
will mark the inode stale and it can be safely revalidated on next
access.

* process-1
zpl_xattr_get -> Takes zp->z_xattr_lock
  __zpl_xattr_get
    zfs_lookup -> Takes zsb->z_teardown_lock in ZFS_ENTER macro

* process-2
zfs_ioc_recv -> Takes zsb->z_teardown_lock in zfs_suspend_fs()
  zfs_resume_fs
    zfs_rezget -> Takes zp->z_xattr_lock

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #3969

8 years agoUse uio for zvol_{read,write}
Chunwei Chen [Tue, 8 Dec 2015 20:37:24 +0000 (12:37 -0800)]
Use uio for zvol_{read,write}

Since uio now supports bvec, we can convert bio into uio and reuse
dmu_{read,write}_uio. This way, we can remove some duplicate code.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4078

8 years agoFix uio_prefaultpages for 0 length iovec
Chunwei Chen [Tue, 8 Dec 2015 20:26:18 +0000 (12:26 -0800)]
Fix uio_prefaultpages for 0 length iovec

Userspace can freely pass in whatever iovec it feels like, and it's perfectly
legal to pass an iovec which contains a zero length segment. In the current
implementation, uio_prefaultpages would touch an out of bound byte in the
"last byte" logic. While this probably wouldn't cause any critical error, we
would like uio_prefaultpages to be able to continue gracefully.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4078

8 years agoHandle damaged blk_birth in dsl_deadlist_insert()
Brian Behlendorf [Fri, 11 Dec 2015 19:09:41 +0000 (11:09 -0800)]
Handle damaged blk_birth in dsl_deadlist_insert()

If a bit were cleared in `bp->blk_birth` such that the txg birth
was now lower than any other txg_birth in the deadlist, then there
will be no entry before this in the tree.

This should be impossible but regardless error handling code has
been added for this case.  By default this is left as a fatal case
and the blk_birth is logged.  However, setting `zfs_recover=1` will
cause the bp to be placed at the start of the deadlist even though
it contains an invalid blk_birth.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #4086
Closes #4089

8 years agoHandle block pointers with a corrupt logical size
Brian Behlendorf [Wed, 9 Dec 2015 19:00:35 +0000 (11:00 -0800)]
Handle block pointers with a corrupt logical size

Commit 5f6d0b6 was originally added to gracefully handle block
pointers with a damaged logical size.  However, it incorrectly
assumed that all passed arc_done_func_t could handle a NULL
arc_buf_t.

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

8 years agoRemove "index" column from dbufstat.py
Olaf Faaland [Sat, 12 Dec 2015 01:56:44 +0000 (17:56 -0800)]
Remove "index" column from dbufstat.py

Commit ca0bf58d to address arcs_mtx contention removed column "index"
from the output of kstats/dbuf.

dbufstat.py was not updated to reflect this, which causes it to crash
when run with -bx

This removes "index" from hardcoded lists of columns.

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4096

8 years agoRevert "Switch ztest mmap(2) ASSERTs to VERIFYs"
Richard Yao [Fri, 11 Dec 2015 23:42:42 +0000 (18:42 -0500)]
Revert "Switch ztest mmap(2) ASSERTs to VERIFYs"

This reverts commit 202619623022722f30c2ee49931a4fa6896421c7.

It is no longer necessary now that we pass -DDEBUG unconditionally.

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

8 years agoUnconditionally build zdb and ztest with -DDEBUG
Richard Yao [Fri, 11 Dec 2015 23:40:05 +0000 (18:40 -0500)]
Unconditionally build zdb and ztest with -DDEBUG

Illumos unconditionally builds zdb and ztest with -DDEBUG. This helps
catch bugs and eliminates the need for commits like
202619623022722f30c2ee49931a4fa6896421c7, which changed ASSERTs to
VERIFYs. The following files in the illumos tree show this:

usr/src/cmd/zdb/Makefile.com
usr/src/cmd/ztest/Makefile.com

Given the usefulness of having early failure in these tools, we should
do it too.

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

8 years agoHold the zfs_snapentry_t before dispatch
Brian Behlendorf [Mon, 14 Dec 2015 18:59:25 +0000 (10:59 -0800)]
Hold the zfs_snapentry_t before dispatch

While exceptionally unlikely to cause a problem the zfs_snapentry_t
hold should be taken before the dispatch to prevent any possibility
of the task being processed before the hold.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
8 years agoFix snapshot automount race cause EREMOTE
Chunwei Chen [Fri, 11 Dec 2015 23:24:34 +0000 (15:24 -0800)]
Fix snapshot automount race cause EREMOTE

When a concorrent mount finishes just before calling to
zfsctl_snapshot_ismounted, if we return EISDIR, the VFS will return
with EREMOTE. We should instead just return 0, so VFS may retry and
would likely notice the dentry is alreadly mounted. This will be
inline with when usermode helper return EBUSY.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoChange zfs_snapshot_lock from mutex to rw lock
Brian Behlendorf [Thu, 10 Dec 2015 23:53:37 +0000 (15:53 -0800)]
Change zfs_snapshot_lock from mutex to rw lock

By changing the zfs_snapshot_lock from a mutex to a rw lock the
zfsctl_lookup_objset() function can be allowed to run concurrently.
This should reduce the latency of fh_to_dentry lookups in ZFS
snapshots which are being accessed over NFS.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
8 years agoFix zfsctl_lookup_objset() deadlock
Brian Behlendorf [Thu, 10 Dec 2015 23:47:18 +0000 (15:47 -0800)]
Fix zfsctl_lookup_objset() deadlock

The zfsctl_snapshot_unmount_delay() function must not be called
from zfsctl_lookup_objset() while it is currently holding the
zfs_snapshot_lock.  This will result in a deadlock.  It is safe
to call zfsctl_snapshot_unmount_delay_impl() directly because the
function already has a reference on the zfs_snapentry_t.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #3997

8 years agoSet 'zfs_expire_snapshot=0' to disable auto-unmount
Brian Behlendorf [Thu, 10 Dec 2015 23:23:26 +0000 (15:23 -0800)]
Set 'zfs_expire_snapshot=0' to disable auto-unmount

There are cases where it's desirable that auto-mounted snapshots
not expire after a fixed duration.  They should be unmounted only
when the filesystem they are a snapshot of is unmounted.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
8 years agoEither _ILP32 or _LP64 must be defined
Brian Behlendorf [Wed, 9 Dec 2015 22:58:29 +0000 (14:58 -0800)]
Either _ILP32 or _LP64 must be defined

For some arm, powerpc, and sparc platforms it was possible that
neither _ILP32 of _LP64 would be defined.  Update the isa_defs.h
header to explicitly set these macros and generate a compile error
in the case neither are defined.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #4048

8 years agoUse spa as key besides objsetid for snapentry
Chunwei Chen [Mon, 7 Dec 2015 23:43:53 +0000 (15:43 -0800)]
Use spa as key besides objsetid for snapentry

objsetid is not unique across pool, so using it solely as key would cause
panic when automounting two snapshot on different pools with the same
objsetid. We fix this by adding spa pointer as additional key.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Issue #3948
Issue #3786
Issue #3887

8 years agoUse large stacks when available
Brian Behlendorf [Wed, 2 Dec 2015 19:53:37 +0000 (11:53 -0800)]
Use large stacks when available

While stack size will vary by architecture it has historically defaulted to
8K on x86_64 systems.  However, as of Linux 3.15 the default thread stack
size was increased to 16K.  These kernels are now the default in most non-
enterprise distributions which means we no longer need to assume 8K stacks.

This patch takes advantage of that fact by appropriately reverting stack
conservation changes which were made to ensure stability.  Changes which
may have had a negative impact on performance for certain workloads.  This
also has the side effect of bringing the code slightly more in line with
upstream.

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

8 years agoUpdate arcstat.py to remove deprecated rmis reference.
cable2999 [Fri, 16 Oct 2015 17:06:33 +0000 (12:06 -0500)]
Update arcstat.py to remove deprecated rmis reference.

Running arcstat.py -x currently throws KeyError due to rmis being
absent, it was removed in commit ca0bf58.

Signed-off-by: cable2999 <cable2999@users.noreply.github.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3931

8 years agoFix cstyle issue from 7a02327
ilovezfs [Thu, 3 Dec 2015 10:40:27 +0000 (02:40 -0800)]
Fix cstyle issue from 7a02327

Continuations should be indented four spaces.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4062

8 years agoIllumos 5959 - clean up per-dataset feature count code
Matthew Ahrens [Fri, 24 Jul 2015 16:53:55 +0000 (09:53 -0700)]
Illumos 5959 - clean up per-dataset feature count code

5959 clean up per-dataset feature count code
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Alex Reece <alex@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/5959
  https://github.com/illumos/illumos-gate/commit/ca0cc39

Porting notes:

illumos code doesn't check for feature_get_refcount() returning
ENOTSUP (which means feature is disabled) in zdb. zfsonlinux added
a check in https://github.com/zfsonlinux/zfs/commit/784652c
due to #3468. The check was reintroduced here.

Ported-by: Witaut Bajaryn <vitaut.bayaryn@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3965

8 years agoAdd zap_prefetch() interface
Brian Behlendorf [Fri, 9 May 2014 21:51:20 +0000 (14:51 -0700)]
Add zap_prefetch() interface

Provide a generic interface to prefetch ZAP entries by name.  This
functionality is being added for external consumers such as Lustre.
It is based of the existing zap_prefetch_uint64() version which is
used by the deduplication code.

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

8 years agoExt4's typical GPT partition type not recognized
ilovezfs [Sun, 22 Nov 2015 12:06:21 +0000 (04:06 -0800)]
Ext4's typical GPT partition type not recognized

Adding additional entries to the efi conversion array will help prevent
the overwriting of the GPTs of disks with in-use file systems in more
cases. Most notably, this adds partition type 8300 "Linux filesystem"
(0FC63DAF-8483-4772-8E79-3D69D8477DE4), which is often used for ext4 and
btrfs, among others.

This commit itself does nothing to address the underlying problematic
behavior that check_slice() isn't called on partitions of an
unrecognized type, even when they contain a currently mounted file
system.

The additional entries were derived from these two resources:
https://en.wikipedia.org/wiki/GUID_Partition_Table
http://sourceforge.net/p/gptfdisk/code/ci/master/tree/parttypes.cc

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4016

8 years agoIllumos 934 - FreeBSD's GPT not recognized
Yuri Pankov [Thu, 23 Feb 2012 03:11:44 +0000 (07:11 +0400)]
Illumos 934 - FreeBSD's GPT not recognized

Reviewed by: Alexander Eremin <alexander.r.eremin@gmail.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Andrew Stormont <Andrew.Stormont@nexenta.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Approved by: Gordon Ross <gwr@nexenta.com>

References:
  https://www.illumos.org/issues/934
  https://github.com/illumos/illumos-gate/commit/e21ea67

Ported-by: ilovezfs <ilovezfs@icloud.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4016

8 years agoOnly trigger SET_ERROR tracepoint event on error
Richard Yao [Wed, 25 Nov 2015 15:39:57 +0000 (10:39 -0500)]
Only trigger SET_ERROR tracepoint event on error

Currently, the SET_ERROR tracepoint triggers regardless of whether there
is an error or not. On Illumos, SET_ERROR only triggers on an actual
error, which is avoids irrelevant noise. Linux 2.6.38 added support for
conditional tracepoints, so we modify SET_ERROR to use them when they
are avaliable for functionality equivalent to the Illumos functionality.

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

8 years agoFix zdb_dump_block on little endian systems
Chunwei Chen [Fri, 20 Nov 2015 23:47:37 +0000 (15:47 -0800)]
Fix zdb_dump_block on little endian systems

When dumping a block on a little endian system the data must be
byte swapped to display correctly.  Example incorrect output:

$ echo 0123456789abcdef > aaa
$ zdb -eR pp 3:1ee00:200
3:1ee00:200
          0 1 2 3 4 5 6 7   8 9 a b c d e f  0123456789abcdef
000000:  3736353433323130  6665646362613938  0123456789abcdef
000010:  000000000000000a  0000000000000000  ................

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4020

8 years agoFix zdb calling behavior in ztest
Chunwei Chen [Fri, 20 Nov 2015 23:50:06 +0000 (15:50 -0800)]
Fix zdb calling behavior in ztest

The current zdb calling behaviour is really fragile, and is guaranteed to
segfault if ztest is not installed in either /sbin or /usr/sbin. With this
patch, the ztest will try to call zdb in the following order.

1. Use environmental variable ZDB_PATH if provided.
2. If ztest resides in build tree, guess the in tree zdb path.
3. Just pass zdb to popen and let it search it in PATH.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3126

8 years agoPrevent rm modules.* when make install
tuxoko [Fri, 20 Nov 2015 01:42:41 +0000 (17:42 -0800)]
Prevent rm modules.* when make install

This was originally in fe0ed8f910c1e4288dc190546cfe98ecf545b547, but somehow
was changed and not working anymore. And it will cause the following error:

modprobe: ERROR: ../libkmod/libkmod.c:506 lookup_builtin_file() could not open builtin file '/lib/modules/4.2.0-18-generic/modules.builtin.bin'

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4027

8 years agoFix --enable-linux-builtin
Brian Behlendorf [Wed, 2 Dec 2015 02:24:40 +0000 (18:24 -0800)]
Fix --enable-linux-builtin

Adding VPATH support, commit 47a4a6f, required that a `src`
and `obj` line be added to the top of the Makefiles.  They
must be removed from the Makefiles when builtin.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/spl#481
Issue zfsonlinux/spl#498

8 years agoLinux 4.4 compat: xattr operations takes xattr_handler
Chunwei Chen [Mon, 23 Nov 2015 23:06:46 +0000 (15:06 -0800)]
Linux 4.4 compat: xattr operations takes xattr_handler

The xattr_hander->{list,get,set} were changed to take a xattr_handler,
and handler_flags argument was removed and should be accessed by
handler->flags.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4021

8 years agoLinux 4.4 compat: make_request_fn returns blk_qc_t
Chunwei Chen [Mon, 23 Nov 2015 22:47:29 +0000 (14:47 -0800)]
Linux 4.4 compat: make_request_fn returns blk_qc_t

As part of block polling support in Linux 4.4, make_request_fn should
return a cookie value of type blk_qc_t. For now, we make zvol_request
always return BLK_QC_T_NONE until we assess whether and how we want
to support block polling.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4021

8 years agoFix zfs_dirty_data_max overflow on 32-bit
tuxoko [Fri, 30 Oct 2015 23:10:01 +0000 (16:10 -0700)]
Fix zfs_dirty_data_max overflow on 32-bit

On 32 bit, the calculation of zfs_dirty_data_max from phymem will overflow,
causing it to be smaller than zfs_dirty_data_sync, and will cause txg being
delayed while no one write to disk. The end result is horrendous write speed.

On 4G ram 32-bit VM, before this patch, simple dd results in ~7MB/s. Now it
can reach speed on par with 64-bit VM.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3973

8 years agoFix null pointer in arc_kmem_reap_now on 32-bit
tuxoko [Fri, 30 Oct 2015 21:34:22 +0000 (14:34 -0700)]
Fix null pointer in arc_kmem_reap_now on 32-bit

On 32 bit system, zio_buf_cache is limit to 1M. Larger than that is all NULL.
So we need to avoid reaping them.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #3973

8 years agoFix snapshot automount behavior when concurrent or fail
Chunwei Chen [Tue, 17 Nov 2015 00:39:52 +0000 (16:39 -0800)]
Fix snapshot automount behavior when concurrent or fail

When concurrent threads accessing the snapdir, one will succeed the user
helper mount while others will get EBUSY. However, the original code treats
those EBUSY threads as success and goes on to do zfsctl_snapshot_add, which
causes repeated avl_add and thus panic.

Also, if the snapshot is already mounted somewhere else, a thread accessing
the snapdir will also get EBUSY from user helper mount. And it will cause
strange things as doing follow_down_one will fail and then follow_up will jump
up to the mountpoint of the filesystem and confuse the hell out of VFS.

The patch fix both behavior by returning 0 immediately for the EBUSY threads.
Note, this will have a side effect for the second case where the VFS will
retry several times before returning ELOOP.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4018

8 years agosysmacros: Make P2ROUNDUP not trigger int overflow
Jason Zaman [Sat, 24 Oct 2015 06:01:08 +0000 (14:01 +0800)]
sysmacros: Make P2ROUNDUP not trigger int overflow

The original P2ROUNDUP and P2ROUNDUP_TYPED macros contain -x which
triggers PaX's integer overflow detection for unsigned integers.
Replace the macros with an equivalent version that does not trigger
the overflow.

Axioms:
A. (-(x)) === (~((x) - 1)) === (~(x) + 1) under two's complement.
B. ~(x & y) === ((~(x)) | (~(y))) under De Morgan's law.
C. ~(~x) === x under the law of excluded middle.

Proof:
0. (-(-(x) & -(align))) original
1. (~(-(x) & -(align)) + 1) by A
2. (((~(-(x))) | (~(-(align)))) + 1) by B
3. (((~(~((x) - 1))) | (~(~((align) - 1)))) + 1) by A
4. (((((x) - 1)) | (((align) - 1))) + 1) by C
Q.E.D.

Signed-off-by: Jason Zaman <jason@perfinion.com>
Reviewed-by: Chris Dunlop <chris@onthe.net.au>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3949

8 years agozimport.sh: Add configure/make option support
Brian Behlendorf [Mon, 16 Nov 2015 17:47:43 +0000 (09:47 -0800)]
zimport.sh: Add configure/make option support

Allow the following environment variables to control the build
behavior of the zimport.sh script.  This can be useful when you
want a debug build or require specific build options.  The
default values are:

CONFIG_OPTIONS=""
MAKE_OPTIONS="-s -j$(nproc)"

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoFollow 0/-E convention for module load errors
Brian Behlendorf [Mon, 16 Nov 2015 23:00:38 +0000 (15:00 -0800)]
Follow 0/-E convention for module load errors

Because errors during module load are so rare it went unnoticed that
it was possible that a positive errno was returned.  This would result
in the module being loaded, nothing being initialized, and a system
panic shortly thereafter.  This is what was causing the hard failures
in the automated testing.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoObey arc_meta_limit default size when changing arc_max
AndCycle [Tue, 10 Nov 2015 14:01:26 +0000 (22:01 +0800)]
Obey arc_meta_limit default size when changing arc_max

When decreasing the maximum ARC size preserve the 3/4 default
ratio for the arc_meta_limit.  Otherwise, the arc_meta_limit
may be set the same as arc_max.

Signed-off-by: AndCycle <andcycle@andcycle.idv.tw>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4001

8 years agoAdd TEST configuration file for buildbot
Brian Behlendorf [Thu, 5 Nov 2015 16:13:52 +0000 (08:13 -0800)]
Add TEST configuration file for buildbot

The TEST file is provided as a hint to the automated test infra-
structure.  It controls which regression tests are run and how they
are run.  This file along with any lines in the commit messages
which start with TEST_*  are sourced by the test scripts and can
be used to override the default values.  For complete details see:

https://github.com/zfsonlinux/zfs-buildbot/

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoFix maybe uninitialized
Brian Behlendorf [Mon, 9 Nov 2015 20:10:02 +0000 (12:10 -0800)]
Fix maybe uninitialized

As of gcc 5.1.1 20150618 (Red Hat 5.1.1-4) the -Werror=maybe-uninitialized
check detects that 'snapname' in recv_incremental_replication() may not be
initialized.  Explicitly initialize the variable to resolved the warning.

  libzfs_sendrecv.c: In function ‘recv_incremental_replication’:
  libzfs_sendrecv.c:2019:2: error: ‘snapname’ may be used uninitialized in
    (void) snprintf(buf, sizeof (buf), "%s@%s", fsname, snapname);

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoRemove shareiscsi description and example from zfs(8).
Turbo Fredriksson [Mon, 5 Oct 2015 18:28:32 +0000 (20:28 +0200)]
Remove shareiscsi description and example from zfs(8).

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
8 years agoUnmount is part of the shutdown process, not the boot process.
Turbo Fredriksson [Sun, 4 Oct 2015 12:03:46 +0000 (14:03 +0200)]
Unmount is part of the shutdown process, not the boot process.

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes: #3762
8 years agoFix fail path in zfs_znode_alloc
Chunwei Chen [Fri, 9 Oct 2015 19:27:01 +0000 (12:27 -0700)]
Fix fail path in zfs_znode_alloc

When sa_bulk_lookup() fails, unlock_new_inode() will spit out a WARNING. It
will also recursive deadlock on ZFS_OBJ_HOLD_ENTER in zfs_zinactive().

Since we never call insert_inode_locked in fail path, I_NEW is never set, the
inode is never hashed. So unlock_new_inode() can be safely remove it.

We set z_sa_hdl to NULL in fail path so that iput path will stop at
zfs_inactive() without entering zfs_zinactive(). This way we can avoid the
deadlock and prevent double sa_handle_destroy().

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #3899

8 years agoFix use-after-free in vdev_disk_physio_completion
Chunwei Chen [Tue, 13 Oct 2015 21:13:52 +0000 (14:13 -0700)]
Fix use-after-free in vdev_disk_physio_completion

Currently, vdev_disk_physio_completion will try to wake up an waiter without
first checking the existence. This creates a race window in which complete is
called after dr is freed.

We add dr_wait in dio_request to indicate the existence of waiter. Also,
remove dr_rw since no one is using it, and reorder dr_ref to make the struct
more compact in 64bit.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #3917
Issue #3880

8 years agoIllumos 6267 - dn_bonus evicted too early
Justin T. Gibbs [Tue, 13 Oct 2015 21:09:45 +0000 (14:09 -0700)]
Illumos 6267 - dn_bonus evicted too early

6267 dn_bonus evicted too early
Reviewed by: Richard Yao <ryao@gentoo.org>
Reviewed by: Xin LI <delphij@freebsd.org>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

References:
  https://www.illumos.org/issues/6267
  https://github.com/illumos/illumos-gate/commit/d205810

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Ned Bass bass6@llnl.gov
Issue #3865
Issue #3443

8 years agozfs-import: Perform verbatim import using cache file
James Lee [Sun, 20 Sep 2015 02:00:36 +0000 (22:00 -0400)]
zfs-import: Perform verbatim import using cache file

This change modifies the import service to use the default cache file
to perform a verbatim import of pools at boot.  This fixes code that
searches all devices and imported all visible pools.

Using the cache file is in keeping with the way ZFS has always worked,
how Solaris, Illumos, FreeBSD, and systemd performs imports, and is how
it is written in the man page (zpool(1M,8)):

    All pools  in  this  cache  are  automatically imported when the
    system boots.

Importantly, the cache contains important information for importing
multipath devices, and helps control which pools get imported in more
dynamic environments like SANs, which may have thousands of visible
and constantly changing pools, which the ZFS_POOL_EXCEPTIONS variable
is not equipped to handle.  Verbatim imports prevent rogue pools from
being automatically imported and mounted where they shouldn't be.

The change also stops the service from exporting pools at shutdown.
Exporting pools is only meant to be performed explicitly by the
administrator of the system.

The old behavior of searching and importing all visible pools is
preserved and can be switched on by heeding the warning and toggling
the ZPOOL_IMPORT_ALL_VISIBLE variable in /etc/default/zfs.

Signed-off-by: James Lee <jlee@thestaticvoid.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3777
Closes #3526

8 years agozdb: segfault in dump_bpobj_subobjs()
Tim Chase [Fri, 9 Oct 2015 18:28:12 +0000 (13:28 -0500)]
zdb: segfault in dump_bpobj_subobjs()

Avoid buffer overrun on all-zero bpobj subobjects by using signed
array index.  Also fix the type cast on the printf() argument.

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

8 years agolibzfs: handle EDOM errors
DHE [Sun, 11 Oct 2015 15:42:42 +0000 (11:42 -0400)]
libzfs: handle EDOM errors

EDOM may occur if a user tries to set `recordsize` too large without
use "zfs set". This can be demonstrated with:

> zpool create testpool -O recordsize=32M /dev/...

Signed-off-by: DHE <git@dehacked.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3911

8 years agoFix 'arc_c < arc_c_min' panic
Brian Behlendorf [Tue, 13 Oct 2015 16:17:01 +0000 (09:17 -0700)]
Fix 'arc_c < arc_c_min' panic

Strictly enforce keeping 'arc_c >= arc_c_min'.  The ASSERTs are
left in place to catch this in a debug build but logic has been
added to gracefully handle in a production build.

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

8 years agoRename 'zed.service' to 'zfs-zed.service'
Turbo Fredriksson [Wed, 23 Sep 2015 21:04:17 +0000 (23:04 +0200)]
Rename 'zed.service' to 'zfs-zed.service'

For consistency all systemd unit files and init scripts now share
the same names.  This prevents an issue where the zed is started
twice on systems where both the systemd and sysv infrastructure is
installed concurrently.

For backward compatibility a 'zed' alias has been added.  This
allows the user to interact with the service using either the
name 'zed' or 'zfs-zed'.

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

8 years agoFix zfs-dkms uninstall/update
Brian Behlendorf [Thu, 1 Oct 2015 00:36:18 +0000 (20:36 -0400)]
Fix zfs-dkms uninstall/update

Modern versions of dkms cleanup the build directory after installing.
This resulted in 'dkms uninstall' never running because the check
added by commit 866c162 which verifies the existance of the
zfs.release build product would never be true.

This patch resolves the issue by updating the conditional to check
in the explicitly installed zfs_config.h file for the version.

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

8 years agozfs_inode_update should not call dmu_object_size_from_db under spinlock
Richard Yao [Wed, 30 Sep 2015 17:25:11 +0000 (13:25 -0400)]
zfs_inode_update should not call dmu_object_size_from_db under spinlock

We should never block when holding a spin lock, but zfs_inode_update can
block in the critical section of a spin lock in zfs_inode_update:

zfs_inode_update -> dmu_object_size_from_db -> zrl_add -> mutex_enter

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

8 years agoRemove obsolete zv_lock
Richard Yao [Tue, 29 Sep 2015 22:28:47 +0000 (18:28 -0400)]
Remove obsolete zv_lock

All users of zv_lock were removed by 37f9dac, but we forgot to remove
it.  Lets remove it as clean up.

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

8 years agoInit script fixes
Turbo Fredriksson [Tue, 22 Sep 2015 07:56:28 +0000 (09:56 +0200)]
Init script fixes

* Fix regression - "OVERLAY_MOUNTS" should have been "DO_OVERLAY_MOUNTS".
* Fix update-rc.d commands in postinst.  Thanx to subzero79@GitHub.
* Fix make sure a filesystem exists before trying to mount in mount_fs()
* Fix local variable usage.
* Fix to read_mtab():
  * Strip control characters (space - \040) from /proc/mounts GLOBALY,
    not just first occurrence.
  * Don't replace unprintable characters ([/-. ]) for use in the variable
    name with underscore. No need, just remove them all together.
* Add check_boolean() to check if a user configure option is
  set ('yes', 'Yes', 'YES' or any combination there of) OR '1'.
  Anything else is considered 'unset'.
* Add a ZFS_POOL_IMPORT to the default config.
  * This is a semi colon separated list of pools to import ONLY.
  * This is intended for systems which have _a lot_ of pools (from
    a SAN for example) and it would be to many to put in the
    ZFS_POOL_EXCEPTIONS variable..
* Add a config option "ZPOOL_IMPORT_OPTS" for adding additional options
  to "zpool import".
* Add documentation and the chance of overriding the ZPOOL_CACHE
  variable in the config file.
* Remove "sort" from find_pools() and setup_snapshot_booting().
  Sometimes not available, and not really necessary.

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

8 years agoFix uioskip crash when skip to end
Chunwei Chen [Tue, 29 Sep 2015 07:02:31 +0000 (00:02 -0700)]
Fix uioskip crash when skip to end

When doing uioskip to skip an iovec to the very end, the current loop
condition will falsely check pass the end of iovec. We fix this checking
uio_iovcnt first.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3806
Closes #3850