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, LK_EXCLUSIVE, curthread);
113 * Drop the vnode returned by vget here.
114 * VOP_RECLAIM(9) should block on internal XFS locks so that
115 * the reclaiming scheme still remains consistent even if the
119 if (vp->v_data != xfs_vp) {
124 vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
129 * purge a vnode from the cache
130 * At this point the vnode is guaranteed to have no references (vn_count == 0)
131 * The caller has to make sure that there are no ways someone could
132 * get a handle (via vn_get) on the vnode (usually done via a mount/vfs lock).
135 vn_purge(struct xfs_vnode *xfs_vp)
139 vn_trace_entry(vp, "vn_purge", (inst_t *)__return_address);
141 vp = xfs_vp->v_vnode;
143 vn_lock(vp, LK_EXCLUSIVE);
144 if (vp->v_holdcnt == 0)
157 if (flags & XFS_ICHGTIME_MOD) {
158 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
159 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
161 if (flags & XFS_ICHGTIME_ACC) {
162 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
163 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
165 if (flags & XFS_ICHGTIME_CHG) {
166 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
167 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
170 //printf ("xfs_ichgtime NI\n");
176 * Bring the atime in the XFS inode uptodate.
177 * Used before logging the inode to disk or when the Linux inode goes away.
181 * It's unclear if we need this since this is for syncing the linux inode's atime
182 * to the xfs inode's atime.
183 * Since FreeBSD doesn't have atime in the vnode is there anything to really
185 * For now just make this a update atime call
189 xfs_synchronize_atime(
198 /* vfs_timestamp looks at the system time accuracy variable */
201 printf("xfs_synchronize_atime old (%d,%d) new (%d,%ld)\n",
202 ip->i_d.di_atime.t_sec,
203 ip->i_d.di_atime.t_nsec,
208 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
209 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
214 * Extracting atime values in various formats
216 void vn_atime_to_bstime(struct xfs_vnode *vp, xfs_bstime_t *bs_atime)
218 bs_atime->tv_sec = vp->v_inode.i_atime.tv_sec;
219 bs_atime->tv_nsec = vp->v_inode.i_atime.tv_nsec;
220 printf("vn_atime_to_bstime NI\n");
225 #ifdef CONFIG_XFS_VNODE_TRACING
227 #define KTRACE_ENTER(vp, vk, s, line, ra) \
228 ktrace_enter( (vp)->v_trace, \
229 /* 0 */ (void *)(__psint_t)(vk), \
230 /* 1 */ (void *)(s), \
231 /* 2 */ (void *)(__psint_t) line, \
232 /* 3 */ (void *)(vn_count(vp)), \
233 /* 4 */ (void *)(ra), \
234 /* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \
235 /* 6 */ (void *)(__psint_t)smp_processor_id(), \
236 /* 7 */ (void *)(__psint_t)(current->pid), \
237 /* 8 */ (void *)__return_address, \
238 /* 9 */ 0, 0, 0, 0, 0, 0, 0)
241 * Vnode tracing code.
244 vn_trace_entry(xfs_vnode_t *vp, char *func, inst_t *ra)
246 KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
250 vn_trace_exit(xfs_vnode_t *vp, char *func, inst_t *ra)
252 KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
256 vn_trace_hold(xfs_vnode_t *vp, char *file, int line, inst_t *ra)
258 KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra);
262 vn_trace_ref(xfs_vnode_t *vp, char *file, int line, inst_t *ra)
264 KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra);
268 vn_trace_rele(xfs_vnode_t *vp, char *file, int line, inst_t *ra)
270 KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
272 #endif /* CONFIG_XFS_VNODE_TRACING */