]> granicus.if.org Git - zfs/log
zfs
8 years agoEnable quota_002_pos, quota_004_pos and quota_005_pos
liaoyuxiangqin [Fri, 14 Oct 2016 16:33:51 +0000 (00:33 +0800)]
Enable quota_002_pos, quota_004_pos and quota_005_pos

In this test the 'ls -ls' command was used to print testfile size in
blocks.  Because the environment variable BLOCK_SIZE was set
the 'ls -ls' command detected this and output its block count as the
number of 8192 blocks.  Rather than change the variable name
the -k was was added to force ls to return 1k blocks.  This has the
additional advantage of behaving consistently across platforms.

For additional details on GNU 'ls' behavior regarding block size:

https://www.gnu.org/software/coreutils/manual/html_node/Block-size.html

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: yuxiang <guo.yong33@zte.com.cn>
Closes #5269

8 years agoEnable zfs_receive_011_pos
Brian Behlendorf [Fri, 14 Oct 2016 16:17:56 +0000 (09:17 -0700)]
Enable zfs_receive_011_pos

The zfs_receive_011_pos test can be enabled now that OpenZFS 6562
has been merged.

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5276

8 years agoOpenZFS 7090 - zfs should throttle allocations
Don Brady [Fri, 14 Oct 2016 00:59:18 +0000 (18:59 -0600)]
OpenZFS 7090 - zfs should throttle allocations

OpenZFS 7090 - zfs should throttle allocations

Authored by: George Wilson <george.wilson@delphix.com>
Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <paul.dagnelie@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Ported-by: Don Brady <don.brady@intel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
When write I/Os are issued, they are issued in block order but the ZIO
pipeline will drive them asynchronously through the allocation stage
which can result in blocks being allocated out-of-order. It would be
nice to preserve as much of the logical order as possible.

In addition, the allocations are equally scattered across all top-level
VDEVs but not all top-level VDEVs are created equally. The pipeline
should be able to detect devices that are more capable of handling
allocations and should allocate more blocks to those devices. This
allows for dynamic allocation distribution when devices are imbalanced
as fuller devices will tend to be slower than empty devices.

The change includes a new pool-wide allocation queue which would
throttle and order allocations in the ZIO pipeline. The queue would be
ordered by issued time and offset and would provide an initial amount of
allocation of work to each top-level vdev. The allocation logic utilizes
a reservation system to reserve allocations that will be performed by
the allocator. Once an allocation is successfully completed it's
scheduled on a given top-level vdev. Each top-level vdev maintains a
maximum number of allocations that it can handle (mg_alloc_queue_depth).
The pool-wide reserved allocations (top-levels * mg_alloc_queue_depth)
are distributed across the top-level vdevs metaslab groups and round
robin across all eligible metaslab groups to distribute the work. As
top-levels complete their work, they receive additional work from the
pool-wide allocation queue until the allocation queue is emptied.

OpenZFS-issue: https://www.illumos.org/issues/7090
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/4756c3d7
Closes #5258

Porting Notes:
- Maintained minimal stack in zio_done
- Preserve linux-specific io sizes in zio_write_compress
- Added module params and documentation
- Updated to use optimize AVL cmp macros

8 years agoFix coverity defects: CID 147692, 147693, 147694
cao [Thu, 13 Oct 2016 21:38:59 +0000 (05:38 +0800)]
Fix coverity defects: CID 147692, 147693, 147694

CID:147692, Type:Uninitialized scalar variable
CID:147693, Type:Uninitialized scalar variable
CID:147694, Type:Uninitialized scalar variable

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5252

8 years agoFix coverity defects: CID 150943, 150938
cao [Thu, 13 Oct 2016 21:30:50 +0000 (05:30 +0800)]
Fix coverity defects: CID 150943, 150938

CID:150943, Type:Unintentional integer overflow
CID:150938, Type:Explicit null dereferenced

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5255

8 years agoFix coverity defects: CID 147571, 147574
luozhengzheng [Thu, 13 Oct 2016 21:25:05 +0000 (05:25 +0800)]
Fix coverity defects: CID 147571, 147574

CID 147571: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
CID 147574: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5268

8 years agoEnable refquota_002_pos and refquota_004_pos
liaoyuxiangqin [Thu, 13 Oct 2016 21:21:15 +0000 (05:21 +0800)]
Enable refquota_002_pos and refquota_004_pos

The refquota_002_pos and refquota_004_pos test cases can pass
without modification.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: yuxiang <guo.yong33@zte.com.cn>
Closes #5273

8 years agoFix coverity defects: CID 147654, 147690
GeLiXin [Thu, 13 Oct 2016 21:02:07 +0000 (05:02 +0800)]
Fix coverity defects: CID 147654, 147690

coverity scan CID:147654,type: Copy into fixed size buffer
- string operation may write past the end of the fixed-size
  destination buffer

coverity scan CID:147690,type: Uninitialized scalar variable
- call zfs_prop_get first in case we use sourcetype and
  share_sourcetype without initialization

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: GeLiXin <ge.lixin@zte.com.cn>
Closes #5253

8 years agoFix coverity defects: CID 153394
luozhengzheng [Wed, 12 Oct 2016 20:24:03 +0000 (04:24 +0800)]
Fix coverity defects: CID 153394

coverity scan CID 153394, Type:String overflow

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5263

8 years agoFix ICP memleak introduced in #4760
Tom Caputi [Wed, 12 Oct 2016 19:52:30 +0000 (15:52 -0400)]
Fix ICP memleak introduced in #4760

The ICP requires destructors to for each crypto module that is added.
These do not necessarily exist in Illumos because they assume that
these modules can never be unloaded from the kernel. Some of this
cleanup code was missed when #4760 was merged, resulting in leaks.
This patch simply fixes that.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Issue #4760
Closes #5265

8 years agoFix coverity defects: CID 147606, 147609
cao [Wed, 12 Oct 2016 18:16:47 +0000 (02:16 +0800)]
Fix coverity defects: CID 147606, 147609

coverity scan CID:147606, Type:resource leak
coverity scan CID:147609, Type:resource leak

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5245

8 years agoFix coverity defects: CID 147452, 147447, 147446
cao [Tue, 11 Oct 2016 18:32:34 +0000 (02:32 +0800)]
Fix coverity defects: CID 147452, 147447, 147446

coverity scan CID:147452, Type:Unchecked return value from library
coverity scan CID:147447, Type:Unchecked return value from library
coverity scan CID:147446, Type:Unchecked return value from library

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5264

8 years agoFix memory leak in recv_skip
luozhengzheng [Tue, 11 Oct 2016 17:24:18 +0000 (01:24 +0800)]
Fix memory leak in recv_skip

When the exception branch exits, the buf is leaked.

Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5262

8 years agoFix zfsctl_snapshot_{,un}mount() issues
Brian Behlendorf [Tue, 11 Oct 2016 16:56:28 +0000 (09:56 -0700)]
Fix zfsctl_snapshot_{,un}mount() issues

Fix use after free in zfsctl_snapshot_unmount(). Use /usr/bin/env
instead of /bin/sh to fix a shell code injection flaw and allow use
with grsecurity.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov
Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Stian Ellingsen <stian@plaimi.net>
Closes #5250
Closes #4377

8 years agoEnable zfs_snapshot_008_neg and zfs_snapshot_009_pos (#5260)
Brian Behlendorf [Tue, 11 Oct 2016 16:32:31 +0000 (09:32 -0700)]
Enable zfs_snapshot_008_neg and zfs_snapshot_009_pos (#5260)

The zfs_snapshot_008_neg test case does not use nested pools and
can be safely enabled.  The zfs_snapshot_009_pos test case is
also passing without modification.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: ChaoyuZhang <zhang.chaoyu@zte.com.cn>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5260

8 years agoEnable reservation_012_pos, reservation_015_pos and reservation_016_pos
liaoyuxiangqin [Tue, 11 Oct 2016 16:28:49 +0000 (00:28 +0800)]
Enable reservation_012_pos, reservation_015_pos and reservation_016_pos

Enable reservation_012_pos, reservation_015_pos and reservation_016_pos
test cases which are passing.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: yuxiang <guo.yong33@zte.com.cn>
Closes #5254

8 years agoFix coverity defects: CID 147639
GeLiXin [Mon, 10 Oct 2016 22:30:22 +0000 (06:30 +0800)]
Fix coverity defects: CID 147639

When array is passed as a parameter it degenerates into a
pointer so the sizeof(path) in is_shorthand_path() and always
get return value of 8, instead of the string length we want.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: GeLiXin <ge.lixin@zte.com.cn>
Closes #5198

8 years agoWrite issue taskq shouldn't be dynamic
Tim Chase [Mon, 10 Oct 2016 22:19:14 +0000 (17:19 -0500)]
Write issue taskq shouldn't be dynamic

This is as much an upstream compatibility as it's a bit of a performance
gain.

The illumos taskq implemention doesn't allow a TASKQ_THREADS_CPU_PCT type
to be dynamic and in fact enforces as much with an ASSERT.

As to performance, if this taskq is dynamic, it can cause excessive
contention on tq_lock as the threads are created and destroyed because it
can see bursts of many thousands of tasks in a short time, particularly
in heavy high-concurrency zvol write workloads.

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

8 years agoPorting over some ICP code that was missed in #4760
Tom Caputi [Mon, 10 Oct 2016 18:34:57 +0000 (14:34 -0400)]
Porting over some ICP code that was missed in #4760

When #4760 was merged tests were added to ensure that the new checksums
were working properly. However, some of the functionality for sha2
functions were not ported over, resulting in some Coverity defects and
code that would be unstable when needed in the future. This patch
simply ports over the missing code and fixes the defects in the
process.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Issue #4760
Closes #5251

8 years agoEnable readonly_001_pos
ChaoyuZhang [Mon, 10 Oct 2016 00:50:16 +0000 (08:50 +0800)]
Enable readonly_001_pos

Enable readonly_001_pos this test is now passing.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: ChaoyuZhang <zhang.chaoyu@zte.com.cn>
8 years agoFix file permissions
Brian Behlendorf [Sat, 8 Oct 2016 21:57:56 +0000 (14:57 -0700)]
Fix file permissions

The following new test cases need to have execute permissions set:

  userquota/groupspace_003_pos.ksh
  userquota/userquota_013_pos.ksh
  userquota/userspace_003_pos.ksh
  upgrade/upgrade_userobj_001_pos.ksh
  upgrade/setup.ksh
  upgrade/cleanup.ksh

The following source files accidentally were marked executable:

  lib/libzpool/kernel.c
  lib/libshare/nfs.c
  lib/libzfs/libzfs_dataset.c
  lib/libzfs/libzfs_util.c
  tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c
  tests/zfs-tests/cmd/dir_rd_update/dir_rd_update.c
  cmd/zed/zed_exec.c
  module/icp/core/kcf_sched.c
  module/zfs/dsl_pool.c
  module/zfs/arc.c
  module/nvpair/nvpair.c
  man/man5/zfs-module-parameters.5

Reviewed-by: GeLiXin <ge.lixin@zte.com.cn>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5241

8 years agoUse env, not sh in zfsctl_snapshot_{,un}mount()
Stian Ellingsen [Thu, 6 Oct 2016 18:03:41 +0000 (20:03 +0200)]
Use env, not sh in zfsctl_snapshot_{,un}mount()

Call mount and umount via /usr/bin/env instead of /bin/sh in
zfsctl_snapshot_mount() and zfsctl_snapshot_unmount().

This change fixes a shell code injection flaw.  The call to /bin/sh
passed the mountpoint unescaped, only surrounded by single quotes.  A
mountpoint containing one or more single quotes would cause the command
to fail or potentially execute arbitrary shell code.

This change also provides compatibility with grsecurity patches.
Grsecurity only allows call_usermodehelper() to use helper binaries in
certain paths.  /usr/bin/* is allowed, /bin/* is not.

8 years agoFix use after free in zfsctl_snapshot_unmount()
Stian Ellingsen [Thu, 6 Oct 2016 17:53:27 +0000 (19:53 +0200)]
Fix use after free in zfsctl_snapshot_unmount()

8 years agoRename hole_birth tunable to match OpenZFS
Brian Behlendorf [Sat, 8 Oct 2016 04:02:24 +0000 (21:02 -0700)]
Rename hole_birth tunable to match OpenZFS

OpenZFS decided that ignore_hole_birth was too imprecise and
incorrect a name (and went with send_holes_without_birth_time).
Rename it in ZoL too, while keeping the name "ignore_hole_birth"
pointing to the same variable for existing consumers.

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #5239

8 years agoFix vdev_open_child() race on updating vdev_parent->vdev_nonrot
Håkan Johansson [Fri, 7 Oct 2016 20:25:35 +0000 (22:25 +0200)]
Fix vdev_open_child() race on updating vdev_parent->vdev_nonrot

Updating vd->vdev_parent->vdev_nonrot in vdev_open_child()
is a race when vdev_open_child is called for many children
from a task queue.

vdev_open_child() is only called by vdev_open_children(), let
the latter update the parent vdev_nonrot member.  The update
was already there, so done twice previously.  Thus using the
same logic at the end in vdev_open_children() to update
vdev_nonrot, either we are vdev_uses_zvols() or not.

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Haakan T Johansson <f96hajo@chalmers.se>
Closes #5162

8 years agoFix coverity defects: CID 147565-147567
cao [Fri, 7 Oct 2016 20:19:43 +0000 (04:19 +0800)]
Fix coverity defects: CID 147565-147567

coverity scan CID:147567, Type:dereference null return value
coverity scan CID:147566, Type:dereference null return value
coverity scan CID:147565, Type:dereference null return value

Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5166

8 years agoFletcher4: Incremental updates and ctx calculation
Brian Behlendorf [Fri, 7 Oct 2016 19:44:12 +0000 (12:44 -0700)]
Fletcher4: Incremental updates and ctx calculation

Fixes ABI issues with fletcher4 code, adds support for
incremental updates, and adds ztest method for testing.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Closes #5164

8 years agoFix uninitialized variable snapprops_nvlist in zfs_receive_one
LOLi [Fri, 7 Oct 2016 17:05:06 +0000 (19:05 +0200)]
Fix uninitialized variable snapprops_nvlist in zfs_receive_one

The variable snapprops_nvlist was never initialized, so properties
were not applied to the received snapshot.

Additionally, add zfs_receive_013_pos.ksh script to ZFS test suite to exercise
'zfs receive' functionality for user properties.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #4338

8 years agoAdd python style checking
Brian Behlendorf [Fri, 7 Oct 2016 16:54:02 +0000 (09:54 -0700)]
Add python style checking

Introduce a make recipe for flake8 to enable python
style checking. Ensure all python scripts pass flake8.
Return an error code of 0 for arcstat.py -v and
dbufstat.py -v.  Add test cases for python scripts.

Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ian Lee <IanLee1521@gmail.com>
Closes #5230

8 years agoOpenZFS 6988 spa_sync() spends half its time in dmu_objset_do_userquota_updates
Jinshan Xiong [Wed, 21 Sep 2016 20:49:47 +0000 (13:49 -0700)]
OpenZFS 6988 spa_sync() spends half its time in dmu_objset_do_userquota_updates

Using a benchmark which creates 2 million files in one TXG, I observe
that the thread running spa_sync() is on CPU almost the entire time we
are syncing, and therefore can be a performance bottleneck. About 50% of
the time in spa_sync() is in dmu_objset_do_userquota_updates().

The problem is that dmu_objset_do_userquota_updates() calls
zap_increment_int(DMU_USERUSED_OBJECT) once for every file that was
modified (or created). In this benchmark, all the files are owned by the
same user/group, so all 2 million calls to zap_increment_int() are
modifying the same entry in the zap. The same issue exists for the
DMU_GROUPUSED_OBJECT.

We should keep an in-memory map from user to space delta while we are
syncing, and when we finish, iterate over the in-memory map and modify
the ZAP once per entry. This reduces the number of calls to
zap_increment_int() from "number of objects modified" to "number of
owners/groups of modified files".

This reduced the time spent in spa_sync() in the file create benchmark
by ~33%, from 11 seconds to 7 seconds.

Upstream bugs: DLPX-44799
Ported by: Ned Bass <bass6@llnl.gov>

OpenZFS-issue: https://www.illumos.org/issues/6988
ZFSonLinux-issue: https://github.com/zfsonlinux/zfs/issues/4642
OpenZFS-commit: unmerged

Porting notes:
- Added curly braces around declaration of userquota_cache_t cache to
  quiet compiler warning;
- Handled the userobj accounting the same way it proposed in this path.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
8 years agoAdd support for user/group dnode accounting & quota
Jinshan Xiong [Tue, 4 Oct 2016 18:46:10 +0000 (11:46 -0700)]
Add support for user/group dnode accounting & quota

This patch tracks dnode usage for each user/group in the
DMU_USER/GROUPUSED_OBJECT ZAPs. ZAP entries dedicated to dnode
accounting have the key prefixed with "obj-" followed by the UID/GID
in string format (as done for the block accounting).
A new SPA feature has been added for dnode accounting as well as
a new ZPL version. The SPA feature must be enabled in the pool
before upgrading the zfs filesystem. During the zfs version upgrade,
a "quotacheck" will be executed by marking all dnode as dirty.

ZoL-bug-id: https://github.com/zfsonlinux/zfs/issues/3500

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: Johann Lombardi <johann.lombardi@intel.com>
8 years agoIntroduce tests for python scripts
Giuseppe Di Natale [Tue, 4 Oct 2016 22:13:42 +0000 (15:13 -0700)]
Introduce tests for python scripts

Implement tests to ensure that python scripts
that are distributed with ZFS continue to at
minimum run without errors. This will help prevent
accidental breaking of these scripts.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
8 years agoIntroduce a make recipe for flake8
Giuseppe Di Natale [Thu, 6 Oct 2016 17:50:15 +0000 (10:50 -0700)]
Introduce a make recipe for flake8

Add a make recipe to enable developers
to easily run flake8 if it is available.
This will help enforce good python coding
standards.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
8 years agoCorrect exit code for dbufstat -v and arcstat -v
Giuseppe Di Natale [Wed, 5 Oct 2016 15:41:26 +0000 (08:41 -0700)]
Correct exit code for dbufstat -v and arcstat -v

Both scripts were returning an error code of 1
when using the -v argument. -v should exit with
an error code of 0.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
8 years agoAdd icp kernel module to dkms build
Marcel Huber [Thu, 6 Oct 2016 17:31:42 +0000 (19:31 +0200)]
Add icp kernel module to dkms build

Added new section to build icp module.

Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5232
Closes #5234

8 years agoUse a different technique to detect whether to mount-zfs
Rudd-O [Thu, 6 Oct 2016 17:26:47 +0000 (17:26 +0000)]
Use a different technique to detect whether to mount-zfs

The behavior of the Dracut module was very wrong before.

The correct behavior: initramfs should not run `zfs-mount` to completion
if the two generator files exist.  If, however, one of them is missing,
it indicates one of three cases:

* The kernel command line did not specify a root ZFS file system, and
  another Dracut module is already handling root mount (via systemd).
  `mount-zfs` can run, but it will do nothing.
* There is no systemd to run `sysroot.mount` to begin with.
  `mount-zfs` must run.
* The root parameter is zfs:AUTO, which cannot be run in sysroot.mount.
  `mount-zfs` must run.

In any of these three cases, it is safe to run `zfs-mount` to completion.

`zfs-mount` must also delete itself if it determines it should not run,
or else Dracut will do the insane thing of running it over and over again.
Literally, the definition of insanity, doing the same thing that did not
work before, expecting different results.  Doing that may have had a great
result before, when we had a race between devices appearing and pools
being mounted, and `mount-zfs` was tasked with the full responsibility
of importing the needed pool, but nowadays it is wrong behavior and
should be suppressed.

I deduced that self-deletion was the correct thing to do by looking at
other Dracut code, because (as we all are very fully aware of) Dracut
is entirely, ahem, "implementation-defined".

Tested-by: @wphilips
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Manuel Amador (Rudd-O) <rudd-o@rudd-o.com>
Closes #5157
Closes #5204

8 years agoCorrect style in test-runner
Giuseppe Di Natale [Thu, 6 Oct 2016 17:11:06 +0000 (10:11 -0700)]
Correct style in test-runner

Correct test-runner.py so it passes flake8
python style checking.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
8 years agoCorrect style in arcstat and arc_summary
Giuseppe Di Natale [Thu, 6 Oct 2016 17:04:54 +0000 (10:04 -0700)]
Correct style in arcstat and arc_summary

Fix arcstat and arc_summary so they pass
flake8 python code style checks.

Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
8 years agoRefactor updating of immutable/appendonly flags
lorddoskias [Wed, 5 Oct 2016 21:47:29 +0000 (00:47 +0300)]
Refactor updating of immutable/appendonly flags

Move the synchronization of inode/znode i_flgas/pflags into
the respective internal zfs function. This is mostly
mechanical work and shouldn't introduce any functional
changes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Issue #227
Closes #5223

8 years agoFletcher4: save/reload implementation context
Gvozden Neskovic [Sat, 24 Sep 2016 22:56:22 +0000 (00:56 +0200)]
Fletcher4: save/reload implementation context

Init, compute, and fini methods are changed to work on internal context object.
This is necessary because ABI does not guarantee that SIMD registers will be preserved
on function calls. This is technically the case in Linux kernel in between
`kfpu_begin()/kfpu_end()`, but it breaks user-space tests and some kernels that
don't require disabling preemption for using SIMD (osx).

Use scalar compute methods in-place for small buffers, and when the buffer size
does not meet SIMD size alignment.

Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
8 years agoFletcher4: Incremental using SIMD
Gvozden Neskovic [Fri, 23 Sep 2016 01:52:29 +0000 (03:52 +0200)]
Fletcher4: Incremental using SIMD

Combine incrementally computed fletcher4 checksums. Checksums are combined
a posteriori, allowing for parallel computation on chunks to be implemented if
required. The algorithm is general, and does not add changes in each SIMD
implementation.
New test in ztest verifies incremental fletcher computations.

Checksum combining matrix for two buffers `a` and `b`, where `Ca` and `Cb` are
respective fletcher4 checksums, `Cab` is combined checksum, `s` is size of buffer
`b` (divided by sizeof(uint32_t)) is:

Cab[A] = Cb[A] + Ca[A]
Cab[B] = Cb[B] + Ca[B] + s * Ca[A]
Cab[C] = Cb[C] + Ca[C] + s * Ca[B] + s(s+1)/2 * Ca[A]
Cab[D] = Cb[D] + Ca[D] + s * Ca[C] + s(s+1)/2 * Ca[B] + s(s+1)(s+2)/6 * Ca[A]

NOTE: this calculation overflows for larger buffers. Thus, internally, the calculation
is performed on 8MiB chunks.

Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
8 years agoFix coverity defects: CID 150953, 147603, 147610
luozhengzheng [Wed, 5 Oct 2016 01:15:57 +0000 (09:15 +0800)]
Fix coverity defects: CID 150953, 147603, 147610

coverity scan CID:150953,type: uninitialized scalar variable
coverity scan CID:147603,type: Resource leak
coverity scan CID:147610,type: Resource leak

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5209

8 years agoMerge OpenZFS 4185
Brian Behlendorf [Tue, 4 Oct 2016 18:20:38 +0000 (11:20 -0700)]
Merge OpenZFS 4185

OpenZFS 4185 - add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: David Quigley <david.quigley@intel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #4760

8 years agozloop: check if core file is generated by zdb
Gvozden Neskovic [Mon, 3 Oct 2016 22:42:13 +0000 (00:42 +0200)]
zloop: check if core file is generated by zdb

Run `gdb` core file inspection with correct program.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Closes #5215

8 years agoUse 100MB pool for filetest_001_pos.ksh checksum test
Tony Hutter [Mon, 15 Aug 2016 23:34:02 +0000 (19:34 -0400)]
Use 100MB pool for filetest_001_pos.ksh checksum test

As part of its tests, filetest_001_pos.ksh wipes the entire vdev to
create checksum errors.  This patch uses the setup/cleanup scripts from
the scrub_mirror test to create a custom 100MB pool, rather than
using the entire device size that is passed into zfs-tests.sh
(which defaults to 2GB).  This speeds up the buildbot tests, and also
makes it possible for someone to use real disks (say, 1TB) without the
test taking an insanely long amount of time.

8 years agoOpenZFS 6585 - sha512, skein, and edonr have an unenforced dependency on extensible...
ilovezfs [Thu, 28 Jan 2016 12:51:19 +0000 (04:51 -0800)]
OpenZFS 6585 - sha512, skein, and edonr have an unenforced dependency on extensible dataset

Authored by: ilovezfs <ilovezfs@icloud.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Ported by: Tony Hutter <hutter2@llnl.gov>

In any pool without the extensible dataset feature flag already enabled,
creating a dataset with dedup set to use one of the new checksums would
result in the following panic as soon as any data was added:

panic[cpu0]/thread=ffffff0006761c40: feature_get_refcount(spa, feature,
&refcount) != 48 (0x30 != 0x30), file: ../../common/fs/zfs/zfeature.c
line 390

Inpsection showed that feature->fi_feature was 7, which is the value of
SPA_FEATURE_EXTENSIBLE_DATASET in the spa_feature enum.  This commit
adds extensible dataset as a dependency for the sha512, edonr, and skein
feature flags, which prevents the panic.

OpenZFS-issue: https://www.illumos.org/issues/6585
OpenZFS-commit: https://github.com/illumos/illumos-gate/commit/892586e8a147c02d7f4053cc405229a13e796928
Porting Notes:
This code was originally from Illumos, but I actually ported it from:
openzfsonosx/zfs@b62a652

8 years agoOpenZFS 6541 - Pool feature-flag check defeated if "verify" is included in the dedup...
ilovezfs [Tue, 26 Jan 2016 07:41:11 +0000 (23:41 -0800)]
OpenZFS 6541 - Pool feature-flag check defeated if "verify" is included in the dedup property value

Authored by: ilovezfs <ilovezfs@icloud.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Ported-by: Tony Hutter <hutter2@llnl.gov>
zio_checksum_to_feature() expects a zio_checksum enum not a raw property
intval, so the new checksums weren't being detected when the
ZIO_CHECKSUM_VERIFY flag got in the way.

Given a pool without feature@sha512,

    zfs create -o dedup=sha512 naughty/fivetwelve_noverify_ds

would fail as expected since the raw intval would indeed be equal to
SPA_FEATURE_SHA512.

However,

    zfs create -o dedup=sha512,verify naughty/fivetwelve_verify_ds

would incorrectly succeed because ZIO_CHECKSUM_VERIFY would be in the
way, the raw intval would not be a member of the enum, and
zio_checksum_to_feature() would return SPA_FEATURE_NONE, with the result
that spa_feature_is_enabled() would never be called.

This was first detected with edonr, since in that case verify is
required.

This commit clears the ZIO_CHECKSUM_VERIFY flag before calling
zio_checksum_to_feature() using the ZIO_CHECKSUM_MASK and verifies in
zio_checksum_to_feature() that ZIO_CHECKSUM_MASK has been applied by the
caller to attempt to prevent the same bug from occurring again in the
future.

OpenZFS-issue: https://www.illumos.org/issues/6541
OpenZFS-commit: https://github.com/illumos/illumos-gate/commit/971640e6aa954c91b0706543741aa4570299f4d7

Porting notes:
This code was originally from Illumos, but I actually ported it from:
openzfsonosx/zfs@bef06e1

8 years agoOpenZFS 4185 - add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R
Tony Hutter [Wed, 15 Jun 2016 22:47:05 +0000 (15:47 -0700)]
OpenZFS 4185 - add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R

Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported by: Tony Hutter <hutter2@llnl.gov>

OpenZFS-issue: https://www.illumos.org/issues/4185
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/45818ee

Porting Notes:
This code is ported on top of the Illumos Crypto Framework code:

    https://github.com/zfsonlinux/zfs/pull/4329/commits/b5e030c8dbb9cd393d313571dee4756fbba8c22d

The list of porting changes includes:

- Copied module/icp/include/sha2/sha2.h directly from illumos

- Removed from module/icp/algs/sha2/sha2.c:
#pragma inline(SHA256Init, SHA384Init, SHA512Init)

- Added 'ctx' to lib/libzfs/libzfs_sendrecv.c:zio_checksum_SHA256() since
  it now takes in an extra parameter.

- Added CTASSERT() to assert.h from for module/zfs/edonr_zfs.c

- Added skein & edonr to libicp/Makefile.am

- Added sha512.S.  It was generated from sha512-x86_64.pl in Illumos.

- Updated ztest.c with new fletcher_4_*() args; used NULL for new CTX argument.

- In icp/algs/edonr/edonr_byteorder.h, Removed the #if defined(__linux) section
  to not #include the non-existant endian.h.

- In skein_test.c, renane NULL to 0 in "no test vector" array entries to get
  around a compiler warning.

- Fixup test files:
- Rename <sys/varargs.h> -> <varargs.h>, <strings.h> -> <string.h>,
- Remove <note.h> and define NOTE() as NOP.
- Define u_longlong_t
- Rename "#!/usr/bin/ksh" -> "#!/bin/ksh -p"
- Rename NULL to 0 in "no test vector" array entries to get around a
  compiler warning.
- Remove "for isa in $($ISAINFO); do" stuff
- Add/update Makefiles
- Add some userspace headers like stdio.h/stdlib.h in places of
  sys/types.h.

- EXPORT_SYMBOL *_Init/*_Update/*_Final... routines in ICP modules.

- Update scripts/zfs2zol-patch.sed

- include <sys/sha2.h> in sha2_impl.h

- Add sha2.h to include/sys/Makefile.am

- Add skein and edonr dirs to icp Makefile

- Add new checksums to zpool_get.cfg

- Move checksum switch block from zfs_secpolicy_setprop() to
  zfs_check_settable()

- Fix -Wuninitialized error in edonr_byteorder.h on PPC

- Fix stack frame size errors on ARM32
   - Don't unroll loops in Skein on 32-bit to save stack space
   - Add memory barriers in sha2.c on 32-bit to save stack space

- Add filetest_001_pos.ksh checksum sanity test

- Add option to write psudorandom data in file_write utility

8 years agoFletcher4: Init in libzfs_init()
Gvozden Neskovic [Sun, 25 Sep 2016 08:35:12 +0000 (10:35 +0200)]
Fletcher4: Init in libzfs_init()

All users of fletcher4 methods must call `fletcher_4_init()/_fini()`
There's no benchmarking overhead when called from user-space.

Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
8 years agoAdd parity generation/rebuild using 128-bits NEON for Aarch64
Romain Dolbeau [Mon, 3 Oct 2016 16:44:00 +0000 (18:44 +0200)]
Add parity generation/rebuild using 128-bits NEON for Aarch64

This re-use the framework established for SSE2, SSSE3 and
AVX2. However, GCC is using FP registers on Aarch64, so
unlike SSE/AVX2 we can't rely on the registers being left alone
between ASM statements. So instead, the NEON code uses
C variables and GCC extended ASM syntax. Note that since
the kernel explicitly disable vector registers, they
have to be locally re-enabled explicitly.

As we use the variable's number to define the symbolic
name, and GCC won't allow duplicate symbolic names,
numbers have to be unique. Even when the code is not
going to be used (e.g. the case for 4 registers when
using the macro with only 2). Only the actually used
variables should be declared, otherwise the build
will fails in debug mode.

This requires the replacement of the XOR(X,X) syntax
by a new ZERO(X) macro, which does the same thing but
without repeating the argument. And perhaps someday
there will be a machine where there is a more efficient
way to zero a register than XOR with itself. This affects
scalar, SSE2, SSSE3 and AVX2 as they need the new macro.

It's possible to write faster implementations (different
scheduling, different unrolling, interleaving NEON and
scalar, ...) for various cores, but this one has the
advantage of fitting in the current state of the code,
and thus is likely easier to review/check/merge.

The only difference between aarch64-neon and aarch64-neonx2
is that aarch64-neonx2 unroll some functions some more.

Reviewed-by: Gvozden Neskovic <neskovic@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Romain Dolbeau <romain.dolbeau@atos.net>
Closes #4801

8 years agoCorrect zpool_vdev_remove() error message
Richard Laager [Sun, 2 Oct 2016 18:34:17 +0000 (13:34 -0500)]
Correct zpool_vdev_remove() error message

The error message in zpool_vdev_remove() said top-level devices
could be removed, but that has never been true.

Reported-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #4506
Closes #5213

8 years agoFix coverity defects: CID 147448, 147449, 147450, 147453, 147454
luozhengzheng [Sun, 2 Oct 2016 18:24:54 +0000 (02:24 +0800)]
Fix coverity defects: CID 147448, 147449, 147450, 147453, 147454

coverity scan CID:147448,type: unchecked return value
coverity scan CID:147449,type: unchecked return value
coverity scan CID:147450,type: unchecked return value
coverity scan CID:147453,type: unchecked return value
coverity scan CID:147454,type: unchecked return value

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5206

8 years agoFix NULL deref in kcf_remove_mech_provider
candychencan [Fri, 30 Sep 2016 23:04:43 +0000 (07:04 +0800)]
Fix NULL deref in kcf_remove_mech_provider

In the default case the function must return to avoid dereferencing
'prov_mech' which will be NULL.

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: candychencan <chen.can2@zte.com.cn>
Closes #5134

8 years agoFix coverity defects: CID 147563, 147560
cao [Fri, 30 Sep 2016 22:56:17 +0000 (06:56 +0800)]
Fix coverity defects: CID 147563, 147560

coverity scan CID:147563, Type:dereference null return value
coverity scan CID:147560, Type:dereference null return value

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5168

8 years agoFix coverity defects: CID 147531 147532 147533 147535
GeLiXin [Fri, 30 Sep 2016 22:47:57 +0000 (06:47 +0800)]
Fix coverity defects: CID 147531 147532 147533 147535

coverity scan CID:147531,type: Argument cannot be negative
- may copy data with negative size
coverity scan CID:147532,type: resource leaks
- may close a fd which is negative
coverity scan CID:147533,type: resource leaks
- may call pwrite64 with a negative size
coverity scan CID:147535,type: resource leaks
- may call fdopen with a negative fd

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: GeLiXin <ge.lixin@zte.com.cn>
Closes #5176

8 years agoFix coverity defects: CID 147536, 147537, 147538
GeLiXin [Fri, 30 Sep 2016 22:40:07 +0000 (06:40 +0800)]
Fix coverity defects: CID 147536, 147537, 147538

coverity scan CID:147536, type: Argument cannot be negative
- may write or close fd which is negative
coverity scan CID:147537, type: Argument cannot be negative
- may call dup2 with a negative fd
coverity scan CID:147538, type: Argument cannot be negative
- may read or fchown with a negative fd

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: GeLiXin <ge.lixin@zte.com.cn>
Closes #5185

8 years agoraidz_test: respect wall time
Gvozden Neskovic [Fri, 30 Sep 2016 22:19:51 +0000 (00:19 +0200)]
raidz_test: respect wall time

When timeout is specified (-t), stop worker threads in the middle of work units.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Issue #5180
Closes #5190

8 years agoFix cppcheck warning in buf_init()
Brian Behlendorf [Fri, 30 Sep 2016 22:04:21 +0000 (15:04 -0700)]
Fix cppcheck warning in buf_init()

Cppcheck 1.63 erroneously complains about an uninitialized value
in buf_init().  Newer versions of cppcheck (1.72) handle this
correctly but we'll initialize the value anyway to silence the
warning.

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5203

8 years agoDisable zpool_import_002_pos and ro_props_001_pos
Brian Behlendorf [Fri, 30 Sep 2016 19:12:53 +0000 (12:12 -0700)]
Disable zpool_import_002_pos and ro_props_001_pos

These test cases fail some percentage of the time resulting
in automated testing failures.  Disable the offending tests
until they can be made reliable.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #5201
Issue #5202
Closes #5194

8 years agoFix coverity defects: CID 147707
cao [Fri, 30 Sep 2016 17:49:16 +0000 (01:49 +0800)]
Fix coverity defects: CID 147707

coverity scan CID:147707, Type:Double free.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5097

8 years agoAdd a script to change file names when upstreaming to OpenZFS/illumos
Matthew Ahrens [Fri, 30 Sep 2016 04:01:50 +0000 (21:01 -0700)]
Add a script to change file names when upstreaming to OpenZFS/illumos

Add a script to change file names when upstreaming to OpenZFS/illumos.

Reviewed-by: Reviewed by: Prashanth Sreenivasa <prashksp@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Ahrens <mahrens@delphix.com>
Closes #5178

8 years agoAvoid undefined shift overflow in fzap_cursor_retrieve()
Gvozden Neskovic [Fri, 2 Sep 2016 13:10:34 +0000 (15:10 +0200)]
Avoid undefined shift overflow in fzap_cursor_retrieve()

Avoid calculating (1<<64) if lh_prefix_len == 0. Semantics of the method remain
the same.

Assert (lh_prefix_len > 0) in zap_expand_leaf() to detect possibly the same
problem.

Issue #4883

Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
8 years agoExplicit integer promotion for bit shift operations
Gvozden Neskovic [Fri, 2 Sep 2016 13:07:00 +0000 (15:07 +0200)]
Explicit integer promotion for bit shift operations

Explicitly promote variables to correct type. Undefined behavior is
reported because length of int is not well defined by C standard.

Issue #4883

Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
8 years agofix: Shift exponent too large
Gvozden Neskovic [Wed, 31 Aug 2016 08:12:08 +0000 (10:12 +0200)]
fix: Shift exponent too large

Undefined operation is reported by running ztest (or zloop) compiled with GCC
UndefinedBehaviorSanitizer. Error only happens on top level of dnode indirection
with large enough offset values. Logically, left shift operation would work,
but bit shift semantics in C, and limitation of uint64_t, do not produce desired
result.

Issue #5059, #4883

Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
8 years agoFix coverity defects: CID 147443, 147656, 147655, 147441, 147653
BearBabyLiu [Thu, 29 Sep 2016 20:33:09 +0000 (04:33 +0800)]
Fix coverity defects: CID 147443, 147656, 147655, 147441, 147653

coverity scan CID:147443, Type: Buffer not null terminated
coverity scan CID:147656, Type: Copy into fixed size buffer
coverity scan CID:147655, Type: Copy into fixed size buffer
coverity scan CID:147441, Type: Buffer not null terminated
coverity scan CID:147653, Type: Copy into fixed size buffer

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: liuhuang <liu.huang@zte.com.cn>
Closes #5165

8 years agoExplicit block device plugging when submitting multiple BIOs
Isaac Huang [Thu, 29 Sep 2016 20:13:31 +0000 (14:13 -0600)]
Explicit block device plugging when submitting multiple BIOs

Without plugging, the default 'noop' scheduler will not merge
the BIOs which are part of a large ZIO.

Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Isaac Huang <he.huang@intel.com>
Closes #5181

8 years agoFix zfs_clone_010_pos.ksh to verify zfs clones property displays right
liaoyuxiangqin [Thu, 29 Sep 2016 20:08:44 +0000 (04:08 +0800)]
Fix zfs_clone_010_pos.ksh to verify zfs clones property displays right

Because the macro ZFS_MAXPROPLEN used in function print_dataset
differs between platforms set it appropriately and calculate the expected
number of passes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: yuxiang <guo.yong33@zte.com.cn>
Closes #5154

8 years agoEnable ro_props_001_pos and onoffs_001_pos
ChaoyuZhang [Thu, 29 Sep 2016 19:56:48 +0000 (03:56 +0800)]
Enable ro_props_001_pos and onoffs_001_pos

Enable ro_props_001_pos and onoffs_001_pos which pass reliably.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: ChaoyuZhang <zhang.chaoyu@zte.com.cn>
Closes #5183

8 years agoFix zfs_clone_010_pos.ksh to verify the space used by multiple copies
liaoyuxiangqin [Thu, 29 Sep 2016 19:46:13 +0000 (03:46 +0800)]
Fix zfs_clone_010_pos.ksh to verify the space used by multiple copies

The default blocksize in Linux is 1024 due to a GNU-ism.  Setting the
expected blocksize resolves the issue.  As mentioned in the PR an
alternate solution would be to set POSIXLY_CORRECT=1.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: yuxiang <guo.yong33@zte.com.cn>
Closes #5167

8 years agoFix coverity defects: CID 147610, 147608, 147607
cao [Thu, 29 Sep 2016 19:11:44 +0000 (03:11 +0800)]
Fix coverity defects: CID 147610, 147608, 147607

coverity scan CID:147610, Type: Resource leak.
coverity scan CID:147608, Type: Resource leak.
coverity scan CID:147607, Type: Resource leak.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5143

8 years agoFix coverity defects: 147658, 147652, 147651
cao [Thu, 29 Sep 2016 19:06:14 +0000 (03:06 +0800)]
Fix coverity defects: 147658, 147652, 147651

coverity scan CID:147658, Type:copy into fixed size buffer.
coverity scan CID:147652, Type:copy into fixed size buffer.
coverity scan CID:147651, Type:copy into fixed size buffer.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5160

8 years agoRefactor inode->i_mode management
lorddoskias [Tue, 27 Sep 2016 21:08:52 +0000 (00:08 +0300)]
Refactor inode->i_mode management

Refactor the code in such a way so that inode->i_mode is being set
at the same time zp->z_mode is being changed. This has the effect of
keeping both in sync without relying on zfs_inode_update.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Closes #5158

8 years agoEnable property_alias_001_pos.ksh
candychencan [Tue, 27 Sep 2016 18:49:45 +0000 (02:49 +0800)]
Enable property_alias_001_pos.ksh

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: candychencan <chen.can2@zte.com.cn>
Closes #5175

8 years agoFix coverity defects: CID 147650, 147649, 147647, 147646
cao [Sun, 25 Sep 2016 22:08:28 +0000 (06:08 +0800)]
Fix coverity defects: CID 147650, 147649, 147647, 147646

coverity scan CID:147650, Type:copy into fixed size buffer.
coverity scan CID:147649, Type:copy into fixed size buffer.
coverity scan CID:147647, Type:copy into fixed size buffer.
coverity scan CID:147646, Type:copy into fixed size buffer.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5161

8 years agoFix coverity defects: CID 147602 147604
cao [Fri, 23 Sep 2016 22:43:46 +0000 (06:43 +0800)]
Fix coverity defects: CID 147602 147604

coverity scan CID:147604, Type: Resource leak.
coverity scan CID:147602, Type: Resource leak.
reason: safe_malloc calcvs, goto children but not free calcvs.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5155

8 years agoFix multilist_create() memory leak
Brian Behlendorf [Fri, 23 Sep 2016 17:55:10 +0000 (10:55 -0700)]
Fix multilist_create() memory leak

In arc_state_fini() the `arc_l2c_only->arcs_list[*]` multilists
must be destroyed.  This accidentally regressed in d3c2ae1c.

Reviewed by: Tom Caputi <tcaputi@datto.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #5151
Closes #5152

8 years agoFix coverity defects: CID 147613 147614 147616 147617
luozhengzheng [Fri, 23 Sep 2016 16:10:50 +0000 (00:10 +0800)]
Fix coverity defects: CID 147613 147614 147616 147617

coverity scan CID:147617,type: resource leaks
coverity scan CID:147616,type: resource leaks
coverity scan CID:147614,type: resource leaks
coverity scan CID:147613,type: resource leaks

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5150

8 years agoLinux 4.7 compat: Fix deadlock during lookup on case-insensitive
tuxoko [Fri, 23 Sep 2016 02:09:16 +0000 (19:09 -0700)]
Linux 4.7 compat: Fix deadlock during lookup on case-insensitive

We must not use d_add_ci if the dentry already has the real name. Otherwise,
d_add_ci()->d_alloc_parallel() will find itself on the lookup hash and wait
on itself causing deadlock.

Tested-by: satmandu
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #5124
Closes #5141
Closes #5147
Closes #5148

8 years agoOpenZFS 6111 - zfs send should ignore datasets created after the ending snapshot
kernelOfTruth aka. kOT, Gentoo user [Fri, 23 Sep 2016 00:22:37 +0000 (02:22 +0200)]
OpenZFS 6111 - zfs send should ignore datasets created after the ending snapshot

Authored by: Alex Deiter <alex.deiter@gmail.com>
Reviewed by: Alex Aizman alex.aizman@nexenta.com
Reviewed by: Alek Pinchuk alek.pinchuk@nexenta.com
Reviewed by: Roman Strashkin roman.strashkin@nexenta.com
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: kernelOfTruth <kerneloftruth@gmail.com>
OpenZFS-issue: https://www.illumos.org/issues/6111
OpenZFS-commit: https://github.com/illumos/illumos-gate/commit/4a20c933
Closes #5110

Porting notes:

There were changes from upstream due to the following commits:
- zfs send -p send properties only for snapshots that are actually sent
  https://github.com/zfsonlinux/zfs/commit/057485504e3a4502c265813ab58e9ec8ffc2a3be
- Produce a full snapshot list for zfs send -p
  https://github.com/zfsonlinux/zfs/commit/e890dd85a7522730ad46daf68150aafd3952d0c1
- Implement zfs_ioc_recv_new() for OpenZFS 2605
  https://github.com/zfsonlinux/zfs/commit/43e52eddb13d8accbd052fac9a242ce979531aa4
- OpenZFS 6314 - buffer overflow in dsl_dataset_name
  ZFS_MAXNAMELEN was changed to the now used ZFS_MAX_DATASET_NAME_LEN since
  https://github.com/zfsonlinux/zfs/commit/eca7b76001a7d33f78bd98884aef8325bdbf98e7

8 years agoOpenZFS 7230 - add assertions to dmu_send_impl() to verify that stream includes BEGIN...
kernelOfTruth aka. kOT, Gentoo user [Thu, 22 Sep 2016 23:01:19 +0000 (01:01 +0200)]
OpenZFS 7230 - add assertions to dmu_send_impl() to verify that stream includes BEGIN and END records

Authored by: Matt Krantz <matt.krantz@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Robert Mustacchi <rm@joyent.com>
Ported-by: kernelOfTruth <kerneloftruth@gmail.com>
OpenZFS-issue: https://www.illumos.org/issues/7230
OpenZFS-commit: https://github.com/illumos/illumos-gate/commit/12b90ee2
Closes #5112

8 years agoFix coverity defects
luozhengzheng [Thu, 22 Sep 2016 22:55:41 +0000 (06:55 +0800)]
Fix coverity defects

1.coverity scan CID:147445 function zfs_do_send in zfs_main.c
Buffer not null terminated (BUFFER_SIZE_WARNING)

2.coverity scan CID:147443 function zfs_do_bookmark in zfs_main.c
Buffer not null terminated (BUFFER_SIZE_WARNING)

3.coverity scan CID:147660 function main in zinject.c
Passing string argv[0] of unknown size to strcpy
By the way, the leak of g_zfs is fixed.

4.coverity scan CID: 147442 function make_disks in zpool_vdev.c
Buffer not null terminated (BUFFER_SIZE_WARNING)

5.coverity scan CID: 147661 function main in dir_rd_update.c
passing string cp1 of unknown size to strcpy

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5130

8 years agoUpdate zfs destroy test scripts
cao [Thu, 22 Sep 2016 22:28:34 +0000 (06:28 +0800)]
Update zfs destroy test scripts

Update and enable zfs_destroy_0[08-13]_*.ksh.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5068

8 years agoFix coverity defects
luozhengzheng [Thu, 22 Sep 2016 01:09:00 +0000 (09:09 +0800)]
Fix coverity defects

coverity scan CID:147633,type: sizeof not portable
coverity scan CID:147637,type: sizeof not portable
coverity scan CID:147638,type: sizeof not portable
coverity scan CID:147640,type: sizeof not portable

In these particular cases sizeof (XX **) happens to be equal to sizeof (X *),
but this is not a portable assumption.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5144

8 years agoFix zfs_destroy_001_pos.ksh
candychencan [Wed, 21 Sep 2016 20:51:53 +0000 (04:51 +0800)]
Fix zfs_destroy_001_pos.ksh

Due to how the Linux VFS was designed busy mount points
cannot be destroyed even when given the force option.  Update
the zfs_destroy_001_pos test case to expect this behavior when
running under Linux.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: candychencan <chen.can2@zte.com.cn>
Closes #5132

8 years agoFix automatically generated release number
Brian Behlendorf [Wed, 21 Sep 2016 20:45:21 +0000 (13:45 -0700)]
Fix automatically generated release number

When building from the head of a branch a release number is
automatically generated with `git describe` using the last tag
on that branch as the base.  For this to work the last tag on the
branch needs to be predictable given the current META file.

This logic was accidentally broken when an -rcX tag was added to
the branch.  Update it to search for a VERSION or VERSION-RELEASE
tag.

Reviewed-by: Chris Siebenmann <cks.git01@cs.toronto.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #5105
Closes #5140

8 years agoReduce noise in tracing logs
Isaac Huang [Wed, 21 Sep 2016 20:37:20 +0000 (14:37 -0600)]
Reduce noise in tracing logs

dbuf_read_impl() returns (SET_ERROR(err)) when err can be 0, which adds
lots of noise in tracing logs.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Isaac Huang <he.huang@intel.com>
Closes #4430
Closes #5146

8 years agoFix regression that broke dracut initramfs generation
Moritz Maxeiner [Wed, 21 Sep 2016 20:35:16 +0000 (22:35 +0200)]
Fix regression that broke dracut initramfs generation

Based upon @ryao's initial fix for 1c73494394fc9de9283b3fd4f00bcdf4bd300a7
5e9843405f63fdabe76e87b92b81a127d488abc7 ) this one also uses
`command -v` instead of `type`, but additionally only applies the
fix to close zfsonlinux/zfs#4749 when `libgcc_s.so.1` has not been included
by dracut automatically (verified by whether `zpool` links directly to
`libgcc_s.so`), as well as change the fallback option to match `libgcc_s.so*`.

Tested-by: Ben Jencks <ben@bjencks.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Moritz Maxeiner <moritz@ucworks.org>
Closes #5089
Closed #5138

8 years agoFix coverity defects
BearBabyLiu [Wed, 21 Sep 2016 02:09:22 +0000 (10:09 +0800)]
Fix coverity defects

coverity scan CID:147504 Type: Explicit null dereferenced
Reason: passing null pointer dl to zfs_dirent_unlock

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: BearBabyLiu <liu.huang@zte.com.cn>
Closes #5131

8 years agoRemove script zfs_commands.cfg
legend-hua [Wed, 21 Sep 2016 01:36:24 +0000 (09:36 +0800)]
Remove script zfs_commands.cfg

zfs_commands.cfg have printed "No such file or directory", When executing
script/zfs-test.sh. The script is a symlink to ../../../zfs-script-config.sh
So delete the symlink, and directly source $SRCDIR/zfs-script-config.sh
when it exists from default.cfg.in

Reviewed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: legend-hua <liu.hua130@zte.com.cn>
Closes #5133

8 years agoFix coverity defects
cao [Wed, 21 Sep 2016 00:45:45 +0000 (08:45 +0800)]
Fix coverity defects

Fix coverity defects:
coverity scan CID:147623, Type: Resource leak.
coverity scan CID:147622, Type: Resource leak.
reason: zpool_open zhp, but not zpool_close zhp. so resource leak.

coverity scan CID:147621, Type: Resource fd leak.
coverity scan CID:147620, Type: Resource fd leak.
reason: do_write do_read open file fd,but exception not close fd.

delete unuse definition DMU_OS_IS_L2COMPRESSIBLE.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5137

8 years agoFix strncpy in taskq_create
candychencan [Tue, 20 Sep 2016 18:27:15 +0000 (02:27 +0800)]
Fix strncpy in taskq_create

Assign the copy length to TASKQ_NAMELEN, so if the name length equals
'TASKQ_NAMELEN+1' , the final '\0' of tq->tq_name is preserved.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: candychencan <chen.can2@zte.com.cn>
Closes #5136

8 years agoChange /etc/mtab to /proc/self/mounts
slashdd [Tue, 20 Sep 2016 17:07:58 +0000 (13:07 -0400)]
Change /etc/mtab to /proc/self/mounts

Fix misleading error message:

 "The /dev/zfs device is missing and must be created.", if /etc/mtab is missing.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com>
Closes #4680
Closes #5029

8 years agoFix arc_adjust_meta_balanced()
Tim Chase [Mon, 19 Sep 2016 16:28:35 +0000 (11:28 -0500)]
Fix arc_adjust_meta_balanced()

The type of "adjustmnt" was erroneously changed to unsigned when the compressed
ARC code was ported in d3c2ae1c0806b183a315e3d43cc8018cfdca79b5.

As a result of it being unsigned, the balanced metadata eviction logic
would evict all of the non-metadata.

Reviewed-by: Chris Severance <github.severach@spamgourmet.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: David Quigley <david.quigley@intel.com>
Signed-off-by: Tim Chase <tim@onlight.com>
Closes #5128
Closes #5129

8 years agoFix FALLOC_FL_PUNCH_HOLE use in randfree_file.c
legend-hua [Sat, 17 Sep 2016 22:20:10 +0000 (06:20 +0800)]
Fix FALLOC_FL_PUNCH_HOLE use in randfree_file.c

The FALLOC_FL_PUNCH_HOLE flag was introduced in the 2.6.38
kernel.  To prevent breaking the build on older systems wrap its use
in a conditional.  When FALLOC_FL_PUNCH_HOLE isn't available
return a non-zero status and error message.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: legend-hua <liu.hua130@zte.com.cn>
Closes #5101

8 years agoFix Coverity defects
luozhengzheng [Sat, 17 Sep 2016 22:08:54 +0000 (06:08 +0800)]
Fix Coverity defects

CID 147659, 150952 and 147645

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: luozhengzheng <luo.zhengzheng@zte.com.cn>
Closes #5103

8 years agoEnable ignore_hole_birth module option by default
Brian Behlendorf [Fri, 16 Sep 2016 21:05:30 +0000 (14:05 -0700)]
Enable ignore_hole_birth module option by default

Enable ignore_hole_birth by default until all known hole birth bugs
have been resolved and relevant test cases added.

Reviewed-by: Boris Protopopov <boris.protopopov@actifio.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4809
Closes #5099

8 years agoDisable zpool_upgrade_004_pos test case
Brian Behlendorf [Fri, 16 Sep 2016 20:25:46 +0000 (13:25 -0700)]
Disable zpool_upgrade_004_pos test case

This test cause frequently triggers issue #4034.  Disable this
test case until the root cause of this issue has been addressed.

Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #4034
Closes #5120

8 years agoSimplify time handling logic in zfs_settattr
Nikolay Borisov [Mon, 12 Sep 2016 19:35:56 +0000 (22:35 +0300)]
Simplify time handling logic in zfs_settattr

Simplify time handling in zfs_setattr by mimicking the logic in
setattr_copy from the linux kernel. In order to achieve this
in the case when ZFS' log is being replayed it is necessary
to unconditionally set the ctime in zfs_replay_setattr.

Also use the timespec_trunc function when assigning values to the
generic inode struct. This is currently a noop since zfs sets
s_time_gran to 1, however in the future rules about precision might
change.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Closes #4916

8 years agoRefactor generic inode time updating
Nikolay Borisov [Mon, 1 Aug 2016 20:02:25 +0000 (23:02 +0300)]
Refactor generic inode time updating

ZFS doesn't provide a custom update_time method meaning it delegates
this job to the generic VFS layer. The only time when it needs to
set the various *time values is when the inode is being marshalled
to/from the disk. Do this by moving the relevant code from
zfs_inode_update_impl to zfs_node_alloc and zfs_rezget. As a result
from this change it is no longer necessary to have multiple versions
of the zfs_inode_update function - so just nuke them and leave only
one.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Issue #227
Closes #4916

8 years agoDLPX-44733 combine arc_buf_alloc_impl() with arc_buf_clone()
Dan Kimmel [Wed, 13 Jul 2016 21:17:41 +0000 (17:17 -0400)]
DLPX-44733 combine arc_buf_alloc_impl() with arc_buf_clone()

Authored by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Tom Caputi <tcaputi@datto.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported by: David Quigley <david.quigley@intel.com>
Issue #5078