Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
7b718769 NS |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
1da177e4 | 4 | * |
7b718769 NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
1da177e4 LT |
7 | * published by the Free Software Foundation. |
8 | * | |
7b718769 NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
1da177e4 | 13 | * |
7b718769 NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
1da177e4 | 17 | */ |
1da177e4 LT |
18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | |
1da177e4 LT |
20 | #include "xfs_inum.h" |
21 | #include "xfs_log.h" | |
22 | #include "xfs_clnt.h" | |
23 | #include "xfs_trans.h" | |
24 | #include "xfs_sb.h" | |
25 | #include "xfs_ag.h" | |
1da177e4 LT |
26 | #include "xfs_dir2.h" |
27 | #include "xfs_imap.h" | |
28 | #include "xfs_alloc.h" | |
29 | #include "xfs_dmapi.h" | |
30 | #include "xfs_mount.h" | |
31 | #include "xfs_quota.h" | |
32 | ||
33 | int | |
34 | vfs_mount( | |
35 | struct bhv_desc *bdp, | |
36 | struct xfs_mount_args *args, | |
37 | struct cred *cr) | |
38 | { | |
39 | struct bhv_desc *next = bdp; | |
40 | ||
41 | ASSERT(next); | |
42 | while (! (bhvtovfsops(next))->vfs_mount) | |
43 | next = BHV_NEXT(next); | |
44 | return ((*bhvtovfsops(next)->vfs_mount)(next, args, cr)); | |
45 | } | |
46 | ||
47 | int | |
48 | vfs_parseargs( | |
49 | struct bhv_desc *bdp, | |
50 | char *s, | |
51 | struct xfs_mount_args *args, | |
52 | int f) | |
53 | { | |
54 | struct bhv_desc *next = bdp; | |
55 | ||
56 | ASSERT(next); | |
57 | while (! (bhvtovfsops(next))->vfs_parseargs) | |
58 | next = BHV_NEXT(next); | |
59 | return ((*bhvtovfsops(next)->vfs_parseargs)(next, s, args, f)); | |
60 | } | |
61 | ||
62 | int | |
63 | vfs_showargs( | |
64 | struct bhv_desc *bdp, | |
65 | struct seq_file *m) | |
66 | { | |
67 | struct bhv_desc *next = bdp; | |
68 | ||
69 | ASSERT(next); | |
70 | while (! (bhvtovfsops(next))->vfs_showargs) | |
71 | next = BHV_NEXT(next); | |
72 | return ((*bhvtovfsops(next)->vfs_showargs)(next, m)); | |
73 | } | |
74 | ||
75 | int | |
76 | vfs_unmount( | |
77 | struct bhv_desc *bdp, | |
78 | int fl, | |
79 | struct cred *cr) | |
80 | { | |
81 | struct bhv_desc *next = bdp; | |
82 | ||
83 | ASSERT(next); | |
84 | while (! (bhvtovfsops(next))->vfs_unmount) | |
85 | next = BHV_NEXT(next); | |
86 | return ((*bhvtovfsops(next)->vfs_unmount)(next, fl, cr)); | |
87 | } | |
88 | ||
89 | int | |
90 | vfs_mntupdate( | |
91 | struct bhv_desc *bdp, | |
92 | int *fl, | |
93 | struct xfs_mount_args *args) | |
94 | { | |
95 | struct bhv_desc *next = bdp; | |
96 | ||
97 | ASSERT(next); | |
98 | while (! (bhvtovfsops(next))->vfs_mntupdate) | |
99 | next = BHV_NEXT(next); | |
100 | return ((*bhvtovfsops(next)->vfs_mntupdate)(next, fl, args)); | |
101 | } | |
102 | ||
103 | int | |
104 | vfs_root( | |
105 | struct bhv_desc *bdp, | |
0a74cd19 | 106 | bhv_vnode_t **vpp) |
1da177e4 LT |
107 | { |
108 | struct bhv_desc *next = bdp; | |
109 | ||
110 | ASSERT(next); | |
111 | while (! (bhvtovfsops(next))->vfs_root) | |
112 | next = BHV_NEXT(next); | |
113 | return ((*bhvtovfsops(next)->vfs_root)(next, vpp)); | |
114 | } | |
115 | ||
116 | int | |
117 | vfs_statvfs( | |
118 | struct bhv_desc *bdp, | |
8285fb58 | 119 | bhv_statvfs_t *statp, |
0a74cd19 | 120 | bhv_vnode_t *vp) |
1da177e4 LT |
121 | { |
122 | struct bhv_desc *next = bdp; | |
123 | ||
124 | ASSERT(next); | |
125 | while (! (bhvtovfsops(next))->vfs_statvfs) | |
126 | next = BHV_NEXT(next); | |
8285fb58 | 127 | return ((*bhvtovfsops(next)->vfs_statvfs)(next, statp, vp)); |
1da177e4 LT |
128 | } |
129 | ||
130 | int | |
131 | vfs_sync( | |
132 | struct bhv_desc *bdp, | |
133 | int fl, | |
134 | struct cred *cr) | |
135 | { | |
136 | struct bhv_desc *next = bdp; | |
137 | ||
138 | ASSERT(next); | |
139 | while (! (bhvtovfsops(next))->vfs_sync) | |
140 | next = BHV_NEXT(next); | |
141 | return ((*bhvtovfsops(next)->vfs_sync)(next, fl, cr)); | |
142 | } | |
143 | ||
144 | int | |
145 | vfs_vget( | |
146 | struct bhv_desc *bdp, | |
0a74cd19 | 147 | bhv_vnode_t **vpp, |
1da177e4 LT |
148 | struct fid *fidp) |
149 | { | |
150 | struct bhv_desc *next = bdp; | |
151 | ||
152 | ASSERT(next); | |
153 | while (! (bhvtovfsops(next))->vfs_vget) | |
154 | next = BHV_NEXT(next); | |
155 | return ((*bhvtovfsops(next)->vfs_vget)(next, vpp, fidp)); | |
156 | } | |
157 | ||
1da177e4 LT |
158 | void |
159 | vfs_init_vnode( | |
160 | struct bhv_desc *bdp, | |
0a74cd19 | 161 | bhv_vnode_t *vp, |
739bfb2a | 162 | struct xfs_inode *ip, |
1da177e4 LT |
163 | int unlock) |
164 | { | |
165 | struct bhv_desc *next = bdp; | |
166 | ||
167 | ASSERT(next); | |
168 | while (! (bhvtovfsops(next))->vfs_init_vnode) | |
169 | next = BHV_NEXT(next); | |
739bfb2a | 170 | ((*bhvtovfsops(next)->vfs_init_vnode)(next, vp, ip, unlock)); |
1da177e4 LT |
171 | } |
172 | ||
173 | void | |
174 | vfs_force_shutdown( | |
175 | struct bhv_desc *bdp, | |
176 | int fl, | |
177 | char *file, | |
178 | int line) | |
179 | { | |
180 | struct bhv_desc *next = bdp; | |
181 | ||
182 | ASSERT(next); | |
183 | while (! (bhvtovfsops(next))->vfs_force_shutdown) | |
184 | next = BHV_NEXT(next); | |
185 | ((*bhvtovfsops(next)->vfs_force_shutdown)(next, fl, file, line)); | |
186 | } | |
187 | ||
188 | void | |
189 | vfs_freeze( | |
190 | struct bhv_desc *bdp) | |
191 | { | |
192 | struct bhv_desc *next = bdp; | |
193 | ||
194 | ASSERT(next); | |
195 | while (! (bhvtovfsops(next))->vfs_freeze) | |
196 | next = BHV_NEXT(next); | |
197 | ((*bhvtovfsops(next)->vfs_freeze)(next)); | |
198 | } | |
199 | ||
b83bd138 | 200 | bhv_vfs_t * |
ec86dc02 NS |
201 | vfs_allocate( |
202 | struct super_block *sb) | |
1da177e4 | 203 | { |
b83bd138 | 204 | struct bhv_vfs *vfsp; |
1da177e4 | 205 | |
b83bd138 | 206 | vfsp = kmem_zalloc(sizeof(bhv_vfs_t), KM_SLEEP); |
1da177e4 LT |
207 | bhv_head_init(VFS_BHVHEAD(vfsp), "vfs"); |
208 | INIT_LIST_HEAD(&vfsp->vfs_sync_list); | |
209 | spin_lock_init(&vfsp->vfs_sync_lock); | |
1da177e4 | 210 | init_waitqueue_head(&vfsp->vfs_wait_single_sync_task); |
ec86dc02 NS |
211 | |
212 | vfsp->vfs_super = sb; | |
213 | sb->s_fs_info = vfsp; | |
214 | ||
215 | if (sb->s_flags & MS_RDONLY) | |
216 | vfsp->vfs_flag |= VFS_RDONLY; | |
217 | ||
1da177e4 LT |
218 | return vfsp; |
219 | } | |
220 | ||
b83bd138 | 221 | bhv_vfs_t * |
ec86dc02 NS |
222 | vfs_from_sb( |
223 | struct super_block *sb) | |
224 | { | |
b83bd138 | 225 | return (bhv_vfs_t *)sb->s_fs_info; |
ec86dc02 NS |
226 | } |
227 | ||
1da177e4 LT |
228 | void |
229 | vfs_deallocate( | |
b83bd138 | 230 | struct bhv_vfs *vfsp) |
1da177e4 LT |
231 | { |
232 | bhv_head_destroy(VFS_BHVHEAD(vfsp)); | |
b83bd138 | 233 | kmem_free(vfsp, sizeof(bhv_vfs_t)); |
1da177e4 LT |
234 | } |
235 | ||
236 | void | |
237 | vfs_insertops( | |
b83bd138 NS |
238 | struct bhv_vfs *vfsp, |
239 | struct bhv_module_vfsops *vfsops) | |
1da177e4 LT |
240 | { |
241 | struct bhv_desc *bdp; | |
242 | ||
243 | bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP); | |
244 | bhv_desc_init(bdp, NULL, vfsp, vfsops); | |
245 | bhv_insert(&vfsp->vfs_bh, bdp); | |
246 | } | |
247 | ||
248 | void | |
249 | vfs_insertbhv( | |
b83bd138 | 250 | struct bhv_vfs *vfsp, |
1da177e4 | 251 | struct bhv_desc *bdp, |
b83bd138 | 252 | struct bhv_vfsops *vfsops, |
1da177e4 LT |
253 | void *mount) |
254 | { | |
255 | bhv_desc_init(bdp, mount, vfsp, vfsops); | |
256 | bhv_insert_initial(&vfsp->vfs_bh, bdp); | |
257 | } | |
258 | ||
259 | void | |
260 | bhv_remove_vfsops( | |
b83bd138 | 261 | struct bhv_vfs *vfsp, |
1da177e4 LT |
262 | int pos) |
263 | { | |
264 | struct bhv_desc *bhv; | |
265 | ||
266 | bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos); | |
267 | if (!bhv) | |
268 | return; | |
269 | bhv_remove(&vfsp->vfs_bh, bhv); | |
270 | kmem_free(bhv, sizeof(*bhv)); | |
271 | } | |
272 | ||
273 | void | |
274 | bhv_remove_all_vfsops( | |
b83bd138 | 275 | struct bhv_vfs *vfsp, |
1da177e4 LT |
276 | int freebase) |
277 | { | |
278 | struct xfs_mount *mp; | |
279 | ||
280 | bhv_remove_vfsops(vfsp, VFS_POSITION_QM); | |
1da177e4 LT |
281 | if (!freebase) |
282 | return; | |
02d7c923 | 283 | mp = XFS_VFSTOM(vfsp); |
1da177e4 LT |
284 | VFS_REMOVEBHV(vfsp, &mp->m_bhv); |
285 | xfs_mount_free(mp, 0); | |
f541d270 | 286 | kmem_free(mp, sizeof(xfs_mount_t)); |
1da177e4 LT |
287 | } |
288 | ||
289 | void | |
290 | bhv_insert_all_vfsops( | |
b83bd138 | 291 | struct bhv_vfs *vfsp) |
1da177e4 LT |
292 | { |
293 | struct xfs_mount *mp; | |
294 | ||
295 | mp = xfs_mount_init(); | |
296 | vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp); | |
297 | vfs_insertdmapi(vfsp); | |
298 | vfs_insertquota(vfsp); | |
299 | } |