xref: /illumos-gate/usr/src/man/man9f/devfs_clean.9f (revision bbf21555)
1cfc3b49fSYuri Pankov.\"
2cfc3b49fSYuri Pankov.\" This file and its contents are supplied under the terms of the
3cfc3b49fSYuri Pankov.\" Common Development and Distribution License ("CDDL"), version 1.0.
4cfc3b49fSYuri Pankov.\" You may only use this file in accordance with the terms of version
5cfc3b49fSYuri Pankov.\" 1.0 of the CDDL.
6cfc3b49fSYuri Pankov.\"
7cfc3b49fSYuri Pankov.\" A full copy of the text of the CDDL should have accompanied this
8cfc3b49fSYuri Pankov.\" source.  A copy of the CDDL is also available via the Internet at
9cfc3b49fSYuri Pankov.\" http://www.illumos.org/license/CDDL.
10cfc3b49fSYuri Pankov.\"
11cfc3b49fSYuri Pankov.\"
12cfc3b49fSYuri Pankov.\" Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
13cfc3b49fSYuri Pankov.\" Copyright 2016 Nexenta Systems, Inc.
14cfc3b49fSYuri Pankov.\"
15cfc3b49fSYuri Pankov.Dd July 26, 2016
16cfc3b49fSYuri Pankov.Dt DEVFS_CLEAN 9F
17cfc3b49fSYuri Pankov.Os
18cfc3b49fSYuri Pankov.Sh NAME
19cfc3b49fSYuri Pankov.Nm devfs_clean
20cfc3b49fSYuri Pankov.Nd destroy unreferenced devfs nodes and detach devices
21cfc3b49fSYuri Pankov.Sh SYNOPSIS
22cfc3b49fSYuri Pankov.In sys/fs/dv_node.h
23cfc3b49fSYuri Pankov.Ft int
24cfc3b49fSYuri Pankov.Fo devfs_clean
25cfc3b49fSYuri Pankov.Fa "dev_info_t *dip"
26cfc3b49fSYuri Pankov.Fa "char *devnm"
27cfc3b49fSYuri Pankov.Fa "uint_t flags"
28cfc3b49fSYuri Pankov.Fc
29cfc3b49fSYuri Pankov.Sh INTERFACE LEVEL
30cfc3b49fSYuri Pankov.Sy Volatile -
31cfc3b49fSYuri Pankovprivate DDI function
32cfc3b49fSYuri Pankov.Pp
33cfc3b49fSYuri PankovThis is a private function that is not part of the stable DDI.
34cfc3b49fSYuri PankovIt may be removed or changed at any time.
35cfc3b49fSYuri Pankov.Sh PARAMETERS
36cfc3b49fSYuri Pankov.Bl -tag -width Ds
37cfc3b49fSYuri Pankov.It Va dip
38cfc3b49fSYuri PankovA pointer to the device's
39cfc3b49fSYuri Pankov.Vt dev_info
40cfc3b49fSYuri Pankovstructure.
41cfc3b49fSYuri PankovClean up is rooted at this device.
42cfc3b49fSYuri Pankov.It Va devnm
43cfc3b49fSYuri PankovAn optional character string used to restrict the devfs nodes list.
44cfc3b49fSYuri Pankov.It Va flags
45cfc3b49fSYuri PankovThe following flag is supported:
46cfc3b49fSYuri Pankov.Bl -tag -width "DV_CLEAN_FORCE"
47cfc3b49fSYuri Pankov.It Sy DV_CLEAN_FORCE
48cfc3b49fSYuri Pankovforce clean of referenced directories, referenced empty directories are marked
49cfc3b49fSYuri Pankovas stale to facilitate DR
50cfc3b49fSYuri Pankov.Pq dynamic reconfiguration
51cfc3b49fSYuri Pankov.El
52cfc3b49fSYuri Pankov.El
53cfc3b49fSYuri Pankov.Sh DESCRIPTION
54cfc3b49fSYuri PankovThe
55cfc3b49fSYuri Pankov.Fn devfs_clean
56cfc3b49fSYuri Pankovfunction is used to clean up and detach devices from the system.
57cfc3b49fSYuri PankovWhile many device drivers may have one or more minor nodes created with
58cfc3b49fSYuri Pankov.Xr ddi_create_minor_node 9F ,
59cfc3b49fSYuri Pankovsome device drivers may have children devices with different device drivers
60cfc3b49fSYuri Pankovattached.
61cfc3b49fSYuri PankovEach of these entries shows up in the file system of the global zone under
62cfc3b49fSYuri Pankov.Pa /devices
63cfc3b49fSYuri Pankov.Po see
64*bbf21555SRichard Lowe.Xr devfs 4FS
65cfc3b49fSYuri Pankov.Pc .
66cfc3b49fSYuri PankovThese nodes are referred to as a devfs nodes
67cfc3b49fSYuri Pankov.Pq Vt dv_node .
68cfc3b49fSYuri Pankov.Pp
69cfc3b49fSYuri Pankov.Nm devfs
70cfc3b49fSYuri Pankovcaches unreferenced devfs nodes to speed up the performance of
71cfc3b49fSYuri Pankov.Nm ls ,
72cfc3b49fSYuri Pankov.Nm find ,
73cfc3b49fSYuri Pankovetc.
74cfc3b49fSYuri PankovThe
75cfc3b49fSYuri Pankov.Fn devfs_clean
76cfc3b49fSYuri Pankovfunction is used to cleanup cached nodes to reclaim memory as well as to
77cfc3b49fSYuri Pankovfacilitate device removal
78cfc3b49fSYuri Pankov.Pq devfs nodes reference dev_info nodes, which prevents driver from detaching .
79cfc3b49fSYuri Pankov.Pp
80cfc3b49fSYuri PankovThe
81cfc3b49fSYuri Pankov.Fn devfs_clean
82cfc3b49fSYuri Pankovfunction starts searching the tree rooted at
83cfc3b49fSYuri Pankov.Va dip .
84cfc3b49fSYuri PankovAll directories encountered are recursed through.
85cfc3b49fSYuri PankovIf
86cfc3b49fSYuri Pankov.Va devnm
87cfc3b49fSYuri Pankovis not NULL, then it is used to limit the nodes that it searches.
88cfc3b49fSYuri PankovIt compares the name of the node, ignoring any part of the device's name that
89cfc3b49fSYuri Pankovcorresponds to a minor node.
90cfc3b49fSYuri PankovIf
91cfc3b49fSYuri Pankov.Va devnm
92cfc3b49fSYuri Pankovhas been specified, then cleanup stops immediately after a busy devfs node has
93cfc3b49fSYuri Pankovbeen encountered.
94cfc3b49fSYuri Pankov.Pp
95cfc3b49fSYuri PankovNot all nodes may be cleaned up when a driver calls the
96cfc3b49fSYuri Pankov.Fn devfs_clean
97cfc3b49fSYuri Pankovfunction.
98cfc3b49fSYuri PankovHowever, this is a non-fatal situation.
99cfc3b49fSYuri PankovCallers should continue trying to offline devices as many holds from userland
100cfc3b49fSYuri Pankovprocesses may exist due to device contracts which will be released when the
101cfc3b49fSYuri Pankovdevice is offlined.
102cfc3b49fSYuri Pankov.Pp
103cfc3b49fSYuri PankovIf a shell parks in a
104cfc3b49fSYuri Pankov.Pa /devices
105cfc3b49fSYuri Pankovdirectory, the devfs node will be held, preventing the corresponding device to
106cfc3b49fSYuri Pankovbe detached.
107cfc3b49fSYuri PankovThis would be a denial of service against DR (dynamic reconfiguration).
108cfc3b49fSYuri PankovTo prevent this, DR code calls
109cfc3b49fSYuri Pankov.Fn devfs_clean
110cfc3b49fSYuri Pankovwith the
111cfc3b49fSYuri Pankov.Sy DV_CLEAN_FORCE
112cfc3b49fSYuri Pankovflag.
113cfc3b49fSYuri Pankov.Sh CONTEXT
114cfc3b49fSYuri PankovThis function may be called in user or kernel context.
115cfc3b49fSYuri Pankov.Sh RETURN VALUES
116cfc3b49fSYuri PankovThe
117cfc3b49fSYuri Pankov.Fn devfs_clean
118cfc3b49fSYuri Pankovfunction always succeeds and returns zero.
119cfc3b49fSYuri Pankov.Sh SEE ALSO
120*bbf21555SRichard Lowe.Xr devfs 4FS
121