2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
35 #include "xfs_macros.h"
39 #include "xfs_trans.h"
45 #include "xfs_alloc.h"
46 #include "xfs_dmapi.h"
47 #include "xfs_mount.h"
48 #include "xfs_quota.h"
50 #include "xfs_mountops.h"
55 struct xfs_mount_args *args,
58 struct bhv_desc *next = bdp;
61 while (! (bhvtovfsops(next))->xvfs_mount)
62 next = BHV_NEXT(next);
63 return ((*bhvtovfsops(next)->xvfs_mount)(next, args, cr));
70 struct xfs_mount_args *args,
73 struct bhv_desc *next = bdp;
76 while (! (bhvtovfsops(next))->xvfs_parseargs)
77 next = BHV_NEXT(next);
78 return ((*bhvtovfsops(next)->xvfs_parseargs)(next, s, args, f));
86 struct bhv_desc *next = bdp;
89 while (! (bhvtovfsops(next))->xvfs_showargs)
90 next = BHV_NEXT(next);
91 return ((*bhvtovfsops(next)->xvfs_showargs)(next, m));
100 struct bhv_desc *next = bdp;
103 while (! (bhvtovfsops(next))->xvfs_unmount)
104 next = BHV_NEXT(next);
105 return ((*bhvtovfsops(next)->xvfs_unmount)(next, fl, cr));
110 struct bhv_desc *bdp,
112 struct xfs_mount_args *args)
114 struct bhv_desc *next = bdp;
117 while (! (bhvtovfsops(next))->xvfs_mntupdate)
118 next = BHV_NEXT(next);
119 return ((*bhvtovfsops(next)->xvfs_mntupdate)(next, fl, args));
124 struct bhv_desc *bdp,
125 struct xfs_vnode **vpp)
127 struct bhv_desc *next = bdp;
130 while (! (bhvtovfsops(next))->xvfs_root)
131 next = BHV_NEXT(next);
132 return ((*bhvtovfsops(next)->xvfs_root)(next, vpp));
137 struct bhv_desc *bdp,
139 struct xfs_vnode *vp)
141 struct bhv_desc *next = bdp;
144 while (! (bhvtovfsops(next))->xvfs_statvfs)
145 next = BHV_NEXT(next);
146 return ((*bhvtovfsops(next)->xvfs_statvfs)(next, sp, vp));
151 struct bhv_desc *bdp,
155 struct bhv_desc *next = bdp;
158 while (! (bhvtovfsops(next))->xvfs_sync)
159 next = BHV_NEXT(next);
160 return ((*bhvtovfsops(next)->xvfs_sync)(next, fl, cr));
165 struct bhv_desc *bdp,
166 struct xfs_vnode **vpp,
169 struct bhv_desc *next = bdp;
172 while (! (bhvtovfsops(next))->xvfs_vget)
173 next = BHV_NEXT(next);
174 return ((*bhvtovfsops(next)->xvfs_vget)(next, vpp, fidp));
179 struct bhv_desc *bdp,
182 struct bhv_desc *next = bdp;
185 while (! (bhvtovfsops(next))->xvfs_dmapiops)
186 next = BHV_NEXT(next);
187 return ((*bhvtovfsops(next)->xvfs_dmapiops)(next, addr));
192 struct bhv_desc *bdp,
197 struct bhv_desc *next = bdp;
200 while (! (bhvtovfsops(next))->xvfs_quotactl)
201 next = BHV_NEXT(next);
202 return ((*bhvtovfsops(next)->xvfs_quotactl)(next, cmd, id, addr));
207 struct bhv_desc *bdp,
211 struct bhv_desc *next = bdp;
213 while (! (bhvtovfsops(next))->xvfs_get_inode)
214 next = BHV_NEXTNULL(next);
215 return ((*bhvtovfsops(next)->xvfs_get_inode)(next, ino, fl));
220 struct bhv_desc *bdp,
221 struct xfs_vnode *vp,
225 struct bhv_desc *next = bdp;
228 while (! (bhvtovfsops(next))->xvfs_init_vnode)
229 next = BHV_NEXT(next);
230 ((*bhvtovfsops(next)->xvfs_init_vnode)(next, vp, bp, unlock));
235 struct bhv_desc *bdp,
240 struct bhv_desc *next = bdp;
243 while (! (bhvtovfsops(next))->xvfs_force_shutdown)
244 next = BHV_NEXT(next);
245 ((*bhvtovfsops(next)->xvfs_force_shutdown)(next, fl, file, line));
249 vfs_allocate(struct mount *mp)
251 struct xfs_vfs *vfsp;
252 struct xfsmount *xmp;
254 xmp = kmem_zalloc(sizeof(*xmp), KM_SLEEP);
255 vfsp = XFSTOVFS(xmp);
257 bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
260 mp->mnt_data = (qaddr_t)xmp;
268 struct xfs_vfs *vfsp)
270 struct xfsmount *xmp;
272 bhv_head_destroy(VFS_BHVHEAD(vfsp));
274 xmp = VFSTOXFS(vfsp);
275 kmem_free(xmp, sizeof(*xmp));
279 * Allocate and initialize a new XFS mount structure
282 xfsmount_allocate(struct mount *mp)
286 vfsp = vfs_allocate(mp);
290 if (mp->mnt_flag & MNT_RDONLY)
291 vfsp->vfs_flag |= VFS_RDONLY;
293 bhv_insert_all_vfsops(vfsp);
294 return (VFSTOXFS(vfsp));
298 xfsmount_deallocate(struct xfsmount *xmp)
302 vfsp = XFSTOVFS(xmp);
303 bhv_remove_all_vfsops(vfsp, 1);
304 vfs_deallocate(vfsp);
310 struct xfs_vfs *vfsp,
311 struct bhv_vfsops *vfsops)
313 struct bhv_desc *bdp;
315 bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP);
316 bhv_desc_init(bdp, NULL, vfsp, vfsops);
317 bhv_insert(&vfsp->vfs_bh, bdp);
322 struct xfs_vfs *vfsp,
323 struct bhv_desc *bdp,
324 struct xvfsops *vfsops,
327 bhv_desc_init(bdp, mount, vfsp, vfsops);
328 bhv_insert_initial(&vfsp->vfs_bh, bdp);
333 struct xfs_vfs *vfsp,
336 struct bhv_desc *bhv;
338 bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos);
340 bhv_remove(&vfsp->vfs_bh, bhv);
341 kmem_free(bhv, sizeof(*bhv));
346 bhv_remove_all_vfsops(
347 struct xfs_vfs *vfsp,
350 struct xfs_mount *mp;
352 bhv_remove_vfsops(vfsp, VFS_POSITION_QM);
353 bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
354 bhv_remove_vfsops(vfsp, VFS_POSITION_IO);
357 mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops));
358 VFS_REMOVEBHV(vfsp, &mp->m_bhv);
359 xfs_mount_free(mp, 0);
363 bhv_insert_all_vfsops(
364 struct xfs_vfs *vfsp)
366 struct xfs_mount *mp;
368 mp = xfs_mount_init();
369 vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp);
370 vfs_insertdmapi(vfsp);
371 vfs_insertquota(vfsp);