4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
29 * University Copyright- Copyright (c) 1982, 1986, 1988
30 * The Regents of the University of California
33 * University Acknowledgment- Portions of this document are derived from
34 * software developed by the University of California, Berkeley, and its
39 #include <sys/types.h>
40 #include <sys/t_lock.h>
41 #include <sys/param.h>
43 #include <sys/cmn_err.h>
44 #include <sys/debug.h>
45 #include <sys/errno.h>
48 #include <sys/vnode.h>
50 #include <sys/fs/snode.h>
51 #include <sys/thread.h>
53 #include <sys/fs_subr.h>
56 * This is the loadable module wrapper.
58 #include <sys/modctl.h>
60 static vfsdef_t vfw
= {
68 extern struct mod_ops mod_fsops
;
71 * Module linkage information for the kernel.
73 static struct modlfs modlfs
= {
74 &mod_fsops
, "filesystem for specfs", &vfw
77 static struct modlinkage modlinkage
= {
78 MODREV_1
, (void *)&modlfs
, NULL
84 return (mod_install(&modlinkage
));
88 _info(struct modinfo
*modinfop
)
90 return (mod_info(&modlinkage
, modinfop
));
95 * No _fini routine. This module cannot be unloaded once loaded.
96 * The NO_UNLOAD_STUB in modstub.s must change if this module ever
97 * is modified to become unloadable.
100 kmutex_t spec_syncbusy
; /* initialized in specinit() */
103 * Run though all the snodes and force write-back
104 * of all dirty pages on the block devices.
108 spec_sync(struct vfs
*vfsp
,
112 struct snode
*sync_list
;
113 register struct snode
**spp
, *sp
, *spnext
;
114 register struct vnode
*vp
;
116 if (mutex_tryenter(&spec_syncbusy
) == 0)
119 if (flag
& SYNC_ATTR
) {
120 mutex_exit(&spec_syncbusy
);
123 mutex_enter(&stable_lock
);
126 * Find all the snodes that are dirty and add them to the sync_list
128 for (spp
= stable
; spp
< &stable
[STABLESIZE
]; spp
++) {
129 for (sp
= *spp
; sp
!= NULL
; sp
= sp
->s_next
) {
132 * Don't bother sync'ing a vp if it's
133 * part of a virtual swap device.
138 if (vp
->v_type
== VBLK
&& vn_has_cached_data(vp
)) {
140 * Prevent vp from going away before we
141 * we get a chance to do a fop_putpage
142 * via sync_list processing
145 sp
->s_list
= sync_list
;
150 mutex_exit(&stable_lock
);
152 * Now write out all the snodes we marked asynchronously.
154 for (sp
= sync_list
; sp
!= NULL
; sp
= spnext
) {
157 (void) fop_putpage(vp
, (offset_t
)0, (uint_t
)0, B_ASYNC
, cr
,
159 VN_RELE(vp
); /* Release our hold on vnode */
161 mutex_exit(&spec_syncbusy
);