dragonfly.git
20 months agosys/vfs/hammer2: hammer2_dump_chain() should belong to hammer2_chain.c
Tomohiro Kusumi [Mon, 3 Oct 2022 06:12:38 +0000 (23:12 -0700)]
sys/vfs/hammer2: hammer2_dump_chain() should belong to hammer2_chain.c

20 months agosys/vfs/hammer2: Use HAMMER2_PFSTYPE_NONE rather than 0
Tomohiro Kusumi [Thu, 29 Sep 2022 04:01:19 +0000 (21:01 -0700)]
sys/vfs/hammer2: Use HAMMER2_PFSTYPE_NONE rather than 0

20 months agosys/vfs/hammer2: Make sure PFS exists after chain lookup on mount
Tomohiro Kusumi [Tue, 27 Sep 2022 08:02:52 +0000 (01:02 -0700)]
sys/vfs/hammer2: Make sure PFS exists after chain lookup on mount

If pmp is NULL at this point, it panics, so return EINVAL.

What makes the existing code complicated is pmp could have already
been found via @label matching about 300 lines above, regardless of
chain lookup result right before this diff.

So return EINVAL on `pmp == NULL` rather than `chain->error != 0`.
In any case, something is wrong if chain lookup failed despite pmp.

20 months agosys/vfs/hammer2: hammer2_ioctl_inode_{get,set} never returns error
Tomohiro Kusumi [Tue, 27 Sep 2022 04:13:40 +0000 (21:13 -0700)]
sys/vfs/hammer2: hammer2_ioctl_inode_{get,set} never returns error

No need to do hammer2_error_to_errno(error).

20 months agosys/vfs/hammer2: Add include guard for hammer2_xxhash.h
Tomohiro Kusumi [Tue, 27 Sep 2022 04:10:24 +0000 (21:10 -0700)]
sys/vfs/hammer2: Add include guard for hammer2_xxhash.h

20 months agosbin/hammer2: Remove HAMMER1 comment from dirhash()
Tomohiro Kusumi [Sun, 25 Sep 2022 09:20:05 +0000 (02:20 -0700)]
sbin/hammer2: Remove HAMMER1 comment from dirhash()

and sync with hammer2_dirhash() which doesn't have this comment.
The latter half of the comment doesn't apply.

20 months agosys/vfs/hammer2: Rename hammer2_chain_core_init() -> hammer2_chain_init()
Tomohiro Kusumi [Sat, 24 Sep 2022 08:11:08 +0000 (01:11 -0700)]
sys/vfs/hammer2: Rename hammer2_chain_core_init() -> hammer2_chain_init()

Currently this function is just a common function to initialize chains.
What it initializes are no longer limited to chain->core as opposed to
when it first appeared in 0dea3156dc9c037aae4fd9fb00c631a401f62e5a in 2013.

Remove "core" for clarity and remove irrelevant comment.

20 months agosys/vfs/hammer2: Change readonly purpose sysctls to CTLFLAG_RD
Tomohiro Kusumi [Sat, 24 Sep 2022 06:12:10 +0000 (23:12 -0700)]
sys/vfs/hammer2: Change readonly purpose sysctls to CTLFLAG_RD

read/write/allocation/process counters shouldn't be writable.

20 months agosys/vfs/hammer2: Use __debugvar for RB_INSERT() result only used in KKASSERT
Tomohiro Kusumi [Fri, 23 Sep 2022 07:10:12 +0000 (00:10 -0700)]
sys/vfs/hammer2: Use __debugvar for RB_INSERT() result only used in KKASSERT

20 months agosys/vfs/hammer2: Use __debugvar rather than trying to use it outside KASSERT
Tomohiro Kusumi [Wed, 21 Sep 2022 03:05:13 +0000 (20:05 -0700)]
sys/vfs/hammer2: Use __debugvar rather than trying to use it outside KASSERT

Redo 9944926ceb4c39de216e512f60f1841d25e267f1.

suggested-by: swildner

20 months agosys/vfs/hammer2: Avoid unused warning when !INVARIANTS
Tomohiro Kusumi [Sun, 18 Sep 2022 10:15:12 +0000 (03:15 -0700)]
sys/vfs/hammer2: Avoid unused warning when !INVARIANTS

Use xchain local variable.
error: variable 'xchain' set but not used [-Werror,-Wunused-but-set-variable]

20 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Sun, 18 Sep 2022 01:11:28 +0000 (18:11 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

 $ git log --pretty="%h %s" 8a656edff0678e34ac00175186cb6850eadc9441.. -- sys/vfs/hammer2/
 b18a596227 Revert "sys/vfs/hammer2: Properly set rdonly flag for PFS"
 617766ee20 sys/vfs/hammer2: Fix typo in error message
 b108516224 sys/vfs/hammer2: Fail mount if root volume was not specified
 e9ecf1728d sys/vfs/hammer2: Remove unused local variable bigread
 de2601344f sys/vfs/hammer2: Remove unused modify_tid argument in hammer2_pfsalloc()
 5f5122fa24 sys/vfs/hammer2: Properly set rdonly flag for PFS
 a5e418c0eb sys/vfs/hammer2: Fix incorrect hammer2_dump_chain() argument

20 months agonrelease - Copy `/etc/ssl/cert.pem` into ISOROOT
Michael Neumann [Sat, 17 Sep 2022 16:28:41 +0000 (18:28 +0200)]
nrelease - Copy `/etc/ssl/cert.pem` into ISOROOT

Otherwise it fails when using target `binpkg`:

```
9984868:error:14FFF086:SSL routines:(UNKNOWN)SSL_internal:certificate verify failed:/usr/src/lib/libressl/../../crypto/libressl/ssl/tls13_client.c:617:
pkg-static: https://mirror-master.dragonflybsd.org/dports/dragonfly:6.4:x86:64/LATEST/packagesite.txz: Authentication error
Unable to update repository Avalon
Error updating repositories!
```

20 months agousr.sbin/makefs: Allow FIFO hardlink for HAMMER2
Tomohiro Kusumi [Sat, 17 Sep 2022 07:24:01 +0000 (00:24 -0700)]
usr.sbin/makefs: Allow FIFO hardlink for HAMMER2

since this is possible on actual HAMMER2 as well.

20 months agousr.sbin/makefs: Support hardlink (vop_nlink) for HAMMER2
Tomohiro Kusumi [Fri, 16 Sep 2022 08:04:36 +0000 (01:04 -0700)]
usr.sbin/makefs: Support hardlink (vop_nlink) for HAMMER2

Currently only regular file is allowed for hardlink.

20 months agousr.sbin/makefs: Support FIFO (vop_nmknod) for HAMMER2
Tomohiro Kusumi [Fri, 16 Sep 2022 03:30:30 +0000 (20:30 -0700)]
usr.sbin/makefs: Support FIFO (vop_nmknod) for HAMMER2

20 months agourtwn - Add support for Edimax EW-7811Un V2 (N150)
Michael Neumann [Wed, 14 Sep 2022 15:40:30 +0000 (17:40 +0200)]
urtwn - Add support for Edimax EW-7811Un V2 (N150)

20 months agoRevert "sys/vfs/hammer2: Properly set rdonly flag for PFS"
Tomohiro Kusumi [Tue, 13 Sep 2022 08:35:07 +0000 (01:35 -0700)]
Revert "sys/vfs/hammer2: Properly set rdonly flag for PFS"

This reverts commit 5f5122fa2471887600e87e29917d577f65d73a05.

pmp->ronly should be set properly, but hammer2_remount() implementation
is missing pmp handling.

20 months agosys/vfs/hammer2: Fix typo in error message
Tomohiro Kusumi [Tue, 13 Sep 2022 07:25:40 +0000 (00:25 -0700)]
sys/vfs/hammer2: Fix typo in error message

21 months agosys/vfs/hammer2: Fail mount if root volume was not specified
Tomohiro Kusumi [Mon, 12 Sep 2022 07:12:04 +0000 (00:12 -0700)]
sys/vfs/hammer2: Fail mount if root volume was not specified

If !rootvoldata->version, root volume was never specified which is invalid.
This prevents panic (in hammer2_verify_volumes_1() via vol->dev->path dereference)
on attempt to mount only non-root volumes.

21 months agosbin/newfs_hammer2: Fix -V option being required for multi-volumes
Tomohiro Kusumi [Sun, 11 Sep 2022 08:30:52 +0000 (01:30 -0700)]
sbin/newfs_hammer2: Fix -V option being required for multi-volumes

Since 2d60b848f2 ("usr.sbin/makefs: Add HAMMER2 support") creating multi-volumes
required explicit '-V 2' option, which wasn't the case before.

21 months agosbin/hammer2: Rename CountBlocks() -> count_blocks()
Tomohiro Kusumi [Sun, 11 Sep 2022 01:30:13 +0000 (18:30 -0700)]
sbin/hammer2: Rename CountBlocks() -> count_blocks()

This (and only this) static function has been camel case.

21 months agousr.sbin/makefs: Correct a typo in a source code comment
Tomohiro Kusumi [Sat, 10 Sep 2022 09:32:04 +0000 (02:32 -0700)]
usr.sbin/makefs: Correct a typo in a source code comment

taken-from FreeBSD 5f285d5537219932c12ce4e6149d1a4f26aa3457

21 months agosys/vfs/hammer2: Remove unused local variable bigread
Tomohiro Kusumi [Fri, 9 Sep 2022 08:05:56 +0000 (01:05 -0700)]
sys/vfs/hammer2: Remove unused local variable bigread

Warned on other platform.
error: variable 'bigread' set but not used [-Werror,-Wunused-but-set-variable]

21 months agodsynth: Call free() after asprintf() .
Antonio Huete Jimenez [Thu, 8 Sep 2022 23:49:38 +0000 (01:49 +0200)]
dsynth: Call free() after asprintf() .

21 months agodsynth - better error reporting for dependency parsing (5)
Alexandr Savca (chinarulezzz) [Thu, 8 Sep 2022 10:53:36 +0000 (13:53 +0300)]
dsynth - better error reporting for dependency parsing (5)

Fix typo.

21 months agosys/vfs/hammer2: Remove unused modify_tid argument in hammer2_pfsalloc()
Tomohiro Kusumi [Thu, 8 Sep 2022 03:30:05 +0000 (20:30 -0700)]
sys/vfs/hammer2: Remove unused modify_tid argument in hammer2_pfsalloc()

No longer used since 0057d3b85eefbd3e0309a08a0a41f2e438f3bf9b in 2015.

21 months agosys/vfs/hammer2: Properly set rdonly flag for PFS
Tomohiro Kusumi [Wed, 7 Sep 2022 07:11:28 +0000 (00:11 -0700)]
sys/vfs/hammer2: Properly set rdonly flag for PFS

VOP's check if PFS is rdonly mount, but pmp->ronly is always 0.

Note that VFS usually returns error for rdonly mount before
process even reaches there.

21 months agodsynth - better error reporting for dependency partsing (4)
Matthew Dillon [Tue, 6 Sep 2022 16:00:44 +0000 (09:00 -0700)]
dsynth - better error reporting for dependency partsing (4)

* Add even more information.  Print which dependency variable
  is having the trouble.

21 months agodsynth - better error reporting for dependency partsing (3)
Matthew Dillon [Tue, 6 Sep 2022 15:48:40 +0000 (08:48 -0700)]
dsynth - better error reporting for dependency partsing (3)

* Sigh

21 months agodsynth - better error reporting for dependency partsing (2)
Matthew Dillon [Tue, 6 Sep 2022 15:46:51 +0000 (08:46 -0700)]
dsynth - better error reporting for dependency partsing (2)

* Output original dependency string (its big) prior to strsep
  changes.

21 months agodsynth - add 'list-system' directive
Matthew Dillon [Tue, 6 Sep 2022 15:03:58 +0000 (08:03 -0700)]
dsynth - add 'list-system' directive

* Add a 'list-system' directive which generates a list of installed
  ports on the current machine that can then be used as a build list
  on another machine.

21 months agodsynth - better error reporting for dependency partsing
Matthew Dillon [Tue, 6 Sep 2022 15:03:18 +0000 (08:03 -0700)]
dsynth - better error reporting for dependency partsing

* Do a better job reporting problems parsing dependencies

Reported-by: tuxillo
21 months agosbin/newfs_hammer2: Remove reference to nonexistent HAMMER2(5)
Tomohiro Kusumi [Mon, 5 Sep 2022 10:10:09 +0000 (03:10 -0700)]
sbin/newfs_hammer2: Remove reference to nonexistent HAMMER2(5)

hammer(5) exists, but no such thing hammer2(5).

21 months agosys/vfs/hammer2: Fix incorrect hammer2_dump_chain() argument
Tomohiro Kusumi [Mon, 5 Sep 2022 09:17:59 +0000 (02:17 -0700)]
sys/vfs/hammer2: Fix incorrect hammer2_dump_chain() argument

The third argument is blockref index within parent,
so initial caller should always pass 0.

Currently i happens to be always 0.

21 months agosys/vfs/autofs: Include <sys/proc.h> for APRINTF()
Tomohiro Kusumi [Mon, 5 Sep 2022 01:40:51 +0000 (18:40 -0700)]
sys/vfs/autofs: Include <sys/proc.h> for APRINTF()

21 months agousr.sbin/makefs: Panic if fifo hits HAMMER2_XOPFIFO
Tomohiro Kusumi [Fri, 2 Sep 2022 17:40:06 +0000 (10:40 -0700)]
usr.sbin/makefs: Panic if fifo hits HAMMER2_XOPFIFO

tsleep() calls assert(0), but explicitly panic if feed detects
fifo limit. HAMMER2 in makefs has no dedicated XOP threads,
so it can't sleep and nobody can wake it up.

21 months agosys/vfs/autofs: Test if curproc is NULL in debug print
Tomohiro Kusumi [Fri, 2 Sep 2022 17:23:05 +0000 (10:23 -0700)]
sys/vfs/autofs: Test if curproc is NULL in debug print

21 months agosbin/newfs_hammer2: Don't fail to zero clear buffer for root inodes
Tomohiro Kusumi [Tue, 23 Aug 2022 08:14:52 +0000 (01:14 -0700)]
sbin/newfs_hammer2: Don't fail to zero clear buffer for root inodes

Seeing root inodes containing garbage on other platform.

21 months agosbin/hammer2: Fix comment mkpfs -> pfs-create
Tomohiro Kusumi [Wed, 17 Aug 2022 06:30:13 +0000 (23:30 -0700)]
sbin/hammer2: Fix comment mkpfs -> pfs-create

"mkpfs" existed only until ae183399278ee71fba31527cd18a7545ac9af2e4 in 2012.

22 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Fri, 12 Aug 2022 07:12:39 +0000 (00:12 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

 # git log --pretty="%h %s" 2d60b848f2503f28d840ceae174d07eb149ccce9.. -- sys/vfs/hammer2/
 668318c124 sys/vfs/hammer2: Remove comment on nonexistent hammer2_pfs_moderate()
 adbe992149 sys/vfs/hammer2: Remove unused pmp local variable
 ebb25fd8bc sys/vfs/hammer2: Remove redundant *dev local variable
 b9777b339d sys/vfs/hammer2: Remove no longer used hammer2_cluster_forcegood()
 e239545684 sys/vfs/hammer2: Fix indentation
 18aaa4b139 sys/vfs/hammer2: Remove unused local variables in hammer2_chain.c
 fc134ad976 sys/vfs/hammer2: Remove unused pmp local variable
 73503323eb sys/vfs/hammer2: Remove unused local variables in hammer2_primary_xops_thread()
 26ded3a850 sys/vfs/hammer2: Remove unused smpresent local variable
 353c2689d5 sys/vfs/hammer2: Remove unused local pmp variable

22 months agosys/vfs/hammer2: Remove comment on nonexistent hammer2_pfs_moderate()
Tomohiro Kusumi [Wed, 10 Aug 2022 07:12:36 +0000 (00:12 -0700)]
sys/vfs/hammer2: Remove comment on nonexistent hammer2_pfs_moderate()

hammer2_pfs_moderate() was removed in
d2a410239c107d0aeceaf0a17417e92b75be24ed in 2018.

22 months agosys/vfs/hammer2: Remove unused pmp local variable
Tomohiro Kusumi [Tue, 9 Aug 2022 07:12:07 +0000 (00:12 -0700)]
sys/vfs/hammer2: Remove unused pmp local variable

Never used since first appeared in
c92abd0f77ba75e840c762f6ac141f120ccb38dd in 2016.

Warned on other platform.
error: variable 'pmp' set but not used [-Werror,-Wunused-but-set-variable]

22 months agosys/vfs/hammer2: Remove redundant *dev local variable
Tomohiro Kusumi [Tue, 9 Aug 2022 04:30:39 +0000 (21:30 -0700)]
sys/vfs/hammer2: Remove redundant *dev local variable

Currently all it does is point to another local variable
and no pointer arithmetic.

22 months agosys/vfs/hammer2: Remove no longer used hammer2_cluster_forcegood()
Tomohiro Kusumi [Sat, 6 Aug 2022 08:30:06 +0000 (01:30 -0700)]
sys/vfs/hammer2: Remove no longer used hammer2_cluster_forcegood()

No longer used since "ends the major refactoring" from
01d71aa5538cba09383737ddbea2fb05e1e75e78 in 2015.

22 months agosys/vfs/hammer2: Fix indentation
Tomohiro Kusumi [Fri, 5 Aug 2022 08:30:12 +0000 (01:30 -0700)]
sys/vfs/hammer2: Fix indentation

22 months agosys/vfs/hammer2: Remove unused local variables in hammer2_chain.c
Tomohiro Kusumi [Thu, 28 Jul 2022 07:25:16 +0000 (00:25 -0700)]
sys/vfs/hammer2: Remove unused local variables in hammer2_chain.c

Remove lots of "set but not used" which get warned on other platform.

These variables mostly come from functions these are based on.

22 months agosys/vfs/hammer2: Remove unused pmp local variable
Tomohiro Kusumi [Wed, 27 Jul 2022 09:34:23 +0000 (02:34 -0700)]
sys/vfs/hammer2: Remove unused pmp local variable

Never used since first appeared in
b7add6753e221920947c96fab3314c39a2f67fe4 in 2015.

Warned on other platform.
error: variable 'pmp' set but not used [-Werror,-Wunused-but-set-variable]

22 months agosys/vfs/hammer2: Remove unused local variables in hammer2_primary_xops_thread()
Tomohiro Kusumi [Wed, 27 Jul 2022 05:37:33 +0000 (22:37 -0700)]
sys/vfs/hammer2: Remove unused local variables in hammer2_primary_xops_thread()

pmp was unused since 21a904588eeea78c4050292c4c477f008a38784f in 2015.
last_desc was never used since first appeared.

These get warned on other platform.
error: variable 'pmp' set but not used [-Werror,-Wunused-but-set-variable]
error: variable 'last_desc' set but not used [-Werror,-Wunused-but-set-variable]

22 months agosys/vfs/hammer2: Remove unused smpresent local variable
Tomohiro Kusumi [Mon, 25 Jul 2022 06:22:08 +0000 (23:22 -0700)]
sys/vfs/hammer2: Remove unused smpresent local variable

Unused since f3bfcc3fda3d70dd80cbb0440b5b8649ca2d07de in 2022
and this gets warned on other platform.
error: variable 'smpresent' set but not used [-Werror,-Wunused-but-set-variable]

22 months agoif_bridge - Fix a broadcast issue, cleanup
Matthew Dillon [Mon, 25 Jul 2022 00:19:58 +0000 (17:19 -0700)]
if_bridge - Fix a broadcast issue, cleanup

* Fix a broadcast issue in bridge_output().  This routine takes packets
  originated on the machine that are sent to an interface that is part
  of the bridge.  These are NOT forwarded packets, but packets originated
  on the machine.

  For all intents and purposes, these packets are being sent to the bridge
  and the interface on the bridge that the system looked-up should not be
  treated specially.

* This should fix issues with ARPs sometimes going into the bit-bucket.

* Distinguish between interfaces that are part of the same bonded set
  (i.e. go to the same place) from round-robin vs backup mode.

  Previously there was some confusion as to whether the interfaces were
  distinct or not.  All interfaces on the bridge with the same MAC are
  considered to be bonded for the purposes of packet rejection when
  forwarding and masking when broadcasting.  i.e. the multiple end-points
  go between the same two end-points.  The mode is then determined by
  the ifpriority of the highest-priority interfaces.  If the ifpriority
  is different, backup mode is assumed.  If the ifpriority for the highest
  priority bonded set is the same, round-robin mode is assumed.

* Clean-up documentation and adjust the syntax for multi-line if()
  statements for readability.

* These fixes do not address potential issues with loops in the
  spanning tree yet.

22 months agoUpdate the pciconf(8) database.
Sascha Wildner [Sat, 23 Jul 2022 00:54:35 +0000 (02:54 +0200)]
Update the pciconf(8) database.

July 17, 2022 snapshot from https://pci-ids.ucw.cz

23 months agolibc - Correct handling of non-hex sequences in strtol*() and related
Matthew Dillon [Wed, 13 Jul 2022 16:07:12 +0000 (09:07 -0700)]
libc - Correct handling of non-hex sequences in strtol*() and related

* The standard clarifies that non-hex sequences such as "0xy"
  should return 0 and a pointer to "xy".  Ours was returning
  0 and a pointer to "y".  Fixed.

* Unlikely to be any net effect on code other than improved
  standards conformity.

Reported-by: Herbert J. Skuhra
23 months agofetch - Fix -T timeout operation for additional cases
Matthew Dillon [Mon, 11 Jul 2022 03:40:46 +0000 (20:40 -0700)]
fetch - Fix -T timeout operation for additional cases

* The -T timeout flag does not always timeout the program.  The
  implementation only tested it during the initial connection and
  header fetch, not during data transfers.

* Makme the -T timeout apply to data transfers.  However, any progress
  on the transfer resets the timer.

* Volatilize several variables that need it, and add an interlock
  to deal with alarm() races.  Also, when the SIGALRM occurs, if
  still enabled it will be re-armed and fire off every second thereafter
  until processed, since the alarm might not catch a blocked system call
  in progress.

23 months agosys/vfs/hammer2: Remove unused local pmp variable
Tomohiro Kusumi [Sun, 10 Jul 2022 08:38:07 +0000 (01:38 -0700)]
sys/vfs/hammer2: Remove unused local pmp variable

Warned on other platform.
error: variable 'pmp' set but not used [-Werror,-Wunused-but-set-variable]

23 months agodrm: retry page fault handler on buffer data in transit
Sergey Zigachev [Fri, 8 Jul 2022 17:31:27 +0000 (22:31 +0500)]
drm: retry page fault handler on buffer data in transit

Fixes Xorg crash on a connect/disconnect monitor when using amdgpu with
modesetting driver. Crash occured because buffer object was in transit
state. Added retry loop that allows up to 100 iterations allowing buffer object
to "catch up". During testing around 30-40 iterations were observed.

Co-authored-by: Matthew Dillon <dillon@apollo.backplane.com>
23 months agoTest commit
Sergey Zigachev [Fri, 8 Jul 2022 17:19:51 +0000 (22:19 +0500)]
Test commit

23 months agousr.sbin/makefs: Cast daddr_t to off_t before multiplication
Tomohiro Kusumi [Wed, 6 Jul 2022 19:43:08 +0000 (12:43 -0700)]
usr.sbin/makefs: Cast daddr_t to off_t before multiplication

Apparently some large-file systems out there, such as my powerpc64le
Linux box, define daddr_t as a 32-bit type, which is sad and stymies
cross-building disk images.  Cast daddr_t to off_t before doing
arithmetic that overflows.

taken-from FreeBSD 7ef082733bf8989797b71025ba6d597a7d17d92b

23 months agousr.sbin/makefs: Allocate extra inodes in makefs when leaving free space in UFS images
Tomohiro Kusumi [Wed, 6 Jul 2022 05:31:01 +0000 (22:31 -0700)]
usr.sbin/makefs: Allocate extra inodes in makefs when leaving free space in UFS images

By default, makefs(8) has very few spare inodes in its output images,
which is fine for static filesystems, but not so great for VM images
where many more files will be added. Make makefs(8) use the same
default settings as newfs(8) when creating images with free space --
there isn't much point to leaving free space on the image if you
can't put files there. If no free space is requested, use current
behavior of a minimal number of available inodes.

taken-from FreeBSD afb6a168f8ee08ac74769464726c396fbef83d0b

23 months agousr.sbin/makefs: Fix calculation of file sizes
Tomohiro Kusumi [Wed, 6 Jul 2022 04:54:34 +0000 (21:54 -0700)]
usr.sbin/makefs: Fix calculation of file sizes

When a new FS image is created we need to calculate how much space each
file is going to consume.
Fix two bugs in that logic:

1) Count the space needed for indirect blocks for large files.
1) Normally the trailing data of a file is written to a block of frag
   size, 4 kB by default.

However for files that use indirect blocks a full block is allocated,
32kB by default.  Take that into account.

Adjust size calculations to match what is done in ffs_mkfs routine:

* Depending on the UFS version the superblock is stored at a different
  offset. Take that into account.
* Add the cylinder group block size.
* All of the above has to be aligned to the block size.

Finally, Remove "ncg" variable. It's always 1 and it was used to
multiply stuff.

taken-from FreeBSD ecdc04d006de93eb343ce3b77208abd937d4f8ac

23 months agodebug - more ncptrace enhancements
Matthew Dillon [Mon, 4 Jul 2022 07:40:55 +0000 (00:40 -0700)]
debug - more ncptrace enhancements

* Accumulate counts for unres, leafs, fache, and negative entries,
  and print at the end.

23 months agokernel - Attempt to fix broken vfs.cache.numunres tracker (2)
Matthew Dillon [Mon, 4 Jul 2022 07:39:32 +0000 (00:39 -0700)]
kernel - Attempt to fix broken vfs.cache.numunres tracker (2)

* The main culprit appears to be cache_allocroot() accounting
  for new root ncps differently than the rest of the module.
  So anything which mounts and umounts continuously, like
  dsynth, can seriously make the numbers whacky.

* Fix that and run an overnight test.

23 months agodebug - add nc_generation output from ncptrace
Matthew Dillon [Mon, 4 Jul 2022 05:28:00 +0000 (22:28 -0700)]
debug - add nc_generation output from ncptrace

* Adjust ncptrace to print the value of nc_generation

23 months agosh - Support writes to non-blocking descriptors
Matthew Dillon [Mon, 4 Jul 2022 03:54:42 +0000 (20:54 -0700)]
sh - Support writes to non-blocking descriptors

* Instead of reporting "write error on stdout", support writes
  to non-blocking sockets by having xwrite() use poll() to block
  when EAGAIN is returned.

* This is possibly related to such errors appearing in the dsynth
  logs.  Presumably (unverified), /bin/sh can wind up being executed
  with descriptor 1 set to non-blocking.  This works fine only as long
  as the other end of the pipe is able to drain it quickly enough.
  But under heavy loads, this might not happen.

23 months agokernel - check nc_generation in nlookup path
Matthew Dillon [Mon, 4 Jul 2022 03:47:32 +0000 (20:47 -0700)]
kernel - check nc_generation in nlookup path

* With nc_generation now operating in a more usable manner, we can
  use it in nlookup() to check for changes.  When a change is detected,
  the related lock will be cycled and the entire nlookup() will retry up
  to debug.nlookup_max_retries, which currently defaults to 4.

* Add debugging via debug.nlookup_debug.  Set to 3 for nc_generation
  debugging.

* Move "Parent directory lost" kprintfs into a debugging conditional,
  reported via (debug.nlookup_debug & 4).

* This fixes lookup/remove races which could sometimes cause open()
  and other system calls to return EINVAL or ENOTCONN.  Basically
  what happened was that nlookup() wound up on a NCF_DESTROYED entry.

* A few minutes worth of a dsynth bulk does not report any random
  generation number mismatches or retries, so the code in this commit
  is probably very close to correct.

23 months agokernel - Change ncp->nc_generation operation
Matthew Dillon [Mon, 4 Jul 2022 00:10:51 +0000 (17:10 -0700)]
kernel - Change ncp->nc_generation operation

* Change nc_generation operation.  Bit 0 is reserved.  The field is
  incremented by 2 whenever major changes are being made to the ncp
  (linking, unlinking, destruction, resolve, unresolve, vnode adjustment),
  and then incremented by 2 again when the operation is complete.

  The caller can test for a major gen change using:

  curr_gen = ncp->nc_generation & ~3;
  if ((orig_gen - curr_gen) & ~1)
      (retry needed)

* Allows unlocked/relocked code to determine whether the ncp has possibly
  changed or not (will be used in upcoming commits).

* Adjust the kern_rename() code to use the generation numbers.

* Bit 0 will be used to check for a combination of major changes and
  lock cycling inthe future.

23 months agokernel - Attempt to fix broken vfs.cache.numunres tracker
Matthew Dillon [Sun, 3 Jul 2022 23:31:00 +0000 (16:31 -0700)]
kernel - Attempt to fix broken vfs.cache.numunres tracker

* Try to fix a mis-count that can accumulate under heavy loads.

* In cache_setvp() and cache_setunresolved(), only adjust the
  unres count for namecache entries that are linked into the
  topology.

23 months agomanual - Silently accept any value for IPV6_V6ONLY sockopt
Matthew Dillon [Fri, 1 Jul 2022 02:41:15 +0000 (19:41 -0700)]
manual - Silently accept any value for IPV6_V6ONLY sockopt

* Update the ip6(4) manual page with the new behavior of IPV6_V6ONLY.

23 months agokernel - Silently accept any value for IPV6_V6ONLY sockopt
Matthew Dillon [Fri, 1 Jul 2022 02:11:11 +0000 (19:11 -0700)]
kernel - Silently accept any value for IPV6_V6ONLY sockopt

* Numerous utilities including named behave horribly if the IPV6_V6ONLY
  socketopt returns a failure.  We were returning failure if anyone
  attempted to set it to 0.

* just silently ignore the value entirely, always return success.  Fixes
  named, libuv (which named uses), and numerous other ports that use
  libuv or otherwise stupidly mess with this socketopt.

Reported-by: tuxillo
23 months agoAdd a small amdgpu.4 manual page.
Sascha Wildner [Sat, 18 Jun 2022 19:36:22 +0000 (21:36 +0200)]
Add a small amdgpu.4 manual page.

Submitted-by: Sergey Zigachev <s.zi@outlook.com>
2 years ago<stdlib.h>: Don't expose malloc_usable_size() in POSIX environments.
Sascha Wildner [Sat, 11 Jun 2022 07:59:09 +0000 (09:59 +0200)]
<stdlib.h>: Don't expose malloc_usable_size() in POSIX environments.

2 years agoUnbreak buildworld.
Sascha Wildner [Sat, 11 Jun 2022 07:58:32 +0000 (09:58 +0200)]
Unbreak buildworld.

csh uses its own malloc_usable_size(), which, now that its prototype comes
in with <stdlib.h>, has to take a const argument, too. :-(

2 years agokernel - namecache eviction fixes
Matthew Dillon [Sat, 11 Jun 2022 04:38:37 +0000 (21:38 -0700)]
kernel - namecache eviction fixes

* Fix several namecache eviction issues which interfere with nlookup*()
  functions.

  There is an optimization where nlookup*() avoids locking intermediate
  ncp's in a path whenever possible on the assumption that the ref on
  the ncp will prevent eviction.  This assumption fails when the machine
  is under a heavy namecache load.

  Errors included spurious ENOTCONN and EINVAL error codes from file
  operations.

* Refactor the namecache code to not evict resolved namecache entries
  which have extra refs under normal operation.  This allows nlookup*()
  and other functions to operate semi-lockless for intermediate elements
  in a path.  However, they still obtain a ref which is a cache-unfriendly
  atomic operation.

  This fixes numerous weird errors that occur during heavy dsynth bulk
  builds.

* Also fix a bug which evicted too many resolved namecache entries when
  attempting to evict unresolved entries.  This should improve performance
  under heavy namecache loads a bit.

2 years agoworld - include malloc_np.h from stdlib.h
Matthew Dillon [Sat, 11 Jun 2022 04:34:27 +0000 (21:34 -0700)]
world - include malloc_np.h from stdlib.h

* Include malloc_np.h from stdlib.h as per FreeBSD manual page.
  Note that linux includes it from <malloc.h>, but BSD's do not
  have a malloc.h so this is the easier path for now.

2 years agolibc - Fix bug in recent malloc_usable_size() support
Matthew Dillon [Thu, 9 Jun 2022 06:25:13 +0000 (23:25 -0700)]
libc - Fix bug in recent malloc_usable_size() support

* Add missing unlock in the bigalloc check path

* Fixes miniruby deadlock and other threaded uses of malloc_usable_size()
  on large memory blocks.

2 years agomalloc.3: Unify RETURN VALUES. Add info about malloc_usable_size().
Sascha Wildner [Wed, 8 Jun 2022 15:06:49 +0000 (17:06 +0200)]
malloc.3: Unify RETURN VALUES. Add info about malloc_usable_size().

2 years agokernel: Add some __printflike() to satisfy -Wsuggest-attribute=format.
Sascha Wildner [Wed, 8 Jun 2022 14:41:43 +0000 (16:41 +0200)]
kernel: Add some __printflike() to satisfy -Wsuggest-attribute=format.

2 years agonewfs_msdos(8): Remove a duplicate fstat() check.
Sascha Wildner [Mon, 6 Jun 2022 19:20:58 +0000 (21:20 +0200)]
newfs_msdos(8): Remove a duplicate fstat() check.

An identical check is done right after it in compute_geometry_from_file().

Spotted-by: n00b659
2 years agousr.sbin/makefs: Rename vnode::logical,vflushed,malloced to start with v_
Tomohiro Kusumi [Mon, 6 Jun 2022 10:13:33 +0000 (19:13 +0900)]
usr.sbin/makefs: Rename vnode::logical,vflushed,malloced to start with v_

Almost all vnode fields in sys/sys/vnode.h start with v_,
so follow that naming rule in makefs(8) vnode as well.

These fields are currently only used by HAMMER2.

2 years agolibc: Add malloc_usable_size(3) support.
Antonio Huete Jimenez [Sun, 5 Jun 2022 22:34:05 +0000 (00:34 +0200)]
libc: Add malloc_usable_size(3) support.

Submitted-by: @dillon
2 years agousr.sbin/makefs: Fix warnings (in FreeBSD)
Tomohiro Kusumi [Sun, 5 Jun 2022 04:56:58 +0000 (13:56 +0900)]
usr.sbin/makefs: Fix warnings (in FreeBSD)

taken from FreeBSD cc1a53bc1aea0675d64e9547cdca241612906592

2 years agosbin/newfs_msdos: Add missing MAKEFS ifdefs
Tomohiro Kusumi [Sat, 4 Jun 2022 18:44:48 +0000 (03:44 +0900)]
sbin/newfs_msdos: Add missing MAKEFS ifdefs

Bring in MAKEFS related conditionals from FreeBSD commits.
162ae9c834f6d9f9cb443bd62cceb23e0b5fef48
9990450e17f79ca6e59866397b979a8a344cd5d4
f775c417fd9dd29d7bd987fc1cd30c6024540312

2 years agousr.sbin/makefs: Add HAMMER2 support
Tomohiro Kusumi [Sat, 4 Jun 2022 11:54:35 +0000 (20:54 +0900)]
usr.sbin/makefs: Add HAMMER2 support

This commit adds HAMMER2 image creation support for makefs(8).
It runs newfs_hammer2(8) and then sys/vfs/hammer2 logic in userspace
to create HAMMER2 image from a given directory.

This commit splits newfs_hammer2(8) into newfs and mkfs part simlarly
to newfs_msdos(8), so that makefs(8) can use newfs functionality.
The entire sys/vfs/hammer2 (with exception of unneeded
hammer2_{bulkfree,ccms,iocom,ioctl,msgops,synchro}.[hc] and reusable
hammer2_disk.h) is copied to usr.sbin/makefs with below modification.
It intends to have minimum amount of diff against sys/vfs/hammer2.

* Header includes are modified so that it compiles in userspace.
* VFS and other kernel functions are usually implemented as simple
 stub functions in hammer2_compat.h and hammer2_buf.c, but some are
 commented out.
* Kernel functions such as kprintf, kmalloc, kprintf, kstrdup, etc
 are implemented using corresponding libc functions.
* Lock primitives are basically NOP, and they (should) never block
 as makefs(8) is a single thread program.
* struct vnode and struct buf (the ones defined locally in makefs(8),
 not sys/sys/*) have new struct members only used by HAMMER2 to
 emulate VFS behavior required by HAMMER2.
* Since makefs(8) is write-only, VOP_{NRESOLVE,NCREATE,NMKDIR,NLINK,
 NSYMLINK,WRITE,STRATEGY} are implemented, but other VOPs just
 return EOPNOTSUPP.
* VOP_{INACTIVE,RECLAIM} may be implemented and used in future to
 better emulate VFS behavior to address current limitation.
* VOP_WRITE is modified to directly call VOP_STRATEGY function.
* The XOP kernel thread is modified to act as a regular function
 called from VOPs, along with simplified admin code.

It currently has following limitations.

* multi-volumes is unsupported, simply due to makefs(8) only taking 1
 image file path.
* Not necessarily a limitation, but it only supports populating 1 PFS,
 which is "DATA" by default. Other PFSes if any won't have anything
 under the root PFS inode.
* makefs(8) process gets killed by OOM for a directory with *extremely*
 large number of files, depending on available memory. This is due to
 the way it currently tries to flush all chains in a single VFS_SYNC.
 Supporting multiple VFS_SYNC calls by checking available memory along
 the way gives chance to free unused vnodes/inodes and chains. This
 may be implemented in future. This limitation is specific to HAMMER2,
 as all other makefs(8) filesystems are not CoW, meaning they allow
 in-place write based objects creation from a top directory to bottom
 whereas HAMMER2 flushes chains in bottom-up direction.

2 years agosbin/newfs_hammer2: Fix `-V 1' option
Tomohiro Kusumi [Fri, 3 Jun 2022 11:12:25 +0000 (20:12 +0900)]
sbin/newfs_hammer2: Fix `-V 1' option

It's been broken since 0b7381572b131c74051832dc251604e7f77b5a54
which introduced multi-volumes. No one probably needed to create
version 1 after that.

Remove sanity check which isn't true when using sbin/hammer2/ondisk.c
from newfs_hammer2(8).

--
$ newfs_hammer2 -V 1 /dev/ad3
Volume /dev/ad3        size   5.00GB
checkvolu header 0 0000000140000000/0000000140000000
newfs_hammer2: Volume count 1 must be 0

2 years agoDRIVER_MODULE.9: Fix prototype of DRIVER_MODULE_ORDERED().
Sascha Wildner [Tue, 31 May 2022 18:59:37 +0000 (20:59 +0200)]
DRIVER_MODULE.9: Fix prototype of DRIVER_MODULE_ORDERED().

2 years agokernel/uaudio: Change a pointer argument 0 -> NULL.
Sascha Wildner [Tue, 31 May 2022 18:41:16 +0000 (20:41 +0200)]
kernel/uaudio: Change a pointer argument 0 -> NULL.

2 years agokern/gtaskqueue: Fix an error message typo.
Sascha Wildner [Tue, 31 May 2022 18:32:31 +0000 (20:32 +0200)]
kern/gtaskqueue: Fix an error message typo.

2 years agokernel - Add kern/subr_gtaskqueue.c
Matthew Dillon [Tue, 31 May 2022 01:18:08 +0000 (18:18 -0700)]
kernel - Add kern/subr_gtaskqueue.c

* Add the gtaskqueue API

Taken-from: FreeBSD

2 years agokernel - Add two more DEVMETHODs (quiesce and register)
Matthew Dillon [Tue, 31 May 2022 00:15:40 +0000 (17:15 -0700)]
kernel - Add two more DEVMETHODs (quiesce and register)

* Add DEVMETHODs quiesce and register to help with future FreeBSD
  porting work.

2 years agobuild - Change '@' symlink to 'dragonfly'
Matthew Dillon [Tue, 31 May 2022 00:14:03 +0000 (17:14 -0700)]
build - Change '@' symlink to 'dragonfly'

* Change the '@' symlink to 'dragonfly', making it easier for
  #include overlays to chain to dragonfly headers in the future.

2 years agokernel - Adjust devlcass arg for DRIVER_MODULE_ORDERED() macro
Matthew Dillon [Tue, 31 May 2022 00:11:29 +0000 (17:11 -0700)]
kernel - Adjust devlcass arg for DRIVER_MODULE_ORDERED() macro

* Adjust the argument to pass in &devclass instead of having the macro
  add the '&'.  This allows NULL to be passed in, for better FreeBSD
  compatibility.

2 years agokernel - Fix lock order reversal in cache_resolve_mp()
Matthew Dillon [Fri, 27 May 2022 05:34:15 +0000 (22:34 -0700)]
kernel - Fix lock order reversal in cache_resolve_mp()

* This function is a helper when path lookups cross mount
  boundaries.

* Locking order between namecache records and vnodes must
  be { ncp, vnode }.

* Fix a lock order reversal in cache_resolve_mp() which
  was doing { vnode, ncp }.  This deadlock is very rare
  because mount points are almost never evicted from the
  namecache.  However, dsynth can trigger this bug due
  to its heavy use of null mounts and high concurrent path
  lookup loads.

2 years agokernel/if: Allow setting a description for network interfaces (closes #3306)
Antonio Huete Jimenez [Sun, 29 May 2022 15:03:22 +0000 (17:03 +0200)]
kernel/if: Allow setting a description for network interfaces (closes #3306)

Taken-from: FreeBSD
Improvements-by: @aly
2 years ago<resolv.h>: Include <netinet/in.h> for in_addr and sockaddr_in.
Sascha Wildner [Mon, 23 May 2022 04:01:48 +0000 (06:01 +0200)]
<resolv.h>: Include <netinet/in.h> for in_addr and sockaddr_in.

2 years agobsd-family-tree: Sync with FreeBSD.
Sascha Wildner [Sat, 21 May 2022 19:33:35 +0000 (21:33 +0200)]
bsd-family-tree: Sync with FreeBSD.

2 years agoUpdate the pciconf(8) database.
Sascha Wildner [Sat, 21 May 2022 19:33:08 +0000 (21:33 +0200)]
Update the pciconf(8) database.

May 18, 2022 snapshot from https://pci-ids.ucw.cz

2 years agostress - Add t_memlock.c, t_memlockall.c
Matthew Dillon [Thu, 19 May 2022 17:43:29 +0000 (10:43 -0700)]
stress - Add t_memlock.c, t_memlockall.c

* Add simple stress test for mlock()/mlockall().

2 years agokernel - Implement mlockall() properly
Matthew Dillon [Thu, 19 May 2022 17:30:29 +0000 (10:30 -0700)]
kernel - Implement mlockall() properly

* Implement mlockall()'s MCL_CURRENT, and generalaly reimplement mlockall()
  using linux-like expectations.  This generally means that the system
  will do a best-effort to allocate and lock the memory associated with
  the process's address space.

* Prior semantics which disallowed protection changes on locked memory have
  been removed.  Modern applications assume that protection changes will
  work on locked memory, even if it would force a fault.

* As with linux, some license is taken and mlockall() will only force fault
  any copy-on-write flagged anonymous pages at the time of the call.  It
  will not force a copy-on-write operation on unmodified file-backed pages
  that have been mapped MAP_PRIVATE, but not yet modified (still represent
  the file's actual content).  Nor will it force-fault the parent process's
  pages when the parent issues a fork() (which forces all anonymous pages in
  both the parent and child to become copy-on-write).

  Such pages can still take a write-fault and be COWd.  The resulting newly
  allocated page will be wired as expected.

Submitted-by: tuxillo
Testing-by: tuxillo, dillon
2 years agomlockall.2: Point out MCL_CURRENT is not yet implemented (refs #1921).
Antonio Huete Jimenez [Mon, 16 May 2022 00:15:16 +0000 (02:15 +0200)]
mlockall.2: Point out MCL_CURRENT is not yet implemented (refs #1921).

2 years agoifconfig.4, bridge.4: Fix typo
Antonio Huete Jimenez [Sun, 15 May 2022 17:04:10 +0000 (19:04 +0200)]
ifconfig.4, bridge.4: Fix typo