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"
34 #include "xfs_mountops.h"
39 struct xfs_mount_args *args,
42 struct bhv_desc *next = bdp;
45 while (! (bhvtovfsops(next))->xvfs_mount)
46 next = BHV_NEXT(next);
47 return ((*bhvtovfsops(next)->xvfs_mount)(next, args, cr));
54 struct xfs_mount_args *args,
57 struct bhv_desc *next = bdp;
60 while (! (bhvtovfsops(next))->xvfs_parseargs)
61 next = BHV_NEXT(next);
62 return ((*bhvtovfsops(next)->xvfs_parseargs)(next, s, args, f));
70 struct bhv_desc *next = bdp;
73 while (! (bhvtovfsops(next))->xvfs_showargs)
74 next = BHV_NEXT(next);
75 return ((*bhvtovfsops(next)->xvfs_showargs)(next, m));
84 struct bhv_desc *next = bdp;
87 while (! (bhvtovfsops(next))->xvfs_unmount)
88 next = BHV_NEXT(next);
89 return ((*bhvtovfsops(next)->xvfs_unmount)(next, fl, cr));
96 struct xfs_mount_args *args)
98 struct bhv_desc *next = bdp;
101 while (! (bhvtovfsops(next))->xvfs_mntupdate)
102 next = BHV_NEXT(next);
103 return ((*bhvtovfsops(next)->xvfs_mntupdate)(next, fl, args));
108 struct bhv_desc *bdp,
109 struct xfs_vnode **vpp)
111 struct bhv_desc *next = bdp;
114 while (! (bhvtovfsops(next))->xvfs_root)
115 next = BHV_NEXT(next);
116 return ((*bhvtovfsops(next)->xvfs_root)(next, vpp));
121 struct bhv_desc *bdp,
123 struct xfs_vnode *vp)
125 struct bhv_desc *next = bdp;
128 while (! (bhvtovfsops(next))->xvfs_statvfs)
129 next = BHV_NEXT(next);
130 return ((*bhvtovfsops(next)->xvfs_statvfs)(next, sp, vp));
135 struct bhv_desc *bdp,
139 struct bhv_desc *next = bdp;
142 while (! (bhvtovfsops(next))->xvfs_sync)
143 next = BHV_NEXT(next);
144 return ((*bhvtovfsops(next)->xvfs_sync)(next, fl, cr));
149 struct bhv_desc *bdp,
150 struct xfs_vnode **vpp,
153 struct bhv_desc *next = bdp;
156 while (! (bhvtovfsops(next))->xvfs_vget)
157 next = BHV_NEXT(next);
158 return ((*bhvtovfsops(next)->xvfs_vget)(next, vpp, fidp));
163 struct bhv_desc *bdp,
166 struct bhv_desc *next = bdp;
169 while (! (bhvtovfsops(next))->xvfs_dmapiops)
170 next = BHV_NEXT(next);
171 return ((*bhvtovfsops(next)->xvfs_dmapiops)(next, addr));
176 struct bhv_desc *bdp,
181 struct bhv_desc *next = bdp;
184 while (! (bhvtovfsops(next))->xvfs_quotactl)
185 next = BHV_NEXT(next);
186 return ((*bhvtovfsops(next)->xvfs_quotactl)(next, cmd, id, addr));
191 struct bhv_desc *bdp,
195 struct bhv_desc *next = bdp;
197 while (! (bhvtovfsops(next))->xvfs_get_inode)
198 next = BHV_NEXTNULL(next);
199 return ((*bhvtovfsops(next)->xvfs_get_inode)(next, ino, fl));
204 struct bhv_desc *bdp,
205 struct xfs_vnode *vp,
209 struct bhv_desc *next = bdp;
212 while (! (bhvtovfsops(next))->xvfs_init_vnode)
213 next = BHV_NEXT(next);
214 ((*bhvtovfsops(next)->xvfs_init_vnode)(next, vp, bp, unlock));
219 struct bhv_desc *bdp,
224 struct bhv_desc *next = bdp;
227 while (! (bhvtovfsops(next))->xvfs_force_shutdown)
228 next = BHV_NEXT(next);
229 ((*bhvtovfsops(next)->xvfs_force_shutdown)(next, fl, file, line));
233 vfs_allocate(struct mount *mp)
235 struct xfs_vfs *vfsp;
236 struct xfsmount *xmp;
238 xmp = kmem_zalloc(sizeof(*xmp), KM_SLEEP);
239 vfsp = XFSTOVFS(xmp);
241 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
252 struct xfs_vfs *vfsp)
254 struct xfsmount *xmp;
256 bhv_head_destroy(VFS_BHVHEAD(vfsp));
258 xmp = VFSTOXFS(vfsp);
259 kmem_free(xmp, sizeof(*xmp));
263 * Allocate and initialize a new XFS mount structure
266 xfsmount_allocate(struct mount *mp)
270 vfsp = vfs_allocate(mp);
274 if (mp->mnt_flag & MNT_RDONLY)
275 vfsp->vfs_flag |= VFS_RDONLY;
277 bhv_insert_all_vfsops(vfsp);
278 return (VFSTOXFS(vfsp));
282 xfsmount_deallocate(struct xfsmount *xmp)
286 vfsp = XFSTOVFS(xmp);
287 bhv_remove_all_vfsops(vfsp, 1);
288 vfs_deallocate(vfsp);
294 struct xfs_vfs *vfsp,
295 struct bhv_vfsops *vfsops)
297 struct bhv_desc *bdp;
299 bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP);
300 bhv_desc_init(bdp, NULL, vfsp, vfsops);
301 bhv_insert(&vfsp->vfs_bh, bdp);
306 struct xfs_vfs *vfsp,
307 struct bhv_desc *bdp,
308 struct xvfsops *vfsops,
311 bhv_desc_init(bdp, mount, vfsp, vfsops);
312 bhv_insert_initial(&vfsp->vfs_bh, bdp);
317 struct xfs_vfs *vfsp,
320 struct bhv_desc *bhv;
322 bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos);
324 bhv_remove(&vfsp->vfs_bh, bhv);
325 kmem_free(bhv, sizeof(*bhv));
330 bhv_remove_all_vfsops(
331 struct xfs_vfs *vfsp,
334 struct xfs_mount *mp;
336 bhv_remove_vfsops(vfsp, VFS_POSITION_QM);
337 bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
338 bhv_remove_vfsops(vfsp, VFS_POSITION_IO);
341 mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops));
342 VFS_REMOVEBHV(vfsp, &mp->m_bhv);
343 xfs_mount_free(mp, 0);
347 bhv_insert_all_vfsops(
348 struct xfs_vfs *vfsp)
350 struct xfs_mount *mp;
352 mp = xfs_mount_init();
353 vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp);
354 vfs_insertdmapi(vfsp);
355 vfs_insertquota(vfsp);