DEVFS_CLEAN(9F) Kernel Functions for Drivers DEVFS_CLEAN(9F)

destroy unreferenced devfs nodes and detach devices

#include <sys/fs/dv_node.h>

devfs_clean(dev_info_t *dip, char *devnm, uint_t flags);

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.

A pointer to the device's dev_info structure. Clean up is rooted at this device.
An optional character string used to restrict the devfs nodes list.
The following flag is supported:
force clean of referenced directories, referenced empty directories are marked as stale to facilitate DR (dynamic reconfiguration)

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(7FS)). These nodes are referred to as a 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.

This function may be called in user or kernel context.

The devfs_clean() function always succeeds and returns zero.

July 26, 2016 OmniOS