mirror_spl.git
11 months agoPrepare SPL repo to merge with ZFS repo master
Brian Behlendorf [Thu, 15 Feb 2018 01:01:15 +0000 (17:01 -0800)]
Prepare SPL repo to merge with ZFS repo

This commit removes everything from the repository except the core
SPL implementation for Linux.  Those files which remain have been
moved to non-conflicting locations to facilitate the merge.
The README.md and associated files have been updated accordingly.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
12 months agoUpdate README: run autogen first
Matthew Ahrens [Mon, 7 May 2018 17:12:25 +0000 (10:12 -0700)]
Update README: run autogen first

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #704

12 months agoFix undefined RPM macros
Brian Behlendorf [Wed, 2 May 2018 22:34:20 +0000 (15:34 -0700)]
Fix undefined RPM macros

Always invoke the SPL_AC_DEBUG* macro's when running configure
so RPM_DEFINE_COMMON is correctly expanded.  A similar change
was already applied to ZFS.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #703

13 months agoExclude python scripts from RPM shebang check
Tony Hutter [Mon, 16 Apr 2018 22:40:14 +0000 (15:40 -0700)]
Exclude python scripts from RPM shebang check

The newest Fedora packaging rules print warnings for scripts using the
/usr/bin/python shebang:

  *** WARNING: mangling shebang in /usr/src/spl-0.7.0/cmd/splslab/splslab.py
  from #!/usr/bin/python to #!/usr/bin/python2. This will become an ERROR,
  fix it manually!

Fedora wants all cross compatible scripts to pick python3.  Since we
don't want our users to have to pick a specific version of python, we
exclude our scripts from the RPM build check.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes: #699
Closes: #700

13 months agoLinux compat 4.16: SECTOR_SIZE
Giuseppe Di Natale [Tue, 10 Apr 2018 00:20:06 +0000 (17:20 -0700)]
Linux compat 4.16: SECTOR_SIZE

As of https://github.com/torvalds/linux/commit/233bde21,
SECTOR_SIZE is defined in linux/blkdev.h. Define SECTOR_SIZE
in sunldi.h only if it's not already defined.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Closes #697

13 months agoRemove sysevents
Brian Behlendorf [Wed, 4 Apr 2018 16:54:20 +0000 (09:54 -0700)]
Remove sysevents

These headers are provided in the ZFS repository and never used
by the SPL.  Remove them to ensure the right ones are included.

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

14 months agoFix spl-kmod builds when using rpm >= 4.14
LOLi [Fri, 9 Mar 2018 21:51:31 +0000 (22:51 +0100)]
Fix spl-kmod builds when using rpm >= 4.14

With rpm-software-management/rpm@5e94633 a package version containing
invalid characters (most commonly a double '-') causes the kmod package
generation to terminate with an error.  This change takes advantage of
the newly introduced rpm macro "_wrong_version_format_terminate_build"
to allow kmod packages to be built.

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

14 months agoFix more cstyle warnings
Brian Behlendorf [Sat, 24 Feb 2018 18:05:37 +0000 (10:05 -0800)]
Fix more cstyle warnings

This patch contains no functional changes.  It is solely intended
to resolve cstyle warnings in order to facilitate moving the spl
source code in to the zfs repository.

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #687

15 months agoFix function name typos
Tomohiro Kusumi [Mon, 19 Feb 2018 11:40:38 +0000 (20:40 +0900)]
Fix function name typos

vn_init() and vn_fini() had been renamed by 12ff95ff in 2011.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
Closes #686

15 months agoStaticize kstat_default_update()
Tomohiro Kusumi [Mon, 19 Feb 2018 10:23:53 +0000 (19:23 +0900)]
Staticize kstat_default_update()

This is only used via ->ks_update of `kstat_t *`.
This isn't exported nor do headers have its prototype.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
Closes #686

15 months agoFix multiple evaluations of VERIFY() and ASSERT() on failures
DeHackEd [Wed, 21 Feb 2018 22:54:26 +0000 (17:54 -0500)]
Fix multiple evaluations of VERIFY() and ASSERT() on failures

Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Closes #684
Closes #685

15 months agoSplit spl-build.m4
Brian Behlendorf [Wed, 7 Feb 2018 19:50:24 +0000 (11:50 -0800)]
Split spl-build.m4

Split the kernel interface configure checks in to seperate m4
macro files.  This is intended to facilitate moving the spl
source code in to the zfs repository.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #682

15 months agoFix cstyle warnings
Brian Behlendorf [Wed, 7 Feb 2018 19:49:38 +0000 (11:49 -0800)]
Fix cstyle warnings

This patch contains no functional changes.  It is solely intended
to resolve cstyle warnings in order to facilitate moving the spl
source code in to the zfs repository.

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

15 months agoAdd cv_timedwait_io()
Brian Behlendorf [Wed, 24 Jan 2018 19:33:47 +0000 (11:33 -0800)]
Add cv_timedwait_io()

Add missing helper function cv_timedwait_io(), it should be used
when waiting on IO with a specified timeout.

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

16 months agoFix Debian packaging on ARMv7/ARM64
LOLi [Thu, 18 Jan 2018 18:14:18 +0000 (19:14 +0100)]
Fix Debian packaging on ARMv7/ARM64

When building packages on Debian-based systems specify the target
architecture used by 'alien' to convert .rpm packages into .deb: this
avoids detecting an incorrect value which results in the following
errors:

<package>.aarch64.rpm is for architecture aarch64 ; the package cannot be built on this system
<package>.armv7l.rpm is for architecture armel ; the package cannot be built on this system

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes zfsonlinux/zfs#7046
Closes #678

17 months agoLinux 4.15 compat: timer updates
Tony Hutter [Thu, 21 Dec 2017 18:56:32 +0000 (10:56 -0800)]
Linux 4.15 compat: timer updates

Use timer_setup() macro and new timeout function definition.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #670
Closes #671

18 months agoLinux 4.14 compat: vfs_read & vfs_write
Brian Behlendorf [Thu, 16 Nov 2017 01:19:23 +0000 (17:19 -0800)]
Linux 4.14 compat: vfs_read & vfs_write

The kernel_read & kernel_write functions have always wrapped the
vfs_read & vfs_write functions respectively.  However, they could
not be used by vn_rdwr() since the offset wasn't passed as a
pointer.  This prevented us from being able to properly update
the file offset.

Linux 4.14 unexported vfs_read & vfs_write but also changed the
signature of kernel_read & kernel_write to provide the needed
functionality.  Use these updated functions when available.

Reviewed-by: Pritam Baral <pritam@pritambaral.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #656
Closes #667

18 months agoRemove all spin_is_locked calls
James Cowgill [Mon, 30 Oct 2017 18:16:56 +0000 (18:16 +0000)]
Remove all spin_is_locked calls

On systems with CONFIG_SMP turned off, spin_is_locked always returns
false causing these assertions to fail. Remove them as suggested in
zfsonlinux/zfs#6558.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Closes #665

18 months agoRemove vn_rename and vn_remove
Brian Behlendorf [Fri, 27 Oct 2017 22:49:14 +0000 (15:49 -0700)]
Remove vn_rename and vn_remove

Both vn_rename and vn_remove have been historically problematic
to implement reliably.  Rather than fixing them yet again they
are being removed.

Reviewed-by: Arkadiusz Bubala <arkadiusz.bubala@open-e.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #648
Closes #661

18 months agoUpdate spl module parameters man5 with missing parameter details
abraunegg [Fri, 27 Oct 2017 22:46:34 +0000 (09:46 +1100)]
Update spl module parameters man5 with missing parameter details

Update spl module parameters man5 with the following missing parameter
details for spl_panic_halt.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alex Braunegg <alex.braunegg@gmail.com>
Closes #664

19 months agoAdd DKMS package on Debian-based distributions
Neal Gompa (ニール・ゴンパ) [Sun, 15 Oct 2017 19:58:12 +0000 (15:58 -0400)]
Add DKMS package on Debian-based distributions

* config/deb.am: Enable building DKMS packages for Debian
* rpm/generic/spl-dkms.spec.in: Adjust spec to be Debian-compatible
  * Condition kernel-devel Requires to RPM distros
  * Ensure that --rpm_safe_upgrade isn't used on non-RPM distros
* config/deb.am: Drop CONFIG_KERNEL and CONFIG_USER guards
* Makefile.am: Add pkg-dkms target

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Neal Gompa <ngompa@datto.com>
Closes #657

19 months agoAdd parenthesis to btop and ptob macros
Brian Behlendorf [Tue, 10 Oct 2017 15:59:17 +0000 (08:59 -0700)]
Add parenthesis to btop and ptob macros

Add missing parenthesis around btop and ptob macros to ensure
operation ordering is preserved after expansion.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #660

19 months agoMake include/linux/ conform to ZFS style standard
Olaf Faaland [Thu, 5 Oct 2017 16:42:20 +0000 (12:42 -0400)]
Make include/linux/ conform to ZFS style standard

No semantic changes.

Fix the following types of style issues:
blank after preprocessor #
#define followed by space instead of tab
improper first line of block comment
indent by spaces instead of tabs
last line in file is blank
missing blank after open comment
missing space before left brace
non-continuation indented 4 spaces
spaces instead of tabs
unparenthesized return expression

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
19 months agoMake file headers conform to ZFS style standard
Olaf Faaland [Wed, 4 Oct 2017 16:33:43 +0000 (12:33 -0400)]
Make file headers conform to ZFS style standard

No semantic changes.

Change
 /************\
and
 \************/

to

 /*
and
  */

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
19 months agoPool io stat shows wlentime instead of rlentime
Richard Elling [Mon, 25 Sep 2017 17:02:24 +0000 (10:02 -0700)]
Pool io stat shows wlentime instead of rlentime

Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Elling <Richard.Elling@RichardElling.com>
Closes #652
Closes #651

21 months agoAllow longer SPA names in stats
gaurkuma [Fri, 11 Aug 2017 15:53:35 +0000 (08:53 -0700)]
Allow longer SPA names in stats

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: gaurkuma <gauravk.18@gmail.com>
Closes #641

21 months agomake module/spl/spl-kmem.c non-executable (again)
Fabian-Gruenbichler [Thu, 10 Aug 2017 22:23:43 +0000 (00:23 +0200)]
make module/spl/spl-kmem.c non-executable (again)

This was probably accidentally committed in

aeb9baa618beea1458ab3ab22cbc0f39213da6cf
Fix: handle NULL case in spl_kmem_free_track()

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Gvozden Neskovic <neskovic@gmail.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Closes #644

21 months agospl-module-parameters.5 manpage: fix macro
Fabian-Gruenbichler [Thu, 10 Aug 2017 22:22:31 +0000 (00:22 +0200)]
spl-module-parameters.5 manpage: fix macro

There is no '.sh' macro in troff/groff/man, only '.SH' for section
headers. I assume .sp for a line break was intended here like
in the rest of the man page.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #643

21 months agosplat.1 manpage: fix spelling of 'hexadecimal'
Fabian-Gruenbichler [Thu, 10 Aug 2017 22:21:54 +0000 (00:21 +0200)]
splat.1 manpage: fix spelling of 'hexadecimal'

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #642

21 months agoAdd assert under lock to detect cases of dispach of a preallocated
Boris Protopopov [Tue, 8 Aug 2017 15:31:52 +0000 (11:31 -0400)]
Add assert under lock to detect cases of dispach of a preallocated

taskq work item to more than one queue concurrently. Also, please
see discussion in zfsonlinux/zfs#3840.

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

21 months agoFix use-after-free in taskq_seq_show_impl
Chunwei Chen [Fri, 4 Aug 2017 16:57:58 +0000 (09:57 -0700)]
Fix use-after-free in taskq_seq_show_impl

taskq_seq_show_impl walks the tq_active_list to show the tqent_func and
tqent_arg. However for taskq_dispatch_ent, it's very likely that the
task entry will be freed during the function call, and causes a
use-after-free bug.

To fix this, we duplicate the task entry to an on-stack struct, and
assign it instead to tqt_task. This way, the tq_lock alone will
guarantee its safety.

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

21 months agoAdd __divmoddi4 and __udivmoddi4 for 32-bit arch
Chunwei Chen [Thu, 3 Aug 2017 17:41:42 +0000 (10:41 -0700)]
Add __divmoddi4 and __udivmoddi4 for 32-bit arch

gcc-7 seems to use __udivmoddi4 for 64-bit division on 32-bit arch. This
patch implement them so we don't get undefined reference error.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes zfsonlinux/zfs#6417
Closes #636

21 months agoRemove misguided HAVE_MUTEX_OWNER check, take 2
Oleg Drokin [Wed, 2 Aug 2017 18:45:16 +0000 (14:45 -0400)]
Remove misguided HAVE_MUTEX_OWNER check, take 2

It is just plain unsafe to peek inside in-kernel
mutex structure and make assumptions about what kernel
does with those internal fields like owner.

Kernel is all too happy to stop doing the expected things
like tracing lock owner once you load a tainted module
like spl/zfs that is not GPL.

As such you will get instant assertion failures like this:

  VERIFY3(((*(volatile typeof((&((&zo->zo_lock)->m_mutex))->owner) *)&
      ((&((&zo->zo_lock)->m_mutex))->owner))) ==
     ((void *)0)) failed (ffff88030be28500 == (null))
  PANIC at zfs_onexit.c:104:zfs_onexit_destroy()
  Showing stack for process 3626
  CPU: 0 PID: 3626 Comm: mkfs.lustre Tainted: P OE ------------ 3.10.0-debug #1
  Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
  Call Trace:
  dump_stack+0x19/0x1b
  spl_dumpstack+0x44/0x50 [spl]
  spl_panic+0xbf/0xf0 [spl]
  zfs_onexit_destroy+0x17c/0x280 [zfs]
  zfsdev_release+0x48/0xd0 [zfs]

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Gvozden Neskovic <neskovic@gmail.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Closes #639
Closes #632

21 months agospl-mutex: fix race in mutex_exit
Gvozden Neskovic [Thu, 3 Aug 2017 03:42:58 +0000 (05:42 +0200)]
spl-mutex: fix race in mutex_exit

Prevent race on accessing kmutex_t when the mutex is
embedded in a ref counted structure.

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

21 months agoRevert "Remove misguided HAVE_MUTEX_OWNER check"
Brian Behlendorf [Wed, 2 Aug 2017 19:07:11 +0000 (15:07 -0400)]
Revert "Remove misguided HAVE_MUTEX_OWNER check"

This reverts commit d89616fda88bc030aaff758d37ede7d35e58841a which
introduced some build failures which need to be resolved before
this can be merged.

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

21 months agoRemove misguided HAVE_MUTEX_OWNER check
Oleg Drokin [Wed, 2 Aug 2017 18:45:16 +0000 (14:45 -0400)]
Remove misguided HAVE_MUTEX_OWNER check

It is just plain unsafe to peek inside in-kernel
mutex structure and make assumptions about what kernel
does with those internal fields like owner.

Kernel is all too happy to stop doing the expected things
like tracing lock owner once you load a tainted module
like spl/zfs that is not GPL.

As such you will get instant assertion failures like this:

  VERIFY3(((*(volatile typeof((&((&zo->zo_lock)->m_mutex))->owner) *)&
      ((&((&zo->zo_lock)->m_mutex))->owner))) ==
     ((void *)0)) failed (ffff88030be28500 == (null))
  PANIC at zfs_onexit.c:104:zfs_onexit_destroy()
  Showing stack for process 3626
  CPU: 0 PID: 3626 Comm: mkfs.lustre Tainted: P OE ------------ 3.10.0-debug #1
  Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
  Call Trace:
  dump_stack+0x19/0x1b
  spl_dumpstack+0x44/0x50 [spl]
  spl_panic+0xbf/0xf0 [spl]
  zfs_onexit_destroy+0x17c/0x280 [zfs]
  zfsdev_release+0x48/0xd0 [zfs]

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Closes #632
Closes #633

21 months agoFix aarch64 build
Brian Behlendorf [Sat, 29 Jul 2017 20:24:39 +0000 (13:24 -0700)]
Fix aarch64 build

Add aarch64 to the list of architecture which do not sanitize the
LDFLAGS from the environment.  See e0aacd9b for details.

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

21 months agoTag spl-0.7.0
Brian Behlendorf [Wed, 26 Jul 2017 17:08:57 +0000 (10:08 -0700)]
Tag spl-0.7.0

META file and changelog updated.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
21 months agoModule parameter to enable spl_panic() to panic the kernel
Oleg Drokin [Wed, 26 Jul 2017 06:03:12 +0000 (02:03 -0400)]
Module parameter to enable spl_panic() to panic the kernel

In unattended operations it's often more useful to have node
panic and reboot when it encounters problems as opposed to
sit there indefinitely waiting for somebody to discover it.

This implements an spl_panic_crash module parameter, set it
to nonzero to cause spl_panic() to call panic().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Closes #634

22 months agoAvoid WARN() from procfs on kstat collision
LOLi [Mon, 24 Jul 2017 17:52:53 +0000 (19:52 +0200)]
Avoid WARN() from procfs on kstat collision

When we load a ZFS pool having spa_name equals to some existing kstat
we would have to create a duplicate entry, which procfs doesn't like.

For instance a ZFS pool named "zil" would have its kstat "txgs"
(module "zfs/zil") intalled under "/proc/spl/kstat/zfs/zil":
unfortunately we already have a kstat named "zil" (module "zfs")
installed in the same procfs location.

Avoid this issue by skipping the duplicate entry creation in procfs.

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

22 months agoLinux 4.13 compat: wait queues
Brian Behlendorf [Mon, 24 Jul 2017 02:32:14 +0000 (19:32 -0700)]
Linux 4.13 compat: wait queues

Commit torvalds/linux@ac6424b9
- Renamed struct wait_queue -> struct wait_queue_entry.

Commit torvalds/linux@2055da97
- Renamed wait_queue_head::task_list -> wait_queue_head::head
- Renamed wait_queue_entry::task_list -> wait_queue_entry::entry

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

22 months agoTag 0.7.0-rc5
Brian Behlendorf [Thu, 13 Jul 2017 19:07:59 +0000 (12:07 -0700)]
Tag 0.7.0-rc5

Fifth release candidate.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
22 months agoDon't cache the system hostid
Brian Behlendorf [Mon, 10 Jul 2017 19:24:52 +0000 (15:24 -0400)]
Don't cache the system hostid

Historically the SPL cached the system hostid the first time it
was accessed.  This was done to speed up subsequent accesses.
But in practice the system host id is rarely accessed and its
inconvenient that it doesn't promptly detect /etc/hostid
configuration changes.  Therefore, zone_get_hostid() has been
updated to always refresh the system hostid reported.

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

22 months agoAdd ASSERT3B/VERIFY3B/USEC2NSEC/NSEC2USEC macros
Prakash Surya [Mon, 10 Jul 2017 19:44:23 +0000 (12:44 -0700)]
Add ASSERT3B/VERIFY3B/USEC2NSEC/NSEC2USEC macros

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Prakash Surya <prakash.surya@delphix.com>
Closes #627

22 months agoFix RWSEM_SPINLOCK_IS_RAW check failed
Chunwei Chen [Mon, 19 Jun 2017 18:02:20 +0000 (11:02 -0700)]
Fix RWSEM_SPINLOCK_IS_RAW check failed

Initialize dummy_lock to fix the build error in gcc 7.1.1 with:
  error: ‘dummy_lock’ is used uninitialized in this function

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #622

2 years agoconfig: allow --with-linux without --with-linux-obj
Chunwei Chen [Wed, 24 May 2017 22:42:34 +0000 (15:42 -0700)]
config: allow --with-linux without --with-linux-obj

Don't use `uname -r` to determine kernel build directory when the user
specified kernel source with --with-linux. Otherwise, the user is forced
to use --with-linux-obj even if they are the same directory, which is
very counterintuitive.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
2 years agoImprove gitignore
Chunwei Chen [Wed, 24 May 2017 22:23:37 +0000 (15:23 -0700)]
Improve gitignore

Exclude Makefile.in in module/ and fix the gitignore in cmd/
Also, ignore *.patch and *.orig files

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
2 years agoFix cv_timedwait timeout
Brian Behlendorf [Thu, 25 May 2017 17:01:44 +0000 (10:01 -0700)]
Fix cv_timedwait timeout

Perform the already past expiration time check before updating
cvp->cv_mutex with the provided mutex.  This check only depends
on local state.  Doing it first ensures that cvp->cv_mutex will not
be updated in the timeout case or if it's ever called with an
expire_time <= now.

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

2 years agoLinux 4.12 compat: PF_FSTRANS was removed
Chunwei Chen [Tue, 9 May 2017 17:36:54 +0000 (10:36 -0700)]
Linux 4.12 compat: PF_FSTRANS was removed

Change SPL_FSTRANS to optionally contains PF_FSTRANS. Also, add
__spl_pf_fstrans_check for the checks specifically for PF_FSTRANS.

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

2 years agoTag 0.7.0-rc4
Brian Behlendorf [Fri, 5 May 2017 16:23:03 +0000 (09:23 -0700)]
Tag 0.7.0-rc4

Fourth release candidate.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2 years agoglibc 2.25 compat: remove assert(X=Y)
Olaf Faaland [Mon, 3 Apr 2017 20:33:49 +0000 (13:33 -0700)]
glibc 2.25 compat: remove assert(X=Y)

The assert() related definitions in glibc 2.25 were altered to warn
about assert(X=Y) when -Wparentheses is used.  See
https://abi-laboratory.pro/tracker/changelog/glibc/2.25/log.html

lib/list.c used this construct to set the value of a magic field which
is defined only when debugging.

Replaced the assert()s with #ifndef/#endifs.

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

2 years agoLinux 4.11 compat: remove stub for __put_task_struct
Olaf Faaland [Mon, 13 Mar 2017 17:37:10 +0000 (10:37 -0700)]
Linux 4.11 compat: remove stub for __put_task_struct

Before kernel 2.6.29 credentials were embedded in task_structs, and zfs had
cases where one thread would need to refer to the credential of another thread,
forcing it to take a hold on the foreign thread's task_struct to ensure it was
not freed.

Since 2.6.29, the credential has been moved out of the task_struct into a
cred_t.

In addition, the mainline kernel originally did not export __put_task_struct()
but the RHEL5 kernel did, according to zfsonlinux/spl@e811949a570.  As of
2.6.39 the mainline kernel exports it.

There is no longer zfs code that takes or releases holds on a task_struct, and
so there is no longer any reference to __put_task_struct().

This affects the linux 4.11 kernel because the prototype for
__put_task_struct() is in a new include file (linux/sched/task.h) and so the
config check failed to detect the exported symbol.

Removing the unnecessary stub and corresponding config check.  This works on
kernels since the oldest one currently supported, 2.6.32 as shipped with
Centos/RHEL.

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #608

2 years agoLinux 4.11 compat: add linux/sched/signal.h
Olaf Faaland [Tue, 7 Mar 2017 23:33:50 +0000 (15:33 -0800)]
Linux 4.11 compat: add linux/sched/signal.h

In Linux 4.11, torvalds/linux@2a1f062, signal handling related functions
were moved from sched.h into sched/signal.h.

Add configure checks to detect this and include the new file where
needed.

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #608

2 years agoLinux 4.11 compat: vfs_getattr() takes 4 args
Olaf Faaland [Tue, 7 Mar 2017 21:18:53 +0000 (13:18 -0800)]
Linux 4.11 compat: vfs_getattr() takes 4 args

There are changes to vfs_getattr() in torvalds/linux@a528d35.  The new
interface is:

int vfs_getattr(const struct path *path, struct kstat *stat,
               u32 request_mask, unsigned int query_flags)

The request_mask argument indicates which field(s) the caller intends to
use.  Fields the caller does not specify via request_mask may be set in
the returned struct anyway, but their values may be approximate.

The query_flags argument indicates whether the filesystem must update
the attributes from the backing store.

This patch uses the query_flags which result in vfs_getattr behaving the same
as it did with the 2-argument version which the kernel provided before
Linux 4.11.

Members blksize and blocks are now always the same size regardless of
arch.  They match the size of the equivalent members in vnode_t.

The configure checks are modified to ensure that the appropriate
vfs_getattr() interface is used.

A more complete fix, removing the ZFS dependency on vfs_getattr()
entirely, is deferred as it is a much larger project.

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #608

2 years agoFix powerpc build
Brian Behlendorf [Mon, 6 Mar 2017 17:16:22 +0000 (09:16 -0800)]
Fix powerpc build

Unlike other architectures which sanitize the LDFLAGS from the
environment in arch/<arch>/Makefile.  The powerpc Makefile
allows LDFLAGS to be passed through resulting in the following
build failure.

  /usr/bin/ld: unrecognized option '-Wl,-z,relro'

LDFLAGS is set in /usr/lib/rpm/redhat/macros by default.  Clear
the environment variable when building kmods for powerpc.

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

2 years agoLinux 4.11 compat: set_task_state() removed
Olaf Faaland [Thu, 23 Feb 2017 17:52:08 +0000 (09:52 -0800)]
Linux 4.11 compat: set_task_state() removed

Replace uses of set_task_state(current, STATE) with
set_current_state(STATE).

In Linux 4.11, torvalds/linux@642fa44, set_task_state() is removed.

All spl uses are of the form set_task_state(current, STATE).
set_current_state(STATE) is equivalent and has been available since
Linux 2.2.26.

Furthermore, set_current_state(STATE) is already used in about 15
locations within spl.  This change should have no impact other than
removing an unnecessary dependency.

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

2 years agoUse kernel slab for vn_cache and vn_file_cache
Chunwei Chen [Tue, 31 Jan 2017 21:44:01 +0000 (13:44 -0800)]
Use kernel slab for vn_cache and vn_file_cache

Resolve a false positive in the kmemleak checker by shifting to the
kernel slab.  It shows up because vn_file_cache is using KMC_KMEM
which is directly allocated using __get_free_pages, which is not
automatically tracked by kmemleak.

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

2 years agoAdd a PAGESHIFT definition
David Quigley [Tue, 31 Jan 2017 18:36:18 +0000 (11:36 -0700)]
Add a PAGESHIFT definition

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: David Quigley <david.quigley@intel.com>
Closes #598

2 years agoTag 0.7.0-rc3
Brian Behlendorf [Fri, 20 Jan 2017 18:16:32 +0000 (10:16 -0800)]
Tag 0.7.0-rc3

Third release candidate.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2 years agoReimplement rt_mutex_owner to fix build with DEBUG & PREEMPT_RT_FULL
clefru [Thu, 19 Jan 2017 22:41:38 +0000 (23:41 +0100)]
Reimplement rt_mutex_owner to fix build with DEBUG & PREEMPT_RT_FULL

rt_mutex_owner is internal to kernel/locking/rtmutex_common.h and
inaccessible for SPL via the public kernel headers. The way of
accessing the owner has been stable since at least 3.13 ([1], [2]),
which is masking the lowest bit in the owner pointer in rt_mutex. We
do the same.

[1] http://lxr.free-electrons.com/source/kernel/locking/rtmutex_common.h?v=3.13#L99
[2] http://lxr.free-electrons.com/source/kernel/locking/rtmutex_common.h?v=4.9#L78

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Clemens Fruhwirth <clemens@endorphin.org>
Closes #593

2 years agoRemove identical if statements in module/spl/spl-vnode.c
George Melikov [Thu, 19 Jan 2017 22:32:45 +0000 (01:32 +0300)]
Remove identical if statements in module/spl/spl-vnode.c

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Melikov <mail@gmelikov.ru>
Closes #594

2 years agoAdd support for recent kmem_cache_create_usercopy
Kevin Tanguy [Tue, 17 Jan 2017 20:05:14 +0000 (21:05 +0100)]
Add support for recent kmem_cache_create_usercopy

SLAB_USERCOPY flag was used to indicate PAX
not to kill copies from kernel to userland.

With recent grsecurity patchset and
CONFIG_GRKERNSEC_HIDESYM that enables
CONFIG_PAX_USERCOPY zfs would panic.

Handle newer API while keeping old one functional.

Tested-by: RageLtMan <rageltman@sempervictus>
Reviewed-by: spendergrsec <spender@grsecurity.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kevin Tanguy <kevin.tanguy@ovh.net>
Closes #595

2 years agoUpdate struct member intializers to C89
RageLtMan [Fri, 13 Jan 2017 22:12:42 +0000 (17:12 -0500)]
Update struct member intializers to C89

When building SPL within the kernel tree, C99 initializers cause
build failures and need to be converted to C89 as kernel CFLAGS
specify -std=gnu89.

This fix was provided by @behlendorf in #595 discussion notes and
manually implemented in the current master revision.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: RageLtMan <rageltman@sempervictus>
Closes #597

2 years agoAdd support for rw semaphore under PREEMPT_RT_FULL
Clemens Fruhwirth [Sat, 17 Dec 2016 16:09:57 +0000 (17:09 +0100)]
Add support for rw semaphore under PREEMPT_RT_FULL

The main complication from the RT patch set is that the RW semaphore
locks change such that read locks on an rwsem can be taken only by
a single thread.  All other threads are locked out. This single
thread can take a read lock multiple times though. The underlying
implementation changes to a mutex with an additional read_depth
count.

The implementation can be best understood by inspecting the RT
patch.  rwsem_rt.h and rt.c give the best insight into how RT
rwsem works. My implementation for rwsem_tryupgrade is basically
an inversion of rt_downgrade_write found in rt.c. Please see the
comments in the code.

Unfortunately, I have to drop SPLAT rwlock test4 completely as this
test tries to take multiple locks from different threads, which RT
rwsems do not support.  Otherwise SPLAT, zconfig.sh, zpios-sanity.sh
and zfs-tests.sh pass on my Debian-testing VM with the kernel
linux-image-4.8.0-1-rt-amd64.

Tested-by: kernelOfTruth <kerneloftruth@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Clemens Fruhwirth <clemens@endorphin.org>
Closes zfsonlinux/zfs#5491
Closes #589
Closes #308

2 years agoRemove stale comment from rw_tryupgrade()
Clemens Fruhwirth [Sat, 17 Dec 2016 16:10:25 +0000 (17:10 +0100)]
Remove stale comment from rw_tryupgrade()

Commit f58040c0fc8bc6490fcc75db7fc3e709dfc3c656 should have removed
this comment which is no longer relevant.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Clemens Fruhwirth <clemens@endorphin.org>
Issue #589

2 years agoRefactor some splat macro to function
Chunwei Chen [Thu, 15 Dec 2016 02:24:47 +0000 (18:24 -0800)]
Refactor some splat macro to function

Refactor the code by making splat_test_{init,fini}, splat_subsystem_{init,fini}
into functions. They don't have reason to be macro and it would be too bloated
to inline every call.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
2 years agoFix splat memleak
Chunwei Chen [Thu, 15 Dec 2016 19:12:50 +0000 (11:12 -0800)]
Fix splat memleak

SPLAT_TEST_FINI didn't call kfree causing memleak.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
2 years agoAdd system_delay_taskq for long delay
Chunwei Chen [Thu, 8 Dec 2016 21:00:20 +0000 (13:00 -0800)]
Add system_delay_taskq for long delay

Add a dedicated system_delay_taskq for long delay like spa_deadman and
zpl_posix_acl_free. This will allow us to use system_taskq in the manner of
dispatch multiple tasks and call taskq_wait_outstanding.

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

2 years agoLimit number of tasks shown in taskq proc
Chunwei Chen [Thu, 1 Dec 2016 18:06:27 +0000 (10:06 -0800)]
Limit number of tasks shown in taskq proc

To prevent holding tq_lock for too long.

Before zfsonlinux/zfs@8e71ab9, hogging delay tasks and cat /proc/spl/taskq
would easily cause a lockup. While that bug has been fixed. It's probably
still a good idea to do this just in case task lists grow too large.

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

2 years agoAdd TASKQID_INVALID and TASKQID_INITIAL macros
Ubuntu [Fri, 28 Oct 2016 21:23:30 +0000 (21:23 +0000)]
Add TASKQID_INVALID and TASKQID_INITIAL macros

Add the TASKQID_INVALID and TASKQID_INITIAL macros and update the
taskq implementation and test cases to use them.  This is solely
for the purposes of readability and introduces no functional change.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2 years agoFix vmem_size()
Ubuntu [Fri, 28 Oct 2016 20:56:38 +0000 (20:56 +0000)]
Fix vmem_size()

Add a minimal implementation of vmem_size() which accounts for the
virtual memory usage of the SPL's kmem cache.  This functionality
is only useful on 32-bit systems with a small virtual address space.

The following assumptions are made:

  1) The major SPL consumer of virtual memory is the kmem cache.
  2) Memory allocated with vmem_alloc() is short lived and can be ignored.
  3) Allow a 4MB floor as a generous pad given normal consumption.
  4) The spl_kmem_cache_sem only contends with cache create/destroy.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2 years agoTag 0.7.0-rc2
Brian Behlendorf [Tue, 25 Oct 2016 20:13:49 +0000 (13:13 -0700)]
Tag 0.7.0-rc2

Second release candidate.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2 years agoLinux 4.9 compat: group_info changes
Chunwei Chen [Wed, 19 Oct 2016 00:30:41 +0000 (17:30 -0700)]
Linux 4.9 compat: group_info changes

In Linux 4.9, torvalds/linux@81243ea, group_info changed from 2d array via
->blocks to 1d array via ->gid. We change the spl cred functions accordingly.

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

2 years agoFix splat-cred.c cred usage
Chunwei Chen [Wed, 19 Oct 2016 00:29:26 +0000 (17:29 -0700)]
Fix splat-cred.c cred usage

No need to crhold current_cred(), fix possible leak in splat_cred_test2

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

2 years agoFix crgetgroups out-of-bound and misc cred fix
Chunwei Chen [Tue, 18 Oct 2016 22:52:30 +0000 (15:52 -0700)]
Fix crgetgroups out-of-bound and misc cred fix

init_groups has 0 nblocks, therefore calling the current crgetgroups with
init_groups would result in out-of-bound access. We fix this by returning NULL
when nblocks is 0.

Cap crgetngroups to NGROUPS_PER_BLOCK, since crgetgroups will only return
blocks[0].

Also, remove all get_group_info. The cred already holds reference on the
group_info, and cred is not mutable. So there's no reason to hold extra
reference, if we hold cred.

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

2 years agoFix out-of-bound in per_cpu in spl_random_init
tuxoko [Sat, 8 Oct 2016 03:59:46 +0000 (20:59 -0700)]
Fix out-of-bound in per_cpu in spl_random_init

When iterating per_cpu values, we need to use for_each_possible_cpu. While
NR_CPUS indicates the number of CPU supported by the kernel, it might not
initialize all of them if the kernel decides it's not possible to use them.

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

2 years agoLinux 4.8 compat: Fix RW_READ_HELD
tuxoko [Sat, 8 Oct 2016 03:53:58 +0000 (20:53 -0700)]
Linux 4.8 compat: Fix RW_READ_HELD

Linux 4.8, starting from torvalds/linux@19c5d690e, will set owner to 1 when
read held instead of leave it NULL. So we change the condition to
`rw_owner(rwp) <= 1` in RW_READ_HELD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes zfsonlinux/zfs#5233
Closes #577

2 years agoFix p0 initializer
Brian Behlendorf [Wed, 5 Oct 2016 00:26:36 +0000 (17:26 -0700)]
Fix p0 initializer

Due to changes in the task_struct the following warning is occurs
when initializing the global p0.  Since this structure only exists
for it's address to be taken initialize it in a manor which isn't
sensitive to internal changes to the structure.

  module/spl/spl-generic.c:58:1: error: missing braces around
  initializer [-Werror=missing-braces]

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

2 years agoFix aarch64 type warning
Brian Behlendorf [Sun, 2 Oct 2016 01:33:01 +0000 (18:33 -0700)]
Fix aarch64 type warning

Explicitly cast type in splat-rwlock.c test case to silence
the following warning.

  warning: format ‘%ld’ expects argument of type ‘long int’,
  but argument N has type ‘int’

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

2 years agoFix automatically generated release number
Brian Behlendorf [Wed, 21 Sep 2016 20:44:32 +0000 (13:44 -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>
Issue zfsonlinux/zfs#5105
Closes #572

2 years agoIncrease spl_kmem_alloc_warn limit
Brian Behlendorf [Sat, 17 Sep 2016 00:10:36 +0000 (17:10 -0700)]
Increase spl_kmem_alloc_warn limit

In order to support ABD with large blocks the spl_kmem_alloc_warn
limit needs to be increased to 64K.

A 16M block requires that pointers be stored for 4096 4K-pages
on an x86_64 system.  Each of these pointers is 8 bytes requiring
an allocation of 8*4096=32,768 bytes.  The addition of a small
header to this structure pushes the allocation over the default
32K warning threshold.

In addition, fix a small bug where MAX was used instead of MIN
when setting the default.  This ensures a reasonable limit is
still set on systems with page sizes larger then 4K.

Reviewed-by: David Quigley <david.quigley@intel.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #571

2 years agoFix spl check.sh script
legend-hua [Thu, 15 Sep 2016 00:17:00 +0000 (08:17 +0800)]
Fix spl check.sh script

Update splat_cmd to reference the correct location of the splat utility.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Liu Hua<liu.hua130@zte.com.cn>
Closes #570

2 years agoCleanup in cred.h
tuxoko [Wed, 14 Sep 2016 23:59:31 +0000 (16:59 -0700)]
Cleanup in cred.h

Remove the code that doesn't make any sense.

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

2 years agoTag 0.7.0-rc1
Brian Behlendorf [Wed, 7 Sep 2016 17:33:21 +0000 (10:33 -0700)]
Tag 0.7.0-rc1

First release candidate.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2 years agoFix: handle NULL case in spl_kmem_free_track()
GeLiXin [Fri, 19 Aug 2016 06:50:21 +0000 (14:50 +0800)]
Fix: handle NULL case in spl_kmem_free_track()

When DEBUG_KMEM_TRACKING is enabled in SPL, we keep tracking all
the buffers alloced by kmem_alloc() and kmem_zalloc().  If a NULL
pointer which indicates no track info in SPL is passed to
spl_kmem_free_track, we just ignore it.

Signed-off-by: GeLiXin <ge.lixin@zte.com.cn>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/zfs#4967
Closes #567

2 years agoFix HAVE_MUTEX_OWNER test for kernels prior to 4.6
Tim Chase [Mon, 1 Aug 2016 13:19:19 +0000 (08:19 -0500)]
Fix HAVE_MUTEX_OWNER test for kernels prior to 4.6

Recent 4.X kernels prior to 4.6 require #include of spinlock.h in
order to get the definition of __ARCH_SPIN_LOCK_UNLOCKED which is
used by DEFINE_MUTEX().

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

2 years agoAdd handling for kernel 4.7's CONFIG_TRIM_UNUSED_KSYMS
Nikolay Borisov [Fri, 29 Jul 2016 15:48:33 +0000 (18:48 +0300)]
Add handling for kernel 4.7's CONFIG_TRIM_UNUSED_KSYMS

Kernel 4.7 added the option to trim the unused exported symbols. In
my testing this showed to be problematic since the PDE_DATA function
was considered unused and as such was trimmed. This in turn caused the
respective test during spl's configure stage to falsely detect that
PDE_DATA is not defined, which in turn caused build failures later.

Handle this situation by adding detection whether CONFIG_TRIM_UNUSED_KSYMS
is enabled and refuse to build against a kernel which has it enabled

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

2 years agoAdd gitignore entry for spl-*.o.d files
Nikolay Borisov [Fri, 29 Jul 2016 15:48:04 +0000 (18:48 +0300)]
Add gitignore entry for spl-*.o.d files

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

2 years agoLinux 4.8 compat: rw_semaphore atomic_long_t count
Brian Behlendorf [Tue, 26 Jul 2016 23:37:46 +0000 (23:37 +0000)]
Linux 4.8 compat: rw_semaphore atomic_long_t count

For non-rwsem-spinlocks the "count" member was changed from a
"long" to "atomic_long_t" type.  A configure check has been
added to detect this change along with new versions of the
_rwsem_tryupgrade() function and RWSEM_COUNT() macro.  See
https://github.com/torvalds/linux/commit/8ee62b18 for complete
details.

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

2 years agoAdded highbit() and lowbit() macros
Tom Caputi [Thu, 14 Jul 2016 19:51:24 +0000 (15:51 -0400)]
Added highbit() and lowbit() macros

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

2 years agoAdd _ALIGNMENT_REQUIRED to isa_defs.h for checksums
Tony Hutter [Wed, 15 Jun 2016 00:36:39 +0000 (17:36 -0700)]
Add _ALIGNMENT_REQUIRED to isa_defs.h for checksums

_ALIGNMENT_REQUIRED needs to be #defined in isa_defs.h in order to
port the Illumos checksum code to ZoL:

4185 add new cryptographic checksums to ZFS: SHA-512, Skein, Edon-R
OpenZFS-issue: https://www.illumos.org/issues/4185
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/45818ee

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #561

2 years agoImprove spl slab cache alloc
Jinshan Xiong [Thu, 19 May 2016 17:59:40 +0000 (10:59 -0700)]
Improve spl slab cache alloc

The policy is to try to allocate with KM_NOSLEEP, which will lead to
memory allocation with GFP_ATOMIC, and if it fails, it will launch
an taskq to expand slab space.

This way it should be able to get better NUMA memory locality and
reduce the overhead of context switch.

Signed-off-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #551

2 years agoFix use-after-free in splat_taskq_test7
Chunwei Chen [Sat, 28 May 2016 00:28:12 +0000 (17:28 -0700)]
Fix use-after-free in splat_taskq_test7

This splat_vprint is using tq_arg->name after tq_arg is freed.

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

2 years agoImplement a proper rw_tryupgrade
Chunwei Chen [Wed, 25 May 2016 23:35:42 +0000 (16:35 -0700)]
Implement a proper rw_tryupgrade

Current rw_tryupgrade does rw_exit and then rw_tryenter(RW_RWITER), and then
does rw_enter(RW_READER) if it fails. This violate the assumption that
rw_tryupgrade should be atomic and could cause extra contention or even lock
inversion.

This patch we implement a proper rw_tryupgrade. For rwsem-spinlock, we take
the spinlock to check rwsem->count and rwsem->wait_list. For normal rwsem, we
use cmpxchg on rwsem->count to change the value from single reader to single
writer.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes zfsonlinux/zfs#4692
Closes #554

2 years agoAdd isa_defs for MIPS
YunQiang Su [Sat, 28 May 2016 11:30:36 +0000 (19:30 +0800)]
Add isa_defs for MIPS

GCC for MIPS only defines _LP64 when 64bit,
while no _ILP32 defined when 32bit.

Signed-off-by: YunQiang Su <syq@debian.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #558

3 years agoFix taskq_wait_outstanding re-evaluate tq_next_id
Chunwei Chen [Mon, 23 May 2016 21:12:22 +0000 (14:12 -0700)]
Fix taskq_wait_outstanding re-evaluate tq_next_id

wait_event is a macro, so the current implementation will cause re-
evaluation of tq_next_id every time it wakes up. This would cause
taskq_wait_outstanding(tq, 0) to be equivalent to taskq_wait(tq)

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

3 years agoFix race between taskq_destroy and dynamic spawning thread
Chunwei Chen [Sat, 21 May 2016 01:04:03 +0000 (18:04 -0700)]
Fix race between taskq_destroy and dynamic spawning thread

While taskq_destroy would wait for dynamic_taskq to finish its tasks, but it
does not implies the thread being spawned is up and running. This will cause
taskq to be freed before the thread can exit.

We fix this by using tq_nspawn to indicate how many threads are being spawned
before they are inserted to the thread list. And have taskq_destroy to wait
for it to drop to zero.

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

3 years agoRestore CALLOUT_FLAG_ABSOLUTE in cv_timedwait_hires
Chunwei Chen [Fri, 20 May 2016 23:35:52 +0000 (16:35 -0700)]
Restore CALLOUT_FLAG_ABSOLUTE in cv_timedwait_hires

In 39cd90e, I mistakenly disabled the ability of using absolute expire time in
cv_timedwait_hires. I don't quite sure why I did that, so let's restore it.

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

3 years agoLinux 4.7 compat: inode_lock() and friends
Chunwei Chen [Wed, 18 May 2016 18:28:46 +0000 (11:28 -0700)]
Linux 4.7 compat: inode_lock() and friends

Linux 4.7 changes i_mutex to i_rwsem, and we should used inode_lock and
inode_lock_shared to do exclusive and shared lock respectively.

We use spl_inode_lock{,_shared}() to hide the difference. Note that on older
kernel you'll always take an exclusive lock.

We also add all other inode_lock friends. And nested users now should
explicitly call spl_inode_lock_nested with correct subclass.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/zfs#4665
Closes #549

3 years agoAdd cv_timedwait_sig_hires to allow interruptible sleep
Chunwei Chen [Wed, 11 May 2016 23:51:29 +0000 (16:51 -0700)]
Add cv_timedwait_sig_hires to allow interruptible sleep

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