Commit graph

1956 commits

Author SHA1 Message Date
Mateusz Guzik
a6e5d03055 zfs: avoid memory allocation in arc_prune_async
(cherry picked from commit 97ed4babb5)
2021-05-22 18:37:28 +00:00
Mateusz Guzik
8ea3f6a3e4 zfs: make vnlru_free_vfsops use conditional on version
Diff reduction against upstream.

(cherry picked from commit feea35bed0)
2021-05-22 18:37:23 +00:00
Mateusz Guzik
8bb6b6a461 zfs: change format string in zio_fini to get rid of the cast
(cherry picked from commit a7fbfdee73)
2021-05-22 18:37:19 +00:00
Mateusz Guzik
bb3b814b25 zfs: make seqc asserts conditional on replay
Avoids tripping on asserts when doing pool recovery.

(cherry picked from commit 59146a6921)
2021-05-22 18:36:29 +00:00
Mateusz Guzik
a9d418fbb8 zfs: use vn_seqc_read_notmodify for racing .. lookups
Catching an in-flight unlocked vnode is fine here.

Reported by;	pho

(cherry picked from commit 7ea3223c78)
2021-05-22 18:30:50 +00:00
Mateusz Guzik
d2e0a3bb21 zfs: damage control racing .. lookups in face of mkdir/rmdir
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29769

(cherry picked from commit 9c651561a2)
2021-05-22 18:30:44 +00:00
Martin Matuska
049d49e40a zfs: merge openzfs/zfs@3522f57b6 (master)
Notable upstream pull request merges:
  #11742 When specifying raidz vdev name, parity count should match
  #11744 Use a helper function to clarify gang block size
  #11771 Support running FreeBSD buildworld on Arm-based macOS hosts

This is the last update that will be MFCed into stable/13.

From now on, the tracking of OpenZFS branches will be different:
- main continues tracking openzfs/zfs/master
- stable/13 is going to track openzfs/zfs/zfs-2.1-release

Obtained from:	OpenZFS

(cherry picked from commit 6db169e920)
2021-04-22 17:03:06 +02:00
Kristof Provost
4f784d330d libnv: Allow use in non-sleepable contexts
44c125c4ce switched the nvlist allocations
to be M_WAITOK, but this precludes the use in non-sleepable contexts.
(E.g. with a nonsleepable lock held).

All callers for these allocation functions already cope with memory
alloation failures, so there's no reason to allow sleeping during
allocations.

Reviewed by:	melifaro, oshogbo
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29556

(cherry picked from commit ab8d25880e)
2021-04-14 10:16:27 +02:00
Martin Matuska
93d1c189bc zfs: merge OpenZFS master-891568c99
Notable upstream pull request merges:
  #11652 Split dmu_zfetch() speculation and execution parts
  #11682 Fix zfs_get_data access to files with wrong generation
  #11735 Clean up RAIDZ/DRAID ereport code
  #11737 Initialize metaslab range trees in metaslab_init
  #11739 FreeBSD: make seqc asserts conditional on replay
  #11763 Allow setting bootfs property on pools with indirect vdevs
  #11767 FreeBSD: Fix memory leaks in kstats

Obtained from:	OpenZFS

(cherry picked from commit f9693bef8d)
2021-04-04 15:19:09 +02:00
Martin Matuska
cf2a726434 zfs: merge OpenZFS master-9305ff2ed
Notable upstream pull request merges:
  #11153 Scalable teardown lock for FreeBSD
  #11651 Don't bomb out when using keylocation=file://
  #11667 zvol: call zil_replaying() during replay
  #11683 abd_get_offset_struct() may allocate new abd
  #11693 Intentionally allow ZFS_READONLY in zfs_write
  #11716 zpool import cachefile improvements
  #11720 FreeBSD: Clean up zfsdev_close to match Linux
  #11730 FreeBSD: bring back possibility to rewind the
         checkpoint from bootloader

Obtained from:	OpenZFS

(cherry picked from commit 9db44a8e5d)
2021-04-04 15:18:45 +02:00
Jessica Clarke
7f8acc8d3d zfs: Cherry-pick upstream commit ef977fce66 to fix macOS/arm64 bootstrap
Upstream commit message:

  Support running FreeBSD buildworld on Arm-based macOS hosts

  Arm-based Macs are like FreeBSD and provide a full 64-bit stat from the
  start, so have no stat64 variants. Thus, define stat64 and fstat64 as
  aliases for the normal versions.

  Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
  Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
  Closes #11771

(cherry picked from commit 3a314eb5bb)
2021-04-03 12:29:31 +01:00
Cy Schubert
76af2649b0 MFC 874b1a3548:
ipfilter: simplify ipf_proxy_check() return codes

ipf_proxy_check() returns -1 for an error and 0 or 1 for success.
ipf_proxy_check()'s callers check for error and if the return code
is 0, they change it to 1 prior to returning to their callers. Simply
by returning -1 or 1 we reduce complexity and cycles burned changing
0 to 1.

(cherry picked from commit 874b1a3548)
2021-04-01 06:24:19 -07:00
Mariusz Zaborski
6bbca5ca3a zfs: bring back possibility to rewind the checkpoint from
Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abff
[2] OpenZFS repo: f2c027bd6a

Originally reviewed by:		tsoome, allanjude
Originally reviewed by:		kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>

PR:		254152
Reported by:	Zhenlei Huang <zlei.huang at gmail.com>
Obtained from:	https://github.com/openzfs/zfs/pull/11730

(cherry picked from commit 653ed678c7)
2021-03-18 22:10:59 +01:00
Mateusz Guzik
4f2e8545f7 vfs: fix vnlru marker handling for filtered/unfiltered cases
The global list has a marker with an invariant that free vnodes are
placed somewhere past that. A caller which performs filtering (like ZFS)
can move said marker all the way to the end, across free vnodes which
don't match. Then a caller which does not perform filtering will fail to
find them. This makes vn_alloc_hard sleep for 1 second instead of
reclaiming, resulting in significant stalls.

Fix the problem by requiring an explicit marker by callers which do
filtering.

As a temporary measure extend vnlru_free to restart if it fails to
reclaim anything.

Big thanks go to the reporter for testing several iterations of the
patch.

Reported by:	Yamagi <lists yamagi.org>
Tested by:	Yamagi <lists yamagi.org>
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29324

(cherry picked from commit e9272225e6)
2021-03-18 15:00:50 +00:00
Alexander V. Chernikov
8a25d3f6ce Fix dpdk/ldradix fib lookup algorithm preference calculation.
The current preference number were copied from IPv4 code,
 assuming 500k routes to be the full-view. Adjust with the current
 reality (100k full-view).

Reported by:	Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>

(cherry picked from commit d5be41beb7)
2021-03-10 21:50:19 +00:00
Martin Matuska
f2d3322c45 zfs: merge OpenZFS master-bedbc13da
Notable upstream commits:
  8e43fa12c Fix vdev_rebuild_thread deadlock
  03ef8f09e Add missing checks for unsupported features
  2e160dee9 Fix assert in FreeBSD-specific dmu_read_pages
  bedbc13da Cancel TRIM / initialize on FAULTED non-writeable vdevs

Obtained from:	OpenZFS

(cherry picked from commit caed7b1c39)
2021-03-10 02:58:07 +01:00
Mateusz Guzik
9629ecfeef zfs: add missing seqc write begin/end around zfs_acl_chown_setattr
It happens to trip over an assert but does not matter for correctness at
this time. However, do it for future proofing.

Reported by:	avg

(cherry picked from commit 1d8510c1a6)
2021-03-10 02:57:25 +01:00
Martin Matuska
ee36544bd8 zfs: add missing checks for unsupported features
After the merge of OpenZFS master-9312e0fd1 it has become possible to
import ZFS pools witn an active org.illumos:edonr feature on FreeBSD,
leading to a panic.

In addition, "zpool status" reported all pools without edonr as upgradable
and "zpool upgrade -v" lists edonr in the list of upgradable features.

This is an accepted but not yet included bugfix by upstream.

Obtained from:		https://github.com/openzfs/zfs/pull/11653
Differential Revision:	https://reviews.freebsd.org/D28935
Reported by:		garga (on freebsd-current@)
Reviewed by:		freqlabs

(cherry picked from commit c170aa9f37)
2021-03-10 02:57:03 +01:00
Martin Matuska
57b9b81894 zfs: merge OpenZFS master-9312e0fd1
Notable upstream changes:
  778869fa1 Fix reporting of mount progress
  e7adccf7f Disable use of hardware crypto offload drivers on FreeBSD
  03e02e5b5 Fix checksum errors not being counted on repeated repair
  64e0fe14f Restore FreeBSD resource usage accounting
  11f2e9a49 Fix panic if scrubbing after removing a slog device

(cherry picked from commit ba27dd8be8)
2021-03-10 02:53:32 +01:00
Martin Matuska
e1f9a18f91 zfs: merge OpenZFS master-bf156c966
Notable upstream changes:
    bf156c966 Remove unused abd_alloc_scatter_offset_chunkcnt
    658fb8020 Add "compatibility" property for zpool feature sets

This update introduces a new pool property called "compatibility"
that can be used to enable a limited set of pool features on pool
creation and "stick" to it, so the "zpool upgrade" does not
accidentally enable features that are not desired. The value of
this property may then be changed later.

See zpool-features(5) for more information about the "compatibility"
pool property.

Obtained from:	OpenZFS

(cherry picked from commit ee36e25a86)
2021-03-10 02:25:54 +01:00
Martin Matuska
9e8f831780 zfs: change file mode of all merged tests
If the ksh files are not executable then the tests are not run
and reported as failed.

(cherry picked from commit afcb3c4cb4)
2021-03-10 02:25:27 +01:00
Martin Matuska
21b12f3e45 zfs: merge OpenZFS master-436ab35a5
- speed up writing to ZFS pools without ZIL devices (aa755b3)
- speed up importing ZFS pools (2d8f72d, a0e0199, cf0977a)
...

Reviewed by:		mjg (partial)
Tested by:		pho
Differential Revision:	https://reviews.freebsd.org/D28677

(cherry picked from commit 184c1b9439)
2021-03-10 02:24:58 +01:00
Eric Joyner
a02640c79e ice_ddp: Update package file to 1.3.19.0
This package is intended to be used with ice(4) version 0.28.1-k.
That update will happen in a forthcoming commit.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Sponsored by: Intel Corporation

(cherry picked from commit a7ac518bff)
2021-03-09 14:35:50 -08:00
Martin Matuska
dc2743434f zfs: cancel TRIM or initialize on FAULTED non-writeable vdevs
From the openzfs commit message:
  When a device which is actively trimming or initializing becomes
  FAULTED, and therefore no longer writable, cancel the active
  TRIM or initialization.  When the device is merely taken offline
  with `zpool offline` then stop the operation but do not cancel it.
  When the device is brought back online the operation will be
  resumed if possible.

Obtained from:	openzfs/zfs@bedbc13daa
MFS after:	3 days

(direct commit)
2021-03-03 02:38:09 +01:00
Martin Matuska
19049a2b2b zfs: fix assert in FreeBSD-specific dmu_read_pages
From the openzfs 2e160dee9 commit message:
  The function has three similar pieces of code: for read-behind pages,
  requested pages and read-ahead pages.  All three pieces had an
  assert to ensure that the page is not mapped.  Later the assert was
  relaxed to require that the page is not mapped for writing.  But that
  was done in two places out of three.  This change fixes the third piece,
  read-ahead.

Obtained from:	openzfs/zfs@2e160dee97
MFS after:	3 days

(direct commit)
2021-03-03 02:32:59 +01:00
Martin Matuska
c706906314 zfs: fix vdev_rebuild_thread deadlock
From the openzfs 8e43fa12c commit message:
  The metaslab_disable() call may block waiting for a txg sync.
  Therefore it's important that vdev_rebuild_thread release the
  SCL_CONFIG read lock it is holding before this call.  Failure
  to do so can result in the txg_sync thread getting blocked
  waiting for this lock which results in a deadlock.

Obtained from:	openzfs/zfs@8e43fa12c5
MFS after:	3 days

(direct commit)
2021-03-03 02:28:56 +01:00
Martin Matuska
f08e17c8a2 zfs: fix overly broad locking in spa_vdev_config_exit()
Resolves a deadlock which can occur when the ZED or zpool
command attaches a new device.

From the openzfs 75a089ed3 commit message:
  Calling vdev_free() only requires the we acquire the spa config
  SCL_STATE_ALL locks, not the SCL_ALL locks.  In particular, we need
  need to avoid taking the SCL_CONFIG lock (included in SCL_ALL) as a
  writer since this can lead to a deadlock.  The txg_sync_thread() may
  block in spa_txg_history_init_io() when taking the SCL_CONFIG lock
  as a reading when it detects there's a pending writer.

Obtained from:	openzfs/zfs@75a089ed34
MFS after:	3 days

(direct commit)
2021-03-03 02:25:03 +01:00
Martin Matuska
2126962573 zfs: restore FreeBSD resource usage accounting
With the switch to OpenZFS 2.0 the platform-dependent resource
usage accounting code got missing.

Patch author:	Ryan Moeller <freqlabs@FreeBSD.org>

Obtained from:	openzfs/zfs@64e0fe14ff
MFS after:	3 days

(direct commit)
2021-02-22 22:20:28 +01:00
Martin Matuska
940415f20a zfs: disable use of hardware crypto offload drivers
From openzfs-master e7adccf7f commit message:
  First, the crypto request completion handler contains a bug in that it
  fails to reset fs_done correctly after the request is completed.  This
  is only a problem for asynchronous drivers.  Second, some hardware
  drivers have input constraints which ZFS does not satisfy.  For
  instance, ccp(4) apparently requires the AAD length for AES-GCM to be a
  multiple of the cipher block size, and with qat(4) the AES-GCM AAD
  length may not be longer than 240 bytes.  FreeBSD's generic crypto
  framework doesn't have a mechanism to automatically fall back to a
  software implementation if a hardware driver cannot process a request,
  and ZFS does not tolerate such errors.

Patch Author:	Mark Johnston <markj@freebsd.org>

Obtained from:	openzfs/zfs@e7adccf7f5
PR:		252981, 253595
MFS after:	3 days

(direct commit)
2021-02-22 18:42:33 +01:00
Martin Matuska
64649f0285 zfs: fix panic if scrubbing after removing a slog device
From openzfs-master 11f2e9a4 commit message:
  vdev_ops: don't try to call vdev_op_hold or vdev_op_rele when NULL

  This prevents a panic after a SLOG add/removal on the root pool followed
  by a zpool scrub.

  When a SLOG is removed, a hole takes its place - the vdev_ops for a hole
  is vdev_hole_ops, which defines the handler functions of vdev_op_hold
  and vdev_op_rele as NULL.

Patch Author: Patrick Mooney <pmooney@pfmooney.com>

Obtained from:	openzfs/zfs@11f2e9a491
PR:		252396
MFS after:	3 days

(direct commit)
2021-02-22 18:26:12 +01:00
Martin Matuska
edb9049c3a zfs: Avoid updating the L2ARC device header unnecessarily
From openzfs-master 0ae184a6b commit message:
  If we do not write any buffers to the cache device and the evict hand
  has not advanced do not update the cache device header.

Cherry-picked from openzfs 0ae184a6ba
Patch Author:   George Amanakis <gamanakis@gmail.com>

Reviewed by:            delphij
Differential Revision:  https://reviews.freebsd.org/D28682

(cherry picked from commit 5dce03847f)
2021-02-18 02:29:46 +01:00
Martin Matuska
6f21b7996a zfs: fix RAIDZ2/3 not healing parity with 2+ bad disks
From openzfs-master 62d4287f2 commit message:
  When scrubbing, (non-sequential) resilvering, or correcting a checksum
  error using RAIDZ parity, ZFS should heal any incorrect RAIDZ parity by
  overwriting it.  For example, if P disks are silently corrupted (P being
  the number of failures tolerated; e.g. RAIDZ2 has P=2), `zpool scrub`
  should detect and heal all the bad state on these disks, including
  parity.  This way if there is a subsequent failure we are fully
  protected.

  With RAIDZ2 or RAIDZ3, a block can have silent damage to a parity
  sector, and also damage (silent or known) to a data sector.  In this
  case the parity should be healed but it is not.

Cherry-picked from openzfs 62d4287f27
Patch Author:	Matthew Ahrens <matthew.ahrens@delphix.com>

Reviewed by:		delphij
Differential Revision:	https://reviews.freebsd.org/D28681

(cherry picked from commit f15e18a642)
2021-02-18 02:28:37 +01:00
Cy Schubert
6bb08afcf9 MFC 57785538c6 and
1e811efbc5:

57785538c6:

Simplify the FreeBSD check using __FreeBSD__ compiler macro.

Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by:	emaste
MFC after:	1 week

(cherry picked from commit 57785538c6)

1e811efbc5:

Fix non-IPv6 build post 57785538c6.

57785538c6 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by:	bdragon
Reported by:	bdragon

(cherry picked from commit 1e811efbc5)
2021-02-15 16:40:50 -08:00
Cy Schubert
cee16a2ff0 MFC 344f1083e1:
ipfilter: Use the softn (NAT softc) host map size in ip_nat6 calculation.

The ipfilter NAT table host map size is a tunable that defaults to
a macro value defined at build time. HOSTMAP_SIZE is saved in softn
(the ipnat softc) at initialization. It can be tuned (changed) at runtime
using the ipf -T command. If the hostmap_size tunable is adjusted the
calculation to determine where to put new entries in the table was
incorrect. Use the tunable in the NAT softc instead of the static build
time value.

(cherry picked from commit 344f1083e1)
2021-02-15 16:40:50 -08:00
Cy Schubert
d751393cdd MFC e673debe7d:
Simplify BSD macro tests.

All FreeBSD and NetBSD are BSD >= 199306 and have been for a long time.

(cherry picked from commit e673debe7d)
2021-02-15 16:40:49 -08:00
Cy Schubert
d81409e2b9 MFC 0f34c80f37:
Replace the redundant MENTAT macro with SOLARIS.

MENTAT and SOLARIS are synonymous. Remove the extraneous duplicate
macro.

(cherry picked from commit 0f34c80f37)
2021-02-15 16:40:49 -08:00
Cy Schubert
d72c88fe27 MFC 7071734fae:
Indentation cleanup resulting from the cleanup of #ifdefs.

The conscious decision was made not to perform any indentation or
whitespace cleanup while cleaning out old redunant #ifdefs. The
reason for this was to avoid confusing future readers of history and
diffs with cosmetic changes, making bisection of any possible bugs
introduced more difficult. This commit cleans up the whitespace
detritus left behind from the previous #ifdef cleanup commits.

(cherry picked from commit 7071734fae)
2021-02-15 16:40:49 -08:00
Cy Schubert
422b6a3048 MFC 4cd1807c7d:
Retire the K&R/STD C __P prototype declarations.

In the old days when K&R C and STD C were each in use a workaround
(read hack) was required to allow the same code to work on each
without modification. All C compilers support STD C. We can finally
put the __P prototype to rest.

(cherry picked from commit 4cd1807c7d)
2021-02-15 16:40:48 -08:00
Antonio Russo
618dee6023 Set file mode during zfs_write
Apply https://github.com/openzfs/zfs/pull/11576

Direct commit from upstream openzfs. Full commit message below:

Set file mode during zfs_write

3d40b65 refactored zfs_vnops.c, which shared much code verbatim between
Linux and BSD.  After a successful write, the suid/sgid bits are reset,
and the mode to be written is stored in newmode.  On Linux, this was
propagated to both the in-memory inode and znode, which is then updated
with sa_update.

3d40b65 accidentally removed the initialization of newmode, which
happened to occur on the same line as the inode update (which has been
moved out of the function).

The uninitialized newmode can be saved to disk, leading to a crash on
stat() of that file, in addition to a merely incorrect file mode.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #11474
Closes #11576

Obtained from:	openzfs/zfs@f8ce8aed0
MFC after:	0 days
Sponsored by:	iXsystems, Inc.

(cherry picked from commit e9d419a053)
2021-02-09 12:51:04 -05:00
Mateusz Guzik
7ba12ba0a2 zfs: use atomic_load_consume_ptr for z_cached_symlink
(cherry picked from commit 7af02ef0b2)
2021-02-01 12:39:16 +00:00
Mateusz Guzik
e92ab3adf4 atomic: make atomic_store_ptr type-aware
(cherry picked from commit cc96f92a57)
2021-02-01 12:39:16 +00:00
Mateusz Guzik
dde453cf7d zfs: fix panics with invariant kernels from zfs_replay_setattr
(cherry picked from commit f40d6217f2)
2021-02-01 12:39:16 +00:00
Mateusz Guzik
c5fcd06736 zfs: add support for lockless symlink lookup
Reviewed by:	kib (previous version)
Tested by:	pho (previous version)
Differential Revision:	https://reviews.freebsd.org/D27488

(cherry picked from commit 3110d4ebd6)
2021-02-01 12:39:15 +00:00
Cy Schubert
514caf57cd MFC: 83edbc3cb5
ipfilter: Retire pre-standard C support.

All C compilers in 2021 support standard C and architectures that did
not were retired long ago. Simplify by removing now redundant
pre-standard C code.

(cherry picked from commit 83edbc3cb5)
2021-01-30 20:28:06 -08:00
John Baldwin
d86d319495 Simplify dynamic ipfilter sysctls.
Pass the structure offset in arg2 instead of arg1.  This avoids
having to undo the pointer arithmetic on arg1.  Instead arg2 can
be used directly as an offset relative to the desired structure.

Reviewed by:	cy
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27961
2021-01-20 16:34:25 -08:00
Emmanuel Vadot
19775aa7bc Re-apply f81b2b9a8a to the new device-tree import 2021-01-15 20:07:13 +01:00
Emmanuel Vadot
78abc9e2e6 Revert upstream commit 27c90e5e48d0
It changed the #pinctrl-cells value to be equal to 2 and the macro
that generates the values.
Based on the bindings docs a value of 2 is only acceptable if the node
used pinctrl-single,bits and not pinctrl-single,pins

This allow booting further on the beaglebone black with 5.9 DTS
2021-01-15 20:07:08 +01:00
Emmanuel Vadot
c66ec88fed Add 'sys/contrib/device-tree/' from commit '5ee353c36d3c9c7f63df7c7671875e73fba70958'
git-subtree-dir: sys/contrib/device-tree
git-subtree-mainline: 94611a8388
git-subtree-split: 5ee353c36d
2021-01-15 12:28:57 +01:00
Alan Somers
58a08f9e99 [skip ci] Delete an accidentally-committed comment
MFC-With:	19cca0b961
2021-01-11 17:01:22 -07:00
Alan Somers
19cca0b961 aio: fix the tests when ZFS is not available
Don't try to cleanup the zpool if we couldn't create a zpool in the
first place.

Submitted by:	tmunro
MFC-with:	022ca2fc7f
2021-01-09 17:16:38 -07:00