DEVFS_CLEAN(9F) Kernel Functions for Drivers DEVFS_CLEAN(9F)
NAME
devfs_clean - destroy unreferenced devfs nodes and detach devices
SYNOPSIS
#include <sys/fs/dv_node.h> int devfs_clean(
dev_info_t *dip,
char *devnm,
uint_t flags);
INTERFACE LEVEL
Volatile - private DDI function
This is a private function that is not part of the stable DDI. It may be
removed or changed at any time.
PARAMETERS
dip A pointer to the device's
dev_info structure. Clean up is rooted
at this device.
devnm An optional character string used to restrict the devfs nodes list.
flags The following flag is supported:
DV_CLEAN_FORCE force clean of referenced directories, referenced
empty directories are marked as stale to facilitate
DR (dynamic reconfiguration)
DESCRIPTION
The
devfs_clean() function is used to clean up and detach devices from the
system. While many device drivers may have one or more minor nodes created
with
ddi_create_minor_node(9F), some device drivers may have children
devices with different device drivers attached. Each of these entries
shows up in the file system of the global zone under
/devices (see
devfs(4FS)). These nodes are referred to as devfs nodes (
dv_node).
devfs caches unreferenced devfs nodes to speed up the performance of
ls,
find, etc. The
devfs_clean() function is used to cleanup cached nodes to
reclaim memory as well as to facilitate device removal (devfs nodes
reference dev_info nodes, which prevents driver from detaching).
The
devfs_clean() function starts searching the tree rooted at
dip. All
directories encountered are recursed through. If
devnm is not NULL, then
it is used to limit the nodes that it searches. It compares the name of
the node, ignoring any part of the device's name that corresponds to a
minor node. If
devnm has been specified, then cleanup stops immediately
after a busy devfs node has been encountered.
Not all nodes may be cleaned up when a driver calls the
devfs_clean()
function. However, this is a non-fatal situation. Callers should continue
trying to offline devices as many holds from userland processes may exist
due to device contracts which will be released when the device is offlined.
If a shell parks in a
/devices directory, the devfs node will be held,
preventing the corresponding device to be detached. This would be a denial
of service against DR (dynamic reconfiguration). To prevent this, DR code
calls
devfs_clean() with the
DV_CLEAN_FORCE flag.
CONTEXT
This function may be called in user or kernel context.
RETURN VALUES
The
devfs_clean() function always succeeds and returns zero.
SEE ALSO
devfs(4FS),
ddi_create_minor_node(9F)illumos August 22, 2023 illumos