The falloc() function obtains two references to newly created 'fp'.
On success we have to drop one after procdesc_finit() and on failure
we have to close allocated slot with fdclose(), which also drops one
reference for us and drop the remaining reference with fdrop().

Without this change closing process descriptor didn't result in killing
pdfork(2)ed child.

Reviewed by:	rwatson
MFC after:	1 month


git-svn-id: svn://svn.freebsd.org/base/head@237276 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Check proper flag (PDF_DAEMON, not PD_DAEMON) when deciding if the process
should be killed or not.

This fixes killing pdfork(2)ed process on last close of the corresponding
process descriptor.

Reviewed by:	rwatson
MFC after:	1 month


git-svn-id: svn://svn.freebsd.org/base/head@237277 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Install filemon.h into /usr/include for userland consumption.


git-svn-id: svn://svn.freebsd.org/base/head@237279 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Update the 'fwdownload' command to also flash disks connected over an
ATA/SATA transport.  The detection logic is automatic, so it should Just
Work.  While here, also improve the progress meter that is displayed
during firmware download.

Submitted by:	Alistair Crooks
Obtained from:	Netflix, Inc.
MFC after:	3 days


git-svn-id: svn://svn.freebsd.org/base/head@237281 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Correct typo in version.


git-svn-id: svn://svn.freebsd.org/base/head@237282 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix potential symlink race condition in "rm -P" by adding a check
that the file we have opened is the one we expected.  Also open in
non-blocking mode to avoid a potential hang with FIFOs.

Obtained from:	NetBSD via OpenBSD


git-svn-id: svn://svn.freebsd.org/base/head@237284 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add progress.c and progress.h, missed in the previous commit to camcontrol.

Submitted by:   Garrett Cooper
Obtained from:  Netflix, Inc.


git-svn-id: svn://svn.freebsd.org/base/head@237285 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Don't close an uninitialized descriptor. [1]
Add a sanity check for the validity of the passed fd.

PR:		kern/139080 [1]
Submitted by:	Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> [1]
Reviewed by:	pjd (briefly)
Approved by:	cperciva
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@237286 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add PV list locking to pmap_copy(), pmap_enter_object(), and
pmap_enter_quick().  These functions are no longer serialized by the pvh
global lock.

There is no need to release the PV list lock before calling free_pv_chunk()
in pmap_remove_pages().


git-svn-id: svn://svn.freebsd.org/base/head@237290 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix viawd(4) that was only working as a module.

Obtained from:	jhb
MFC after: 3 days


git-svn-id: svn://svn.freebsd.org/base/head@237295 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Allow booting XENHVM kernel without Xen hypervisor.

MFC after:	3 days


git-svn-id: svn://svn.freebsd.org/base/head@237322 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix several reference counting and object lifetime issues between
the pass(4) and enc(4) drivers and devfs.

The pass(4) driver uses the destroy_dev_sched() routine to
schedule its device node for destruction in a separate thread
context.  It does this because the passcleanup() routine can get
called indirectly from the passclose() routine, and that would
cause a deadlock if the close routine tried to destroy its own
device node.

In any case, once a particular passthrough driver number, e.g.
pass3, is destroyed, CAM considers that unit number (3 in this
case) available for reuse.

The problem is that devfs may not be done cleaning up the previous
instance of pass3, and will panic if isn't done cleaning up the
previous instance.

The solution is to get a callback from devfs when the device node
is removed, and make sure we hold a reference to the peripheral
until that happens.

Testing exposed some other cases where we have reference counting
issues, and those were also fixed in the pass(4) driver.

cam_periph.c:	In camperiphfree(), reorder some of the operations.

		The peripheral destructor needs to be called before
		the peripheral is removed from the peripheral is
		removed from the list.  This is because once we
		remove the peripheral from the list, and drop the
		topology lock, the peripheral number may be reused.
		But if the destructor hasn't been called yet, there
		may still be resources hanging around (like devfs
		nodes) that haven't been fully cleaned up.

cam_xpt.c:	Add an argument to xpt_remove_periph() to indicate
		whether the topology lock is already held.

scsi_enc.c:	Acquire an extra reference to the peripheral during
		registration, and release it once we get a callback
		from devfs indicating that the device node is gone.

		Call destroy_dev_sched_cb() in enc_oninvalidate()
		instead of calling destroy_dev() in the cleanup
		routine.

scsi_pass.c:	Add reference counting to handle peripheral and
		devfs object lifetime issues.

		Add a reference to the peripheral and the devfs
		node in the peripheral registration.

		Don't attempt to add a physical path alias if the
		peripheral has been marked invalid.

		Release the devfs reference once the initial
		physical path alias taskqueue run has completed.

		Schedule devfs node destruction in the
		passoninvalidate(), and release our peripheral
		reference in a new routine, passdevgonecb() once
		the devfs node is gone.  This allows the peripheral
		to fully go away, and the peripheral destructor,
		passcleanup(), will get called.

MFC after:	3 days
Sponsored by:	Spectra Logic


git-svn-id: svn://svn.freebsd.org/base/head@237328 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix ARM compilation issue.

X-MFC: 237260


git-svn-id: svn://svn.freebsd.org/base/head@237329 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Now that there is an est(4) man page, reference it here in cpufreq(4).


git-svn-id: svn://svn.freebsd.org/base/head@237330 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Move the per-thread deferred user map entries list into a private list
in vm_map_process_deferred() which is then iterated to release map entries.
This avoids having a nested vm map unlock operation called from the loop
body attempt to recuse into vm_map_process_deferred().  This can happen if
the vm_map_remove() triggers the OOM killer.

Reviewed by:	alc, kib
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@237334 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Check status of cam_periph_hold() inside cdclose().  If cd device was
invalidated while open, cam_periph_hold() will return error and won't
get the reference.  Following reference release will crash the system.

Sponsored by:	iXsystems, Inc.
MFC after:	3 days


git-svn-id: svn://svn.freebsd.org/base/head@237335 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Remove unused error variables in cdclose() and daclose().


git-svn-id: svn://svn.freebsd.org/base/head@237336 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Only output a list of file systems that need to be dumped if the system
has a non-empty dumpdates file.

Reviewed by:	brooks
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@237337 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Don't return an error if a kld does not contain any modules (e.g. a
kld that only contained a sysctl).  The kernel linker allows such
modules, so the boot loader should not reject them.

MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@237338 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Polish previous revision: if the fts_* routines have lstat()'ed the
directory entry then use the struct stat from that instead of doing
it again, and skip the rm_overwrite() call if fts_read() indicated
that the entry couldn't be a regular file.

Obtained from:	OpenBSD
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@237339 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f