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