2 * Copyright (c) 2000-2004 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/
38 #include "xfs_trans.h"
42 #include "xfs_alloc.h"
43 #include "xfs_dmapi.h"
44 #include "xfs_quota.h"
45 #include "xfs_mount.h"
46 #include "xfs_alloc_btree.h"
47 #include "xfs_bmap_btree.h"
48 #include "xfs_ialloc_btree.h"
49 #include "xfs_btree.h"
50 #include "xfs_ialloc.h"
51 #include "xfs_attr_sf.h"
52 #include "xfs_dir_sf.h"
53 #include "xfs_dir2_sf.h"
54 #include "xfs_dinode.h"
55 #include "xfs_inode.h"
58 #include "xfs_rtalloc.h"
59 #include "xfs_error.h"
60 #include "xfs_itable.h"
66 #include "xfs_buf_item.h"
67 #include "xfs_utils.h"
68 #include "xfs_version.h"
70 #include <geom/geom.h>
71 #include <geom/geom_vfs.h>
73 extern struct vop_vector xfs_fifoops;
74 extern struct buf_ops xfs_ops;
78 unsigned int blockshift)
88 bhv_desc_t *inode_bhv,
91 xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
93 if (!inode_bhv->bd_vobj) {
94 vp->v_vfsp = bhvtovfs(bdp);
95 bhv_desc_init(inode_bhv, ip, vp, &xfs_vnodeops);
96 bhv_insert(VN_BHV_HEAD(vp), inode_bhv);
100 * XXX: Use VNON as an indication of freshly allocated vnode
101 * which need to be initialized and unlocked.
102 * This is _not_ like the same place in Linux version of
105 if (vp->v_type != VNON)
108 vp->v_type = IFTOVT(ip->i_d.di_mode);
109 vp->v_vnode->v_type = vp->v_type;
111 if (vp->v_type == VFIFO)
112 vp->v_vnode->v_op = &xfs_fifoops;
114 ASSERT_VOP_LOCKED(vp->v_vnode, "xfs_initialize_vnode");
116 /* For new inodes we need to set the ops vectors,
117 * and unlock the inode.
120 VOP_UNLOCK(vp->v_vnode, 0, curthread);
136 printf("xfs_flush_inode NI\n");
143 printf("xfs_flush_device NI\n");
144 xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
152 struct vnode **bdevp)
155 struct nameidata *ndp = &nd;
159 struct g_consumer *cp;
160 struct g_provider *pp;
165 NDINIT(ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, name, td);
166 if ((error = namei(ndp)) != 0)
168 NDFREE(ndp, NDF_ONLY_PNBUF);
171 if (!vn_isdisk(devvp, &error)) {
176 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
178 ronly = ((XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY) != 0);
182 accessmode |= VWRITE;
183 if ((error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td))!= 0){
193 * XXX: Do not allow more than one consumer to open a device
194 * associated with a particular GEOM provider.
195 * This disables multiple read-only mounts of a device,
196 * but it gets rid of panics in bmemfree() when you try to
197 * mount the same device more than once.
198 * During mounting, XFS does a bread() of the superblock, but does
199 * not brelse() it. A subsequent mount of the same device
200 * will try to bread() the superblock, resulting in a panic in
201 * bremfree(), "buffer not on queue".
203 pp = g_dev_getprovider(devvp->v_rdev);
204 if ((pp != NULL) && ((pp->acr | pp->acw | pp->ace ) != 0))
207 error = g_vfs_open(devvp, &cp, "xfs", ronly ? 0 : 1);
212 VOP_UNLOCK(devvp, 0, td);
218 devvp->v_bufobj.bo_private = cp;
219 devvp->v_bufobj.bo_ops = &xfs_ops;
229 struct g_consumer *cp;
234 vinvalbuf(devvp, V_SAVE, curthread, 0, 0);
236 cp = devvp->v_bufobj.bo_private;
239 g_wither_geom_close(cp->geom, ENXIO);
250 printf("xfs_flush_buftarg NI %p\n",btp);
257 xfs_flush_buftarg(btp);
258 kmem_free(btp, sizeof(*btp));
262 xfs_readonly_buftarg(
265 struct g_consumer *cp;
267 KASSERT(btp->specvp->v_bufobj.bo_ops == &xfs_ops,
268 ("Bogus xfs_buftarg_t pointer"));
269 cp = btp->specvp->v_bufobj.bo_private;
271 return (cp->acw == 0);
278 printf("xfs_readonly_buftarg NI %p\n",btp);
285 struct g_consumer *cp;
286 cp = btp->specvp->v_bufobj.bo_private;
287 return (cp->provider->sectorsize);
293 unsigned int blocksize,
294 unsigned int sectorsize)
296 printf("xfs_setsize_buftarg NI %p\n",btp);
305 btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
307 btp->dev = bdev->v_rdev;
316 static char message[] =
317 XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";