dragonfly.git
11 months agousr.sbin/makefs: Add HAMMER2 offline inode get support
Tomohiro Kusumi [Fri, 16 Jun 2023 07:15:21 +0000 (00:15 -0700)]
usr.sbin/makefs: Add HAMMER2 offline inode get support

The offline inode takes HAMMER2 specific "-o I" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o I=get:/path/to/file /dev/adx --
$ makefs -t hammer2 -o I=get:/path/to/file /path/to/hammer2.img --

The "-o I" option requires inode command name argument, which is
currently only "get". "get" takes `:<inode_path>` string after command
name. "get" is equivalent to hammer2(8) printinode directive.

11 months agousr.sbin/makefs: Add offline HAMMER2IOC_VERSION_GET support
Tomohiro Kusumi [Thu, 15 Jun 2023 07:28:07 +0000 (00:28 -0700)]
usr.sbin/makefs: Add offline HAMMER2IOC_VERSION_GET support

The offline version get uses existing "-o V" option with no argument.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o V /dev/adx --
$ makefs -t hammer2 -o V /path/to/hammer2.img --

There is no hammer2(8) directive for this as it's internally used.

11 months agousr.sbin/makefs: Introduce hammer2_makefs_options_t::ioctl_cmd flag
Tomohiro Kusumi [Thu, 15 Jun 2023 06:12:08 +0000 (23:12 -0700)]
usr.sbin/makefs: Introduce hammer2_makefs_options_t::ioctl_cmd flag

rather than having boolean flag for each ioctl command
since now that many of the hammer2(8) ioctls are implemented.

11 months agousr.sbin/makefs: Minor cleanup
Tomohiro Kusumi [Wed, 14 Jun 2023 06:13:47 +0000 (23:13 -0700)]
usr.sbin/makefs: Minor cleanup

11 months agousr.sbin/makefs: Fix "-o D" option when intermediate directories exist
Tomohiro Kusumi [Mon, 12 Jun 2023 08:44:12 +0000 (01:44 -0700)]
usr.sbin/makefs: Fix "-o D" option when intermediate directories exist

HAMMER2_DELETE_FILE assumes a given inode is a directory containing
dirent whose name is destroy.path. Therefore ioctl caller side needs
to split path components and only pass the last component along with
its direct parent directory inode.

It currently worked only when a target file path is the last component
without intermediate directories (no intermediate '/').

hammer2_ioc_destroy_t::path should be renamed to "name", as it
doesn't allow a file "path".

11 months agousr.sbin/makefs: Fix makefs(8) man page on -m option
Tomohiro Kusumi [Sun, 11 Jun 2023 07:05:56 +0000 (00:05 -0700)]
usr.sbin/makefs: Fix makefs(8) man page on -m option

-m and -o m are different options (latter is HAMMER2 specific),
and this context refers to -o m option.

11 months agousr.sbin/makefs: Add HAMMER2 offline PFS get|lookup|create|delete|snapshot support
Tomohiro Kusumi [Sat, 10 Jun 2023 08:12:06 +0000 (01:12 -0700)]
usr.sbin/makefs: Add HAMMER2 offline PFS get|lookup|create|delete|snapshot support

The offline PFS takes HAMMER2 specific "-o P" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o P=get /dev/adx --
$ makefs -t hammer2 -o P=lookup:name /path/to/hammer2.img --
$ makefs -t hammer2 -o P=create:name /dev/adx --
$ makefs -t hammer2 -o P=delete:name /path/to/hammer2.img --
$ makefs -t hammer2 -o P=snapshot:name /dev/adx --
$ makefs -t hammer2 -o P=snapshot /path/to/hammer2.img --

The "-o P" option requires PFS command name argument, which are
"get" (alias "list"), "lookup", "create", "delete" and "snapshot".
lookup, create and delete take `:<pfs_name>` string after command name.
snapshot takes optional `:<pfs_name>` string after command name.

Use -m option (default "DATA") to specify target PFS for snapshot.

11 months agousr.sbin/makefs: Minor fix / cleanup
Tomohiro Kusumi [Fri, 9 Jun 2023 07:04:11 +0000 (00:04 -0700)]
usr.sbin/makefs: Minor fix / cleanup

11 months agousr.sbin/makefs: Add HAMMER2 emergency mode support
Tomohiro Kusumi [Fri, 9 Jun 2023 07:07:01 +0000 (00:07 -0700)]
usr.sbin/makefs: Add HAMMER2 emergency mode support

The "-o E" option sets emergency mode flag.
This can be used in conjunction with other operations,
but there is no point in using this option for regular usage.

11 months agonvme - Print detailed status on I/O error
Matthew Dillon [Thu, 8 Jun 2023 17:41:24 +0000 (10:41 -0700)]
nvme - Print detailed status on I/O error

* Print a rate-limited detailed status when a NVME I/O error occurs.

* Make the nvme_sync_delay sysctl __read_mostly

11 months agolibc - pthread_key_create() adjustments
Matthew Dillon [Fri, 2 Jun 2023 23:56:36 +0000 (16:56 -0700)]
libc - pthread_key_create() adjustments

* Have libc's stub conditionals ignore any error return from
  pthread_key_create() stubs, in case we decide to change the
  stub in the future.

* Change pthread_key_create() to start allocating keys at key #1
  to work around issues with third party programs making assumptions
  about the valid key range.

11 months agousr.sbin/makefs: Add HAMMER2 offline destroy support
Tomohiro Kusumi [Thu, 8 Jun 2023 07:46:22 +0000 (00:46 -0700)]
usr.sbin/makefs: Add HAMMER2 offline destroy support

The offline destroy takes HAMMER2 specific "-o D" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o D=/a.out /dev/adx --
$ makefs -t hammer2 -o D=1234 /path/to/hammer2.img --

The "-o D" option reuires file path or inode number argument.
- If it's a file path, optarg must start with '/'.
- If it's an inum, optarg must start with "0x" or '0'-'9'.
Note that destroy by inum seems broken not only in makefs, but also
in real HAMMER2 ioctl.

11 months agousr.sbin/makefs/hammer2: Minor cleanup
Tomohiro Kusumi [Thu, 8 Jun 2023 07:12:29 +0000 (00:12 -0700)]
usr.sbin/makefs/hammer2: Minor cleanup

11 months agousr.sbin/makefs: Add HAMMER2 offline growfs support
Tomohiro Kusumi [Wed, 7 Jun 2023 08:12:14 +0000 (01:12 -0700)]
usr.sbin/makefs: Add HAMMER2 offline growfs support

The offline growfs takes HAMMER2 specific "-o G" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o G /dev/adx --
$ makefs -t hammer2 -o G /path/to/hammer2.img --

By default expands volume to image file or block device size.
If -s option is specified, use that size.
No shrink support in the same way hammer2(8) growfs doesn't.

11 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Wed, 7 Jun 2023 08:34:12 +0000 (01:34 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 01a24a934a5d6fd384584e1d72f1f9dd25bb98d3.. -- sys/vfs/hammer2/
0f90a2c50b sys/vfs/hammer2: Fail ioctl(HAMMER2IOC_GROWFS) if size > devvp size
a3364d7fa7 sys/vfs/hammer2: Change growfs kprintf format %jd -> %016jx for hammer2_off_t

11 months agosys/vfs/hammer2: Fail ioctl(HAMMER2IOC_GROWFS) if size > devvp size
Tomohiro Kusumi [Wed, 7 Jun 2023 07:49:20 +0000 (00:49 -0700)]
sys/vfs/hammer2: Fail ioctl(HAMMER2IOC_GROWFS) if size > devvp size

Currently, ioctl(HAMMER2IOC_GROWFS) with growfs->size larger than
devvp size can destroy the volume. The ioctl needs to fail if size
> devvp size.

Note that hammer2(8) growfs directive always uses growfs->size == 0,
meaning the volume is always expanded to its devvp size.

11 months agosys/vfs/hammer2: Change growfs kprintf format %jd -> %016jx for hammer2_off_t
Tomohiro Kusumi [Wed, 7 Jun 2023 07:25:24 +0000 (00:25 -0700)]
sys/vfs/hammer2: Change growfs kprintf format %jd -> %016jx for hammer2_off_t

like all other kprintfs in HAMMER2.
These sizes are usually block device size (i.e. multilple of 1GiB).

11 months agousr.sbin/makefs: Add HAMMER2 offline bulkfree support
Tomohiro Kusumi [Sat, 3 Jun 2023 07:12:15 +0000 (00:12 -0700)]
usr.sbin/makefs: Add HAMMER2 offline bulkfree support

Since makefs HAMMER2 implements the entire HAMMER2 logic in userspace
with selected vops using single threaded xops, it's actually trivial
to support other operations, e.g. HAMMER2 ioctls.

This commit adds bulkfree (free unreferenced blocks by scanning the
entire data chains from vchain) option to makefs. Unlike the existing
hammer2(8) "bulkfree" directive which requires live filesystem, this
option enables offline bulkfree against unmounted HAMMER2 image.

The offline bulkfree takes HAMMER2 specific "-o B" option. When this
option is specified, makefs runs offline bulkfree against `image-file`
argument instead of creating one, hence it must be a valid HAMMER2
image. `image-file` can be either a regular file or block device.
Unlike normal use case, `directory` argument is unused, but it's
still required. It can be any valid path or simply "--".

e.g.
$ makefs -t hammer2 -o B /dev/adx --
$ makefs -t hammer2 -o B /path/to/hammer2.img --

Technically, all HAMMER2 ioctls can be implemented in makefs as
offline version, but "bulkfree" and "growfs" are probably the only
hammer2(8) directives that make sense to exist as offline version.

Note that the limitation regarding OOM mentioned in 2d60b848f2 also
applies to bulkfree, i.e. makefs(8) could fail with partially written
`image-file` if it contains insane number of files or directories.

11 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Fri, 2 Jun 2023 08:35:15 +0000 (01:35 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 6966bebf98ca11fee72e5ba9849224a5049211dd.. -- sys/vfs/hammer2/
23d820f091 sys/vfs/hammer2: Use howmany() to calculate bulkfree bmap size
e12df3bcd3 sys/vfs/hammer2: Fix comment on bmradix in freemap
8d92096877 sys/vfs/hammer2: Remove obsolete comments in freemap
f517f709f2 sys/vfs/hammer2: Remove redundant NULL chain test in bulkfree
c4cc6dbe36 sys/vfs/hammer2: Remove obsolete code/comment in freemap
a4cea70ee4 sys/vfs/hammer2: Fix 53b767003a to use plural
53b767003a sys/vfs/hammer2: Fix multiple "radii" -> "radix"

11 months agoboot: Expose SMBIOS entry point via kenv
Aaron LI [Sat, 6 May 2023 00:48:11 +0000 (08:48 +0800)]
boot: Expose SMBIOS entry point via kenv

The SMBIOS Reference Specification (v3.6.0) says (in Section 5.2.1):

"On UEFI-based systems, the SMBIOS Entry Point structure can be located
by looking in the EFI Configuration Table for the SMBIOS GUID
(SMBIOS_TABLE_GUID, {EB9D2D31-2D88-11D3-9A16- 0090273FC14D}) and using
the associated pointer."

So export the SMBIOS entry point via kenv to allow the SMBIOS table be
found in UEFI-only mode, where the BIOS is not mapped into the standard
address space and thus the SMBIOS table might not appear between 0xf0000
and 0xfffff.  For example, dmidecode(8) was failing with:

    Scanning /dev/mem for entry point.
    # No SMBIOS nor DMI entry point found, sorry.

Use the same kenv 'hint.smbios.0.mem' as FreeBSD to help with dports(7).

Refer-to: FreeBSD (revision 307326)
Discussed-with: swildner

11 months agoboot/efi: Recognize four more configuration tables
Aaron LI [Fri, 5 May 2023 23:24:30 +0000 (07:24 +0800)]
boot/efi: Recognize four more configuration tables

Recognize the following four configuration tables:
f2fd1544-9794-4a2c-992e-e5bbcf20e394 (SMBIOS3_TABLE_GUID)
b122a263-3661-4f68-9929-78f8b0d62180 (EFI_SYSTEM_RESOURCE_TABLE_GUID)
ee4e5898-3914-4259-9d6e-dc7bd79403cf (LZMA_CUSTOM_DECOMPRESS_GUIDE)
00781ca1-5de3-405f-abb8-379c3c076984 (AMI_ROM_LAYOUT_GUID)

Tested on my HPE MicroServer Gen10, which has SMBIOS3_TABLE_GUID,
EFI_SYSTEM_RESOURCE_TABLE_GUID and AMI_ROM_LAYOUT_GUID.

Refer-to: https://reviews.freebsd.org/D14036

11 months agostand/contrib: Add two more TianoCore EDK II headers
Aaron LI [Fri, 5 May 2023 23:10:16 +0000 (07:10 +0800)]
stand/contrib: Add two more TianoCore EDK II headers

Taken from the 'stable202302' release of repository:
https://github.com/tianocore/edk2

Paths:
- MdeModulePkg/Include/Guid/LzmaDecompress.h
- MdePkg/Include/Guid/SystemResourceTable.h

Modification: changed CRLF line endings to LF.

Suggested-by: swildner
11 months agox86_64/identcpu: Print supported XSAVE features
Aaron LI [Sat, 29 Apr 2023 03:20:04 +0000 (11:20 +0800)]
x86_64/identcpu: Print supported XSAVE features

Referred to FreeBSD.

11 months agox86_64/identcpu: Print more CPU features
Aaron LI [Sat, 29 Apr 2023 03:18:00 +0000 (11:18 +0800)]
x86_64/identcpu: Print more CPU features

Generally keep in sync with 'x86_64/include/specialreg.h'.

11 months agox86_64/identcpu: Add comments to features for consistency
Aaron LI [Sat, 29 Apr 2023 03:11:52 +0000 (11:11 +0800)]
x86_64/identcpu: Add comments to features for consistency

11 months agox86_64/identcpu: Style cleanups
Aaron LI [Sat, 29 Apr 2023 03:05:13 +0000 (11:05 +0800)]
x86_64/identcpu: Style cleanups

11 months agox86_64/identcpu: Add printing of CPU family and model
Aaron LI [Sat, 29 Apr 2023 01:39:24 +0000 (09:39 +0800)]
x86_64/identcpu: Add printing of CPU family and model

Obtained-from: FreeBSD

11 months agox86_64/identcpu: Remove whitespace in printing CPU vendor/ID/stepping
Aaron LI [Sat, 29 Apr 2023 01:33:40 +0000 (09:33 +0800)]
x86_64/identcpu: Remove whitespace in printing CPU vendor/ID/stepping

For consistency with the prints of other CPU features.

Obtained-from: FreeBSD

11 months agox86_64/specialreg.h: Add several more CPUID defines
Aaron LI [Sat, 29 Apr 2023 01:24:29 +0000 (09:24 +0800)]
x86_64/specialreg.h: Add several more CPUID defines

Obtained from NetBSD and FreeBSD.

11 months agosys/vfs/hammer2: Use howmany() to calculate bulkfree bmap size
Tomohiro Kusumi [Sun, 28 May 2023 09:15:12 +0000 (02:15 -0700)]
sys/vfs/hammer2: Use howmany() to calculate bulkfree bmap size

Note that the calculation here is based on the ratio below.
1GB (layer1 size) : 32KB (layer1 bmap total) = hmp->total_size : size

12 months agosys/vfs/hammer2: Fix comment on bmradix in freemap
Tomohiro Kusumi [Fri, 19 May 2023 08:30:26 +0000 (01:30 -0700)]
sys/vfs/hammer2: Fix comment on bmradix in freemap

The maximum radix is 16 (HAMMER2_RADIX_MAX),
so bmradix for radix > HAMMER2_FREEMAP_BLOCK_RADIX is either
4 (2 << (15-14)) for 32KiB or 8 (2 << (16-14)) for 64KiB.

12 months agostand - cleanup efi boot, fix corrupted free()
Matthew Dillon [Sat, 20 May 2023 06:32:51 +0000 (23:32 -0700)]
stand - cleanup efi boot, fix corrupted free()

* When freeing failed load resources, two of the resources allocated
  by boot services were being freed via free(), causing a panic.

* Do not complain if a path component is not a directory, simply fail.
  Remove unnecessary noise from alternative config file tests.

* Pre-assign NULL to pointers so they are NULL during error paths.
  Target procedures do not necessarily set them in error paths.

* Display EFI errors in hex, not virtually unreadable decimal.

* Cleanup for readability.

12 months agosys/vfs/hammer2: Remove obsolete comments in freemap
Tomohiro Kusumi [Thu, 18 May 2023 06:45:16 +0000 (23:45 -0700)]
sys/vfs/hammer2: Remove obsolete comments in freemap

ip, bref->key, bits, mask no longer appear here since commits in 2013.

12 months agosys/vfs/hammer2: Remove redundant NULL chain test in bulkfree
Tomohiro Kusumi [Tue, 16 May 2023 05:10:21 +0000 (22:10 -0700)]
sys/vfs/hammer2: Remove redundant NULL chain test in bulkfree

chain is never NULL at this point (see right above this),
and there are chain dereferences without test after this as well.

12 months agosys/vfs/hammer2: Remove obsolete code/comment in freemap
Tomohiro Kusumi [Fri, 12 May 2023 06:26:29 +0000 (23:26 -0700)]
sys/vfs/hammer2: Remove obsolete code/comment in freemap

The code for this comment (freemap_radix) was removed in
93f3933ac3e2ad37a7ba775663c711b13588f147 in 2013.

The #if0'd code right below this is unrelated code from
different commit, and it also does not compile anymore.

12 months agosys/vfs/hammer2: Fix 53b767003a to use plural
Tomohiro Kusumi [Fri, 12 May 2023 06:22:12 +0000 (23:22 -0700)]
sys/vfs/hammer2: Fix 53b767003a to use plural

suggested-by: swildner

12 months agostand/edk2: Reorganize the edk2 contrib hierarchy a bit.
Sascha Wildner [Thu, 11 May 2023 02:34:39 +0000 (04:34 +0200)]
stand/edk2: Reorganize the edk2 contrib hierarchy a bit.

* Move sys/contrib/edk2 to stand/contrib/edk2 where it really belongs.

* Put the *Pkg dir as an additional layer. Work that is currently in
  progress will require headers from other *Pkg's and we don't want to
  jumble them all into one directory.

In-discussion-with: aly

12 months agoRemove two empty private namespaces. One was commented out anyway.
Sascha Wildner [Tue, 9 May 2023 18:53:17 +0000 (20:53 +0200)]
Remove two empty private namespaces. One was commented out anyway.

12 months agolibz: Stop exporting internal functions.
Sascha Wildner [Tue, 9 May 2023 18:44:45 +0000 (20:44 +0200)]
libz: Stop exporting internal functions.

By default, this affects the following functions, which are now local:

0000000000009d1d t _tr_align
0000000000009d17 t _tr_flush_bits
0000000000009e09 t _tr_flush_block
0000000000009b8d t _tr_init
0000000000009bfa t _tr_stored_block
000000000000a433 t _tr_tally
0000000000004d69 t gz_error
000000000000ccbd t inflate_fast
000000000000dc92 t inflate_table
000000000000dc6e t zcalloc
000000000000dc81 t zcfree

Remove them from the ZLIBprivate_1.0 namespace, too. Also remove
gz_intmax here. It is not built on DragonFly.

12 months agosys/vfs/hammer2: Fix multiple "radii" -> "radix"
Tomohiro Kusumi [Tue, 9 May 2023 08:00:04 +0000 (01:00 -0700)]
sys/vfs/hammer2: Fix multiple "radii" -> "radix"

12 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Sat, 6 May 2023 10:12:22 +0000 (03:12 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" a0373a75974db9f2e5b8420fcc1111337d553f30.. -- sys/vfs/hammer2/
cbf2d85db0 sys/vfs/hammer2: Fix -Wformat warnings on other platforms
2a6d3b8baa sys/vfs/hammer2: Fix memory leak for second PFS mount and after

12 months agousr.sbin/makefs: Fix -Wformat warnings on other platforms
Tomohiro Kusumi [Sat, 6 May 2023 06:00:27 +0000 (23:00 -0700)]
usr.sbin/makefs: Fix -Wformat warnings on other platforms

Mostly from HAMMER2, except for DragonFly specific makefs_daddr_t
part in ffs/buf.c. Includes the same diff as cbf2d85db0.

12 months agosys/vfs/hammer2: Fix -Wformat warnings on other platforms
Tomohiro Kusumi [Thu, 4 May 2023 08:12:07 +0000 (01:12 -0700)]
sys/vfs/hammer2: Fix -Wformat warnings on other platforms

bref.key and meta.inum are always casted to "%ld" / long
(rather than intmax_t or long long) in sys/vfs/hammer2.

12 months agoamdpm.4: Mention intpm(4) in SEE ALSO
Aaron LI [Wed, 3 May 2023 11:53:53 +0000 (19:53 +0800)]
amdpm.4: Mention intpm(4) in SEE ALSO

12 months agointpm.4: Update description and supported chipsets
Aaron LI [Wed, 3 May 2023 11:51:17 +0000 (19:51 +0800)]
intpm.4: Update description and supported chipsets

Well, the intpm(4) Intel power management driver actually supports
some AMD chipsets.

Also update SEE ALSO items.

Obtained-from: FreeBSD

12 months agostand/boot: Fix typos.
Sascha Wildner [Wed, 3 May 2023 15:05:47 +0000 (17:05 +0200)]
stand/boot: Fix typos.

12 months agousr.sbin/makefs/hammer2: Print chian/dio count on vflush()
Tomohiro Kusumi [Wed, 3 May 2023 08:11:12 +0000 (01:11 -0700)]
usr.sbin/makefs/hammer2: Print chian/dio count on vflush()

in addition to inode count currently printed.

12 months agosys/vfs/hammer2: Fix memory leak for second PFS mount and after
Tomohiro Kusumi [Sat, 29 Apr 2023 05:30:09 +0000 (22:30 -0700)]
sys/vfs/hammer2: Fix memory leak for second PFS mount and after

When mounting, hmp and its ->devvpl are initialized only if it's
the first PFS mount of that hmp. For the second PFS mount and after,
malloc'd memory in a devvpl list (64 bytes per device per PFS)
has been leaked.

Found on FreeBSD on kldunload.
--
Warning: memory type hammer2_mount leaked memory on destroy (1 allocations, 64 bytes leaked).

13 months agousr.sbin/makefs/hammer2: Use blkno -1 for logical vnode for clarity
Tomohiro Kusumi [Tue, 25 Apr 2023 06:30:19 +0000 (23:30 -0700)]
usr.sbin/makefs/hammer2: Use blkno -1 for logical vnode for clarity

At logical vnode layer, only bio_offset from uio_offset is used,
in the same way DragonFly VFS does. Since blkno should never be used,
set it to -1.

Then the bio_offset turns into bref's data_off through chain lookup.
At physical vnode layer, bref's data_off turns into a buf associated
with dio's devvp.

At this point dio's devvp buf needs a valid blkno (but not a valid
offset as getblk/bread/bwrite functions in ffs/buf.c are based on
FreeBSD VFS) to calculate file offset within image.

13 months agousr.sbin/makefs/ffs: Remove m_buf::b_is_hammer2
Tomohiro Kusumi [Sat, 22 Apr 2023 07:41:49 +0000 (00:41 -0700)]
usr.sbin/makefs/ffs: Remove m_buf::b_is_hammer2

FreeBSD makefs(8) now calls brelse() on bwrite(), whereas DragonFly
has had that behavior specifically for HAMMER2 to emulate VFS behavior.

m_buf::b_is_hammer2 flag which was introduced for this reason now
needs to be removed, otherwise it attempts to double free struct m_buf.

13 months agousr.sbin/makefs/ffs: Sync buf.c with FreeBSD
Tomohiro Kusumi [Sat, 22 Apr 2023 07:29:32 +0000 (00:29 -0700)]
usr.sbin/makefs/ffs: Sync buf.c with FreeBSD

Bring in following FreeBSD commits,
while keeping DragonFly specific code for HAMMER2.

Note that msdosfs_vnops.c diff in FreeBSD e5551216d8e5 was never
merged to DragonFly makefs(8), so no need to apply (revert).

Sun Apr 16 15:45:17 2023 -0400 e5551216d8e5 makefs: call brelse from bread
Tue Apr 11 11:21:36 2023 -0400 af7624ed3145 makefs: use %s and __func__ in printf messages
Mon Apr 10 18:50:27 2023 -0400 1d1ffa2efd2a makefs: use size_t or ssize_t where appropriate

13 months agousr.sbin/makefs/hammer2: Change fsinode::priv -> param
Tomohiro Kusumi [Sat, 22 Apr 2023 07:09:01 +0000 (00:09 -0700)]
usr.sbin/makefs/hammer2: Change fsinode::priv -> param

FreeBSD makefs(8) now has a void* pointer ->param for ZFS support
which points to fs specific data structure.

makefs HAMMER2 has had a void* pointer ->priv for the same purpose,
so rename it to ->param to sync with FreeBSD, though no intention
to bring in ZFS support.

13 months agousr.sbin/makefs/hammer2: Avoid #include "makefs.h" in hammer2.h
Tomohiro Kusumi [Sat, 22 Apr 2023 07:01:12 +0000 (00:01 -0700)]
usr.sbin/makefs/hammer2: Avoid #include "makefs.h" in hammer2.h

Not a build error from ddd1d3d1ff2fecb3b58ce152a65095abaf634491,
but safer to avoid including "makefs.h" in usr.sbin/makefs/hammer2/hammer2.h
which basically shouldn't know anything about makefs(8).

13 months agousr.sbin/makefs/hammer2: Include <stdbool.h> for hammer2_update_time()
Tomohiro Kusumi [Sat, 22 Apr 2023 06:55:19 +0000 (23:55 -0700)]
usr.sbin/makefs/hammer2: Include <stdbool.h> for hammer2_update_time()

A bool argument from ddd1d3d1ff2fecb3b58ce152a65095abaf634491 needs <stdbool.h>.
It fails to compile on some platforms.

13 months agodhcpcd: Note upgrade to 10.0.1
Roy Marples [Fri, 21 Apr 2023 09:51:34 +0000 (10:51 +0100)]
dhcpcd: Note upgrade to 10.0.1

13 months agoMerge branch 'vendor/DHCPCD'
Roy Marples [Fri, 21 Apr 2023 09:50:16 +0000 (10:50 +0100)]
Merge branch 'vendor/DHCPCD'

13 months agoUpdate to dhcpcd-10.0.1 with the following changes:
Roy Marples [Fri, 21 Apr 2023 09:43:47 +0000 (10:43 +0100)]
Update to dhcpcd-10.0.1 with the following changes:

 * privsep: keep resources open rather than open/close
 * dhcp6: OPTION_NTP_SERVER is now preferred over OPTION_SNTP_SERVER
 * Misc bug fixes mainly around privsep for many platforms.
 * Fix for reading the some BSD routing table entries.
 * Fix reading authtokens from config.

13 months agobsd-family-tree: Sync with FreeBSD.
Sascha Wildner [Thu, 20 Apr 2023 09:28:18 +0000 (11:28 +0200)]
bsd-family-tree: Sync with FreeBSD.

13 months agoUpdate the pciconf(8) database.
Sascha Wildner [Thu, 20 Apr 2023 09:27:36 +0000 (11:27 +0200)]
Update the pciconf(8) database.

April 10, 2023 snapshot from https://pci-ids.ucw.cz

13 months agosbin/newfs_hammer2: Use uuid_create(3) rather than uuidgen(2)
Tomohiro Kusumi [Wed, 19 Apr 2023 07:20:14 +0000 (00:20 -0700)]
sbin/newfs_hammer2: Use uuid_create(3) rather than uuidgen(2)

for portability.
uuid_create(3), which is a wrapper over uuidgen(2) in DragonFly,
is the common interface among *BSD's.

The code has been using uuid(3) functions except for creation.

13 months agousched - Add support for > 64 cpus
Matthew Dillon [Tue, 18 Apr 2023 17:01:16 +0000 (10:01 -0700)]
usched - Add support for > 64 cpus

* Add support, allow cpumask to be parsed as mask[,mask[,mask[,...]]],
  in 64-bit chunks, lsb chunk first.

13 months agousr.sbin/makefs/hammer2: Derive timestamp from source inodes
Tomohiro Kusumi [Tue, 18 Apr 2023 07:30:26 +0000 (00:30 -0700)]
usr.sbin/makefs/hammer2: Derive timestamp from source inodes

makefs(8) HAMMER2 has been using current time for inode's ctime/mtime.
Change hammer2_update_time() to use current fsnode's timestamp.
Also support -T option.

Note that both hammer2_curnode (current fsnode) and stampst (-T option)
are global variables.

13 months agokernel: Adjust two Makefiles for my recent opt_*.h changes.
Sascha Wildner [Sun, 16 Apr 2023 09:57:34 +0000 (11:57 +0200)]
kernel: Adjust two Makefiles for my recent opt_*.h changes.

13 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Fri, 14 Apr 2023 07:00:45 +0000 (00:00 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" e49cd5358c56593a7923a00706d26dbc4e8bdaed.. -- sys/vfs/hammer2/
d6f11ef8ed sys/vfs/hammer2: Remove unneeded (char *)bp->b_data cast
0a7ab00601 sys/vfs/hammer2: Comment out unused local variables
8fd12ec463 sys/vfs/hammer2: Remove KKASSERT expecting path to start with "/dev/"
2e3d3c15cd sys/vfs/hammer2: Use HAMMER2_ROOT_VOLUME instead of 0
9be1b0c77a Revert "sys/vfs/hammer2: Avoid void* pointer arithmetic"

13 months agosys/vfs/hammer2: Remove unneeded (char *)bp->b_data cast
Tomohiro Kusumi [Fri, 14 Apr 2023 06:54:53 +0000 (23:54 -0700)]
sys/vfs/hammer2: Remove unneeded (char *)bp->b_data cast

Aside from 9be1b0c77afd935ea1e16400d86ee504c084ff74,
this was the only one originally existed in HAMMER2.

13 months agorbootd: add missing change to make it work
Roy Marples [Thu, 13 Apr 2023 17:05:04 +0000 (18:05 +0100)]
rbootd: add missing change to make it work

13 months agorbootd: Just open /dev/bpf rather than loop /dev/bpfN
Roy Marples [Thu, 13 Apr 2023 17:00:49 +0000 (18:00 +0100)]
rbootd: Just open /dev/bpf rather than loop /dev/bpfN

/dev/bpf is a cloner on modern BSD.
/dev/bpfN needs to go away.

13 months agosys/vfs/hammer2: Comment out unused local variables
Tomohiro Kusumi [Wed, 12 Apr 2023 07:38:07 +0000 (00:38 -0700)]
sys/vfs/hammer2: Comment out unused local variables

Warned on FreeBSD.
bmmask10 is used by #if0'd code, so keep it as comment.

--
warning: variable 'bmmask01' set but not used [-Wunused-but-set-variable]
        hammer2_bitmap_t bmmask01;
                         ^
warning: variable 'bmmask10' set but not used [-Wunused-but-set-variable]
        hammer2_bitmap_t bmmask10;
                         ^

13 months agousr.sbin/makefs: Remove unused local variable
Tomohiro Kusumi [Wed, 12 Apr 2023 07:34:05 +0000 (00:34 -0700)]
usr.sbin/makefs: Remove unused local variable

Warned on FreeBSD.

--
warning: variable 'tot' set but not used [-Wunused-but-set-variable]
        size_t tot = 0;
               ^

13 months agosbin/*hammer2: Include <stdint.h> for intmax_t/uintmax_t
Tomohiro Kusumi [Mon, 10 Apr 2023 07:12:25 +0000 (00:12 -0700)]
sbin/*hammer2: Include <stdint.h> for intmax_t/uintmax_t

intmax_t/uintmax_t belong to <stdint.h>.
These files don't compile on OpenBSD without explicit includes.

13 months agokernel/ffs: Add missing opt_quota.h include to get at QUOTA.
Sascha Wildner [Wed, 5 Apr 2023 02:00:24 +0000 (04:00 +0200)]
kernel/ffs: Add missing opt_quota.h include to get at QUOTA.

13 months agokernel/pmap: Add missing opt_ddb.h include to get at DDB.
Sascha Wildner [Wed, 5 Apr 2023 01:59:32 +0000 (03:59 +0200)]
kernel/pmap: Add missing opt_ddb.h include to get at DDB.

Also fix the printing of a backtrace in two error cases.

13 months agokernel/machdep: Add missing opt_maxmem.h include to get at MAXMEM.
Sascha Wildner [Wed, 5 Apr 2023 01:58:35 +0000 (03:58 +0200)]
kernel/machdep: Add missing opt_maxmem.h include to get at MAXMEM.

13 months agokernel/platform: Remove useless commented out includes of use_npx.h.
Sascha Wildner [Wed, 5 Apr 2023 01:58:06 +0000 (03:58 +0200)]
kernel/platform: Remove useless commented out includes of use_npx.h.

13 months agoktrace/kdump: Implement sysctl tracing.
Sascha Wildner [Tue, 4 Apr 2023 19:42:20 +0000 (21:42 +0200)]
ktrace/kdump: Implement sysctl tracing.

Useful to know which sysctls exactly are being accessed.

Adapted-from: FreeBSD

13 months agokernel/icmp: Add missing opt_icmpprintfs.h include to get at ICMPPRINTFS.
Sascha Wildner [Tue, 4 Apr 2023 19:24:08 +0000 (21:24 +0200)]
kernel/icmp: Add missing opt_icmpprintfs.h include to get at ICMPPRINTFS.

13 months agokernel/gif: Add missing opt_xbonehack.h include to get at XBONEHACK.
Sascha Wildner [Tue, 4 Apr 2023 19:23:16 +0000 (21:23 +0200)]
kernel/gif: Add missing opt_xbonehack.h include to get at XBONEHACK.

13 months ago<sys/ktrace.h>: Clean up the prototypes a bit.
Sascha Wildner [Tue, 4 Apr 2023 18:57:08 +0000 (20:57 +0200)]
<sys/ktrace.h>: Clean up the prototypes a bit.

13 months agokernel/fwohci: Avoid confusion with USB's OHCI_DEBUG kernel option.
Sascha Wildner [Sat, 1 Apr 2023 17:26:20 +0000 (19:26 +0200)]
kernel/fwohci: Avoid confusion with USB's OHCI_DEBUG kernel option.

fwohci's is just an internal define that enables a debug printf.

13 months agokernel: Rename the HZ kernel option to HZ_DEFAULT.
Sascha Wildner [Sat, 1 Apr 2023 14:22:00 +0000 (16:22 +0200)]
kernel: Rename the HZ kernel option to HZ_DEFAULT.

The define used by the kernel (and altered by this option) was renamed
back in 6de4cf8a045febfcb20dde5bb7a51ca13e3d33a6.

This also avoids some confusion with the drm code which uses its own
HZ define.

13 months agosys/vfs/hammer2: Remove KKASSERT expecting path to start with "/dev/"
Tomohiro Kusumi [Sat, 1 Apr 2023 07:04:12 +0000 (00:04 -0700)]
sys/vfs/hammer2: Remove KKASSERT expecting path to start with "/dev/"

Unlike Linux, mount(8) variants don't support mounting regular files,
so devvp initialization expects a devvp path to start with "/dev/",
but let vn_isdisk() handle error without KKASSERT here.

13 months agokernel/802_11: Remove some dead includes.
Sascha Wildner [Fri, 31 Mar 2023 21:06:57 +0000 (23:06 +0200)]
kernel/802_11: Remove some dead includes.

13 months agovkernel/autoconf: Add missing opt_swap.h include to get at NSWBUF_MIN.
Sascha Wildner [Fri, 31 Mar 2023 19:13:36 +0000 (21:13 +0200)]
vkernel/autoconf: Add missing opt_swap.h include to get at NSWBUF_MIN.

13 months agoLINT64: Enable NSWBUF_MIN because it enables (a bit) more code.
Sascha Wildner [Fri, 31 Mar 2023 19:11:40 +0000 (21:11 +0200)]
LINT64: Enable NSWBUF_MIN because it enables (a bit) more code.

We comment out options in LINT64 only when they reduce coverage.

13 months agokernel/ext2fs: Add missing opt_suiddir.h include to get at SUIDDIR.
Sascha Wildner [Fri, 31 Mar 2023 18:41:09 +0000 (20:41 +0200)]
kernel/ext2fs: Add missing opt_suiddir.h include to get at SUIDDIR.

13 months agoFix the vkernel build.
Sascha Wildner [Fri, 31 Mar 2023 18:08:26 +0000 (20:08 +0200)]
Fix the vkernel build.

13 months agoedk2: Sync our TianoCore EDK II headers with the edk2-stable202302 tag.
Sascha Wildner [Thu, 30 Mar 2023 21:10:21 +0000 (23:10 +0200)]
edk2: Sync our TianoCore EDK II headers with the edk2-stable202302 tag.

Mostly whitespace. In the non-whitespace changes, I didn't see anything
that affects us directly.

13 months agokernel/ip6_mroute: Add missing opt_mrouting.h include to get at MROUTING.
Sascha Wildner [Thu, 30 Mar 2023 19:37:50 +0000 (21:37 +0200)]
kernel/ip6_mroute: Add missing opt_mrouting.h include to get at MROUTING.

13 months agokernel/sn: Remove some dead includes.
Sascha Wildner [Thu, 30 Mar 2023 19:26:57 +0000 (21:26 +0200)]
kernel/sn: Remove some dead includes.

13 months agokernel/oce: Add missing opt_inet{,6}.h include to get at INET{,6}.
Sascha Wildner [Thu, 30 Mar 2023 19:18:23 +0000 (21:18 +0200)]
kernel/oce: Add missing opt_inet{,6}.h include to get at INET{,6}.

All this only affects inactive code because LRO support is missing.

13 months agokernel/rum: Remove some dead includes.
Sascha Wildner [Thu, 30 Mar 2023 16:11:04 +0000 (18:11 +0200)]
kernel/rum: Remove some dead includes.

13 months agokernel/pf: Add missing opt_inet6.h include to get at INET6.
Sascha Wildner [Thu, 30 Mar 2023 15:36:09 +0000 (17:36 +0200)]
kernel/pf: Add missing opt_inet6.h include to get at INET6.

While here, remove a bogus INET6 check.

13 months agokernel/vm: Add missing opt_reset.h include to get at BROKEN_KEYBOARD_RESET.
Sascha Wildner [Thu, 30 Mar 2023 15:10:22 +0000 (17:10 +0200)]
kernel/vm: Add missing opt_reset.h include to get at BROKEN_KEYBOARD_RESET.

13 months agokernel: Remove opt_vm.h include from files that don't actually need it.
Sascha Wildner [Thu, 30 Mar 2023 14:46:27 +0000 (16:46 +0200)]
kernel: Remove opt_vm.h include from files that don't actually need it.

13 months agokernel/vm: Add missing opt_vm.h include to get at NO_SWAPPING.
Sascha Wildner [Thu, 30 Mar 2023 14:34:53 +0000 (16:34 +0200)]
kernel/vm: Add missing opt_vm.h include to get at NO_SWAPPING.

Also, fix the build with a config that has NO_SWAPPING set.

13 months agoUpdate the pciconf(8) database.
Sascha Wildner [Thu, 30 Mar 2023 14:04:48 +0000 (16:04 +0200)]
Update the pciconf(8) database.

February 23, 2023 snapshot from https://pci-ids.ucw.cz

13 months agosys/vfs/hammer2: Use HAMMER2_ROOT_VOLUME instead of 0
Tomohiro Kusumi [Wed, 29 Mar 2023 08:12:05 +0000 (01:12 -0700)]
sys/vfs/hammer2: Use HAMMER2_ROOT_VOLUME instead of 0

13 months agokernel/backlight: Remove bogus include from the Makefile.
Sascha Wildner [Tue, 28 Mar 2023 19:50:27 +0000 (21:50 +0200)]
kernel/backlight: Remove bogus include from the Makefile.

13 months agopoll/select: Fix panic in kqueue backend
Matthew Dillon [Tue, 28 Mar 2023 02:11:05 +0000 (19:11 -0700)]
poll/select: Fix panic in kqueue backend

* The poll and select system calls use kqueue as a backend and
  attempt to cache active events from prior calls to improve
  performance.

  However, this makes a potential race more likely where in a
  high-concurrency application one thread close()es a descriptor
  that another thread had previously used in a poll/select operation
  and this close() races the later poll/select operation that is
  attempting to remove the kevent.

* The race can sometimes prevent the poll/select kevent copyout
  code from removing previously cached but no-longer-used
  events, because the removal references the events by their
  descriptor rather than directly and the descriptor is no longer
  valid.

  This causes kern_kevent() to loop infinite and hit a panic
  designed to check for that situation.

* Fix the problem by moving the removal of old events from the
  poll/select copyout code into kqueue_scan().  kqueue_scan()
  can detect old unused events using the sequence id that the
  poll/select kernel code stores in the kevent.

14 months agoroute(8): Only decode route messages we know
Roy Marples [Mon, 20 Mar 2023 21:35:55 +0000 (21:35 +0000)]
route(8): Only decode route messages we know