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/
34 #include "xfs_types.h"
38 #include "xfs_trans.h"
39 #include "xfs_trans_priv.h"
44 #include "xfs_dmapi.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"
51 #include "xfs_alloc.h"
52 #include "xfs_attr_sf.h"
53 #include "xfs_dir_sf.h"
54 #include "xfs_dir2_sf.h"
55 #include "xfs_dinode.h"
56 #include "xfs_ialloc.h"
57 #include "xfs_inode.h"
58 #include "xfs_inode_item.h"
69 printf("vn_iowait doing nothing on FreeBSD?\n");
76 XFS_STATS_INC(vn_active);
77 XFS_STATS_INC(vn_alloc);
79 /* Initialize the first behavior and the behavior chain head. */
80 vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
82 #ifdef CONFIG_XFS_VNODE_TRACING
83 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
84 #endif /* CONFIG_XFS_VNODE_TRACING */
86 vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
91 * Get a reference on a vnode. Need to drop vnode reference
92 * to accomodate for vhold by VMAP regardless of whether or
93 * not we were able to successfully grab the vnode.
97 struct xfs_vnode *xfs_vp,
103 XFS_STATS_INC(vn_get);
107 error = vget(vp, 0, curthread);
114 if (vp->v_data != xfs_vp) {
119 vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
124 * purge a vnode from the cache
125 * At this point the vnode is guaranteed to have no references (vn_count == 0)
126 * The caller has to make sure that there are no ways someone could
127 * get a handle (via vn_get) on the vnode (usually done via a mount/vfs lock).
130 vn_purge(struct xfs_vnode *xfs_vp)
134 vn_trace_entry(vp, "vn_purge", (inst_t *)__return_address);
136 vp = xfs_vp->v_vnode;
138 vn_lock(vp, LK_EXCLUSIVE, curthread);
139 if (vp->v_holdcnt == 0)
142 VOP_UNLOCK(vp, 0, curthread);
152 if (flags & XFS_ICHGTIME_MOD) {
153 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
154 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
156 if (flags & XFS_ICHGTIME_ACC) {
157 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
158 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
160 if (flags & XFS_ICHGTIME_CHG) {
161 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
162 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
165 //printf ("xfs_ichgtime NI\n");
171 * Bring the atime in the XFS inode uptodate.
172 * Used before logging the inode to disk or when the Linux inode goes away.
176 * It's unclear if we need this since this is for syncing the linux inode's atime
177 * to the xfs inode's atime.
178 * Since FreeBSD doesn't have atime in the vnode is there anything to really
180 * For now just make this a update atime call
184 xfs_synchronize_atime(
193 /* vfs_timestamp looks at the system time accuracy variable */
196 printf("xfs_synchronize_atime old (%d,%d) new (%d,%ld)\n",
197 ip->i_d.di_atime.t_sec,
198 ip->i_d.di_atime.t_nsec,
203 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
204 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
209 * Extracting atime values in various formats
211 void vn_atime_to_bstime(struct xfs_vnode *vp, xfs_bstime_t *bs_atime)
213 bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec;
214 bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec;
215 printf("vn_atime_to_bstime NI\n");
220 #ifdef CONFIG_XFS_VNODE_TRACING
222 #define KTRACE_ENTER(vp, vk, s, line, ra) \
223 ktrace_enter( (vp)->v_trace, \
224 /* 0 */ (void *)(__psint_t)(vk), \
225 /* 1 */ (void *)(s), \
226 /* 2 */ (void *)(__psint_t) line, \
227 /* 3 */ (void *)(vn_count(vp)), \
228 /* 4 */ (void *)(ra), \
229 /* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \
230 /* 6 */ (void *)(__psint_t)smp_processor_id(), \
231 /* 7 */ (void *)(__psint_t)(current->pid), \
232 /* 8 */ (void *)__return_address, \
233 /* 9 */ 0, 0, 0, 0, 0, 0, 0)
236 * Vnode tracing code.
239 vn_trace_entry(xfs_vnode_t *vp, char *func, inst_t *ra)
241 KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
245 vn_trace_exit(xfs_vnode_t *vp, char *func, inst_t *ra)
247 KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
251 vn_trace_hold(xfs_vnode_t *vp, char *file, int line, inst_t *ra)
253 KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra);
257 vn_trace_ref(xfs_vnode_t *vp, char *file, int line, inst_t *ra)
259 KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra);
263 vn_trace_rele(xfs_vnode_t *vp, char *file, int line, inst_t *ra)
265 KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
267 #endif /* CONFIG_XFS_VNODE_TRACING */