2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
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
7 * published by the Free Software Foundation.
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.
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
23 #include "xfs_trans.h"
29 #include "xfs_alloc.h"
30 #include "xfs_dmapi.h"
31 #include "xfs_mount.h"
32 #include "xfs_quota.h"
37 struct xfs_mount_args *args,
40 struct bhv_desc *next = bdp;
43 while (! (bhvtovfsops(next))->vfs_mount)
44 next = BHV_NEXT(next);
45 return ((*bhvtovfsops(next)->vfs_mount)(next, args, cr));
52 struct xfs_mount_args *args,
55 struct bhv_desc *next = bdp;
58 while (! (bhvtovfsops(next))->vfs_parseargs)
59 next = BHV_NEXT(next);
60 return ((*bhvtovfsops(next)->vfs_parseargs)(next, s, args, f));
68 struct bhv_desc *next = bdp;
71 while (! (bhvtovfsops(next))->vfs_showargs)
72 next = BHV_NEXT(next);
73 return ((*bhvtovfsops(next)->vfs_showargs)(next, m));
82 struct bhv_desc *next = bdp;
85 while (! (bhvtovfsops(next))->vfs_unmount)
86 next = BHV_NEXT(next);
87 return ((*bhvtovfsops(next)->vfs_unmount)(next, fl, cr));
94 struct xfs_mount_args *args)
96 struct bhv_desc *next = bdp;
99 while (! (bhvtovfsops(next))->vfs_mntupdate)
100 next = BHV_NEXT(next);
101 return ((*bhvtovfsops(next)->vfs_mntupdate)(next, fl, args));
106 struct bhv_desc *bdp,
107 struct bhv_vnode **vpp)
109 struct bhv_desc *next = bdp;
112 while (! (bhvtovfsops(next))->vfs_root)
113 next = BHV_NEXT(next);
114 return ((*bhvtovfsops(next)->vfs_root)(next, vpp));
119 struct bhv_desc *bdp,
120 bhv_statvfs_t *statp,
121 struct bhv_vnode *vp)
123 struct bhv_desc *next = bdp;
126 while (! (bhvtovfsops(next))->vfs_statvfs)
127 next = BHV_NEXT(next);
128 return ((*bhvtovfsops(next)->vfs_statvfs)(next, statp, vp));
133 struct bhv_desc *bdp,
137 struct bhv_desc *next = bdp;
140 while (! (bhvtovfsops(next))->vfs_sync)
141 next = BHV_NEXT(next);
142 return ((*bhvtovfsops(next)->vfs_sync)(next, fl, cr));
147 struct bhv_desc *bdp,
148 struct bhv_vnode **vpp,
151 struct bhv_desc *next = bdp;
154 while (! (bhvtovfsops(next))->vfs_vget)
155 next = BHV_NEXT(next);
156 return ((*bhvtovfsops(next)->vfs_vget)(next, vpp, fidp));
161 struct bhv_desc *bdp,
164 struct bhv_desc *next = bdp;
167 while (! (bhvtovfsops(next))->vfs_dmapiops)
168 next = BHV_NEXT(next);
169 return ((*bhvtovfsops(next)->vfs_dmapiops)(next, addr));
174 struct bhv_desc *bdp,
179 struct bhv_desc *next = bdp;
182 while (! (bhvtovfsops(next))->vfs_quotactl)
183 next = BHV_NEXT(next);
184 return ((*bhvtovfsops(next)->vfs_quotactl)(next, cmd, id, addr));
189 struct bhv_desc *bdp,
190 struct bhv_vnode *vp,
194 struct bhv_desc *next = bdp;
197 while (! (bhvtovfsops(next))->vfs_init_vnode)
198 next = BHV_NEXT(next);
199 ((*bhvtovfsops(next)->vfs_init_vnode)(next, vp, bp, unlock));
204 struct bhv_desc *bdp,
209 struct bhv_desc *next = bdp;
212 while (! (bhvtovfsops(next))->vfs_force_shutdown)
213 next = BHV_NEXT(next);
214 ((*bhvtovfsops(next)->vfs_force_shutdown)(next, fl, file, line));
219 struct bhv_desc *bdp)
221 struct bhv_desc *next = bdp;
224 while (! (bhvtovfsops(next))->vfs_freeze)
225 next = BHV_NEXT(next);
226 ((*bhvtovfsops(next)->vfs_freeze)(next));
231 struct super_block *sb)
233 struct bhv_vfs *vfsp;
235 vfsp = kmem_zalloc(sizeof(bhv_vfs_t), KM_SLEEP);
236 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
237 INIT_LIST_HEAD(&vfsp->vfs_sync_list);
238 spin_lock_init(&vfsp->vfs_sync_lock);
239 init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
241 vfsp->vfs_super = sb;
242 sb->s_fs_info = vfsp;
244 if (sb->s_flags & MS_RDONLY)
245 vfsp->vfs_flag |= VFS_RDONLY;
252 struct super_block *sb)
254 return (bhv_vfs_t *)sb->s_fs_info;
259 struct bhv_vfs *vfsp)
261 bhv_head_destroy(VFS_BHVHEAD(vfsp));
262 kmem_free(vfsp, sizeof(bhv_vfs_t));
267 struct bhv_vfs *vfsp,
268 struct bhv_module_vfsops *vfsops)
270 struct bhv_desc *bdp;
272 bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP);
273 bhv_desc_init(bdp, NULL, vfsp, vfsops);
274 bhv_insert(&vfsp->vfs_bh, bdp);
279 struct bhv_vfs *vfsp,
280 struct bhv_desc *bdp,
281 struct bhv_vfsops *vfsops,
284 bhv_desc_init(bdp, mount, vfsp, vfsops);
285 bhv_insert_initial(&vfsp->vfs_bh, bdp);
290 struct bhv_vfs *vfsp,
293 struct bhv_desc *bhv;
295 bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos);
298 bhv_remove(&vfsp->vfs_bh, bhv);
299 kmem_free(bhv, sizeof(*bhv));
303 bhv_remove_all_vfsops(
304 struct bhv_vfs *vfsp,
307 struct xfs_mount *mp;
309 bhv_remove_vfsops(vfsp, VFS_POSITION_QM);
310 bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
313 mp = XFS_VFSTOM(vfsp);
314 VFS_REMOVEBHV(vfsp, &mp->m_bhv);
315 xfs_mount_free(mp, 0);
319 bhv_insert_all_vfsops(
320 struct bhv_vfs *vfsp)
322 struct xfs_mount *mp;
324 mp = xfs_mount_init();
325 vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp);
326 vfs_insertdmapi(vfsp);
327 vfs_insertquota(vfsp);